Skip to content

OxTelemetry - integration of ox, ox flows with OpenTelemetry - #527

Open
pawelsadlo wants to merge 19 commits into
softwaremill:masterfrom
pawelsadlo:oxTelemetry
Open

pawelsadlo wants to merge 19 commits into
softwaremill:masterfrom
pawelsadlo:oxTelemetry

Conversation

@pawelsadlo

Copy link
Copy Markdown

Provides some basic integration for open telemetry tracing via one OxTracing interface.

Implementation lives in:

  1. OxTracingBase - general span API
    • byNameSpan - spans execution of any piece of code, makes opened span a child of current ongoing span
    • currentSpanUnsafe - access to current span, its not unsafe per se, however exposes otel span api to user which may be used unsafely breaking currently opened spans by other, safe oxTracing methods
    • spanUnsafe - opens span and returns AutoCloseableSpan, which contains created span and logic to finalize span (by closing it and bringing back previous otel context). its unsafe because user is expected to finalize span properly, even in case of errors and also should handle correct order of closing spans in case more spans are started by this method, makes opened span a child of current ongoing span
  2. OxFlowTracing - flow span extensions
    • span - opens span when flow start emitting elements and closes it when it finishes/fails, makes opened span a child of current ongoing span

Provided native implementation relies on ox.otel.context.PropagatingVirtualThreadFactory as a open telemetry context propagation mechanism between threads.

note:
this wont work out of the box with ComputeIntensive

note2:
need to tidy up some tests yet

@adamw

adamw commented Oct 9, 2026

Copy link
Copy Markdown
Member

Thanks, some remarks:

  • docs are missing - showing how to use the functionality
  • I think that instead of import tracer.*; flow.span() it would be better to be more explicit: flow.span(tracer). The tracer needs to be imported anyway, and it's less "magical"
  • do we need the context setting/unsetting? If we control the entire span start/stop?

@adamw

adamw commented Oct 9, 2026

Copy link
Copy Markdown
Member

Ah and finally - did you try reviewing your code with Claude/Codex/Cursor?

@pawelsadlo

pawelsadlo commented Oct 12, 2026 •

Copy link
Copy Markdown
Author

Thanks, some remarks:

  • docs are missing - showing how to use the functionality

will do

  • I think that instead of import tracer.*; flow.span() it would be better to be more explicit: flow.span(tracer). The tracer needs to be imported anyway, and it's less "magical"
  • do we need the context setting/unsetting? If we control the entire span start/stop?

yes, for integration with third party libs relying on automatic otel instrumentation that may start spans within our span

@adamw

adamw commented Oct 12, 2026

Copy link
Copy Markdown
Member

yes, for integration with third party libs relying on automatic otel instrumentation that may start spans within our span

Bue doesn't span.start() automatically set the current span in the whatever is configured as context? That is, we could just rely on what the end-user sets as the context propagator.

@pawelsadlo

Copy link
Copy Markdown
Author

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.

2 participants