-
Notifications
You must be signed in to change notification settings - Fork 408
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
feat(llmobs): submit span events rather than llmobs records #8339
Conversation
BenchmarksBenchmark execution time: 2024-02-14 23:07:55 Comparing candidate commit c7d15a1 in PR branch Found 20 performance improvements and 17 performance regressions! Performance is the same for 158 metrics, 9 unstable metrics. scenario:coreapiscenario-context_with_data_no_listeners
scenario:coreapiscenario-core_dispatch_no_listeners
scenario:coreapiscenario-core_dispatch_only_all_listeners
scenario:coreapiscenario-core_dispatch_with_results_no_listeners
scenario:flasksimple-appsec-telemetry
scenario:httppropagationextract-datadog_tracecontext_tracestate_propagated_on_trace_id_match
scenario:httppropagationextract-empty_headers
scenario:httppropagationextract-invalid_span_id_header
scenario:httppropagationextract-invalid_trace_id_header
scenario:httppropagationextract-large_valid_headers_all
scenario:httppropagationextract-medium_valid_headers_all
scenario:httppropagationextract-none_propagation_style
scenario:httppropagationextract-valid_headers_all
scenario:httppropagationextract-valid_headers_basic
scenario:httppropagationextract-wsgi_invalid_trace_id_header
scenario:httppropagationextract-wsgi_large_header_no_matches
scenario:httppropagationextract-wsgi_large_valid_headers_all
scenario:httppropagationextract-wsgi_medium_header_no_matches
scenario:httppropagationextract-wsgi_medium_valid_headers_all
scenario:httppropagationextract-wsgi_valid_headers_all
scenario:httppropagationinject-with_all
scenario:httppropagationinject-with_dd_origin
scenario:httppropagationinject-with_priority_and_origin
scenario:httppropagationinject-with_sampling_priority
scenario:httppropagationinject-with_tags
scenario:httppropagationinject-with_tags_max_size
scenario:otelspan-start
scenario:otelspan-start-finish-telemetry
scenario:sethttpmeta-all-disabled
scenario:sethttpmeta-collectipvariant_exists
scenario:sethttpmeta-no-collectipvariant
scenario:sethttpmeta-obfuscation-no-query
scenario:sethttpmeta-obfuscation-regular-case-implicit-query
scenario:sethttpmeta-obfuscation-send-querystring-disabled
scenario:sethttpmeta-obfuscation-worst-case-implicit-query
scenario:sethttpmeta-useragentvariant_not_exists_1
scenario:span-start-finish
|
type spans and submitting to LLMObs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
- Remove apm_context - Move kind --> meta.span.kind - Replace status --> error (0=ok, 1=err) - Move status_message --> meta.error.message
…8339 to 2.8] (#8986) Backport #8339 to 2.8. This PR changes the langchain integration such that it will check for partner libraries before attempting to patch them. The langchain integration patches `langchain_openai.OpenAIEmbeddings.*` and `langchain_pinecone.PineconeVectorStore.*`, which are partner libraries that are not required to be installed. Currently if they are not available, we raise `ModuleNotFoundError`. This PR fixes this so that we'll skip patching those methods if the corresponding partner library is not available. Additionally, this PR also adds importing `langchain_community.llm/chat_models` as those are not automatically imported by importing `langchain_community`. This is important as we reference those submodules in our patch code later on. ## Checklist - [x] Change(s) are motivated and described in the PR description - [x] Testing strategy is described if automated tests are not included in the PR - [x] Risks are described (performance impact, potential for breakage, maintainability) - [x] Change is maintainable (easy to change, telemetry, documentation) - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) are followed or label `changelog/no-changelog` is set - [x] Documentation is included (in-code, generated user docs, [public corp docs](https://github.com/DataDog/documentation/)) - [x] Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) - [x] If this PR changes the public interface, I've notified `@DataDog/apm-tees`. ## Reviewer Checklist - [x] Title is accurate - [x] All changes are related to the pull request's stated goal - [x] Description motivates each change - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - [x] Testing strategy adequately addresses listed risks - [x] Change is maintainable (easy to change, telemetry, documentation) - [x] Release note makes sense to a user of the library - [x] Author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment - [x] Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
Summary
This PR does a few things:
LLMObsWriter
class switches from submitting LLMObs records to submit Span events.LLMObsWriter
is now a single class owned by theLLMObs
service instance rather than eachLLMIntegration
classes owning an instance ofLLMObsWriter
.LLMIntegration
classes now mark LLM (completion/chat) spans and set temporary ml_obs tags to be extracted by the LLMObs serviceLLMObsTraceProcessor
to create span events and submit them to theLLMObsWriter
to be written to LLMObs intake.DD_APP_KEY
as a config option.llm
which theLLMObsTraceProcessor
uses to identify spans which should also be converted to LLMObs span events and submitted to LLMObs.LLMObs Records --> LLMObs Span Event
The
LLMIntegration
classes currently generate LLMObs records and pass it to theirLLMObsWriter
instance to submit it to LLMObs' record intake. However, the LLMObs intake is being updated to accept Span events, which this PR creates new support for (and removes support for submitting LLMObs records). The new span event structure looks something like this:This also includes some changes to the LLMObs writer:
https://llmobs-intake.{DD_SITE}/api/v2/llmobs
.DD_APP_KEY
as a config option, as the new endpoint does not need it (only needs API key).New Workflow (who owns the LLMObsWriter now?)
Currently, the workflow for LLMObs involves something like this:
The proposed workflow looks something like this:
Note: in this approach, we're creating temporary
ml_obs.*
tags on the APM spans before removing them to populate the LLMObs span event to submit to LLMObs. These temporary tags will only be created if LLMObs is enabled, and will never be submitted on the APM span object.Checklist
changelog/no-changelog
is set@DataDog/apm-tees
.@DataDog/security-design-and-guidance
.Reviewer Checklist