Add custom resource attributes and span links to OtelTraceSink#476
Open
bmdhodl wants to merge 3 commits into
Open
Add custom resource attributes and span links to OtelTraceSink#476bmdhodl wants to merge 3 commits into
bmdhodl wants to merge 3 commits into
Conversation
Narrow Later-bucket sink improvement: enhance the existing OtelTraceSink without a new exporter module or new dependency. - resource_attributes constructor arg stamps agentguard.resource.* on every emitted span; values coerced to strings - span-start events may carry a links list referencing tracked spans, converted to OTel Link objects; unknown/malformed entries skipped - backward compatible: both new behaviors default to off - 10 new tests; full suite 750 passing Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b5b0971a24
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
_build_links called .items() on a link entry's attributes field without
checking it was a mapping; a string/list value raised AttributeError and
aborted emit(). Coerce non-dict attributes to {} before iterating.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds a narrow OtelTraceSink enhancement for opt-in per-span resource-style attributes and OTel span links while keeping the SDK dependency boundary unchanged.
Changes:
- Adds
resource_attributessupport toOtelTraceSink. - Converts span-start
linksentries into OTelLinkobjects for tracked spans. - Adds mock-based tests and root planning/research/QA artifacts.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
sdk/agentguard/sinks/otel.py |
Implements resource attribute stamping and span-link construction. |
sdk/tests/test_otel_sink.py |
Extends fake OTel types and adds tests for resource attributes and links. |
WORK_PLAN.md |
Documents intended scope, approach, and completion checklist. |
RESEARCH.md |
Records implementation research and test evidence. |
QA_REPORT.md |
Summarizes QA checks and claimed readiness. |
Comments suppressed due to low confidence (2)
RESEARCH.md:15
- This cites
sdk/pyproject.toml:74as a Ruff exclusion, but that line is the setuptools package-findexclude, not Ruff configuration. Ruff only ignores a few rules per file fortests/**; the tests are omitted because the project lint command targetssdk/agentguard/and selected scripts, so this evidence is inaccurate as written.
- Ruff config (`sdk/pyproject.toml:74`) excludes `tests*` and `examples*`, so
the 4 pre-existing F401 unused-import warnings in `test_otel_sink.py` are not
CI-checked and are out of scope for this task. The production file
`agentguard/sinks/otel.py` passes `ruff check` cleanly.
QA_REPORT.md:29
- This repeats the inaccurate claim that Ruff config excludes
tests*. The cited exclusion is package metadata, while Ruff would still check tests if invoked on them (apart from the listed per-file ignored rules); the reason CI/local lint skips these imports is the lint command's target set, not Ruff configuration.
- Pre-existing ruff F401 unused imports in `test_otel_sink.py` (`call`,
`MagicMock`, `patch`, `sys`) were left untouched — out of scope, and ruff
config excludes `tests*` so CI does not check them. Production file
`otel.py` passes `ruff check` cleanly.
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.
Summary
2026-05-15-0010-blocked-decision-agent47-otel-exporter-direction), no newagentguard47.exporters.otelmodule, no new OTel dependencies, no observability repositioning.OtelTraceSink.__init__gains an optionalresource_attributesdict — entries are coerced to strings and stamped asagentguard.resource.*on every span the sink emits.linkslist of{"span_id", "attributes"}entries referencing already-tracked spans; these become OTelLinkobjects. Unknown/malformed entries are skipped.Test plan
pytest tests/test_otel_sink.py— 19 passed (9 original unchanged + 10 new)pytest tests/— 750 passed, no regressionsruff check agentguard/sinks/otel.py— cleanArtifacts
WORK_PLAN.md, RESEARCH.md, QA_REPORT.md committed at repo root. QA verdict: PASS — no secrets, no denylist paths, no coverage regression.
Risk
Low. Additive, opt-in, no new dependency; core SDK stays zero-dep. Diff ~297 lines.