Skip to content

Introduce OpenTelemetry-style tracing spans: Begin/End span pair - #6654

Draft
Icelandjack wants to merge 1 commit into
masterfrom
baldurb/span
Draft

Introduce OpenTelemetry-style tracing spans: Begin/End span pair#6654
Icelandjack wants to merge 1 commit into
masterfrom
baldurb/span

Conversation

@Icelandjack

Copy link
Copy Markdown
Contributor

Description

Introduce Cardano.Node.Tracing.Span, an OpenTelemetry-shaped tracing
primitive layered on top of the trace-dispatcher framework. It gives a
Loki/Tempo (or any OTel-compatible) backend correlated Begin/End trace
events with a shared trace_id, parent-child parent_span_id links,
and a client-side measured duration, without requiring the consumer to
pair events itself.

What lands

  • SpanTrace:
    • SpanBegin traceId spanId parentSpanId name
    • SpanEnd traceId spanId name durationMs
  • withSpan tr ctx name action — brackets an action with finally:
    emits SpanBegin on entry, SpanEnd on exit (including exception),
    updates the context to point at the new span, and restores the
    previous state on the way out. Nesting composes without explicit
    parent threading:
    ctx <- newSpanContext
    withSpan tr ctx "replayLedger" $ do
      ...outer work...
      withSpan tr ctx "flushWAL" $ do
        -- parent_span_id is the outer span's id, same trace_id
        ...inner work...

Tests

Test.Cardano.Node.Tracing.Span adds seventeen Hedgehog properties
into the existing cardano-node-test suite (no new binary):

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. These may include:
    • golden tests
    • property tests
    • roundtrip tests
    • integration tests
      See Running tests for more details
  • Any changes are noted in the CHANGELOG.md for affected package
    • cardano-node-chairman, cardano-submit-api and cardano-testnet instead need a
      changelog fragment in <package>/.changes/, because their CHANGELOG.md is generated
      from fragments at release time. Copy _TEMPLATE.yml from that directory, or run
      nix run github:input-output-hk/cardano-dev#herald -- new
  • The version bounds in .cabal files are updated
  • CI passes. See note on CI. The following CI checks are required:
    • Code is linted with hlint. See .github/workflows/check-hlint.yml to get the hlint version
    • Code is formatted with stylish-haskell. See .github/workflows/stylish-haskell.yml to get the stylish-haskell version
    • Code builds on Linux, MacOS and Windows for ghc-9.6 and ghc-9.12
  • Self-reviewed the diff

Note on CI

If your PR is from a fork, the necessary CI jobs won't trigger automatically for security reasons.
You will need to get someone with write privileges. Please contact IOG node developers to do this
for you.

@Icelandjack
Icelandjack requested a review from a team as a code owner August 19, 2026 13:02
@Icelandjack
Icelandjack marked this pull request as draft August 19, 2026 13:02
@Icelandjack Icelandjack changed the title Introduce OpenTelemetry-style tracing spans: Begin/End span pair, wit… Introduce OpenTelemetry-style tracing spans: Begin/End span pair Aug 19, 2026
@Icelandjack
Icelandjack force-pushed the baldurb/span branch 2 times, most recently from 996fd33 to c0c7565 Compare August 19, 2026 13:23
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