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

Enable propagation of the trace context from collector #5670

Merged
merged 51 commits into from
Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
dd261c0
Enable propagation of the trace context from collector
pavankrish123 Jul 11, 2022
653ffb8
added changelog entry
pavankrish123 Jul 11, 2022
514136e
Update service/telemetry/config.go
pavankrish123 Jul 11, 2022
352436b
Merge branch 'main' into feature/prop
pavankrish123 Jul 11, 2022
9eeb7c0
merge conflict resolve
pavankrish123 Jul 11, 2022
987e213
Merge branch 'feature/prop' of https://github.com/pavankrish123/opent…
pavankrish123 Jul 11, 2022
2466bbd
added config per suggestion
pavankrish123 Jul 11, 2022
6aab1e0
added test file
pavankrish123 Jul 11, 2022
e33c768
added test file
pavankrish123 Jul 11, 2022
7067399
added test file
pavankrish123 Jul 11, 2022
dd94bc6
config->featuregate
pavankrish123 Jul 12, 2022
0f62c54
config -> featuregate
pavankrish123 Jul 12, 2022
ccf607e
fixed imports
pavankrish123 Jul 12, 2022
989932b
added test case
pavankrish123 Jul 12, 2022
e35e48b
added test case
pavankrish123 Jul 12, 2022
05c32ef
fixed comment
pavankrish123 Jul 12, 2022
c3e9798
fixed comment
pavankrish123 Jul 12, 2022
6b8b2e1
Update telemetry.go
pavankrish123 Jul 13, 2022
aaf9f96
Merge branch 'main' into feature/prop
pavankrish123 Jul 14, 2022
0661296
Merge branch 'feature/prop' of https://github.com/pavankrish123/opent…
pavankrish123 Jul 14, 2022
2163b0d
don't use autoprop
pavankrish123 Jul 14, 2022
abd268b
don't use autoprop
pavankrish123 Jul 14, 2022
75e6098
reverting back to using autoprop
pavankrish123 Jul 14, 2022
c5a453d
added comment
pavankrish123 Jul 14, 2022
48875c0
updated go.sum
pavankrish123 Jul 14, 2022
63a76f6
updated go.sum
pavankrish123 Jul 14, 2022
decb4f9
updated go.sum
pavankrish123 Jul 14, 2022
841b1c0
updated go.sum
pavankrish123 Jul 14, 2022
4df2ea5
Merge branch 'main' into feature/prop
pavankrish123 Jul 15, 2022
ae9579e
introduce configuration to read the list of propagtors to be enabled …
pavankrish123 Jul 28, 2022
df829e2
introduce configuration to read the list of propagtors to be enabled …
pavankrish123 Jul 28, 2022
3d9ac12
added tests
pavankrish123 Jul 28, 2022
9e35ff1
make genotelcorecol
pavankrish123 Jul 28, 2022
de1e7b4
Merge branch 'main' into feature/prop
pavankrish123 Jul 29, 2022
b9c9388
Merge branch 'main' into feature/prop
pavankrish123 Aug 5, 2022
c564d44
tracepropagation tests
pavankrish123 Aug 5, 2022
2a5d900
tracepropagation tests
pavankrish123 Aug 5, 2022
9843e9c
Merge branch 'main' into feature/prop
pavankrish123 Aug 5, 2022
b53ed76
tracepropagation tests
pavankrish123 Aug 5, 2022
924cd7a
Merge branch 'feature/prop' of https://github.com/pavankrish123/opent…
pavankrish123 Aug 5, 2022
797c415
updated autoprop version to official released
pavankrish123 Aug 8, 2022
e16886d
Merge branch 'main' into feature/prop
pavankrish123 Aug 8, 2022
83c045c
Merge branch 'main' into feature/prop
pavankrish123 Aug 12, 2022
1d78eee
go mod tidy
pavankrish123 Aug 12, 2022
c3c8f80
go mod tidy
pavankrish123 Aug 12, 2022
f6e4649
csv is now an actual list
pavankrish123 Aug 12, 2022
fc48710
made changes per latest suggestion
pavankrish123 Aug 16, 2022
18bf85d
Merge branch 'main' into feature/prop
pavankrish123 Aug 16, 2022
eea5c4e
fixed readme
pavankrish123 Aug 16, 2022
14df763
Merge branch 'main' into feature/prop
pavankrish123 Aug 16, 2022
b9272d5
Update CHANGELOG.md
Aug 16, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

