-
Notifications
You must be signed in to change notification settings - Fork 725
otelconf: add support for 1.0.0 release candidate #8026
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
Merged
MrAlias
merged 58 commits into
open-telemetry:main
from
codeboten:codeboten/otelconf-v1.0.0-rc1
Nov 24, 2025
Merged
Changes from 54 commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
03578c6
copy v0.3.0 and update import definition
codeboten ba8730b
update AttributeNameValueType to AttributeType
codeboten b21f94b
update Zipkin to ZipkinSpanExporter
codeboten 6c9e47c
rename LanguageSpecificInstrumentation -> ExperimentalLanguageSpecifi…
codeboten 245cd8c
Prometheus -> ExperimentalPrometheusMetricExporter
codeboten 1005fcb
Console -> ConsoleExporter
codeboten 967e3c4
update OTLP exporter config
codeboten 7f63de5
add testdata
codeboten c9611d9
update config
codeboten ca1e391
update signals
codeboten 7d4de9a
update resource parsing
codeboten 6192a42
incremental improvements
codeboten 1840b0a
add 1.0.0-rc1 test file
codeboten 45598a1
set defaults for disabled/log_level
codeboten 625f805
add json parsing/tests
codeboten 472e29b
refactor common logic
codeboten 8ad1d98
add env parsing test
codeboten 115b925
fix test
codeboten 24718b1
fix license check
codeboten e252a4c
add changelog
codeboten 4f8330f
move common code
codeboten 63b3719
add validation tests for BatchLogRecordProcessor
codeboten 3e75483
add validation tests for BatchSpanProcessor
codeboten 2948c97
add validation/tests for CardinalityLimits
codeboten 5bb32a3
add validation/tests for SpanLimits
codeboten f768493
these have been moved
codeboten 9b5fc2c
remove dupe files, update test data to add detectors TODO
codeboten 6237c08
remove createTLSConfig, reuse refactored code
codeboten 64211b5
clean up
codeboten 5e18781
test cleanup
codeboten 49f9e77
remove dead code
codeboten 91eda36
lint
codeboten c14fcc3
re-enable tests with NewSDK
codeboten 8d05a12
clean up
codeboten 2714a67
update tests
codeboten e10a1b2
Added Test for http.Handler returned from zpages.NewTracezHandler (#8…
sonalgaud12 577d0d2
Merge branch 'main' into codeboten/otelconf-v1.0.0-rc1
codeboten e5659f0
Merge branch 'main' into codeboten/otelconf-v1.0.0-rc1
codeboten 666c1ee
Merge branch 'main' into codeboten/otelconf-v1.0.0-rc1
codeboten ae318e2
Merge branch 'main' into codeboten/otelconf-v1.0.0-rc1
codeboten d37bcf6
Merge branch 'main' into codeboten/otelconf-v1.0.0-rc1
codeboten d3c85a7
Merge branch 'main' into codeboten/otelconf-v1.0.0-rc1
codeboten ad8ca18
Merge branch 'main' into codeboten/otelconf-v1.0.0-rc1
codeboten 7c259a9
Merge branch 'main' into codeboten/otelconf-v1.0.0-rc1
codeboten 4201525
Merge branch 'main' into codeboten/otelconf-v1.0.0-rc1
codeboten 6b54d73
support translation strategy
codeboten 820d03a
tidy
codeboten 770913b
Merge branch 'main' into codeboten/otelconf-v1.0.0-rc1
codeboten 2932999
Merge branch 'main' into codeboten/otelconf-v1.0.0-rc1
codeboten 9e5302e
Merge branch 'main' into codeboten/otelconf-v1.0.0-rc1
codeboten d5d3fc2
Merge branch 'main' into codeboten/otelconf-v1.0.0-rc1
codeboten 2ee1554
Update otelconf/fuzz_test.go
codeboten ddf240a
Merge branch 'main' into codeboten/otelconf-v1.0.0-rc1
codeboten 0365499
Merge branch 'main' into codeboten/otelconf-v1.0.0-rc1
codeboten 76b7e9e
tidy
codeboten d39555e
Update otelconf/testdata/v1.0.0.yaml
codeboten 240c0b8
Update otelconf/config_test.go
codeboten 5e66923
Merge branch 'main' into codeboten/otelconf-v1.0.0-rc1
codeboten File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,171 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| // Package otelconf provides an OpenTelemetry declarative configuration SDK. | ||
| package otelconf // import "go.opentelemetry.io/contrib/otelconf" | ||
|
|
||
| import ( | ||
| "context" | ||
| "errors" | ||
|
|
||
| "go.opentelemetry.io/otel/log" | ||
| nooplog "go.opentelemetry.io/otel/log/noop" | ||
| "go.opentelemetry.io/otel/metric" | ||
| noopmetric "go.opentelemetry.io/otel/metric/noop" | ||
| sdklog "go.opentelemetry.io/otel/sdk/log" | ||
| sdkmetric "go.opentelemetry.io/otel/sdk/metric" | ||
| sdktrace "go.opentelemetry.io/otel/sdk/trace" | ||
| "go.opentelemetry.io/otel/trace" | ||
| nooptrace "go.opentelemetry.io/otel/trace/noop" | ||
| yaml "go.yaml.in/yaml/v3" | ||
|
|
||
| "go.opentelemetry.io/contrib/otelconf/internal/provider" | ||
| ) | ||
|
|
||
| // SDK is a struct that contains all the providers | ||
| // configured via the configuration model. | ||
| type SDK struct { | ||
| meterProvider metric.MeterProvider | ||
| tracerProvider trace.TracerProvider | ||
| loggerProvider log.LoggerProvider | ||
| shutdown shutdownFunc | ||
| } | ||
|
|
||
| // TracerProvider returns a configured trace.TracerProvider. | ||
| func (s *SDK) TracerProvider() trace.TracerProvider { | ||
| return s.tracerProvider | ||
| } | ||
|
|
||
| // MeterProvider returns a configured metric.MeterProvider. | ||
| func (s *SDK) MeterProvider() metric.MeterProvider { | ||
| return s.meterProvider | ||
| } | ||
|
|
||
| // LoggerProvider returns a configured log.LoggerProvider. | ||
| func (s *SDK) LoggerProvider() log.LoggerProvider { | ||
| return s.loggerProvider | ||
| } | ||
|
|
||
| // Shutdown calls shutdown on all configured providers. | ||
| func (s *SDK) Shutdown(ctx context.Context) error { | ||
| return s.shutdown(ctx) | ||
| } | ||
|
|
||
| var noopSDK = SDK{ | ||
| loggerProvider: nooplog.LoggerProvider{}, | ||
| meterProvider: noopmetric.MeterProvider{}, | ||
| tracerProvider: nooptrace.TracerProvider{}, | ||
| shutdown: func(context.Context) error { return nil }, | ||
| } | ||
|
|
||
| // NewSDK creates SDK providers based on the configuration model. | ||
| func NewSDK(opts ...ConfigurationOption) (SDK, error) { | ||
| o := configOptions{ | ||
| ctx: context.Background(), | ||
| } | ||
| for _, opt := range opts { | ||
| o = opt.apply(o) | ||
| } | ||
| if o.opentelemetryConfig.Disabled != nil && *o.opentelemetryConfig.Disabled { | ||
| return noopSDK, nil | ||
| } | ||
|
|
||
| r, err := newResource(o.opentelemetryConfig.Resource) | ||
| if err != nil { | ||
| return noopSDK, err | ||
| } | ||
|
|
||
| mp, mpShutdown, err := meterProvider(o, r) | ||
| if err != nil { | ||
| return noopSDK, err | ||
| } | ||
|
|
||
| tp, tpShutdown, err := tracerProvider(o, r) | ||
| if err != nil { | ||
| return noopSDK, err | ||
| } | ||
|
|
||
| lp, lpShutdown, err := loggerProvider(o, r) | ||
| if err != nil { | ||
| return noopSDK, err | ||
| } | ||
|
|
||
| return SDK{ | ||
| meterProvider: mp, | ||
| tracerProvider: tp, | ||
| loggerProvider: lp, | ||
| shutdown: func(ctx context.Context) error { | ||
| return errors.Join(mpShutdown(ctx), tpShutdown(ctx), lpShutdown(ctx)) | ||
| }, | ||
| }, nil | ||
| } | ||
|
|
||
| // ConfigurationOption configures options for providers. | ||
| type ConfigurationOption interface { | ||
| apply(configOptions) configOptions | ||
| } | ||
|
|
||
| type configurationOptionFunc func(configOptions) configOptions | ||
|
|
||
| func (fn configurationOptionFunc) apply(cfg configOptions) configOptions { | ||
| return fn(cfg) | ||
| } | ||
|
|
||
| // WithContext sets the context.Context for the SDK. | ||
| func WithContext(ctx context.Context) ConfigurationOption { | ||
| return configurationOptionFunc(func(c configOptions) configOptions { | ||
| c.ctx = ctx | ||
| return c | ||
| }) | ||
| } | ||
|
|
||
| // WithOpenTelemetryConfiguration sets the OpenTelemetryConfiguration used | ||
| // to produce the SDK. | ||
| func WithOpenTelemetryConfiguration(cfg OpenTelemetryConfiguration) ConfigurationOption { | ||
| return configurationOptionFunc(func(c configOptions) configOptions { | ||
| c.opentelemetryConfig = cfg | ||
| return c | ||
| }) | ||
| } | ||
|
|
||
| // WithLoggerProviderOptions appends LoggerProviderOptions used for constructing | ||
| // the LoggerProvider. OpenTelemetryConfiguration takes precedence over these options. | ||
| func WithLoggerProviderOptions(opts ...sdklog.LoggerProviderOption) ConfigurationOption { | ||
| return configurationOptionFunc(func(c configOptions) configOptions { | ||
| c.loggerProviderOptions = append(c.loggerProviderOptions, opts...) | ||
| return c | ||
| }) | ||
| } | ||
|
|
||
| // WithMeterProviderOptions appends metric.Options used for constructing the | ||
| // MeterProvider. OpenTelemetryConfiguration takes precedence over these options. | ||
| func WithMeterProviderOptions(opts ...sdkmetric.Option) ConfigurationOption { | ||
| return configurationOptionFunc(func(c configOptions) configOptions { | ||
| c.meterProviderOptions = append(c.meterProviderOptions, opts...) | ||
| return c | ||
| }) | ||
| } | ||
|
|
||
| // WithTracerProviderOptions appends TracerProviderOptions used for constructing | ||
| // the TracerProvider. OpenTelemetryConfiguration takes precedence over these options. | ||
| func WithTracerProviderOptions(opts ...sdktrace.TracerProviderOption) ConfigurationOption { | ||
| return configurationOptionFunc(func(c configOptions) configOptions { | ||
| c.tracerProviderOptions = append(c.tracerProviderOptions, opts...) | ||
| return c | ||
| }) | ||
| } | ||
|
|
||
| // ParseYAML parses a YAML configuration file into an OpenTelemetryConfiguration. | ||
| func ParseYAML(file []byte) (*OpenTelemetryConfiguration, error) { | ||
| file, err := provider.ReplaceEnvVars(file) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| var cfg OpenTelemetryConfiguration | ||
| err = yaml.Unmarshal(file, &cfg) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| return &cfg, nil | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.