Skip to content

Commit 2a51ae8

Browse files
Suppress external instrumentations for fetch calls from ApiClient (#1788)
Signed-off-by: Erin Allison <[email protected]> Co-authored-by: Matt Aitken <[email protected]>
1 parent 4fda8a5 commit 2a51ae8

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

.changeset/red-wasps-cover.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@trigger.dev/core": patch
3+
---
4+
5+
Suppress external instrumentation for fetch calls from ApiClient

packages/core/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@
172172
"@jsonhero/path": "^1.0.21",
173173
"@opentelemetry/api": "1.9.0",
174174
"@opentelemetry/api-logs": "0.52.1",
175+
"@opentelemetry/core": "^1.30.1",
175176
"@opentelemetry/exporter-logs-otlp-http": "0.52.1",
176177
"@opentelemetry/exporter-trace-otlp-http": "0.52.1",
177178
"@opentelemetry/instrumentation": "0.52.1",

packages/core/src/v3/apiClient/core.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { calculateNextRetryDelay } from "../utils/retries.js";
55
import { ApiConnectionError, ApiError, ApiSchemaValidationError } from "./errors.js";
66

77
import { Attributes, context, propagation, Span } from "@opentelemetry/api";
8+
import {suppressTracing} from "@opentelemetry/core"
89
import { SemanticInternalAttributes } from "../semanticInternalAttributes.js";
910
import type { TriggerTracer } from "../tracer.js";
1011
import { accessoryAttributes } from "../utils/styleAttributes.js";
@@ -216,7 +217,9 @@ async function _doZodFetchWithRetries<TResponseBodySchema extends z.ZodTypeAny>(
216217
attempt = 1
217218
): Promise<ZodFetchResult<z.output<TResponseBodySchema>>> {
218219
try {
219-
const response = await fetch(url, requestInitWithCache(requestInit));
220+
const response = await context.with(suppressTracing(context.active()), () =>
221+
fetch(url, requestInitWithCache(requestInit))
222+
);
220223

221224
const responseHeaders = createResponseHeaders(response.headers);
222225

pnpm-lock.yaml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)