Repository navigation
Closed
Labels
area/stdlibCore abstractions: Context, MOT, SamplingStrategy, formatters, serializationarea/telemetryOTel spans, metrics, tracing, semconvenhancementNew feature or requestp2Medium/low: minor bugs, niche features, polish, docs, tests, cleanup. Scoped, lower urgency.refactor
Description
Background
Session-level and act-level spans are currently emitted via direct trace_application(...) calls in mellea/stdlib/session.py and mellea/stdlib/functional.py. This leaks tracing concerns into stdlib.
Replaces retired sub-issue #470.
Scope
- Move session-context span emission into a session-lifecycle hook consumed by a plugin in
tracing_plugins.py. (If no suitable session-lifecycle hook exists, open a small prerequisite issue inmellea/plugins/to add one; prefer reusing existing hooks.) - Move
aactspan emission into a plugin hooked on the appropriate pre/post action hook. Preserve existing attributes but addmellea.prefix (per refactor: rename tracing env vars to plural and align with OTel semconv #1046). - Remove
trace_application,set_span_attributeimports fromstdlib/session.pyandstdlib/functional.py. - Consider adding
gen_ai.conversation.idon session spans (overlaps with OTel omissions/gaps: chat content events, gen_ai.conversation.id, prompt templates, error status #1035 — coordinate with PR feat(telemetry): close five OTel GenAI semantic convention emission gaps (#1035) #1036).
Phase & dependencies
Phase 2 (coverage). Depends on Phase 1 (#1045, #1046, #1047). Can proceed in parallel with #1049, #1050, #1051, #1052, and with PR #1036 rebased onto Phase 1.
Acceptance criteria
-
mellea/stdlib/no longer imports frommellea.telemetry.tracing. - Session → aact → backend span hierarchy preserved.
- Tests cover parent-child span relationships.
Parent epic: #444
Metadata
Metadata
Assignees
Labels
area/stdlibCore abstractions: Context, MOT, SamplingStrategy, formatters, serializationarea/telemetryOTel spans, metrics, tracing, semconvenhancementNew feature or requestp2Medium/low: minor bugs, niche features, polish, docs, tests, cleanup. Scoped, lower urgency.refactor
Activity
ajbozarth commentedon Jun 8, 2026
While going through PR #1181 review, surfaced a privacy bug from
@planetf1 that's in scope for this issue:
mellea.response(set inaactatstdlib/functional.py:707) currentlycaptures up to 500 chars of model output unconditionally — it doesn't gate
on
is_content_tracing_enabled()/MELLEA_TRACES_CONTENT. Pre-existingleak, but PR #1181 makes
MELLEA_TRACES_CONTENTuser-visible in the docs,which turns this from undocumented behavior into a documented broken
contract.
Disposition: not fixing in #1181 because the inline emission code is what
this issue replaces. When moving
aactspan emission to the new plugin,the
mellea.responsecapture should be gated onis_content_tracing_enabled().mellea.response_lengthis fine to keepungated (a non-content metric).
Original review comment: #1181 (comment)
planetf1 commentedon Jun 9, 2026
While reviewing PR #1181, two related findings were deferred here that aren't currently reflected in the acceptance criteria:
is_content_tracing_enabled()is defined and exported but never called anywhere in the codebase. SettingMELLEA_TRACES_CONTENT=trueorOTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=truehas no effect.mellea.responseis set unconditionally on everyaactspan instdlib/functional.py, regardless of whether the operator has opted in to content capture.When the
aactspan emission moves to a plugin in this issue, the fix is natural: checkis_content_tracing_enabled()before settingmellea.response(andmellea.promptif that gets added). Worth adding to the acceptance criteria so it doesn't slip through.refactor(telemetry): action spans via plugin hooks; session spans direct
refactor(telemetry): action spans via plugin hooks; session spans direct
refactor(telemetry): action spans via plugin hooks; session spans direct
refactor(telemetry): migrate application spans to plugin hooks (gener…