OTLP Trace File Parser (runtime/otel.py)

jcodemunch-mcp · src/jcodemunch_mcp/runtime/otel.py · python · MIT
ai, analytics, infra, lang:python, tag:json

A utility to parse OpenTelemetry JSON trace files and extract code-location attributes. Reuse this for observability tools or debugging runtime execution paths.

# Source: https://github.com/jgravelle/jcodemunch-mcp | License: MIT | Copyright 2024-2026 J. Gravelle (https://github.com/jgravelle)
# Provided via justclaw.it.com; keep this notice with the code.
"""OTLP JSON file parser for runtime trace ingest (Phase 1).

Reads the file format produced by the OTel Collector ``file`` exporter
(or any tool that emits OTLP/JSON), iterates spans, and extracts the
code-location attributes defined by the OpenTelemetry semantic
conventions:

  - ``code.filepath``  — file path (absolute or repo-relative)
  - ``code.lineno``    — 1-based line number within ``code.filepath``
  - ``code.function``  — function / method name
  - ``code.namespace`` — module / class namespace (kept for diagnostics)

Spans without any code attribute are still iterated and reported as


... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key