-
Notifications
You must be signed in to change notification settings - Fork 783
config: add support for configuring propagators #6727
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
Changes from all commits
d09831f
2d858e6
5ec3c25
a73e9ea
df3d0af
88928e6
c485443
4cc8205
c6af81b
e40d6df
7a9f116
b61af11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
pellared marked this conversation as resolved.
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package config // import "go.opentelemetry.io/contrib/config/v0.3.0" | ||
|
|
||
| import ( | ||
| "errors" | ||
|
|
||
| "go.opentelemetry.io/contrib/propagators/autoprop" | ||
| "go.opentelemetry.io/otel/propagation" | ||
| ) | ||
|
|
||
| var ( | ||
| errInvalidPropagatorEmpty = errors.New("invalid propagator name: empty") | ||
| errInvalidPropagatorNil = errors.New("invalid propagator name: nil") | ||
| ) | ||
|
|
||
| func propagator(cfg configOptions) (propagation.TextMapPropagator, error) { | ||
| if cfg.opentelemetryConfig.Propagator == nil { | ||
| return autoprop.NewTextMapPropagator(), nil | ||
| } | ||
|
|
||
| n := len(cfg.opentelemetryConfig.Propagator.Composite) | ||
| if n == 0 { | ||
| return autoprop.NewTextMapPropagator(), nil | ||
| } | ||
|
Comment on lines
+23
to
+26
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a difference between "propagator": {
}, and "propagator": {
"composite": []
}, From the specification:
The first one should return the default value. The second an empty composite propagator. if cfg.opentelemetryConfig.Propagator.Composite == nil {
return propagation.NewCompositeTextMapPropagator()
}
n := len(cfg.opentelemetryConfig.Propagator.Composite)
if n == 0 {
return autoprop.NewTextMapPropagator(), nil
} |
||
|
|
||
| names := make([]string, 0, n) | ||
| for _, name := range cfg.opentelemetryConfig.Propagator.Composite { | ||
| if name == nil { | ||
| return nil, errInvalidPropagatorNil | ||
| } | ||
| if *name == "" { | ||
| return nil, errInvalidPropagatorEmpty | ||
| } | ||
|
Comment on lines
+33
to
+35
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not see anything in the schema that disallows using empty name. See: https://github.com/open-telemetry/opentelemetry-configuration/blob/main/schema/propagator.json
Sorry that I was not precise in #6727 (comment) 🙇
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i opened an issue in the configuration repo to discuss this, i submitted a PR to propose enforcing a minimum length on propagator configuration |
||
|
|
||
| names = append(names, *name) | ||
| } | ||
|
|
||
| return autoprop.TextMapPropagator(names...) | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.