feat(o11y): outgoing fetch metrics (counter + histogram)#1155
feat(o11y): outgoing fetch metrics (counter + histogram)#1155nicacioliveira wants to merge 2 commits into
Conversation
Tagging OptionsShould a new tag be published when this PR is merged?
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughOptional OpenTelemetry metrics added to record outgoing fetches: an Changes
Sequence Diagram(s)sequenceDiagram
participant Fetch as "Outgoing Fetch"
participant Handler as "onFetch Handler"
participant Metrics as "OTel Metrics SDK"
participant Exporter as "OTel Exporter"
Fetch->>Handler: emit fetch event (url, method, status, durationMs)
Handler->>Handler: parse host, normalize attributes (app, host, method, status)
Handler->>Metrics: increment outgoing_fetch counter (attributes)
Handler->>Metrics: record outgoing_fetch_duration histogram (durationMs, attributes)
Metrics->>Exporter: export metrics batch
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…ICS_OUTGOING_FETCH=true
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="observability/otel/metrics.ts">
<violation number="1" location="observability/otel/metrics.ts:71">
P1: Outgoing fetch metrics are now gated by `OTEL_METRICS_OUTGOING_FETCH`, which disables the feature by default instead of keeping it always-on.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| import { ValueType } from "../../deps.ts"; | ||
| import { onFetch, parseUrlParts } from "../../utils/patched_fetch.ts"; | ||
|
|
||
| if (Deno.env.get("OTEL_METRICS_OUTGOING_FETCH") === "true") { |
There was a problem hiding this comment.
P1: Outgoing fetch metrics are now gated by OTEL_METRICS_OUTGOING_FETCH, which disables the feature by default instead of keeping it always-on.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At observability/otel/metrics.ts, line 71:
<comment>Outgoing fetch metrics are now gated by `OTEL_METRICS_OUTGOING_FETCH`, which disables the feature by default instead of keeping it always-on.</comment>
<file context>
@@ -64,10 +64,12 @@ if (OTEL_IS_ENABLED) {
import { ValueType } from "../../deps.ts";
import { onFetch, parseUrlParts } from "../../utils/patched_fetch.ts";
+if (Deno.env.get("OTEL_METRICS_OUTGOING_FETCH") === "true") {
+
const fetchCount = meter.createCounter("outgoing_fetch", {
</file context>
What
Adds always-on metrics for outgoing HTTP fetches:
outgoing_fetchcounter — total calls byapp,host,method,statusoutgoing_fetch_durationhistogram (ms) — latency byapp,host,method,statusUses
hostonly (notpath) to keep cardinality low.Queries
Always on, no env var needed. Log-based
outgoing fetchremains off by default (OTEL_LOG_OUTGOING_FETCH=true).Summary by cubic
Adds metrics for outgoing HTTP fetches to track request volume and latency with low-cardinality labels. Disabled by default; enable with
OTEL_METRICS_OUTGOING_FETCH=true.outgoing_fetchcounter: counts requests byapp,host,method,status.outgoing_fetch_durationhistogram (ms): records latency with the same labels.hostonly (nopath) to keep cardinality low.OTEL_LOG_OUTGOING_FETCH=true.Written for commit 994e7dc. Summary will update on new commits.
Summary by CodeRabbit