Skip to content

feat(semconv): autoload namespaces so a single require exposes all constants#2204

Open
bdewater-thatch wants to merge 2 commits into
open-telemetry:mainfrom
bdewater-thatch:semconv-autoload
Open

feat(semconv): autoload namespaces so a single require exposes all constants#2204
bdewater-thatch wants to merge 2 commits into
open-telemetry:mainfrom
bdewater-thatch:semconv-autoload

Conversation

@bdewater-thatch

Copy link
Copy Markdown
Contributor

Consuming apps previously had to require each SemConv namespace by hand (require 'opentelemetry/semconv/http'), which got verbose. This PR registers every stable and incubating namespace with Ruby's autoload instead, so a single require 'opentelemetry-semantic_conventions' makes them all referenceable while still loading a namespace's file only on first use, preserving the goal of not pulling in constants an app never touches.

…nstants

Consuming apps previously had to require each SemConv namespace by hand
(`require 'opentelemetry/semconv/http'`, ...), which got verbose. Register
every stable and incubating namespace with Ruby's `autoload` instead, so a
single `require 'opentelemetry-semantic_conventions'` makes them all
referenceable while still loading a namespace's file only on first use --
preserving the goal of not pulling in constants an app never touches.

- Generate lib/opentelemetry/semconv.rb (autoload manifest) via a new
  `generate_autoload_manifest` Rake task wired into `rake generate`; it reads
  the existing rollup files, so it needs no Docker/weaver.
- Require the manifest from the gem entrypoint. Backward compatible: manual
  per-namespace requires and the legacy SemanticConventions path still work.
- Document the single-require pattern in the README.
- Add tests covering lazy loading (in a clean subprocess) and a drift guard
  asserting every generated rollup has an autoload entry.
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