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

[exporter/azuremonitor] Exporter doesn't export span links #35855

Open
tombiddulph opened this issue Oct 17, 2024 · 1 comment
Open

[exporter/azuremonitor] Exporter doesn't export span links #35855

tombiddulph opened this issue Oct 17, 2024 · 1 comment
Labels
bug Something isn't working exporter/azuremonitor needs triage New item requiring triage

Comments

@tombiddulph
Copy link

Component(s)

exporter/azuremonitor

What happened?

Description

The AzureMonitor exporter doesn't seem to export span links. I've had a look through the code and I can't see any mapping of span links taking place.

Steps to Reproduce

In a C# app with otel configured and pointing to a collector with the azure monitor exporter

var remoteActivity = GetActivityFromSomeRemoteSource();
var myActivity = CreateLocalActivityWithoutRemoteContext( links: new List<ActivityLink> { new ActivityLink(remoteActivity.Context} );

Expected Result

Link between activities to appear in application insights timeline view

Actual Result

No link in timeline view

Collector version

a2a52e43c1a80aa94120ad78c2db68780eb90e6d11c8db5b3ce2f6a0cc6b5029

Environment information

Environment

OS: (macos 14.7)
Collector image otel/opentelemetry-collector-contrib sha256:a2a52e43c1a80aa94120ad78c2db68780eb90e6d11c8db5b3ce2f6a0cc6b5029
Dotnet sdk: 8.0.401
OpenTelemetry.* Nuget packages: 1.9.0

OpenTelemetry Collector configuration

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
      http:
        endpoint: 0.0.0.0:4318
    
processors:
exporters:
  debug:
    verbosity: detailed # '
  azuremonitor:
    connection_string: 
    spaneventsenabled: true

service:
  telemetry:
    logs:
      level: debug
  pipelines:
    traces:
      receivers: [otlp]
      processors: []
      exporters: [ debug, azuremonitor]
    logs:
      receivers: [otlp]
      processors: []
      exporters: [debug, azuremonitor]

Log output

2024-10-17 09:16:32 SpanLink #0
2024-10-17 09:16:32      -> Trace ID: 8a399a6101a2783da2ee92c57c6dc77f
2024-10-17 09:16:32      -> ID: ce21439755dcecfe
2024-10-17 09:16:32      -> TraceState: 
2024-10-17 09:16:32      -> DroppedAttributesCount: 0

Additional context

I've attached logs from the collector showing that span are being produced links

Workaround

Setting a tag on the localActivity with the key of _MS.links and and array of operation links with the following schema links the activities in the application insights timeline view

[
   {
       "operation_Id": <remoteActivity.Context.TraceId>,
       "id":  <remoteActivity.Context.SpanId>
   }
]

Processor

 public class LinkProcessor : BaseProcessor<Activity>
 {
        public override void OnEnd(Activity data)
        {
            if (data.Links.Any())
            {
                var links = data.Links.Select(activityLink => new OperationLink(activityLink.Context.TraceId.ToString(), activityLink.Context.SpanId.ToString())).ToList();
                data.SetTag("_MS.links", JsonSerializer.Serialize(links));
            }
            base.OnEnd(data);
        }

        private record OperationLink(
            [property: JsonPropertyName("operation_Id")] string OperationId,
            [property: JsonPropertyName("id")] string Id);
}
@tombiddulph tombiddulph added bug Something isn't working needs triage New item requiring triage labels Oct 17, 2024
Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working exporter/azuremonitor needs triage New item requiring triage
Projects
None yet
Development

No branches or pull requests

1 participant