open-telemetry / opentelemetry-dotnet

The OpenTelemetry .NET Client
https://opentelemetry.io
Apache License 2.0
3.09k stars 736 forks source link

Sending metadata from client to server #517

Closed lukasz-pyrzyk closed 4 years ago

lukasz-pyrzyk commented 4 years ago

I would like to use OpenTelemetry to spread metadata information about a client that starts the tracing graph. I imagine it by sending a metadata from a client that makes HTTP request to the server, for example, something like requestkind: selftest or sender: selftest. This value is needed in the last child.

If I'm not mistaken, in OpenTracing spec it sounds like `Baggage Items https://opentracing.io/docs/overview/tags-logs-baggage/

I found in the code that ISpan has a method like SetBaggageItem or GetBaggageItem, but they are not implemented internally with the comment// TODO Revisit once DistributedContext is finalized https://github.com/open-telemetry/opentelemetry-dotnet/blob/633dda37bdb171f337596ba4b53021b5d35f117c/src/OpenTelemetry.Shims.OpenTracing/SpanShim.cs#L136

Is my assumption okay to try to use OpenTelemetry for spreading information about the first traceParent to the child spans? If yes, how to do it?

SergeyKanzhelev commented 4 years ago

DistributedContext / CorrelationContext needs to be used in OpenTelemetry. @MikeGoldsmith is working on it: https://github.com/open-telemetry/opentelemetry-dotnet/pull/462

@MikeGoldsmith can you please comment on when it may be ready?

I mentioned this scenario here: https://devblogs.microsoft.com/aspnet/improvements-in-net-core-3-0-for-troubleshooting-and-monitoring-distributed-apps/ and here https://medium.com/opentelemetry/opentelemetry-beyond-getting-started-5ac43cd0fe26

SergeyKanzhelev commented 4 years ago

Marked for better documentation for the 0.4 milestone

MikeGoldsmith commented 4 years ago

Sorry for the slow reply.

The OpenTelemetry spec moved from baggage to Correlations. I'm working on this and expect it to be done by the end of this week. It's a far reaching change and touches on a large number of areas.

Once updated, correlations set on parent spans will be passed to child spans the same way baggage worked.

SergeyKanzhelev commented 4 years ago

closing in favor of Correlation Context work #461