Skip to content

fix(exporter/awsxray): use local service name for Consumer local root segments#47568

Open
ogulcanaydogan wants to merge 3 commits into
open-telemetry:mainfrom
ogulcanaydogan:fix/awsxray-consumer-local-root-segment-name
Open

fix(exporter/awsxray): use local service name for Consumer local root segments#47568
ogulcanaydogan wants to merge 3 commits into
open-telemetry:mainfrom
ogulcanaydogan:fix/awsxray-consumer-local-root-segment-name

Conversation

@ogulcanaydogan

Copy link
Copy Markdown
Contributor

Description

Fixes #43432.

After PR #42633, Consumer spans that are local roots are promoted to X-Ray Segments (rather than just subsegments). However, the segment naming logic in MakeSegment still treated Consumer spans like dependency spans (using aws.remote.service / operation name), while Server segments already used aws.local.service / resource.service.name.

Root cause

Two gaps in MakeSegment (both in segment.go):

  1. aws.local.service check (line 361) — only guarded by SpanKindServer, so Consumer local root spans never used this attribute for naming.
  2. resource.service.name fallback (line 425) — also only for SpanKindServer, so Consumer local root spans fell through to the span (operation) name.

Fix

Extend both checks to also cover SpanKindConsumer && isLocalRoot(span):

// Before
if span.Kind() == ptrace.SpanKindServer {

// After  
if span.Kind() == ptrace.SpanKindServer || (span.Kind() == ptrace.SpanKindConsumer && isLocalRoot(span)) {

The dependency subsegment produced alongside the service segment is unaffected: MakeDependencySubsegmentForLocalRootDependencySpan explicitly overrides the name to aws.remote.service after calling MakeSegment, so the subsegment name remains correct.

Tests

  • Existing TestLocalRootConsumer and TestLocalRootConsumerAWSNamespace continue to pass.
  • New TestLocalRootConsumerUsesResourceServiceName: Consumer local root span without aws.local.service attribute — service segment name must be resource.service.name ("signup_aggregator"), not the operation name ("destination operation").

Checklist

  • Tests added
  • Existing tests pass
  • Fixes #43432 linked

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 75033f54fb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


// support x-ray specific service name attributes as segment name if it exists
if span.Kind() == ptrace.SpanKindServer {
if span.Kind() == ptrace.SpanKindServer || (span.Kind() == ptrace.SpanKindConsumer && isLocalRoot(span)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restrict local-service naming to the promoted service segment

For local-root Consumer spans, this new condition also runs while building the dependency subsegment via MakeDependencySubsegmentForLocalRootDependencySpan. When aws.remote.service is absent, the later name override (if myAwsRemoteService, ok := ...) is skipped, so the subsegment now keeps a local-service name (or resource.service.name from the later fallback) instead of a dependency-oriented name. This regression is specific to local-root Consumer spans missing aws.remote.service, and it can make dependency subsegments collapse onto the same name as the local service segment in X-Ray.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid catch. Moved the fix out of MakeSegment (which also runs for the dependency subsegment) and into MakeServiceSegmentForLocalRootDependencySpan directly, so only the service segment is affected, regardless of whether aws.remote.service is present

ogulcanaydogan added a commit to ogulcanaydogan/opentelemetry-collector-contrib that referenced this pull request Apr 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions Bot added the Stale label Apr 27, 2026
… segments

Before this change, an X-Ray segment produced from a Consumer span that
is a local root used the remote service name (aws.remote.service) or,
if that attribute was absent, fell back to the span (operation) name.
Server local root spans already used aws.local.service / resource
service.name. Consumer local root spans should behave the same way now
that PR open-telemetry#42633 promotes them to Segments.

Changes in MakeSegment:
1. Extend the aws.local.service attribute check to also cover Consumer
   spans that are local roots (mirrors the existing Server logic).
2. Extend the resource.service.name fallback to also cover Consumer
   local root spans when neither aws.local.service nor
   aws.remote.service is set.

Fixes open-telemetry#43432

Assisted-by: Claude Sonnet 4.6
… segments

After PR open-telemetry#42633 promoted Consumer local root spans to X-Ray Segments,
the service segment naming still fell through to the span (operation)
name when aws.local.service was absent, while Server segments already
fell back to resource.service.name.

Fix is applied directly in MakeServiceSegmentForLocalRootDependencySpan
rather than in MakeSegment, so the dependency subsegment produced
alongside is unaffected regardless of whether aws.remote.service is
present.

Naming priority for the service segment (unchanged for all other paths):
1. aws.local.service attribute (existing behavior)
2. resource.service.name (new fallback, mirrors Server span behavior)
3. span name / other existing fallbacks

Fixes open-telemetry#43432

Assisted-by: Claude Sonnet 4.6
@ogulcanaydogan ogulcanaydogan force-pushed the fix/awsxray-consumer-local-root-segment-name branch from 4ccd610 to 53a1295 Compare May 1, 2026 17:55
@github-actions github-actions Bot removed the Stale label May 2, 2026
@axw

axw commented May 11, 2026

Copy link
Copy Markdown
Contributor

@srprash @wangzlei please review

@github-actions

Copy link
Copy Markdown
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions Bot added Stale and removed Stale labels May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[exporter/awsxrayexporter] Consumer Segments should set the name to be local service name if possible

3 participants