Skip to content

Commit d0cfcd3

Browse files
authored
fix: support skipURLs property in http instrumentation (#559)
1 parent 60644bf commit d0cfcd3

File tree

1 file changed

+8
-1
lines changed
  • packages/otel/src/instrumentations

1 file changed

+8
-1
lines changed

packages/otel/src/instrumentations/http.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,14 @@ export class HttpInstrumentation implements Instrumentation {
147147

148148
private onRequest({ request }: { request: ClientRequest }): void {
149149
const tracer = this.getTracer()
150-
if (!tracer) return
150+
const url = new URL(request.path, `${request.protocol}//${request.host}`)
151+
152+
if (
153+
!tracer ||
154+
this.config.skipURLs?.some((skip) => (typeof skip == 'string' ? url.href.startsWith(skip) : skip.test(url.href)))
155+
) {
156+
return
157+
}
151158

152159
const span = tracer.startSpan(
153160
this.getRequestMethod(request.method),

0 commit comments

Comments
 (0)