Skip to content

[logs-sdk] Remove LogData and extend SDK LogRecord to have instrumentation scope #4676

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

hectorhdzg
Copy link
Member

@hectorhdzg hectorhdzg commented Jul 9, 2025

Description

Removing LogData and extending SDK LogRecord to have instrumentation scope

Fixes #4313

Type of change

Please delete options that are not relevant.

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A

@hectorhdzg hectorhdzg requested a review from a team as a code owner July 9, 2025 23:05
@hectorhdzg
Copy link
Member Author

Contrib tests expect an object like log.log_record returned in log_exporter.get_finished_logs()
I can update contrib tests for this breaking issue, let me know your thoughts

@DylanRussell
Copy link
Contributor

What if instead of removing LogData, we remove LogRecord from the SDK, and update LogData to have 3 fields: the API LogRecord, the resource, and the instrumentation_scope..

I don't think we need a LogRecord in both the API and the SDK, when they are exactly the same except for 2 additional fields on the SDK version (resource and instrumentation_scope)..

This way we don't need to update 2 classes every time a change is made to the log data structure.

Also I think our implementation is confusing the 2 classes in a bunch of places maybe because they are named the same. For example I think Logger.emit should be taking an API LogRecord instead of an SDK one. We tell instrumentations to use the API LogRecord, and instrumentations therfore call Logger.emit with the API LogRecord, the SDK implementation should be adding instrumentation_scope and resource (to LogData) and then forward it along..

@hectorhdzg
Copy link
Member Author

@DylanRussell
Copy link
Contributor

DylanRussell commented Jul 14, 2025

Yeah I think i'm OK with that name too. But what do you think of it being just the 3 fields I mentioned above ? And switching Logger.emit in the SDK to take the API LogRecord and then create the SDK LogRecord and attach instrumentation_scope/resource to it..

That looks to be what javascript is doing too:

https://github.com/open-telemetry/opentelemetry-js/blob/99dde7786f52d8d7e3d080a0a69b9685104c29e2/experimental/packages/sdk-logs/src/Logger.ts#L42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Logs SDK: consider removing LogData and extending SDK LogRecord to have instrumentation scope
2 participants