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

trace: split tracer and versioned_tracer methods #682

Merged
merged 3 commits into from
Dec 24, 2021

Conversation

jtescher
Copy link
Member

The trace spec requires that TracerProviders MUST accept optional version and schema_url parameters. This introduces ergonomic issues as rust does not have a variadic solution outside of macros, leading to many calls with only a single relevant argument (e.g. tracer(name, None, None)).

This patch splits the current TracerProvider::tracer method into TracerProvider::versioned_tracer which implements the spec mandated optional fields, as well as a TracerProvider::tracer method that accepts only a name parameter as a convenience method for the above listed common case.

The [trace spec] requires that `TracerProvider`s MUST accept optional
`version` and `schema_url` parameters. This introduces ergonomic issues
as rust does not have a variadic solution outside of macros, leading to
many calls with only a single relevant argument (e.g. `tracer(name, None, None)`).

This patch splits the current `TracerProvider::tracer` method into
`TracerProvider::versioned_tracer` which implements the spec mandated
optional fields, as well as a `TracerProvider::tracer` method that
accepts only a `name` parameter as a convenience method for the above
listed common case.

[trace spec]: https://github.com/open-telemetry/opentelemetry-specification/blob/v1.4.0/specification/trace/api.md#get-a-tracer
@jtescher jtescher requested a review from a team as a code owner December 23, 2021 18:40
@codecov
Copy link

codecov bot commented Dec 23, 2021

Codecov Report

Merging #682 (bda6a15) into main (ec40cd4) will decrease coverage by 0.04%.
The diff coverage is 53.57%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #682      +/-   ##
==========================================
- Coverage   63.85%   63.81%   -0.05%     
==========================================
  Files          95       96       +1     
  Lines        7717     7725       +8     
==========================================
+ Hits         4928     4930       +2     
- Misses       2789     2795       +6     
Impacted Files Coverage Δ
opentelemetry-datadog/src/exporter/mod.rs 12.06% <0.00%> (-0.22%) ⬇️
opentelemetry-jaeger/src/exporter/mod.rs 58.72% <0.00%> (-0.29%) ⬇️
opentelemetry-otlp/src/span.rs 0.00% <ø> (ø)
opentelemetry-zipkin/src/exporter/mod.rs 0.00% <0.00%> (ø)
opentelemetry/src/sdk/export/trace/stdout.rs 9.67% <ø> (ø)
opentelemetry/src/sdk/propagation/composite.rs 95.58% <ø> (ø)
opentelemetry/src/trace/context.rs 46.42% <ø> (ø)
opentelemetry/src/trace/mod.rs 72.88% <ø> (ø)
opentelemetry/src/global/trace.rs 22.95% <33.33%> (ø)
opentelemetry/src/sdk/trace/provider.rs 83.11% <100.00%> (-0.11%) ⬇️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ec40cd4...bda6a15. Read the comment docs.

@TommyCpp
Copy link
Contributor

I think it's related to #555. Since we started preparing GA. One question here is what if the spec adds another parameter in the future?

@jtescher
Copy link
Member Author

I think as the trace spec is frozen we can assume they will not for now. If they do, then the simplest thing seems to be to either add another method or do a major version bump to support the new spec.

Copy link
Contributor

@TommyCpp TommyCpp left a comment

Choose a reason for hiding this comment

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

Looks good 👍

@TommyCpp
Copy link
Contributor

I think we can close #555 with this PR

@jtescher jtescher merged commit 50510e3 into open-telemetry:main Dec 24, 2021
@jtescher jtescher deleted the versioned-tracer branch December 24, 2021 18:41
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.

None yet

2 participants