Skip to content

refactor(tracing): replace custom Dapper schemas with OpenTelemetry SDK#185

Merged
gowthamrao merged 1 commit into
20260509-nemoclaw-by-issuefrom
feat/otel-tracing-migration
May 12, 2026
Merged

refactor(tracing): replace custom Dapper schemas with OpenTelemetry SDK#185
gowthamrao merged 1 commit into
20260509-nemoclaw-by-issuefrom
feat/otel-tracing-migration

Conversation

@gowthamrao
Copy link
Copy Markdown
Contributor

Summary

Replaces CoReason's custom Dapper-style distributed tracing schemas (ExecutionSpanReceipt, SpanEvent, TraceExportManifest) with the industry-standard OpenTelemetry SDK and OTLP exporters.

Closes #184

Why?

  • Borrow, Don't Build: OpenTelemetry is the absolute industry standard for distributed tracing. Custom span serialization is engineering waste.
  • Zero-code LLM tracing: The instructor library (already a dependency) has native OTel auto-instrumentation.
  • Zero-code workflow tracing: temporalio (already a dependency) has native OTel interceptors.
  • Eliminates ~150 lines of manual JSON validation in EmitSpanIOActivity.

Changes

New Files

  • src/coreason_runtime/utils/tracing.pyTracerProvider initialization with OTLP exporter, get_tracer() utility, no-op fallbacks
  • tests/utils/test_tracing.py — Comprehensive test suite for the tracing module

Modified Files

File Change
pyproject.toml Add opentelemetry-api, opentelemetry-sdk, opentelemetry-exporter-otlp
activities.py EmitSpanIOActivity now emits real OTel spans instead of validating ExecutionSpanReceipt
logger.py otel_telemetry_sink replaced — real OTel span emission instead of debug stub
predict_router.py Initialize TracerProvider to enable instructor auto-instrumentation
test_activities_standalone.py Updated test_emit_span_valid for OTel-native payloads
test_logger.py Updated test_otel_telemetry_sink_forwards_message for OTel behavior

NOT in Scope

  • ExecutionNodeReceipt stays — it's Merkle-DAG provenance, not tracing
  • Schema deprecation in coreason-manifest will be a separate PR (Phase 3 of the plan)

Configuration

Standard OTel env vars:

OTEL_SERVICE_NAME=coreason-runtime
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
OTEL_EXPORTER_OTLP_PROTOCOL=grpc

Testing

  • ruff format
  • ruff check
  • mypy ✅ (no new errors; pre-existing DempsterShaferBeliefVector error unchanged)
  • pytest — 207 passed, 1 pre-existing failure (test_synthesize_scratch_zero_day_forge)

…DK (#184)

- Add opentelemetry-api, opentelemetry-sdk, opentelemetry-exporter-otlp to deps
- Create src/coreason_runtime/utils/tracing.py with TracerProvider, OTLP export,
  and no-op fallbacks
- Refactor EmitSpanIOActivity to emit native OTel spans instead of validating
  ExecutionSpanReceipt Pydantic JSON
- Replace otel_telemetry_sink placeholder stub in logger.py with real OTel
  span emission
- Enable instructor auto-instrumentation via TracerProvider init in predict_router
- Add comprehensive test suite for tracing module (tests/utils/test_tracing.py)
- Update test_emit_span_valid and test_otel_telemetry_sink_forwards_message

Closes #184
@gowthamrao gowthamrao changed the base branch from main to 20260509-nemoclaw-by-issue May 12, 2026 16:33
@gowthamrao gowthamrao merged commit 215b678 into 20260509-nemoclaw-by-issue May 12, 2026
10 of 12 checks passed
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.

refactor: Replace custom distributed tracing schemas with OpenTelemetry (OTLP)

1 participant