feat(telemetry): report export status, duration, and phase timings#6509
feat(telemetry): report export status, duration, and phase timings#6509FarhanAliRaza wants to merge 5 commits into
Conversation
Track per-phase timings (compile/build/zip) and success/failure for `reflex export`, and stop mutating the cached event defaults so kwargs from one event can't leak into the next.
Greptile SummaryThis PR adds per-phase timing (
Confidence Score: 4/5Safe to merge — the core bug fix is correct and the new telemetry instrumentation is well-tested across all branch paths. The cached-mutation fix is correct and thoroughly exercised. The two observations (setup_frontend grouped into build_duration, overwrite guard removed) are non-breaking design choices with no effect on production behaviour today. reflex/utils/export.py is worth a second glance on the phase grouping decision if PostHog analysis needs to distinguish frontend-setup failures from build failures. Important Files Changed
Sequence DiagramsequenceDiagram
participant C as Caller
participant E as export()
participant P as prerequisites
participant B as build
participant T as telemetry.send()
participant PH as PostHog API
C->>E: export(frontend, zipping, ...)
E->>E: "start = time.monotonic()"
E->>E: "phase_durations = {}"
E->>E: "status = success"
opt "frontend=True"
E->>P: get_compiled_app() [_time_phase(compile_duration)]
P-->>E: ok / raises
E->>B: setup_frontend() + build.build() [_time_phase(build_duration)]
B-->>E: ok / raises
end
opt "zipping=True"
E->>B: zip_app() [_time_phase(zip_duration)]
B-->>E: ok / raises
end
alt Exception raised
E->>E: "status=failure, detail=type(exc).__name__, raise"
end
E->>T: send(export, status, detail, duration, compile_duration, build_duration, zip_duration)
T->>T: _prepare_event(): copy defaults, filter None kwargs
T->>PH: POST event (async background task)
T-->>E: done (fire-and-forget)
E-->>C: return (or re-raise)
Reviews (1): Last reviewed commit: "feat(telemetry): report export status, d..." | Re-trigger Greptile |
…vent Time `build.setup_frontend` separately from `build.build` and skip additional keys already present in defaults so callers can't overwrite them.
# Conflicts: # reflex/utils/export.py # reflex/utils/telemetry.py # tests/units/test_telemetry.py
Drop redundant Args docstrings, unused console mocks, and a tautological duration check; use call_args.kwargs directly instead of unpacking.
| def _patch_event_defaults(mocker: MockerFixture, value): | ||
| """Replace the cached get_event_defaults() so it returns ``value``, bypassing the once_unless_none cache.""" | ||
| mocker.patch("reflex.utils.telemetry.get_event_defaults", return_value=value) |
There was a problem hiding this comment.
this should be a fixture so it doesn't have to be called in every test case that wants to use it
| ], | ||
| ) | ||
| def test_send(mocker: MockerFixture, event, kwargs, expected_props): | ||
| httpx_post_mock = mocker.patch("httpx.post") |
There was a problem hiding this comment.
this should probably also be a fixture as well. these set up steps shouldn't comingle with the test logic. AI likes to do that a lot.
Track per-phase timings (compile/build/zip) and success/failure for
reflex export, and stop mutating the cached event defaults so kwargs from one event can't leak into the next.All Submissions:
Type of change
New Feature Submission:
Changes To Core Features:
fixes ENG-9477