fix: enable prom exporter only if config set#934
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes OpenTelemetry metrics initialization so the Prometheus exporter/reader is only created when prometheusMetricsEnabled is enabled in config, and refactors some repeated Jest test helpers into shared test utilities.
Changes:
- Guard Prometheus exporter creation in
otel-metricsbehindprometheusMetricsEnabled. - Add a regression test ensuring no Prometheus reader is created when Prometheus metrics are disabled.
- Extract
createDeferredand an async module-isolation helper intosrc/test/utils.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/internal/monitoring/otel-metrics.ts | Only instantiates the Prometheus exporter when prometheusMetricsEnabled is true. |
| src/test/otel-metrics.test.ts | Adds coverage for the “Prometheus disabled” case; switches to shared isolate helper and resets modules in teardown. |
| src/test/otel-tracing.test.ts | Reuses shared createDeferred and isolate helper; adjusts one test to control class-instrumentations timing. |
| src/test/progressive-migrations.test.ts | Reuses shared createDeferred helper. |
| src/test/utils/promise.ts | New shared deferred-promise utility. |
| src/test/utils/jest.ts | New shared async “isolate modules” utility for tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9e3ec9d to
64f3aa3
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
64f3aa3 to
b473634
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b473634 to
8c4a562
Compare
8c4a562 to
b987dd5
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b987dd5 to
55f9beb
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>
55f9beb to
2c4cbdc
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 7 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
What kind of change does this PR introduce?
Bug fix
What is the current behavior?
Prom exporter is created unconditionally even if config is set to false.
What is the new behavior?
Guard to create only if config requires.
Extract some test functions into utilities.
Additional context
It should help to stabilize memory usage.