Search code examples
amazon-ecsopen-telemetrydatadogopen-telemetry-collector

Opentelemetry recource attributes processor: can't set a value


I'm using OTel collector in AWS ECS Fargate environment, a task have application container and collector sidecar. I use resourcedetector ecs to extract task attributes, and I need to set "3 main tags": service.name, service.version, deployment.environment. This values are required by Datadog unified tagging for correlation. And I want to set this values using attributes extracted by resourcedetector. Here is partially my collector config:

receivers:
    otlp:

processors:
    resourcedetection/ecs:
        detectors: [env, ecs]
        timeout: 2s
        override: false
    batch:
    transform:
        error_mode: ignore
        trace_statements:
          - context: span
            statements:
                - set(resource.attributes["service.name"], resource.attributes["aws.ecs.task.family"])
                - replace_pattern(resource.attributes["service.name"], "^[^-]+-", "") 
# converts <env>-<service-name> (ecs service names I have) into <service-name>

service:
    pipelines:
    traces:
      receivers: [otlp]
      processors: [resourcedetection/ecs, transform, batch]
      exporters: [datadog/connector, datadog/exporter]

in Datadog trace view I don't have service.name set for trace. trace metadata overview screenshot

Is this mistake in processors usage, Datadog platform issue or something else?

Tried setting the value on local setup with SigNoz (local deployment) and container.name attribute by docker resourcedetertor - set(resource.attributes["service.name"], resource.attributes["container.name"]) the value was set. Did the same to test pattern with value set using processor 'resource:attributes:-key:aws.ecs.task.family ...', also worked, service.name is set in traces (also in metrics with same statement) Tried set or attributes["service.name"] or resource.attributes["service.name"] for span.


Solution

  • It appeared there is no issue in the provided code. And the behavior of Datadog platform where service.name attribute is not displayed - is just how the platform works, you can see that on the screenshot in the original question.