open-telemetry / open-telemetry/opentelemetry-ruby

Implement `Logger#enabled?`

Open
#2,348 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

Logger SHOULD provide an Enabled function (api.md:105-107,131-157 (L105-L107, L131-L157)); the No-Op Enabled MUST always return false (noop.md:60-62 (permalink)); the SDK's Enabled MUST return false when there are no registered LogRecordProcessors or when all registered processors implement Enabled and return false, otherwise SHOULD return true (sdk.md:263-278 (permalink)); a LogRecordProcessor MAY implement its own Enabled to support this filtering (sdk.md:429-464 (permalink)).

Current behavior

No enabled?/enabled method exists on OpenTelemetry::Logs::Logger (logs_api/lib/opentelemetry/logs/logger.rb (permalink)), the SDK Logger (logs_sdk/lib/opentelemetry/sdk/logs/logger.rb (permalink)), the base LogRecordProcessor (logs_sdk/lib/opentelemetry/sdk/logs/log_record_processor.rb (permalink)), or either built-in processor.

Suggested fix

Add enabled to the no-op Logger (always false); add it to the SDK Logger (false if no processors are registered, else true unless every processor implements and returns false from its own Enabled); add an optional Enabled hook to LogRecordProcessor/SimpleLogRecordProcessor/BatchLogRecordProcessor.

Related rows in SPEC_COMPLIANCE_LOGS.md

API-8, API-11, NOOP-4, SDK-23, SDK-35

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

Review the API Logger, SDK Logger, LogRecordProcessor, SimpleLogRecordProcessor, and BatchLogRecordProcessor files named in the issue, starting with their current interfaces and processor registration flow. Implement the specified no-op, SDK, and processor-hook behavior, then verify it against the linked OpenTelemetry logs API, no-op, and SDK requirements and the API-8, API-11, NOOP-4, SDK-23, and SDK-35 compliance rows.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.