open-telemetry / open-telemetry/opentelemetry-ruby

Add `attributes` support to LoggerProvider#logger

Open
#2,346 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement logs spec-compliance spec:stable
Dominant language
Ruby
Stars
606
Forks
301
Avg merge
3d 19h
Merged PRs (30d)
42

Description

Spec requirement

Get a Logger MUST be structured to accept a variable number of instrumentation-scope attributes, including none (api.md:86-91).

Current behavior

Neither the no-op LoggerProvider#logger (logs_api/lib/opentelemetry/logs/logger_provider.rb:20 (permalink)) nor the SDK's version of the method (logs_sdk/lib/opentelemetry/sdk/logs/logger_provider.rb:44 (permalink)) accept an attributes parameter. logs_sdk/lib/opentelemetry/sdk/logs/logger.rb:25 (permalink) builds InstrumentationScope.new(name, version) without a slot to receive either.
The InstrumentationScope class sdk/lib/opentelemetry/sdk/instrumentation_scope.rb (permalink) has been recently updated to accept attributes and these improvements should be included in logs.

Suggested fix

Add attributes: keyword param to both LoggerProvider#logger implementations. See PR #2273 for how Metrics added this keyword.

Related rows in SPEC_COMPLIANCE_LOGS.md

API-6, NOOP-2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with logs_api/lib/opentelemetry/logs/logger_provider.rb:20 and logs_sdk/lib/opentelemetry/sdk/logs/logger_provider.rb:44, then inspect logs_sdk/lib/opentelemetry/sdk/logs/logger.rb:25 and the updated InstrumentationScope class. Review PR #2273 for the Metrics pattern. Done means both logger methods accept optional attributes and the SDK passes them into InstrumentationScope, covering API-6 and NOOP-2.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
observability
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
84/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.