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

added fix in entity logic to fallback to workload name when unknown service is set by OTEL SDK #1557

Merged
merged 3 commits into from
Feb 21, 2025

Conversation

nathalapooja
Copy link
Contributor

Description of the issue

Describe the problem or feature in addition to a link to the issues.

If an application instrumented with an OTEL SDK doesn't specify the service.name as a resource attribute, it will return unknown_service:<process.executable.name> or unknown_service for its Service name: https://opentelemetry.io/docs/specs/semconv/attributes-registry/service/.

[2] service.name: MUST be the same for all instances of horizontally scaled services. If the value was not specified, SDKs MUST fallback to unknown_service: concatenated with process.executable.name, e.g. unknown_service:bash. If process.executable.name is not available, the value MUST be set to unknown_service.

In the context of a service entity, this would populate the Service name to be an unknown service value.
com.amazonaws.cloudwatch.entity.internal.service.name: Str(unknown_service:java)

But for entity, we want the agent to fallback to workload when the service name is unknown.

Description of changes

How does this change address the problem?

Added logic in entity processor to check if the service name is prefixed with unknown_service, and fallback to workload.

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

Describe what tests you have done.
Unit tests
Manual tests

  1. Created an EKS cluster and deployed the Amazon CloudWatch Observability EKS add-on.
  2. Set up sample application by following https://aws-otel.github.io/docs/getting-started/adot-eks-add-on/sample-app.
    Removed resource attributes.
    Changed OTEL_EXPORTER_OTLP_ENDPOINT to http://cloudwatch-agent.amazon-cloudwatch:4317.
  3. cloned amazon-cloudwatch-agent Add k8sattributesprocessor to otlp pipeline with workload type detection #1524 k8s-attr branch to replicate the issue
  4. Built the agent image by running make docker-build-amd64 and changed the image in the AmazonCloudWatchAgent custom resource.
  5. Added debug exporter to OTLP pipeline for testing.

Before code change

"com.amazonaws.cloudwatch.entity.internal.k8s.workload.name":"sample-app","com.amazonaws.cloudwatch.entity.internal.platform.type":"AWS::EKS","com.a │ │ mazonaws.cloudwatch.entity.internal.service.name":"unknown_service:java"
"service.name":"unknown_service:java"

After code change

"com.amazonaws.cloudwatch.entity.internal.k8s.workload.name":"sample-app","com.amazonaws.cloudwatch.entity.internal.platform.type":"AWS::EKS","com.am │
│ azonaws.cloudwatch.entity.internal.service.name":"sample-app","com.amazonaws.cloudwatch.entity.internal.service.name.source":"K8sWorkload"
"service.name":"unknown_service:java"

Requirements

Before commit the code, please do the following steps.

  1. Run make fmt and make fmt-sh
  2. Run make lint

@nathalapooja nathalapooja requested a review from a team as a code owner February 20, 2025 16:52
@nathalapooja nathalapooja merged commit c23457c into feature-custom-metrics-entity Feb 21, 2025
7 checks passed
@nathalapooja nathalapooja deleted the telemetry-source-entity branch February 21, 2025 16:03
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

Successfully merging this pull request may close these issues.

3 participants