-
Notifications
You must be signed in to change notification settings - Fork 780
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
Invoke SDK initialization when using OpenTelemetry.Extensions.Hosting #2901
Conversation
examples/MicroserviceExample/Utils/Messaging/MessageReceiver.cs
Outdated
Show resolved
Hide resolved
@@ -58,7 +58,7 @@ public void StartConsumer() | |||
public void ReceiveMessage(BasicDeliverEventArgs ea) | |||
{ | |||
// Extract the PropagationContext of the upstream parent from the message headers. | |||
var parentContext = Propagator.Extract(default, ea.BasicProperties, this.ExtractTraceContextFromBasicProperties); | |||
var parentContext = Propagators.DefaultTextMapPropagator.Extract(default, ea.BasicProperties, this.ExtractTraceContextFromBasicProperties); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the first message received, the DefaultTextMapPropagator
is the noop instance. By the second message received it has been initialized to the composite propagator that extracts trace context and baggage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we "touch" SDK somewhere super early......
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved this by touching the Sdk
class in OpenTelemetry.Extensions.Hosting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A gentle touch, and SDK behaves!
Codecov Report
@@ Coverage Diff @@
## main #2901 +/- ##
==========================================
- Coverage 84.20% 84.19% -0.01%
==========================================
Files 252 252
Lines 8893 8895 +2
==========================================
+ Hits 7488 7489 +1
- Misses 1405 1406 +1
|
0ebb2b5
to
48f7957
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be good to add changelog.md entry too in hosting package?
Yes, I wavered on this, but I think I came up with something that makes sense. |
Fixes #2898
Using the microservice example to demonstrate that the SDK does not get initialized when expected.
The the static constructor on
OpenTelemtry.Sdk
does not get invoked until after the first message is sent and received in the microservice example:opentelemetry-dotnet/src/OpenTelemetry/Sdk.cs
Lines 30 to 36 in aca7efc
@utpilla