opentelemetry-dotnet icon indicating copy to clipboard operation
opentelemetry-dotnet copied to clipboard

[Traces] Support DI scenarios in instrumentation without SDK dependency + named options in SqlClient instrumentation

Open CodeBlanch opened this issue 3 years ago • 1 comments

Changes

#3533 doesn't tackle IDeferredTracerProviderBuilder which is needed for instrumentation libraries which do not have a dependency on SDK. Such libraries are limited in what they can participate in because without IServiceCollection they can't register anything.

What this PR does is expose IServiceCollection to API and shows how OpenTelemetry.Instrumentation.SqlClient can then use the same patterns as everything else.

To do this API needs a Microsoft.Extensions.DependencyInjection.Abstractions reference. Is that a big deal? 🤷‍♀️ That reference comes with SDK regardless, so most users are going to get it one way or another.

Opening as a draft to gather feedback.

TODOs

  • [ ] Appropriate CHANGELOG.md updated for non-trivial changes
  • [ ] Changes in public API reviewed

CodeBlanch avatar Sep 14 '22 22:09 CodeBlanch

Codecov Report

Merging #3663 (7a4300f) into main (ef46e82) will decrease coverage by 0.16%. The diff coverage is 77.27%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3663      +/-   ##
==========================================
- Coverage   87.61%   87.45%   -0.17%     
==========================================
  Files         283      283              
  Lines       10270    10282      +12     
==========================================
- Hits         8998     8992       -6     
- Misses       1272     1290      +18     
Impacted Files Coverage Δ
...c/OpenTelemetry.Api/Trace/TracerProviderBuilder.cs 33.33% <0.00%> (-66.67%) :arrow_down:
...y/Trace/Builder/TracerProviderBuilderExtensions.cs 97.29% <ø> (-0.38%) :arrow_down:
...lemetry/Trace/Builder/TracerProviderBuilderBase.cs 90.65% <85.71%> (-0.78%) :arrow_down:
...ation.SqlClient/TracerProviderBuilderExtensions.cs 100.00% <100.00%> (ø)
...entation/ExportClient/OtlpGrpcTraceExportClient.cs 35.71% <0.00%> (-42.86%) :arrow_down:
...xporter.OpenTelemetryProtocol/OtlpTraceExporter.cs 36.36% <0.00%> (-40.91%) :arrow_down:
...tation/OpenTelemetryProtocolExporterEventSource.cs 75.00% <0.00%> (-10.00%) :arrow_down:
...metryProtocol/Implementation/ActivityExtensions.cs 91.75% <0.00%> (-4.40%) :arrow_down:
src/OpenTelemetry/Logs/OpenTelemetryLogger.cs 86.66% <0.00%> (-2.23%) :arrow_down:
...Telemetry/Internal/SelfDiagnosticsEventListener.cs 96.87% <0.00%> (-0.79%) :arrow_down:
... and 10 more

codecov[bot] avatar Sep 14 '22 22:09 codecov[bot]

This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or Pushing will instruct the bot to automatically remove the label. This bot runs once per day.

github-actions[bot] avatar Sep 23 '22 04:09 github-actions[bot]

Closed as inactive. Feel free to reopen if this PR is still being worked on.

github-actions[bot] avatar Sep 30 '22 04:09 github-actions[bot]