ENG-9166 feat(otel): compile spans (2/3)

Merged
FA
1mo ago
+155-39

Part of #6227 (ENG-9166). Stack: 1/3 โ†’ 2/3 (this) โ†’ 3/3. Base is farhan/eng-9166-reflex-otel (1/3); the diff is one commit.

What

  • App._compile runs inside a reflex.compile span (reflex.compile.trigger, reflex.compile.dry_run); the compile stages get explicit child spans in compiler.py: reflex.compile.evaluate_pages, .pages, .copy_assets, .install_frontend_packages, .write.
  • otel.span() / otel.compile_span() helpers (no-op nullcontext when disabled; compile is not a hot path).

Log correlation (trace_id/span_id on JSON log records) was split out of this stack: it needs the JsonHandler from the logging pipeline (#6863) and will follow as a small PR once that lands (#6903).

Tests

test_otel.py (span helpers, compile_span attributes/nesting), test_app.py::test_compile_emits_stage_spans (real compile, stages nest under reflex.compile).