Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logs: incorrect service.name transformation #356

Open
sudomateo opened this issue Jul 2, 2024 · 3 comments
Open

logs: incorrect service.name transformation #356

sudomateo opened this issue Jul 2, 2024 · 3 comments

Comments

@sudomateo
Copy link

When the service.name attribute is set as a resource attribute or as an attribute on the log, the Datadog user interface shows a JSON object instead of the name of the service.

This issue actually spawns a larger discussion about how the transform function is meant to work. Specifically, the transform function retrieves the value for service, among others, from either resource attributes or attributes on the log. It then uses that service value to set the Service field on the datadogV2.HTTPLogItem. Since values can be set from both resource attributes or attributes on the log, it's not clear which method operators should be using in their code. Perhaps this should be broken out into a separate issue for further discussion. Either way, I'm bringing it up here because it was a bit confusing when reading the code.

if service != "" {
l.Service = datadog.PtrString(service)
}

Here's the transform processor I used to set the service.name attribute on the log.

processors:
  transform:
    log_statements:
      - context: log
        statements:
          - set(attributes["service.name"], "sudomateo")
          - set(attributes["ddtags"], "source:sudomateo")

Notice how this appears incorrectly as a JSON object in the Datadog user interface. With this incorrect behavior I cannot use service:sudomateo to filter logs.

Screenshot 2024-07-02 at 19 12 57 Screenshot 2024-07-02 at 19 12 03
@liustanley
Copy link
Contributor

This should be fixed in open-telemetry/opentelemetry-collector-contrib#34420.

@sudomateo
Copy link
Author

This should be fixed in open-telemetry/opentelemetry-collector-contrib#34420.

Thank you. I'll give it a test when the beta is live then.

@liustanley
Copy link
Contributor

This should be fixed in open-telemetry/opentelemetry-collector-contrib#34420.

Thank you. I'll give it a test when the beta is live then.

Sounds good, you can either wait until the beta is live or you can enable the exporter.datadogexporter.UseLogsAgentExporter feature flag to fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants