diff --git a/.chloggen/resource-attribute-from-annotations.yaml b/.chloggen/resource-attribute-from-annotations.yaml index f9cb826166..90b006e03c 100755 --- a/.chloggen/resource-attribute-from-annotations.yaml +++ b/.chloggen/resource-attribute-from-annotations.yaml @@ -1,16 +1,14 @@ -# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' -change_type: enhancement +change_type: breaking -# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) component: auto-instrumentation -# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). note: Add support for k8s labels such as app.kubernetes.io/name and annotations for resource attributes -# One or more tracking issues related to the change issues: [3112] -# (Optional) One or more lines of additional information to render under the primary note. -# These lines will be padded with 2 spaces and then inserted directly into the document. -# Use pipe (|) for multiline entries. -subtext: +subtext: | + It's a breaking change because these annotations are well-known and widely used in the Kubernetes ecosystem. The following labels are supported: + - `app.kubernetes.io/name` becomes `service.name` + - `app.kubernetes.io/version` becomes `service.version` + - `app.kubernetes.io/part-of` becomes `service.namespace` + - `app.kubernetes.io/instance` becomes `service.instance.id` diff --git a/README.md b/README.md index 1fbf1d5f4c..32ac3d865d 100644 --- a/README.md +++ b/README.md @@ -716,7 +716,7 @@ spec: EOF ``` -### Setting instrumentation resource attributes via namespace annotations +### Setting instrumentation resource attributes via annotations and labels This example shows a pod configuration with OpenTelemetry annotations using the `resource.opentelemetry.io/` prefix. These annotations can be used to add resource attributes to data produced by OpenTelemetry instrumentation. @@ -733,7 +733,31 @@ spec: containers: - name: main-container image: your-image:tag - ``` +``` + +You can also use labels to set resource attributes. + +The following labels are supported: +- `app.kubernetes.io/name` becomes `service.name` +- `app.kubernetes.io/version` becomes `service.version` +- `app.kubernetes.io/part-of` becomes `service.namespace` +- `app.kubernetes.io/instance` becomes `service.instance.id` + +```yaml +apiVersion: v1 +kind: Pod +metadata: + name: example-pod + labels: + app.kubernetes.io/name: "my-service" + app.kubernetes.io/version: "1.0.0" + app.kubernetes.io/part-of: "shop" + app.kubernetes.io/instance: "my-service-123" +spec: + containers: + - name: main-container + image: your-image:tag +``` ## Compatibility matrix