Skip to content

Add module-level tracer and exception span recording - #6

Draft
sfc-gh-ppruett wants to merge 1 commit into
otel-feature-flagfrom
ppruett/otel-module-tracer
Draft

sfc-gh-ppruett wants to merge 1 commit into
otel-feature-flagfrom
ppruett/otel-module-tracer

Conversation

@sfc-gh-ppruett

Copy link
Copy Markdown
Collaborator

What

Addresses the two outstanding human-reviewer (tauhid621) comments on the OpenTelemetry work.

  • jinja.py — moved the dbt.runner tracer from MacroGenerator.__init__ to module level, so it's created once at import instead of once per macro call. Behavior is unchanged; the tracer is still inert until the --snowflake-projects-otel gate opens a span in __call__.
  • runnable.py — record the exception on the node span in call_runner's exception path. When run_with_hooks raises (result is None), the span now gets StatusCode.ERROR and record_exception(thread_exception) before _handle_thread_exception, so failed nodes carry the exception. When OTel is disabled the span is INVALID_SPAN and both calls are no-ops.

Testing

  • Added test_call_runner_exception_records_on_span covering the new span error status and exception event.
  • Ran an end-to-end OTel capture against Snowflake with local editable builds of dbt-core/common/adapters/snowflake: full build emitted the expected node + hook spans (the module-level tracer change is exercised by the hook spans), and a deliberately-failing model confirmed node spans get ERROR status.
  • All pre-commit hooks pass on the changed files (the one mypy error in get_supported_languages is pre-existing upstream, unrelated to this diff).

🤖 Generated with Claude Code

- jinja.py: moved the dbt.runner tracer from MacroGenerator.__init__ to
  module level, so it's created once at import instead of once per macro call.

- runnable.py: record the exception on the node span in call_runner's
  exception path. When run_with_hooks raises (result is None), the span
  now gets StatusCode.ERROR and record_exception(thread_exception) before
  _handle_thread_exception, so failed nodes carry the exception instead
  of an unset status. When OTel is disabled the span is INVALID_SPAN and
  both calls are no-ops.

Add test_call_runner_exception_records_on_span covering the new span
error status and exception event.
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