Repository navigation
feat: add mark_agent_root() to mark a trace's agent root span - #48
Merged
Merged
Conversation
OpenSearch Agent Traces lists a trace by its root span when that span is a GenAI span, or by a span marked with derived.gen_ai.is_root. Data Prepper marks the outermost GenAI span when the root is an HTTP handler (opensearch-project/data-prepper#7191). mark_agent_root() lets applications choose the span themselves. Signed-off-by: Shenoy Pratik Gurudatt <4348487+ps48@users.noreply.github.com>
This was referenced Oct 15, 2026
Merged
ruff format --check now formats Python code blocks in Markdown and was failing on existing README examples. Whitespace only. Signed-off-by: Shenoy Pratik Gurudatt <4348487+ps48@users.noreply.github.com>
Member
Author
|
CI notes:
I can fix the exporter tests in a separate PR if that's useful. |
ps48
marked this pull request as ready for review
October 15, 2026 17:14
ps48
requested review from
joshuali925,
kylehounslow and
vamsimanohar
as code owners
October 15, 2026 17:14
kylehounslow
approved these changes
Oct 15, 2026
Collaborator
|
@ps48 changes LGTM. There are some CI errors (python tests), please take a look |
joshuali925
approved these changes
Oct 15, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #48 +/- ##
=======================================
Coverage ? 93.34%
=======================================
Files ? 9
Lines ? 857
Branches ? 0
=======================================
Hits ? 800
Misses ? 57
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
- opentelemetry-exporter-otlp-proto-http 1.45 passes the session= argument to an internal transport instead of storing it as self._session, so the exporter tests that read exporter._session failed. AWSSigV4OTLPExporter now keeps its own signing_session reference. A new test checks that an export really goes through the signing session. - pip-audit flagged the runner's preinstalled setuptools 79.0.1 (PYSEC-2026-3447, fixed in 83.0.0). The audit job now upgrades setuptools along with pip. Signed-off-by: Shenoy Pratik Gurudatt <4348487+ps48@users.noreply.github.com>
Data Prepper now marks the outermost GenAI span of every trace, the root included when it is a GenAI span, so describe the marker that way rather than only for HTTP-root traces. Signed-off-by: Shenoy Pratik Gurudatt <4348487+ps48@users.noreply.github.com>
ps48
force-pushed
the
feat/mark-agent-root
branch
from
October 15, 2026 23:02
19886e0 to
a93bfaf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
mark_agent_root(), which marks the active span as its trace's agent root by settingderived.gen_ai.is_root = true.OpenSearch Agent Traces lists a trace by the span marked with
derived.gen_ai.is_root. Data Prepper marks the outermost GenAI span of each trace (opensearch-project/data-prepper#7192, for opensearch-project/data-prepper#7191): the root when it is a GenAI span, or the agent span below it, for example when an HTTP handler runs the agent. This helper lets applications choose the span themselves, for example a service's agent entry point. A span marked at the source wins, and Data Prepper then marks nothing else in that part of the trace.Also exports the attribute name as
AGENT_ROOT_ATTRIBUTEand documents the helper and the raw attribute in the README.Related: OpenSearch Dashboards Agent Traces lists marked spans, opensearch-project/OpenSearch-Dashboards#12977.
Type of Change
How Has This Been Tested?
Unit tests pass
Integration tests pass (end to end, see below)
Manual testing performed
New
TestMarkAgentRoot: marks the current span only (not its children), and is a no-op without an active span.pytest tests/test_enrich.py: 15 passed.ruff format,ruff checkandmypyare clean.4 tests in
tests/test_exporters.py(TestAWSSigV4OTLPExporterInit,'AWSSigV4OTLPExporter' object has no attribute '_session') fail locally with the dependency versions I installed. They are unrelated to this change, which doesn't touch the exporters.End to end on observability-stack: a FastAPI app used this SDK branch, with a Data Prepper image built from Mark the outermost GenAI span of traces with a non-GenAI root data-prepper#7192.
mark_agent_root()called in the HTTP handler, OpenSearch hadderived.gen_ai.is_root: trueon that span only, and Data Prepper marked no other span.Checklist