perf: Add pytest-benchmark suite and PR regression gate#1
Closed
JacksonWeber wants to merge 1 commit into
Closed
Conversation
Adds a small pytest-benchmark suite that measures the overhead of the distro on top of upstream OpenTelemetry, and a CI workflow that fails the PR (and posts a sticky comment) when a gating scenario regresses by more than PERF_REGRESSION_THRESHOLD percent (default 15%). Scenarios (tests/perf/test_overhead.py): - test_azure_monitor_span / test_azure_monitor_log (gating): configure_azure_monitor with network exporters disabled, then exercise the OTel API hot path. - test_otel_span / test_otel_log (informational): plain opentelemetry-sdk TracerProvider/LoggerProvider reference using in-memory exporters. The benchmarks are skipped by default via addopts = --benchmark-skip in pyproject.toml; the performance workflow opts in with --benchmark-only. perf/compare.py consumes the pytest-benchmark JSON, emits a markdown comparison table, and exits non-zero on regression. The workflow runs the suite once with the PR code installed and once with the base branch installed, then compares. Inspired by microsoft/ApplicationInsights-node.js#1500. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a pytest-benchmark perf suite plus a CI workflow that gates PRs against perf regressions, inspired by microsoft/ApplicationInsights-node.js#1500.
Scenarios ( ests/perf/test_overhead.py)
configure_azure_monitor+tracer.start_as_current_spanconfigure_azure_monitor+logger.infoopentelemetry-sdkTracerProviderreferenceopentelemetry-sdkLoggerProviderreferenceThe Azure-Monitor pair shares a session-scoped fixture that calls
configure_azure_monitoronce with all network-facing features disabled (live metrics, perf counters, offline storage). The OTel pair builds its ownTracerProvider/LoggerProviderdirectly so it isn't perturbed by the global mutation. Non-gating scenarios are reported but never fail CI.Skipped by default
pyproject.tomlsetsaddopts = "--benchmark-skip"so a normalpytestinvocation skips the perf tests entirely. The perf workflow opts in with--benchmark-only.CI (.github/workflows/performance.yml)
pytest tests/perf --benchmark-only --benchmark-json=pr.json.base.json.perf/compare.pyproduces a markdown report and exits non-zero if any gating scenario regresses by more thanPERF_REGRESSION_THRESHOLDpercent (default 15).marocchino/sticky-pull-request-comment@v2; JSON + report uploaded as artifacts.Local usage
Verified locally
pytest tests/perf --benchmark-onlyruns all 4 benchmarks and writes a valid JSON.perf/compare.pyexits 0 on equal results and 1 when a gating scenario's median is doubled.pytest tests/perfwith no flags reports4 skipped— confirms the default-skip works.