-
Notifications
You must be signed in to change notification settings - Fork 868
[hosting] Register OpenTelemetry at the beginning of IServiceCollection #4883
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
Changes from 1 commit
4c02e55
c3421f9
89e1785
58a7a11
d402991
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -34,10 +34,16 @@ public static class OpenTelemetryServicesExtensions | |||||
| /// cref="IServiceCollection"/>. | ||||||
| /// </summary> | ||||||
| /// <remarks> | ||||||
| /// Note: This is safe to be called multiple times and by library authors. | ||||||
| /// Notes: | ||||||
| /// <list type="bullet"> | ||||||
| /// <item>This is safe to be called multiple times and by library authors. | ||||||
| /// Only a single <see cref="TracerProvider"/> and/or <see | ||||||
| /// cref="MeterProvider"/> will be created for a given <see | ||||||
| /// cref="IServiceCollection"/>. | ||||||
| /// cref="IServiceCollection"/>.</item> | ||||||
| /// <item>OpenTelemetry SDK services are inserted at the beginning of the | ||||||
| /// <see cref="IServiceCollection"/> in an attempt to provide a better | ||||||
|
||||||
| /// <see cref="IServiceCollection"/> in an attempt to provide a better | |
| /// <see cref="IServiceCollection"/> in an attempt to ensure telemetry generated from other services are also collected, but this is not guranteed. |
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.
Seems hard to capture all the nuance here. Maybe we should just link to a doc?
/// <item>OpenTelemetry SDK services are inserted at the beginning of the <see cref="IServiceCollection"/> and started with the host. For details about the ordering of events and capturing telemetry in <see cref="IHostedService" />s see: <see href="https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/src/OpenTelemetry.Extensions.Hosting/README.md#hosted-service-ordering-and-telemetry-capture" />.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.
If we are going to put something in the README then I think including a link here makes the most sense. One potential downside is that the link could break.
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.
@CodeBlanch @cijothomas can we come to an agreement on the preferred documentation style? Just don't want this to sit stale.
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.
My vote would be... do the link as I have it above and just stub out the anchor section in the README with "TBD" as the content. We can flush it out on a follow-up.
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.
not something added in this PR, but this is not to be called by library authors....so must be a typo here? @CodeBlanch do you think this was intended?
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.
There's really 2 questions...
Q: Is it safe for library authors to call this?
A: Yes! Multiple calls will stack. Everything is building-up/modifying a single provider for any given IServiceCollection. This is what the comments are saying.
Q: Should library authors call this?
A: It depends! If you want to force OpenTelemetry to be started, perfectly fine to call this. If you just want to configure something in the event OTel happens to be used by the host, don't call this. That is what
IServiceCollection.ConfigureOpenTelemetry[Tracer|Meter|Logger]Providerextensions are for. The current comments aren't really addressing that bit, I'll follow-up on that.