-
Notifications
You must be signed in to change notification settings - Fork 18
feat(log-enrichment): add custom session ID attribute for enriched spans #181
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
Merged
krisztianfekete
merged 5 commits into
agentevals-dev:main
from
AaronProbha18:feat/174-stop-stash-session-id
Jul 27, 2026
+44
−19
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
74c5409
feat(log-enrichment): add custom session ID attribute for enriched spans
AaronProbha18 844b474
fix(log-enrichment): update session ID attribute to use underscore no…
AaronProbha18 f21396e
tests: add regression test for agent name preservation with session ID
AaronProbha18 67e3274
test: enhance session ID and agent name assertions
AaronProbha18 7ef33b6
style: ruff format check
AaronProbha18 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,8 +84,8 @@ def test_session_id_injected(self): | |
| logs = [_make_log("gen_ai.user.message", {"content": "hi"})] | ||
| result = enrich_spans_with_logs(spans, logs, session_id="my-session") | ||
|
|
||
| agent_name = _get_injected_attr(result[0], "gen_ai.agent.name", parse_json=False) | ||
| assert agent_name == "my-session" | ||
| session_attr = _get_injected_attr(result[0], "agentevals.session_id", parse_json=False) | ||
| assert session_attr == "my-session" | ||
|
|
||
| def test_choice_extracts_nested_content(self): | ||
| spans = [_make_span()] | ||
|
|
@@ -139,6 +139,23 @@ def test_logs_matched_to_correct_span(self): | |
| msgs_s2 = _get_injected_attr(result[1], "gen_ai.input.messages") | ||
| assert msgs_s2 == [{"role": "user", "content": "question 2"}] | ||
|
|
||
| def test_agent_name_preserved_with_session_id(self): | ||
| """Regression: real gen_ai.agent.name attr must survive enrichment, | ||
| session_id lands in its own attr, doesn't clobber it.""" | ||
| span = _make_span( | ||
| "s1", | ||
| attrs=[{"key": "gen_ai.agent.name", "value": {"stringValue": "roll_die_agent"}}], | ||
| ) | ||
| logs = [_make_log("gen_ai.user.message", {"content": "hi"}, span_id="s1")] | ||
| result = enrich_spans_with_logs([span], logs, session_id="sess-123") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure this catches the regression. Let's do it via |
||
|
|
||
| agent_name_attrs = [a for a in result[0]["attributes"] if a["key"] == "gen_ai.agent.name"] | ||
| assert len(agent_name_attrs) == 1, f"expected exactly one gen_ai.agent.name attr, found {len(agent_name_attrs)}" | ||
| assert agent_name_attrs[0]["value"]["stringValue"] == "roll_die_agent" | ||
|
|
||
| session_attr = _get_injected_attr(result[0], "agentevals.session_id", parse_json=False) | ||
| assert session_attr == "sess-123" | ||
|
|
||
| def test_span_without_logs_not_enriched(self): | ||
| spans = [_make_span("s1"), _make_span("s2")] | ||
| logs = [ | ||
|
|
@@ -156,8 +173,8 @@ def test_session_id_on_all_spans(self): | |
| ] | ||
| result = enrich_spans_with_logs(spans, logs, session_id="test") | ||
|
|
||
| assert _get_injected_attr(result[0], "gen_ai.agent.name", parse_json=False) == "test" | ||
| assert _get_injected_attr(result[1], "gen_ai.agent.name", parse_json=False) == "test" | ||
| assert _get_injected_attr(result[0], "agentevals.session_id", parse_json=False) == "test" | ||
| assert _get_injected_attr(result[1], "agentevals.session_id", parse_json=False) == "test" | ||
|
|
||
| def test_tool_calls_in_assistant_message(self): | ||
| spans = [_make_span("s1")] | ||
|
|
||
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.
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.
One q: what reads
agentevals.session.iddownstream? I only see it written, never read. There might be benefits for OTLP export consumers, just want to confirm it's intentional and not dead now.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.
It is write-only inside runtime code. I found no downstream internal reader in the repo beyond being appended during enrichment. So this looks intentional as exported metadata for external OTLP consumers rather than an in-repo dependency today.