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

Avoid overriding configuration of tracer provider #1633

Merged
merged 4 commits into from
Mar 8, 2021

Conversation

ijsong
Copy link
Contributor

@ijsong ijsong commented Mar 3, 2021

This change adds WithDefaultSampler and WithSpanLimits to the tracer provider and removed WithConfig from it.

Before this change, WithConfig is the only way to set sampler or limits of a span. However, it is prone to misuse, since WithConfig can override tracing configurations that are configured by WithResource or
WithIDGenerator. Thus to fix this, it adds new functional options -WithDefaultSampler and WithSpanLimits and removes WithConfig.

Resolves #1631.

@codecov
Copy link

codecov bot commented Mar 3, 2021

Codecov Report

Merging #1633 (e942912) into main (2b4d5ac) will increase coverage by 0.0%.
The diff coverage is 100.0%.

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #1633   +/-   ##
=====================================
  Coverage   77.1%   77.2%           
=====================================
  Files        128     128           
  Lines       6735    6742    +7     
=====================================
+ Hits        5196    5205    +9     
+ Misses      1288    1286    -2     
  Partials     251     251           
Impacted Files Coverage Δ
exporters/otlp/internal/otlptest/otlptest.go 74.5% <100.0%> (ø)
exporters/trace/jaeger/jaeger.go 93.6% <100.0%> (+0.1%) ⬆️
sdk/trace/provider.go 83.0% <100.0%> (+0.2%) ⬆️
exporters/otlp/otlpgrpc/connection.go 88.7% <0.0%> (+1.8%) ⬆️

Copy link
Contributor

@MrAlias MrAlias 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 overall, minor documentation fixes needed.

sdk/trace/provider.go Outdated Show resolved Hide resolved
sdk/trace/provider.go Outdated Show resolved Hide resolved
Copy link
Member

@Aneurysm9 Aneurysm9 left a comment

Choose a reason for hiding this comment

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

This looks good to me, though as @MrAlias mentioned in Slack it would be good if we went one step further and avoided exporting the TracerProvider.ApplyConfig method and related Config struct. It looks like they're only used in a couple places that should be able to be rewritten using the new options.

@MrAlias
Copy link
Contributor

MrAlias commented Mar 3, 2021

This looks good to me, though as @MrAlias mentioned in Slack it would be good if we went one step further and avoided exporting the TracerProvider.ApplyConfig method and related Config struct. It looks like they're only used in a couple places that should be able to be rewritten using the new options.

Tracking this topic here so the scope of this PR isn't overloaded.

@ijsong
Copy link
Contributor Author

ijsong commented Mar 3, 2021

It seems to be unrelated. Waiting time for reconnection maybe not enough sometimes.

--- FAIL: TestNewExporter_collectorConnectionDiesThenReconnects (0.25s)
    otlp_integration_test.go:248: 
        	Error Trace:	otlp_integration_test.go:248
        	Error:      	Received unexpected error:
        	            	no client
        	Test:       	TestNewExporter_collectorConnectionDiesThenReconnects
FAIL

@MrAlias MrAlias added this to the RC1 milestone Mar 4, 2021
@MrAlias MrAlias added area:trace Part of OpenTelemetry tracing pkg:SDK Related to an SDK package labels Mar 4, 2021
@MrAlias
Copy link
Contributor

MrAlias commented Mar 8, 2021

@ijsong it looks like WithConfig was added in a few more places upstream. Let me know if you want help resolving these conflicts. Otherwise, I think this looks good to merge once they are resolved.

ijsong and others added 4 commits March 9, 2021 06:16
This change adds `WithDefaultSampler` and `WithSpanLimits` to the tracer
provider and removed `WithConfig` from it.

Before this change, `WithConfig` is the only way to set sampler or
limits of a span. However, it is prone to misuse, since `WithConfig` can
override tracing configurations that are configured by `WithResource` or
`WithIDGenerator`.  Thus to fix this, it adds new functional options -
`WithDefaultSampler` and `WithSpanLimits` and removes `WithConfig`.

Resolves open-telemetry#1631.
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
@MrAlias MrAlias merged commit d75e268 into open-telemetry:main Mar 8, 2021
Copy link
Member

@XSAM XSAM left a comment

Choose a reason for hiding this comment

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

We might need to write a tool to prevent changes to the released changelog.

@@ -56,6 +56,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
| Windows | 1.14 | amd64 |
| Windows | 1.15 | 386 |
| Windows | 1.14 | 386 |
- Added `WithDefaultSampler` and `WithSpanLimits` to tracer provider. (#1633)
Copy link
Member

Choose a reason for hiding this comment

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

It seems it is the wrong place to put this changelog.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry to not have checked carefully.

Copy link
Member

Choose a reason for hiding this comment

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

That is fine. This should be handled by an automatic tool, which lowers everyone's mental burden. ;)

@XSAM XSAM mentioned this pull request Mar 9, 2021
@MrAlias MrAlias mentioned this pull request Mar 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:trace Part of OpenTelemetry tracing pkg:SDK Related to an SDK package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Easily accidental overriding Config with WithConfig in sdk/trace/provider.go
4 participants