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

[Traces] Add named options support to OtlpTraceExporter builder extensions #3653

Merged
merged 3 commits into from
Sep 13, 2022

Conversation

CodeBlanch
Copy link
Member

@CodeBlanch CodeBlanch commented Sep 13, 2022

Changes

Applies the named options pattern from #3648 to OtlpTraceExporter.

TODOs

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

@CodeBlanch CodeBlanch requested a review from a team September 13, 2022 17:40
static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, string name, System.Action<OpenTelemetry.Exporter.OtlpExporterOptions> configureExporter) -> OpenTelemetry.Metrics.MeterProviderBuilder
*REMOVED*static OpenTelemetry.Trace.OtlpTraceExporterHelperExtensions.AddOtlpExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action<OpenTelemetry.Exporter.OtlpExporterOptions> configure = null) -> OpenTelemetry.Trace.TracerProviderBuilder
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If some user was binding to this reflectively and specifically looking at metadata for the optional parameter they would no longer find it and break but I don't think that is really worth worrying about. The benefit to this change is to keep consistency with everything else and allow for future safe expansion/overload additions without default parameter ambiguity issues.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If they explicitly had builder.AddOtlpExporter(null) could nullablility cause any problems? I think the answer is no, but just asking. Basically should the new overload be

static OpenTelemetry.Trace.OtlpTraceExporterHelperExtensions.AddOtlpExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action<OpenTelemetry.Exporter.OtlpExporterOptions>? configure) -> OpenTelemetry.Trace.TracerProviderBuilder

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we had nullable enabled in OpenTelemetry.Exporter.OpenTelemetryProtocol project then yes we would want the ?. But we don't, so the existing signature accepts null as a traditional ref would. Basically null is expected and works fine. RE: Nullable, I'm almost done annotating SDK after which I was thinking I would do API and then start branching out into other projects. It is a very slow burn 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yea right, forgot it wasn't enabled yet.

@codecov
Copy link

codecov bot commented Sep 13, 2022

Codecov Report

Merging #3653 (91effcb) into main (6ea078e) will increase coverage by 0.19%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3653      +/-   ##
==========================================
+ Coverage   87.62%   87.82%   +0.19%     
==========================================
  Files         283      283              
  Lines       10234    10237       +3     
==========================================
+ Hits         8968     8991      +23     
+ Misses       1266     1246      -20     
Impacted Files Coverage Δ
...metryProtocol/OtlpTraceExporterHelperExtensions.cs 92.00% <100.00%> (+1.09%) ⬆️
...tpListener/Internal/PrometheusCollectionManager.cs 78.04% <0.00%> (-2.44%) ⬇️
src/OpenTelemetry/Logs/OpenTelemetryLogger.cs 88.88% <0.00%> (+2.22%) ⬆️
...metryProtocol/Implementation/ActivityExtensions.cs 95.05% <0.00%> (+3.29%) ⬆️
...xporter.OpenTelemetryProtocol/OtlpTraceExporter.cs 77.27% <0.00%> (+40.90%) ⬆️
...entation/ExportClient/OtlpGrpcTraceExportClient.cs 78.57% <0.00%> (+42.85%) ⬆️

Copy link
Member

@alanwest alanwest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question about the new overload, but LGTM

@CodeBlanch CodeBlanch merged commit b4ade26 into open-telemetry:main Sep 13, 2022
@CodeBlanch CodeBlanch deleted the otlp-traces-namedoptions branch September 13, 2022 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants