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

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

Open
aabmass opened this issue Jan 24, 2025 · 4 comments
Open

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

aabmass opened this issue Jan 24, 2025 · 4 comments
Labels

Comments

@aabmass
Copy link
Member

aabmass commented Jan 24, 2025

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.
@drewby
Copy link
Member

drewby commented Jan 27, 2025

We are currently making an implicit assumption that events are recorded as part of a span, but the specification does not explicitly require this—though all the examples at the end show events within spans. It might be worth updating the specification to clarify this expectation either way.

@xrmx
Copy link
Contributor

xrmx commented Jan 27, 2025

My thinking is that traces and logs are two different signals and so they should be ~independent.

@aabmass
Copy link
Member Author

aabmass commented Jan 27, 2025

I agree it's cleaner to keep them separate when writing instrumentation. Maybe the logging SDK can provide a means to tie span sampling to event sampling. We have some precedent here in Exemplars where the default ExemplarFilter is TraceBased.

@aabmass aabmass changed the title Should GenAI events be recorded only when a span is recording? Provide a way for Logs SDK to sample based on span context Jan 31, 2025
@aabmass
Copy link
Member Author

aabmass commented Jan 31, 2025

Discussed in SIG and we agreed Logs/events SDK should have way to configure this behavior. Changing to a feature request and I think we may need a spec discussion

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

No branches or pull requests

3 participants