Skip to content

Conversation

iRevive
Copy link
Contributor

@iRevive iRevive commented Jul 19, 2025

@iRevive iRevive requested a review from NthPortal July 19, 2025 06:13
@mergify mergify bot added module:core Features and improvements to core module logs Improvements to logs module labels Jul 19, 2025
* @see
* [[https://opentelemetry.io/docs/specs/otel/logs/data-model/]]
*/
trait LogRecordBuilder[F[_], Ctx] {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the unfortunate part.

The spec explicitly says the API must accept the Context:

The Context associated with the LogRecord. When implicit Context is supported, then this parameter SHOULD be optional and if unspecified then MUST use current Context. When only explicit Context is supported, this parameter SHOULD be required.

@iRevive
Copy link
Contributor Author

iRevive commented Jul 28, 2025

@NthPortal could you please take a look at it once you have a moment?

Copy link
Contributor

@NthPortal NthPortal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm so sorry for taking so long.

I'm a bit concerned that this part of the spec is listed as having the "Development" status, but this code does seem to follow the spec.

my only concern is that it seems to be missing a way to add an EventName

@iRevive
Copy link
Contributor Author

iRevive commented Jul 29, 2025

I'm a bit concerned that this part of the spec is listed as having the "Development" status, but this code does seem to follow the spec.

That's a fair concern. If I understand correctly, only the attribute-conversion API is under development.

The API SHOULD provide functionality for users to convert Standard Attributes so they can be used, or directly accept them, in the log signal. This allows the reuse of Standard Attributes across signals.

The log record builder API accepts logs attributes, which is basically Map[String, AnyValue], while we use standard attributes Map[String, Attribute[_]].

otel-java uses standard attributes in the LogRecordBuilder API as well: https://github.com/open-telemetry/opentelemetry-java/blob/v1.52.0/api/all/src/main/java/io/opentelemetry/api/logs/LogRecordBuilder.java#L98-L105.

And there is a problem. Even if we define LogsAttributes = Map[String, AnyValue], we cannot translate them directly into the standard attributes, and as a result, we cannot reliably use otel-java as a backend.

I think at this point we should follow oteljava route.

my only concern is that it seems to be missing a way to add an EventName

Hm, indeed. Let me add this one.

@iRevive iRevive closed this Jul 29, 2025
@iRevive iRevive reopened this Jul 29, 2025
@iRevive
Copy link
Contributor Author

iRevive commented Jul 30, 2025

Done. I added the withEventName method

@iRevive iRevive requested a review from NthPortal July 30, 2025 12:04
@iRevive iRevive merged commit d71013f into typelevel:main Aug 2, 2025
11 checks passed
@iRevive iRevive deleted the core-logs/log-record-builder branch August 2, 2025 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
logs Improvements to logs module module:core Features and improvements to core module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants