Skip to content

feat(logger): add OTel context lifecycle for DTB#81

Open
pradystar wants to merge 1 commit into
mainfrom
feat/otel-context-lifecycle
Open

feat(logger): add OTel context lifecycle for DTB#81
pradystar wants to merge 1 commit into
mainfrom
feat/otel-context-lifecycle

Conversation

@pradystar

Copy link
Copy Markdown
Collaborator

Summary

Establish the OpenTelemetry context foundation required to convert and export handler-based telemetry through DTB.

Every handler-produced step now receives stable OTel identity and explicit parentage at creation time. Active OTel context follows only the genuinely open execution chain, preserving correct parent-child relationships for nested spans, completed leaves, distributed traces, and concurrent requests.

Why

DTB and DTA need stable trace and span identity before proprietary steps are converted or exported. Assigning that identity only at flush time would lose the active distributed parent and could make completed sibling leaves appear nested. This change records identity when each step is created while keeping activity aligned with the logger's real open lifecycle.

What changed

  • Assign stable OTel trace IDs, span IDs, trace state, and parent context to every Path 1 step: traces, workflows, agents, LLMs, retrievers, tools, controls, and both steps in a single-LLM trace.
  • Keep completed leaves from becoming accidental parents of sibling spans.
  • Activate promoted tool and retriever spans when they become genuine parents.
  • Restore parent or upstream OTel context when steps conclude.
  • Preserve upstream trace ID and tracestate while always sampling locally generated spans.
  • Coordinate context across concurrent requests, copied async contexts, logger flush execution-context hops, and interleaved logger instances.
  • Clean up identity and active-context bookkeeping during conclusion, reset, flush, and termination.
  • Make the OTel API, SDK, and OTLP HTTP exporter required package dependencies.
  • Remove the obsolete otel extra and update repository examples that referenced it.
  • Keep caller-owned tracer providers unchanged; the SDK does not replace the global provider.

Testing

env GALILEO_HOME_DIR=/tmp/splunk-ao-test-home poetry run pytest -q — 1,742 passed, 101 skipped; PR context suite — 13 passed; focused logger/handler/decorator/OTel regressions — 277 passed, 1 skipped; changed-file Ruff, configured mypy, lockfile validation, wheel build, and wheel dependency verification passed.

Repository-wide Ruff continues to report three pre-existing import-order findings in two untouched files.

Compatibility and risk

There are no public logger API changes. The base package now installs the OTel dependencies previously exposed through the otel extra, increasing the default dependency footprint. Existing repository references to splunk-ao[otel] have been updated to splunk-ao.

This PR establishes identity, parentage, and context lifecycle only. Conversion, batching/export, and replacement of the legacy distributed tracing API remain separate follow-up work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant