Skip to content

Commit 95bf139

Browse files
committed
Do not instrument transmitter requests
Requests performed by the transmitter after the integration has been initialised, such as those performed by the heartbeats module, were being instrumented by OpenTelemetry. This commit uses `suppressTracing` to prevent that.
1 parent f730711 commit 95bf139

File tree

2 files changed

+29
-18
lines changed

2 files changed

+29
-18
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
bump: patch
3+
type: fix
4+
---
5+
6+
Prevent internal AppSignal requests from being instrumented and appearing in the "Slow API requests" panel.

src/transmitter.ts

+23-18
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import { Configuration } from "./config"
66
import { URL, URLSearchParams } from "url"
77
import { Client } from "./client"
88

9+
import { context } from "@opentelemetry/api"
10+
import { suppressTracing } from "@opentelemetry/core"
11+
912
const REDIRECT_COUNT = Symbol("redirect-count")
1013

1114
type TransmitterRequestOptions = {
@@ -101,32 +104,34 @@ export class Transmitter {
101104
}
102105

103106
public request(requestOptions: TransmitterRequestOptions) {
104-
const { method, params = new URLSearchParams(), onError } = requestOptions
107+
context.with(suppressTracing(context.active()), () => {
108+
const { method, params = new URLSearchParams(), onError } = requestOptions
105109

106-
const initialOptions = {
107-
method,
108-
...this.urlRequestOptions()
109-
}
110+
const initialOptions = {
111+
method,
112+
...this.urlRequestOptions()
113+
}
110114

111-
const { protocol, path } = initialOptions
115+
const { protocol, path } = initialOptions
112116

113-
const options = {
114-
...initialOptions,
115-
...this.paramsRequestOptions(path ?? "", params),
116-
...this.bodyRequestOptions(method),
117-
...this.caRequestOptions(protocol ?? "")
118-
}
117+
const options = {
118+
...initialOptions,
119+
...this.paramsRequestOptions(path ?? "", params),
120+
...this.bodyRequestOptions(method),
121+
...this.caRequestOptions(protocol ?? "")
122+
}
119123

120-
const module = this.requestModule(protocol ?? "")
124+
const module = this.requestModule(protocol ?? "")
121125

122-
const callback = this.handleRedirectsCallback(requestOptions)
126+
const callback = this.handleRedirectsCallback(requestOptions)
123127

124-
const request = module.request(options, callback)
128+
const request = module.request(options, callback)
125129

126-
request.on("error", onError)
130+
request.on("error", onError)
127131

128-
this.writeRequest(method, request)
129-
request.end()
132+
this.writeRequest(method, request)
133+
request.end()
134+
})
130135
}
131136

132137
private handleRedirectsCallback({

0 commit comments

Comments
 (0)