Skip to content

feat: add span exclusion sampler and fix context handling#9

Merged
Taure merged 1 commit intonovaframework:mainfrom
Taure:feat/context-token-and-sampler
Mar 17, 2026
Merged

feat: add span exclusion sampler and fix context handling#9
Taure merged 1 commit intonovaframework:mainfrom
Taure:feat/context-token-and-sampler

Conversation

@Taure
Copy link
Copy Markdown
Contributor

@Taure Taure commented Mar 17, 2026

Summary

  • Fix context token handling: replace otel_ctx:clear() with otel_ctx:detach(PrevCtxToken) in terminate/3 to properly restore previous OTel context instead of destroying it
  • Add otel_nova_sampler module implementing otel_sampler behaviour for excluding server spans by name (e.g. health checks, metrics endpoints)
  • Add opentelemetry as a main dependency (required for otel_sampler behaviour)

Sampler usage

{opentelemetry, [
    {sampler, {parent_based, #{
        root => {otel_nova_sampler, [<<"GET /metrics">>, <<"GET /healthz">>]}
    }}}
]}.

Test plan

  • New test: stream_handler_restores_context_on_terminate — verifies context is restored, not cleared
  • New suite: otel_nova_sampler_SUITE — 3 tests (excludes matching server spans, records non-matching, records non-server spans even if name matches)
  • All 33 tests pass
  • rebar3 fmt --check — clean
  • rebar3 xref — 0 warnings
  • rebar3 dialyzer — 0 warnings

Replace otel_ctx:clear() with otel_ctx:detach() to properly restore
previous context after span termination. Add otel_nova_sampler for
excluding server spans by name (e.g. health/metrics endpoints).
@Taure Taure merged commit 787b1fd into novaframework:main Mar 17, 2026
14 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.

1 participant