Skip to content

feat(chore): declarative configuration for trace_provider - #2161

Open
xuan-cao-swi wants to merge 17 commits into
open-telemetry:mainfrom
xuan-cao-swi:otelconfig
Open

feat(chore): declarative configuration for trace_provider#2161
xuan-cao-swi wants to merge 17 commits into
open-telemetry:mainfrom
xuan-cao-swi:otelconfig

Conversation

@xuan-cao-swi

@xuan-cao-swi xuan-cao-swi commented May 25, 2026

Copy link
Copy Markdown
Contributor

Description

This PR introduces an initial declarative configuration implementation for OpenTelemetry Ruby under otelconfig, intentionally scoped to tracing only.

I followed the Go otelconfig convention for config structure and behavior where it maps well to Ruby.

Minimalist approach: no hard dependency on optional components, which optional propagators and resource detectors are resolved only if the corresponding gem has been required by the user. If an optional component is not available, configuration continues safely with warnings instead of failing startup.

Scope in this PR

  • Trace configuration only:
    • tracer provider setup
    • samplers
    • span processors
    • trace exporters
    • span limits
  • Declarative resource and propagation wiring needed for trace setup
  • Instrumentation mapping/installation flow for declarative config
  • Tests and example configuration for the implemented behavior

Try /example

Updated (2026-06-13):

  • The in-memory struct of opentelemetry configuration now is based on https://github.com/open-telemetry/opentelemetry-configuration/tree/v1.0.0-rc.3/schema. bundle exec rake generate:constants will auto-generate the struct file.
  • configuration will return RubySDK struct that contain providers, which user need to set the global provider point to the providers
    sdk = OpenTelemetry::OtelConfig.configure
    OpenTelemetry.tracer_provider = sdk.tracer_provider

@thompson-tomo thompson-tomo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One other thing, how are we ensuring the loading of the the env variables are disabled when covered by declarative config?

Will the current approach support dynamic reloading of the config which is also a part of the spec?

Comment thread otelconfig/Rakefile Outdated
Comment thread otelconfig/lib/opentelemetry/components/trace.rb
Comment thread otelconfig/lib/opentelemetry/components/trace.rb
Comment thread otelconfig/lib/opentelemetry/components/trace.rb
Comment thread otelconfig/lib/opentelemetry/otelconfig/instrumentation.rb Outdated
Comment thread otelconfig/lib/opentelemetry/components/trace.rb
Comment thread otelconfig/lib/opentelemetry/otelconfig/resource.rb
Comment thread otelconfig/opentelemetry-otelconfig.gemspec Outdated
Comment thread otelconfig/opentelemetry-otelconfig.gemspec Outdated
Comment thread otelconfig/opentelemetry-otelconfig.gemspec Outdated
@xuan-cao-swi
xuan-cao-swi marked this pull request as ready for review June 15, 2026 19:36
@xuan-cao-swi
xuan-cao-swi requested review from a team as code owners June 29, 2026 18:07

@mwear mwear left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I like the approach overall. I have a few comments based on a first pass through.

Comment thread otelconfig/lib/tasks/generate_constants.rake
Comment thread otelconfig/opentelemetry-otelconfig.gemspec

private

def apply(config)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This only returns an SDK on the happy path. Other paths vary in what they return. We should define what happens on these other paths? Do we want to always return an SDK backed by no-op components or something else?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Now it will return noop sdk (e.g. noop provider and propagator) if parsing failed

Comment thread otelconfig/lib/opentelemetry-otelconfig.rb
Comment thread otelconfig/README.md

@mwear mwear left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry, I have been slow to review the declarative config PRs. I notice we also have #21960 proposing a slightly different shape for declarative config. We should discuss further in #2127 and see if we can align on an approach.

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.

3 participants