Skip to content

Provide a way for Logs SDK to sample based on span context #3207

Open
@aabmass

Description

@aabmass

The OpenAI instrumentation currently only records events if the span is recording:

if span.is_recording():
for message in kwargs.get("messages", []):
event_logger.emit(
message_to_event(message, capture_content)
)

This makes sense, since event recording can be quite expensive and we can piggyback on the sampling decision. However it feels like the Logging API should be more integrated and instrumentation shouldn't need to do these checks. Most logging libraries also have an API to check if recording like Logger.isEnabledFor() and/or support lazy evaluation of log fields. So two questions are

  1. Should GenAI events be recorded only when a span is recording?
  2. Should the instrumentation be in charge of this or should the Logging SDK provide its own API to check for recording or lazily evaluate log entry fields.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions