Skip to content

Commit 64cd327

Browse files
committed
add env var to disable additional detectors
1 parent c22dbe9 commit 64cd327

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

apps/webapp/app/env.server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ const EnvironmentSchema = z.object({
354354
INTERNAL_OTEL_METRIC_EXPORTER_INTERVAL_MS: z.coerce.number().int().default(30_000),
355355
INTERNAL_OTEL_HOST_METRICS_ENABLED: BoolEnv.default(true),
356356
INTERNAL_OTEL_NODEJS_METRICS_ENABLED: BoolEnv.default(true),
357+
INTERNAL_OTEL_ADDITIONAL_DETECTORS_ENABLED: BoolEnv.default(true),
357358

358359
ORG_SLACK_INTEGRATION_CLIENT_ID: z.string().optional(),
359360
ORG_SLACK_INTEGRATION_CLIENT_SECRET: z.string().optional(),

apps/webapp/app/v3/tracer.server.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
3636
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
3737
import { PrismaInstrumentation } from "@prisma/instrumentation";
3838
import { HostMetrics } from "@opentelemetry/host-metrics";
39-
import { AwsInstrumentation } from "@opentelemetry/instrumentation-aws-sdk";
39+
import { AwsInstrumentation as AwsSdkInstrumentation } from "@opentelemetry/instrumentation-aws-sdk";
4040
import { awsEcsDetector, awsEc2Detector } from "@opentelemetry/resource-detector-aws";
4141
import {
4242
detectResources,
@@ -45,6 +45,7 @@ import {
4545
osDetector,
4646
hostDetector,
4747
processDetector,
48+
type ResourceDetector,
4849
} from "@opentelemetry/resources";
4950
import { env } from "~/env.server";
5051
import type { AuthenticatedEnvironment } from "~/services/apiAuth.server";
@@ -171,16 +172,13 @@ export async function emitWarnLog(message: string, params: Record<string, unknow
171172
}
172173

173174
function getResource() {
174-
const detectedResource = detectResources({
175-
detectors: [
176-
serviceInstanceIdDetector,
177-
osDetector,
178-
hostDetector,
179-
processDetector,
180-
awsEcsDetector,
181-
awsEc2Detector,
182-
],
183-
});
175+
const detectors: ResourceDetector[] = [serviceInstanceIdDetector];
176+
177+
if (env.INTERNAL_OTEL_ADDITIONAL_DETECTORS_ENABLED) {
178+
detectors.push(osDetector, hostDetector, processDetector, awsEcsDetector, awsEc2Detector);
179+
}
180+
181+
const detectedResource = detectResources({ detectors });
184182

185183
const baseResource = resourceFromAttributes({
186184
[ATTR_SERVICE_NAME]: env.SERVICE_NAME,
@@ -285,7 +283,7 @@ function setupTelemetry() {
285283
let instrumentations: Instrumentation[] = [
286284
new HttpInstrumentation(),
287285
new ExpressInstrumentation(),
288-
new AwsInstrumentation({
286+
new AwsSdkInstrumentation({
289287
suppressInternalInstrumentation: true,
290288
}),
291289
];

0 commit comments

Comments
 (0)