Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions observability/otel/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,33 @@ if (OTEL_IS_ENABLED) {
}

export const meter: IMeter = meterProvider.getMeter("deco");

// Outgoing fetch metrics — disabled by default. Enable with OTEL_METRICS_OUTGOING_FETCH=true.
import { ValueType } from "../../deps.ts";
import { onFetch, parseUrlParts } from "../../utils/patched_fetch.ts";

if (Deno.env.get("OTEL_METRICS_OUTGOING_FETCH") === "true") {

@cubic-dev-ai cubic-dev-ai Bot Apr 6, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Fix with Cubic


const fetchCount = meter.createCounter("outgoing_fetch", {
unit: "1",
valueType: ValueType.INT,
});

const fetchDuration = meter.createHistogram("outgoing_fetch_duration", {
unit: "ms",
valueType: ValueType.DOUBLE,
});

onFetch((event) => {
const { host } = parseUrlParts(event.url);
const attrs = {
app: event.app ?? "unknown",
host: host ?? "unknown",
method: event.method,
status: event.status,
};
fetchCount.add(1, attrs);
fetchDuration.record(event.durationMs, attrs);
});

} // OTEL_METRICS_OUTGOING_FETCH
Loading