### 💡 Enhancements 💡

- Add support to propagate trace context of collector's internal spans if `telemetry.allowTraceContextPropagation` featuregate is enabled (#5572)
pavankrish123 marked this conversation as resolved.
Show resolved Hide resolved

### 🧰 Bug fixes 🧰

## v0.58.0 Beta
Expand Down
7 changes: 6 additions & 1 deletion cmd/otelcorecol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ go 1.18
require (
github.com/stretchr/testify v1.8.0
go.opentelemetry.io/collector v0.58.0
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a
golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664
)

require (
Expand Down Expand Up @@ -59,6 +59,11 @@ require (
go.opentelemetry.io/collector/semconv v0.56.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.34.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.34.0 // indirect
go.opentelemetry.io/contrib/propagators/autoprop v0.34.0 // indirect
pavankrish123 marked this conversation as resolved.
Show resolved Hide resolved
go.opentelemetry.io/contrib/propagators/aws v1.9.0 // indirect
go.opentelemetry.io/contrib/propagators/b3 v1.9.0 // indirect
go.opentelemetry.io/contrib/propagators/jaeger v1.9.0 // indirect
go.opentelemetry.io/contrib/propagators/ot v1.9.0 // indirect
go.opentelemetry.io/contrib/zpages v0.34.0 // indirect
go.opentelemetry.io/otel v1.9.0 // indirect
go.opentelemetry.io/otel/exporters/prometheus v0.31.0 // indirect
Expand Down
13 changes: 12 additions & 1 deletion cmd/otelcorecol/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,16 @@ go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.3
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.34.0/go.mod h1:fk1+icoN47ytLSgkoWHLJrtVTSQ+HgmkNgPTKrk/Nsc=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.34.0 h1:9NkMW03wwEzPtP/KciZ4Ozu/Uz5ZA7kfqXJIObnrjGU=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.34.0/go.mod h1:548ZsYzmT4PL4zWKRd8q/N4z0Wxzn/ZxUE+lkEpwWQA=
go.opentelemetry.io/contrib/propagators/autoprop v0.34.0 h1:S1iBWYnf1iqK4O/qnjUhQ2MMNis/h5+LeB/51+uzGHI=
go.opentelemetry.io/contrib/propagators/autoprop v0.34.0/go.mod h1:lJppyBme+d8vGNukA9sHdlKvw/q4i4c9JXx2RTpuHmM=
go.opentelemetry.io/contrib/propagators/aws v1.9.0 h1:60BnkzNPdU3WD12oOGQNTjgbyws8iDggIaBWpghvcVo=
go.opentelemetry.io/contrib/propagators/aws v1.9.0/go.mod h1:lYGAfTJZU1mo92QxtuiuNJjRyRyEWj1ldO1b0Vpc1I0=
go.opentelemetry.io/contrib/propagators/b3 v1.9.0 h1:Lzb9zU98jCE2kyfCjWfSSsiQoGtvBL+COxvUBf7FNhU=
go.opentelemetry.io/contrib/propagators/b3 v1.9.0/go.mod h1:fyx3gFXn+4w5uWTTiqaI8oBNBW/6w9Ow5zxXf7NGixU=
go.opentelemetry.io/contrib/propagators/jaeger v1.9.0 h1:edJTgwezAtLKUINAXfjxllJ1vlsphNPV7RkuKNd/HkQ=
go.opentelemetry.io/contrib/propagators/jaeger v1.9.0/go.mod h1:Q/AXutvrBTfEDSeRLwOmKhyviX5adJvTesg6JFTybYg=
go.opentelemetry.io/contrib/propagators/ot v1.9.0 h1:+pYoqyFoA3H6EZ7Wie2ZQdqS4ZfG42PAGvj3eLUukHE=
go.opentelemetry.io/contrib/propagators/ot v1.9.0/go.mod h1:D2GfaecHHX67fXT93/5iKl2DArjt8+H0XWtFD8b4Z+k=
go.opentelemetry.io/contrib/zpages v0.34.0 h1:8ZXfrPkhegp/5GQYrO0pWMv2k3DQ7f+VBjaS6fMaBLM=
go.opentelemetry.io/contrib/zpages v0.34.0/go.mod h1:zuVCe4eoOREH+liRJLCtGITqL3NiUvkdr6U/4j9iQRg=
go.opentelemetry.io/otel v1.9.0 h1:8WZNQFIB2a71LnANS9JeyidJKKGOOremcUtb/OtHISw=
Expand Down Expand Up @@ -545,8 +555,9 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664 h1:v1W7bwXHsnLLloWYTVEdvGvA7BHMeBYsPcF0GLDxIRs=
golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
7 changes: 6 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ require (
go.opentelemetry.io/collector/semconv v0.56.0
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.34.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.34.0
go.opentelemetry.io/contrib/propagators/autoprop v0.34.0
go.opentelemetry.io/contrib/zpages v0.34.0
go.opentelemetry.io/otel v1.9.0
go.opentelemetry.io/otel/exporters/prometheus v0.31.0
Expand All @@ -35,7 +36,7 @@ require (
go.uber.org/multierr v1.8.0
go.uber.org/zap v1.21.0
golang.org/x/net v0.0.0-20220225172249-27dd8689420f
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a
golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa
google.golang.org/grpc v1.48.0
google.golang.org/protobuf v1.28.1
Expand Down Expand Up @@ -73,6 +74,10 @@ require (
github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tklauser/numcpus v0.4.0 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.opentelemetry.io/contrib/propagators/aws v1.9.0 // indirect
go.opentelemetry.io/contrib/propagators/b3 v1.9.0 // indirect
go.opentelemetry.io/contrib/propagators/jaeger v1.9.0 // indirect
go.opentelemetry.io/contrib/propagators/ot v1.9.0 // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
Expand Down
13 changes: 12 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,16 @@ go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.3
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.34.0/go.mod h1:fk1+icoN47ytLSgkoWHLJrtVTSQ+HgmkNgPTKrk/Nsc=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.34.0 h1:9NkMW03wwEzPtP/KciZ4Ozu/Uz5ZA7kfqXJIObnrjGU=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.34.0/go.mod h1:548ZsYzmT4PL4zWKRd8q/N4z0Wxzn/ZxUE+lkEpwWQA=
go.opentelemetry.io/contrib/propagators/autoprop v0.34.0 h1:S1iBWYnf1iqK4O/qnjUhQ2MMNis/h5+LeB/51+uzGHI=
go.opentelemetry.io/contrib/propagators/autoprop v0.34.0/go.mod h1:lJppyBme+d8vGNukA9sHdlKvw/q4i4c9JXx2RTpuHmM=
go.opentelemetry.io/contrib/propagators/aws v1.9.0 h1:60BnkzNPdU3WD12oOGQNTjgbyws8iDggIaBWpghvcVo=
go.opentelemetry.io/contrib/propagators/aws v1.9.0/go.mod h1:lYGAfTJZU1mo92QxtuiuNJjRyRyEWj1ldO1b0Vpc1I0=
go.opentelemetry.io/contrib/propagators/b3 v1.9.0 h1:Lzb9zU98jCE2kyfCjWfSSsiQoGtvBL+COxvUBf7FNhU=
go.opentelemetry.io/contrib/propagators/b3 v1.9.0/go.mod h1:fyx3gFXn+4w5uWTTiqaI8oBNBW/6w9Ow5zxXf7NGixU=
go.opentelemetry.io/contrib/propagators/jaeger v1.9.0 h1:edJTgwezAtLKUINAXfjxllJ1vlsphNPV7RkuKNd/HkQ=
go.opentelemetry.io/contrib/propagators/jaeger v1.9.0/go.mod h1:Q/AXutvrBTfEDSeRLwOmKhyviX5adJvTesg6JFTybYg=
go.opentelemetry.io/contrib/propagators/ot v1.9.0 h1:+pYoqyFoA3H6EZ7Wie2ZQdqS4ZfG42PAGvj3eLUukHE=
go.opentelemetry.io/contrib/propagators/ot v1.9.0/go.mod h1:D2GfaecHHX67fXT93/5iKl2DArjt8+H0XWtFD8b4Z+k=
go.opentelemetry.io/contrib/zpages v0.34.0 h1:8ZXfrPkhegp/5GQYrO0pWMv2k3DQ7f+VBjaS6fMaBLM=
go.opentelemetry.io/contrib/zpages v0.34.0/go.mod h1:zuVCe4eoOREH+liRJLCtGITqL3NiUvkdr6U/4j9iQRg=
go.opentelemetry.io/otel v1.9.0 h1:8WZNQFIB2a71LnANS9JeyidJKKGOOremcUtb/OtHISw=
Expand Down Expand Up @@ -549,8 +559,9 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664 h1:v1W7bwXHsnLLloWYTVEdvGvA7BHMeBYsPcF0GLDxIRs=
golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
44 changes: 44 additions & 0 deletions service/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,50 @@ func TestCollectorStartWithOpenTelemetryMetrics(t *testing.T) {
}
}

func TestCollectorStartWithTraceContextPropagation(t *testing.T) {
tests := []struct {
file string
errExpected bool
}{
{file: "otelcol-invalidprop.yaml", errExpected: true},
{file: "otelcol-nop.yaml", errExpected: false},
}

for _, tt := range tests {
t.Run(tt.file, func(t *testing.T) {
factories, err := componenttest.NopFactories()
require.NoError(t, err)

cfgProvider, err := NewConfigProvider(newDefaultConfigProviderSettings([]string{filepath.Join("testdata", tt.file)}))
require.NoError(t, err)

colTel := newColTelemetry(featuregate.NewRegistry())
err = colTel.registry.Apply(map[string]bool{allowTraceContextPropagationFeatureGateID: true})
require.NoError(t, err)

set := CollectorSettings{
BuildInfo: component.NewDefaultBuildInfo(),
Factories: factories,
ConfigProvider: cfgProvider,
telemetry: colTel,
}

col, err := New(set)
require.NoError(t, err)

if tt.errExpected {
require.Error(t, col.Run(context.Background()))
assert.Equal(t, Closed, col.GetState())
} else {
wg := startCollector(context.Background(), t, col)
col.Shutdown()
wg.Wait()
assert.Equal(t, Closed, col.GetState())
}
})
}
}

func TestCollectorRun(t *testing.T) {
tests := []struct {
file string
Expand Down
7 changes: 7 additions & 0 deletions service/internal/configunmarshaler/defaultunmarshaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ func unmarshalService(srvRaw map[string]interface{}) (config.Service, error) {
InitialFields: map[string]interface{}(nil),
},
Metrics: defaultServiceTelemetryMetricsSettings(),
Traces: defaultServiceTelemetryTracesSettings(),
},
}

Expand All @@ -204,6 +205,12 @@ func defaultServiceTelemetryMetricsSettings() telemetry.MetricsConfig {
}
}

func defaultServiceTelemetryTracesSettings() telemetry.TracesConfig {
return telemetry.TracesConfig{
Propagators: "tracecontext",
}
}

// LoadReceiver loads a receiver config from componentConfig using the provided factories.
func LoadReceiver(componentConfig *confmap.Conf, id config.ComponentID, factory component.ReceiverFactory) (config.Receiver, error) {
// Create the default config for this receiver.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func TestDecodeConfig(t *testing.T) {
Level: configtelemetry.LevelNormal,
Address: ":8081",
},
Traces: telemetry.TracesConfig{Propagators: "tracecontext"},
}, cfg.Service.Telemetry)

// Verify Service Extensions
Expand Down
26 changes: 26 additions & 0 deletions service/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import (
ocmetric "go.opencensus.io/metric"
"go.opencensus.io/metric/metricproducer"
"go.opencensus.io/stats/view"
"go.opentelemetry.io/contrib/propagators/autoprop"
"go.opentelemetry.io/otel"
otelprometheus "go.opentelemetry.io/otel/exporters/prometheus"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/sdk/metric/aggregator/histogram"
Expand Down Expand Up @@ -54,6 +56,10 @@ const (
// useOtelForInternalMetricsfeatureGateID is the feature gate ID that controls whether the collector uses open
// telemetrySettings for internal metrics.
useOtelForInternalMetricsfeatureGateID = "telemetry.useOtelForInternalMetrics"

// allowTraceContextPropagationFeatureGateID is the feature gate ID to propagate trace context of collector's
// internal spans
allowTraceContextPropagationFeatureGateID = "telemetry.allowTraceContextPropagation"
)

type telemetryInitializer struct {
Expand All @@ -74,6 +80,13 @@ func newColTelemetry(registry *featuregate.Registry) *telemetryInitializer {
Description: "controls whether the collector to uses OpenTelemetry for internal metrics",
Enabled: false,
})

registry.MustRegister(featuregate.Gate{
ID: allowTraceContextPropagationFeatureGateID,
Description: "controls whether to propagate trace context headers of the internal spans",
Enabled: false,
})

return &telemetryInitializer{
registry: registry,
mp: metric.NewNoopMeterProvider(),
Expand Down Expand Up @@ -124,6 +137,19 @@ func (tel *telemetryInitializer) initOnce(buildInfo component.BuildInfo, logger
telAttrs[semconv.AttributeServiceVersion] = buildInfo.Version
}

if tel.registry.IsEnabled(allowTraceContextPropagationFeatureGateID) {
Copy link
Member

Choose a reason for hiding this comment

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

This absolutely needs to be documented. Can it be done as part of this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @jpkrohling I will add the section to telemetry doc in another PR after this is merged.

Copy link
Member

Choose a reason for hiding this comment

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

I think a simpler implementation is to make this featuregate just control the default of the configuration. So the list is empty if the gate is not enabled, otherwise is ["tracecontext]? What do you think? Then be default we don't send this, also we have the gate to change the behavior to be default send, and for people that enable the config works without any gate?

props := strings.Split(cfg.Traces.Propagators, ",")

textMapPropagators, err := autoprop.TextMapPropagator(props...)
pavankrish123 marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return err
}

if textMapPropagators != nil {
otel.SetTextMapPropagator(textMapPropagators)
}
}

var pe http.Handler
var err error
if tel.registry.IsEnabled(useOtelForInternalMetricsfeatureGateID) {
Expand Down
9 changes: 9 additions & 0 deletions service/telemetry/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
type Config struct {
Logs LogsConfig `mapstructure:"logs"`
Metrics MetricsConfig `mapstructure:"metrics"`
Traces TracesConfig `mapstructure:"traces"`
bogdandrutu marked this conversation as resolved.
Show resolved Hide resolved

// Resource specifies user-defined attributes to include with all emitted telemetry.
// Note that some attributes are added automatically (e.g. service.version) even
Expand Down Expand Up @@ -103,3 +104,11 @@ type MetricsConfig struct {
// Address is the [address]:port that metrics exposition should be bound to.
Address string `mapstructure:"address"`
}

// TracesConfig exposes the common Telemetry configuration for collector's internal spans.
type TracesConfig struct {
// Propagators is a comma separated list of TextMapPropagators from the default registered list
// (tracecontext, baggage, b3, b3multi, jaeger, xray, or ottrace). The default propagator used in
// tracecontext and setting the vale to "none" disables the context propagation altogether.
Propagators string `mapstructure:"propagators"`
pavankrish123 marked this conversation as resolved.
Show resolved Hide resolved
}
18 changes: 18 additions & 0 deletions service/testdata/otelcol-invalidprop.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
receivers:
nop:

processors:
nop:

exporters:
nop:

service:
telemetry:
traces:
propagators: "unknown,tracecontext"
pipelines:
traces:
receivers: [nop]
processors: [nop]
exporters: [nop]