open-telemetry / open-telemetry/opentelemetry-ruby

Log attribute-discard messages at most once per `LogRecord` (both truncation paths)

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

Nobody has claimed this yet.

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

Description

Spec requirement

There SHOULD be a message printed in the SDK's log to indicate an attribute was discarded due to a limit; to prevent excessive logging, the message MUST be printed at most once per LogRecord, not per discarded attribute (sdk.md:354-357 (permalink)).

Current behavior

logs_sdk/lib/opentelemetry/sdk/logs/log_record.rb:138-141 (permalink) (truncate_attributes, the attribute-count-limit path) drops excess attributes via attributes.shift with no logging call.

:143-159 (permalink) (validate_attributes, the type-validity path) calls OpenTelemetry.handle_error once per invalid attribute inside a keep_if block, so a record with 3 bad attributes logs 3 separate messages, causing too many messages to be logged.

Suggested fix

Add a single summarizing discard-logging call to truncate_attributes, and collect invalid-attribute violations in validate_attributes into one summary message per LogRecord instead of one handle_error call per attribute.

Related rows in SPEC_COMPLIANCE_LOGS.md

SDK-31

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_sdk/lib/opentelemetry/sdk/logs/log_record.rb, reading truncate_attributes and validate_attributes alongside sdk.md:354-357. Verify both attribute-discard paths and the existing OpenTelemetry.handle_error behavior. Done means each LogRecord produces at most one summarizing discard message, including when both truncation paths are involved.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.