-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fetch instrumentationConfig ignoreUrls not working #110
Comments
Having the same issue, except instead of using // instrumentation.node.ts
import { Resource } from "@opentelemetry/resources";
import { NodeSDK } from "@opentelemetry/sdk-node";
import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-node";
import { SEMRESATTRS_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
import { FetchInstrumentation, OTLPHttpJsonTraceExporter } from "@vercel/otel";
const resource = new Resource({
[SEMRESATTRS_SERVICE_NAME]: "my-project",
});
const traceExporter = new OTLPHttpJsonTraceExporter({ url: "..." });
const batchSpanProcessor = new BatchSpanProcessor(traceExporter, { scheduledDelayMillis: 500 });
const promExporter = new PrometheusExporter();
const meterProvider = new MeterProvider({ resource, readers: [promExporter] });
const sdk = new NodeSDK({
resource,
spanProcessors: [batchSpanProcessor],
instrumentations: [
new FetchInstrumentation({
ignoreUrls: ["/api/health-check", "/api/metrics/prometheus"], // doesn't work
}),
],
});
sdk.start(); |
After doing a bit more investigation today, I realised that this is an ignore list for outgoing fetch requests from Next.js, not incoming requests to Next.js. I was able to ignore requests made to APIs from our Node server in |
@harry-gocity i hope this works for you: import { Resource } from "@opentelemetry/resources";
import { NodeSDK } from "@opentelemetry/sdk-node";
import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-node";
import { SEMRESATTRS_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
import { FetchInstrumentation, OTLPHttpJsonTraceExporter } from "@vercel/otel";
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
const resource = new Resource({
[SEMRESATTRS_SERVICE_NAME]: "my-project",
});
const traceExporter = new OTLPHttpJsonTraceExporter({ url: "..." });
const batchSpanProcessor = new BatchSpanProcessor(traceExporter, { scheduledDelayMillis: 500 });
const promExporter = new PrometheusExporter();
const meterProvider = new MeterProvider({ resource, readers: [promExporter] });
const sdk = new NodeSDK({
resource,
spanProcessors: [batchSpanProcessor],
instrumentations: [
new FetchInstrumentation({
ignoreUrls: ["/api/health-check", "/api/metrics/prometheus"], // doesn't work
}),
new HttpInstrumentation({
enabled: true,
ignoreIncomingRequestHook: (request: IncomingMessage) => {
const ignorePatterns = [
/^\/_next\//, // starts with /_next/
/^\/images\//, // starts with /images/
/\?_rsc=/, // contains ?_rsc=
/^\/hc/, // starts with /hc
];
const url = request.url;
if (typeof url === 'string' && ignorePatterns.some((pattern) => pattern.test(url))) {
return true;
}
return false;
},
ignoreOutgoingRequestHook: () => {
return true;
},
}),
],
});
sdk.start(); |
Hi,
i am trying to instrument parts of my nextjs application.
I want to exclude a lot of urls from this project by using the ignoreUrls config option
My Custom JSONProcessor is written for debug purposes that just console.logs every span in the onEnd function.
This shows that not a single exception is being made and the whole application is being instrumented even though i explicitly tell it to exclude every url that does not contain
/chat
If i make cherry picked examples by just providing possible string prefixes instead of a regex, the same thing happens. It also is not ignored when explicitly setting
opentelemetry.ignore = true
in the fetch operation like in the example below.Thanks!
The text was updated successfully, but these errors were encountered: