-
Notifications
You must be signed in to change notification settings - Fork 1.8k
ENG-9166 feat(otel): compile spans (2/3) #6900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| Add inert OpenTelemetry trace points and metrics around event handler execution, state acquisition and socket messages (`reflex_base.otel`); they cost one boolean check until the `reflex-otel` package enables them. | ||
| Add inert OpenTelemetry trace points and metrics around event handler execution, state acquisition, socket messages and compile stages (`reflex_base.otel`); they cost one boolean check until the `reflex-otel` package enables them. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| Add the `reflex-otel` package: an OpenTelemetry instrumentor that turns on the framework's built-in trace points and metrics (one span per event handler run, chained events parented under the enqueuing span, frontend `traceparent` propagation, event/state/websocket metrics) and wraps the ASGI app in the OpenTelemetry ASGI middleware. | ||
| Add the `reflex-otel` package: an OpenTelemetry instrumentor that turns on the framework's built-in trace points and metrics (one span per event handler run, chained events parented under the enqueuing span, frontend `traceparent` propagation, event/state/websocket metrics, compile spans) and wraps the ASGI app in the OpenTelemetry ASGI middleware. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ | |
| from pathlib import Path | ||
| from typing import TYPE_CHECKING, Any | ||
|
|
||
| from reflex_base import constants | ||
| from reflex_base import constants, otel | ||
| from reflex_base.components.component import ( | ||
| BaseComponent, | ||
| Component, | ||
|
|
@@ -1176,7 +1176,10 @@ def compile_app( | |
| app.style = evaluate_style_namespaces(app.style) | ||
|
|
||
| if not should_compile and not dry_run: | ||
| with console.timing("Evaluate Pages (Backend)"): | ||
| with ( | ||
| console.timing("Evaluate Pages (Backend)"), | ||
| otel.span("reflex.compile.evaluate_pages"), | ||
|
greptile-apps[bot] marked this conversation as resolved.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] Include the stateful-marker backend evaluation in When |
||
| ): | ||
| for route in app._unevaluated_pages: | ||
| console.debug(f"Evaluating page: {route}") | ||
| app._compile_page(route, save_page=False) | ||
|
|
@@ -1218,7 +1221,11 @@ def compile_app( | |
| ), | ||
| ) | ||
|
|
||
| with console.timing("Compile pages"), compile_ctx: | ||
| with ( | ||
| console.timing("Compile pages"), | ||
| otel.span("reflex.compile.pages"), | ||
| compile_ctx, | ||
| ): | ||
| compile_ctx.compile( | ||
| evaluate_progress=lambda: progress.advance(task), | ||
| render_progress=lambda: progress.advance(task), | ||
|
|
@@ -1325,7 +1332,7 @@ def compile_app( | |
|
|
||
| assets_src = Path.cwd() / constants.Dirs.APP_ASSETS | ||
| if assets_src.is_dir() and not dry_run: | ||
| with console.timing("Copy assets"): | ||
| with console.timing("Copy assets"), otel.span("reflex.compile.copy_assets"): | ||
| path_ops.update_directory_tree( | ||
| src=assets_src, | ||
| dest=Path.cwd() / prerequisites.get_web_dir() / constants.Dirs.PUBLIC, | ||
|
|
@@ -1404,7 +1411,10 @@ def add_save_task( | |
| # dry-run return) so ``--dry`` never mutates ``.web`` or the manifest. | ||
| utils.prune_stale_memo_files(path for path, _ in memo_component_files) | ||
|
|
||
| with console.timing("Install Frontend Packages"): | ||
| with ( | ||
| console.timing("Install Frontend Packages"), | ||
| otel.span("reflex.compile.install_frontend_packages"), | ||
| ): | ||
| app._get_frontend_packages(all_imports) | ||
|
|
||
| frontend_skeleton.update_react_router_config( | ||
|
|
@@ -1454,7 +1464,7 @@ def add_save_task( | |
| raise FileNotFoundError(msg) | ||
| output_mapping[path] = modify_fn(file_content) | ||
|
|
||
| with console.timing("Write to Disk"): | ||
| with console.timing("Write to Disk"), otel.span("reflex.compile.write"): | ||
| for output_path, code in output_mapping.items(): | ||
| utils.write_file(output_path, code) | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.