Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sdk/log: Log when an attribute was discarded or truncated due to limits #5317

Closed
pellared opened this issue May 8, 2024 · 1 comment · Fixed by #5376
Closed

sdk/log: Log when an attribute was discarded or truncated due to limits #5317

pellared opened this issue May 8, 2024 · 1 comment · Fixed by #5376
Assignees
Labels
area:logs Part of OpenTelemetry logs enhancement New feature or request pkg:SDK Related to an SDK package
Milestone

Comments

@pellared
Copy link
Member

pellared commented May 8, 2024

From https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/sdk.md#logrecord-limits:

There SHOULD be a message printed in the SDK's log to indicate to the user that an attribute was discarded due to such a limit. To prevent excessive logging, the message MUST be printed at most once per LogRecord (i.e., not per discarded attribute).

@pellared pellared added enhancement New feature or request pkg:SDK Related to an SDK package area:logs Part of OpenTelemetry logs labels May 8, 2024
@MrAlias

This comment was marked as resolved.

@MrAlias MrAlias modified the milestones: v1.27.0, v1.28.0 May 10, 2024
@MrAlias MrAlias self-assigned this May 17, 2024
MrAlias added a commit that referenced this issue May 28, 2024
Fix #5317 

According to the
[specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/sdk.md#logrecord-limits),
there should be a message printed in the SDK's log to indicate to the
user that an attribute was discarded due to such a limit. To prevent
excessive logging, the message must be printed at most once per
`LogRecord` (i.e., not per discarded attribute).

This change centralizes the `Record` dropped field writes and calls a
global logging function. This will at most log once per any `Record`
dropping attributes, meeting the specification requirement.

This does not log once per `Record` when an attribute is dropped. To do
that we would need to maintain state within the `Record` (i.e.
`sync.Mutex` or `sync.Once`). These types cannot be copied, meaning the
`Record` would take on this "no copy" requirement. This seems too
restrictive and with the permissive specification allowing a single log
line, that is the solution added.

---------

Co-authored-by: Robert Pająk <pellared@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:logs Part of OpenTelemetry logs enhancement New feature or request pkg:SDK Related to an SDK package
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants