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

[sdk] ConcurrencyMode and export processor registration APIs #5758

Closed

Conversation

CodeBlanch
Copy link
Member

Relates to #5642
Relates to #5643

Changes

  • Adds ConcurrencyModes and ConcurrencyModesAttribute
  • Adds AddBatchExportProcessor and AddSimpleExportProcessor extensions on LoggerProviderBuilder and TracerProviderBuilder
  • Implements IDeferredLoggerProviderBuilder on OpenTelemetryLoggerOptions

Details

ConcurrencyModes

We want to allow users (component authors) to be able to opt-out of the lock used by SimpleExportProcessor. @reyang introduced ConcurrencyModes on #5643 but the challenge there is SimpleExportProcessor<T> needs to implement all the logic which makes it a) not very simple and b) more expensive (perf-wise). The goal here was to support ConcurrencyModes but in a way where we could specialize the implementation(s) without leaking them into public APIs. There could also be more ConcurrencyModes in the future for example Global was originally in the design which uses an OS-level synchronization mechanism and further complicates SimpleExportProcessor<T>.

AddBatchExportProcessor and AddSimpleExportProcessor extensions

Mistakes have been made in the design of BatchExportProcessor<T>. Users (component authors) must correctly pass in settings on the ctor. Those settings should be controllable by users. Some exporters do this manually (OneCollector), some do it using BatchExportActivityProcessorOptions (Geneva), and some don't give users any configurability at all (AzureMonitor).

Adding AddBatchExportProcessor and AddSimpleExportProcessor extensions allow the SDK to take care of this so it is always done correctly and gives it a spot to inspect ConcurrencyMode to select the correct implementation to use when SimpleExportProcessor<T> is requested.

Implement IDeferredLoggerProviderBuilder on OpenTelemetryLoggerOptions

In 1.9.0 we exposed LoggerProviderBuilder which is where the new extensions landed. The problem is we also have OpenTelemetryLoggerOptions and a lot of shipped registration extensions targeting it which need to create simple or batch processors. I really didn't want to add new builder methods on OpenTelemetryLoggerOptions as we ought to obsolete the existing ones. What I did was implement IDeferredLoggerProviderBuilder on OpenTelemetryLoggerOptions so that component authors can access the LoggerProviderBuilder extensions if needed. This is an explicit implementation so it is hidden from users unless they perform a cast. Is this safe to do? Yes. OpenTelemetryLoggerOptions can perform all the late-bound builder tasks because it has the IServiceProvider available. It just can't do the early stuff which needs IServiceCollection. So it may be IDeferredLoggerProviderBuilder but it can't be ILoggerProviderBuilder.

Follow-up work

PeriodicExportingMetricReader is really subject to the same pitfalls as BatchExportProcessor<T> but that isn't addressed here. If this goes forward similar work will need to happen for it. Probably an extension on MeterProviderBuilder along the lines of AddPeriodicExportingMetricReader.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

@github-actions github-actions bot added documentation Documentation related pkg:OpenTelemetry.Exporter.Console Issues related to OpenTelemetry.Exporter.Console NuGet package pkg:OpenTelemetry.Exporter.InMemory Issues related to OpenTelemetry.Exporter.InMemory NuGet package pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package pkg:OpenTelemetry.Exporter.Zipkin Issues related to OpenTelemetry.Exporter.Zipkin NuGet package pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package labels Jul 24, 2024
Copy link

codecov bot commented Jul 24, 2024

Codecov Report

Attention: Patch coverage is 76.01246% with 77 lines in your changes missing coverage. Please review.

Project coverage is 86.00%. Comparing base (6250307) to head (898c1a8).
Report is 285 commits behind head on main.

Files Patch % Lines
...ry/Logs/Builder/LoggerProviderBuilderExtensions.cs 57.14% 21 Missing ⚠️
...y/Trace/Builder/TracerProviderBuilderExtensions.cs 69.38% 15 Missing ⚠️
...porter.Console/ConsoleExporterLoggingExtensions.cs 0.00% 9 Missing ⚠️
...xporter.Console/ConsoleExporterHelperExtensions.cs 0.00% 8 Missing ⚠️
...penTelemetry/SimpleMultithreadedExportProcessor.cs 0.00% 8 Missing ⚠️
...ssor/SimpleMultithreadedActivityExportProcessor.cs 0.00% 6 Missing ⚠️
src/OpenTelemetry/ConcurrencyModesAttribute.cs 54.54% 5 Missing ⚠️
...lemetry/Logs/ILogger/OpenTelemetryLoggerOptions.cs 72.22% 5 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5758      +/-   ##
==========================================
+ Coverage   83.38%   86.00%   +2.62%     
==========================================
  Files         297      261      -36     
  Lines       12531    11319    -1212     
==========================================
- Hits        10449     9735     -714     
+ Misses       2082     1584     -498     
Flag Coverage Δ
unittests ?
unittests-Project-Experimental 85.95% <76.01%> (?)
unittests-Project-Stable 85.97% <76.01%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...orter.InMemory/InMemoryExporterHelperExtensions.cs 100.00% <100.00%> (ø)
...rter.InMemory/InMemoryExporterLoggingExtensions.cs 100.00% <100.00%> (+33.33%) ⬆️
...enTelemetryProtocol/Builder/OtlpExporterBuilder.cs 100.00% <100.00%> (ø)
...etryProtocol/Builder/OtlpExporterBuilderOptions.cs 100.00% <100.00%> (ø)
...orter.OpenTelemetryProtocol/OtlpExporterOptions.cs 99.09% <100.00%> (+2.72%) ⬆️
...lemetryProtocol/OtlpLogExporterHelperExtensions.cs 94.64% <100.00%> (+23.57%) ⬆️
...metryProtocol/OtlpTraceExporterHelperExtensions.cs 98.76% <100.00%> (+2.09%) ⬆️
....Exporter.Zipkin/ZipkinExporterHelperExtensions.cs 100.00% <100.00%> (+1.81%) ⬆️
...Telemetry.Exporter.Zipkin/ZipkinExporterOptions.cs 100.00% <100.00%> (ø)
src/OpenTelemetry/BatchExportProcessorOptions.cs 100.00% <100.00%> (ø)
... and 11 more

... and 196 files with indirect coverage changes

Copy link
Contributor

github-actions bot commented Aug 1, 2024

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 github-actions bot added the Stale Issues and pull requests which have been flagged for closing due to inactivity label Aug 1, 2024
Copy link
Contributor

github-actions bot commented Aug 9, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Documentation related pkg:OpenTelemetry.Exporter.Console Issues related to OpenTelemetry.Exporter.Console NuGet package pkg:OpenTelemetry.Exporter.InMemory Issues related to OpenTelemetry.Exporter.InMemory NuGet package pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package pkg:OpenTelemetry.Exporter.Zipkin Issues related to OpenTelemetry.Exporter.Zipkin NuGet package pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package Stale Issues and pull requests which have been flagged for closing due to inactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant