Skip to content

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

Open
FarhanAliRaza wants to merge 1 commit into
farhan/eng-9166-reflex-otelfrom
farhan/eng-9166-reflex-otel-3
Open

ENG-9166 feat(otel): compile spans (2/3)#6900
FarhanAliRaza wants to merge 1 commit into
farhan/eng-9166-reflex-otelfrom
farhan/eng-9166-reflex-otel-3

Conversation

@FarhanAliRaza

@FarhanAliRaza FarhanAliRaza commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Part of #6227 (ENG-9166). Stack: 1/32/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).

@FarhanAliRaza
FarhanAliRaza requested a review from a team as a code owner August 17, 2026 20:57
@linear-code

linear-code Bot commented Aug 17, 2026

Copy link
Copy Markdown

ENG-9166

@greptile-apps

greptile-apps Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds OpenTelemetry instrumentation around the full application compilation and its major stages.

  • Adds no-op-capable generic and compile-specific span helpers.
  • Wraps App._compile in a root compile span with trigger and dry-run attributes.
  • Instruments page evaluation, page compilation, asset copying, frontend package installation, and disk writes.
  • Adds documentation, changelog entries, and tests for span attributes and parent-child relationships.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
packages/reflex-base/src/reflex_base/otel.py Adds generic internal-span and compile-span context managers that become no-ops when tracing is disabled.
reflex/app.py Wraps the existing compilation and telemetry-accounting flow in a root OpenTelemetry compile span.
reflex/compiler/compiler.py Adds child spans around five major stages of the existing compilation pipeline.
tests/units/reflex_base/test_otel.py Tests disabled behavior, compile attributes, and nested span parenting.
tests/units/test_app.py Verifies that a real application compile emits stage spans parented to the root compile span.

Reviews (5): Last reviewed commit: "feat(otel): compile spans" | Re-trigger Greptile

Comment thread reflex/compiler/compiler.py
@codspeed-hq

codspeed-hq Bot commented Aug 17, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 26 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing farhan/eng-9166-reflex-otel-3 (7427498) with farhan/eng-9166-reflex-otel (2f9b04d)

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e88ec4f6ef

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/reflex-otel/src/reflex_otel/__init__.py

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 28 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/reflex-otel/src/reflex_otel/__init__.py Outdated
Comment thread pyproject.toml
Comment thread packages/reflex-base/src/reflex_base/otel.py
Comment thread news/6227.feature.md
Comment thread packages/reflex-otel/pyproject.toml
Comment thread packages/reflex-base/pyproject.toml Outdated
Comment thread packages/reflex-base/src/reflex_base/otel.py
Comment thread reflex/app.py
@FarhanAliRaza FarhanAliRaza changed the title ENG-9166 feat(otel): compile spans and trace ids on JSON log records (2/3) ENG-9166 feat(otel): compile spans (2/3) Aug 17, 2026
@FarhanAliRaza
FarhanAliRaza force-pushed the farhan/eng-9166-reflex-otel-3 branch from e88ec4f to 1f5b784 Compare August 17, 2026 21:21
@FarhanAliRaza
FarhanAliRaza requested a review from Alek99 as a code owner August 17, 2026 21:21
@FarhanAliRaza
FarhanAliRaza changed the base branch from farhan/eng-10963-log-5-deprecate-console to farhan/eng-9166-reflex-otel August 17, 2026 21:21
@FarhanAliRaza
FarhanAliRaza force-pushed the farhan/eng-9166-reflex-otel-3 branch 2 times, most recently from 7c86654 to acf9a22 Compare August 17, 2026 21:53

@Alek99 Alek99 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The initial compile trace works locally, but the common backend-startup/stateful-marker path omits one advertised stage.

with console.timing("Evaluate Pages (Backend)"):
with (
console.timing("Evaluate Pages (Backend)"),
otel.span("reflex.compile.evaluate_pages"),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Include the stateful-marker backend evaluation in reflex.compile.evaluate_pages

When .web/backend exists and stateful_pages.json is present, the earlier branch evaluates each marked page with _compile_page(..., save_page=False) and returns at line 1171 before this span is entered. I reproduced that normal backend_startup path with an OTLP exporter: only the reflex.compile root was emitted even though page evaluation ran. Please wrap the marker-driven loop in the same stage span (or factor both paths through a shared helper) and cover the early-return marker path.

@FarhanAliRaza
FarhanAliRaza force-pushed the farhan/eng-9166-reflex-otel-3 branch from acf9a22 to 7427498 Compare August 18, 2026 16:54
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