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

Clarify what LogRecordProcessor is able to modify #3902

Closed
pellared opened this issue Feb 26, 2024 · 2 comments · Fixed by #3907
Closed

Clarify what LogRecordProcessor is able to modify #3902

pellared opened this issue Feb 26, 2024 · 2 comments · Fixed by #3907
Assignees
Labels
spec:logs Related to the specification/logs directory triaged-accepted The issue is triaged and accepted by the OTel community, one can proceed with creating a PR proposal

Comments

@pellared
Copy link
Member

pellared commented Feb 26, 2024

What are you trying to achieve?

I want to model LogRecordProcessor for Go SDK (open-telemetry/opentelemetry-go#4896).

Currently this is what the spec says about ReadWriteLogRecord (the OnEmit argument):

A function receiving this as an argument MUST be able to write to the full LogRecord and additionally MUST be able to retrieve all information that was added to the LogRecord (as with ReadableLogRecord).

Take notice that the full LogRecord contains info such us Resource and InstrumentationScope. According to the spec the LogRecordProcessor should enable modifying them. Personally, I am not sure if it is desired.

What should we do if the processor modifies the resource? Should we alter it for records emitted by the SDK or only this one being processed?

What should we do if the processor modifies the instrumentation? Should we alter it for all records associated with the instrumentation scope or only this one being processed?

Can the processor also modify the counts for attributes due to collection limits?

Shouldn't the processor be only allowing to modify the fields which can be set via Emit (via `Logger) using the Bridge API?

Additionally, I am also not certain if the processor should be able to alter the Trace Context Fields.

I propose to explicitly list what LogRecordProcessor is able to modify.

Additional context

This is what it is possible to do with a LogRecordProcessor in different stable logs SDK implementations:

  • Java SDK allows only setting log attributes (replacing existing with same key or adding new)
  • .NET SDK operates on a record that does not allow accessing nor setting resource and instrumentation scope. However, it allows modifying the Trace Context Fields.
  • C++ SDK makes it possible to alter everything, including the resource and instrumentation scope (I have no idea what will happen in such case) and Trace Context Fields.
  • PHP SDK does not allow any log record modification
@pellared pellared added the spec:logs Related to the specification/logs directory label Feb 26, 2024
@MrAlias
Copy link
Contributor

MrAlias commented Feb 26, 2024

cc @open-telemetry/java-approvers @open-telemetry/dotnet-approvers @open-telemetry/php-approvers @open-telemetry/cpp-approvers @open-telemetry/specs-logs-approvers

@reyang reyang added the triaged-accepted The issue is triaged and accepted by the OTel community, one can proceed with creating a PR proposal label Feb 28, 2024
@jack-berg
Copy link
Member

Take notice that the full LogRecord contains info such us Resource and InstrumentationScope. According to the spec the LogRecordProcessor should enable modifying them. Personally, I am not sure if it is desired.

Discussed in the 2/27/24 spec SIG. The intent was not for log processors to be able to mutate scopes or resource. We should clarify this and treat it as a bug.

The log processor should be able to modify all the other fields on the log record, with exceptions for things like dropped_attributes_count, which are computed.

Additionally, I am also not certain if the processor should be able to alter the Trace Context Fields.

Trace context fields weren't discussed as an exception, so while I can't think of reasons why a processor would want to change them, I think allowing a processor to do so is aligned with the spirit of the specification.

I propose to explicitly list what LogRecordProcessor is able to modify.

I support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spec:logs Related to the specification/logs directory triaged-accepted The issue is triaged and accepted by the OTel community, one can proceed with creating a PR proposal
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants