HTTP tracing is configured with the top-level http option.
Alongside the standard HTTP instrumentation options, Monocle adds few specific features:
sanitizeUrlsto redact sensitive query parameters from URL span attributescaptureBodiesto record request and response payloads on spans
Both features are disabled by default. Configure sanitizeUrls to enable URL sanitization. For body capture, set captureBodies.enabled: true, or opt in per side with incoming.request.enabled, incoming.response.enabled, and so on.
export default defineConfig({
// ...
// High-level HTTP tracing options.
http: {
// Ignore noisy routes before spans are exported.
ignoredUrls: ['/internal/*', '/api/ping'],
// Redact sensitive query params in URL span attributes.
sanitizeUrls: {
queryParams: ['code', 'state', 'token', 'id_token', 'session_state'],
censor: 'REDACTED',
},
// Capture request and response payloads on HTTP spans.
captureBodies: {
enabled: true,
// Server-side traffic handled by your Adonis app.
incoming: {
request: {
// Limit the number of bytes stored on the span.
maxBodySize: 16_384,
},
response: {},
},
// Client-side traffic instrumented by node:http / node:https.
outgoing: {
request: {},
response: {},
},
// Declarative redaction merged with Monocle's built-in safe defaults.
redact: {
bodyKeys: ['password', 'token', 'secret'],
headers: ['authorization', 'cookie'],
queryParams: ['token'],
censor: 'REDACTED',
},
// Final hook to mutate or replace the captured payload.
transform: (record) => {
if (!record.http.url?.includes('/oauth/callback')) return
record.http.body = { redacted: true }
},
},
},
})URL sanitization
sanitizeUrls rewrites URL span attributes such as http.url, url.full, http.target, and url.query.
export default defineConfig({
// ...
http: {
sanitizeUrls: {
queryParams: ['code', 'state', 'id_token', 'session_state'],
},
},
})For example, an OAuth callback like:
/oauth/callback?code=oauth-code&state=oauth-state&id_token=jwt-tokenbecomes:
/oauth/callback?code=REDACTED&state=REDACTED&id_token=REDACTEDFor more control, you can provide a custom sanitize function that takes the full URL object and returns a sanitized string.
export default defineConfig({
// ...
http: {
sanitizeUrls: {
sanitize: (url) => {
// Only keep the pathname for OAuth callbacks
if (url.pathname === '/oauth/callback') return url.pathname
// Otherwise, keep the full URL
return url.href
},
},
},
})Body capture scope
incoming captures traffic handled by your Adonis app:
incoming.requestfor the HTTP request body sent to your serverincoming.responsefor the HTTP response body returned by your server
outgoing captures traffic created by Node HTTP clients inside your app:
outgoing.requestfor the request body your app sends to another serviceoutgoing.responsefor the response body returned by that service
captureBodies.outgoing only applies to traffic instrumented by
@opentelemetry/instrumentation-http, which means node:http and node:https. It does not cover
fetch or undici.
Body capture defaults
captureBodies is opt-in because payload capture can expose sensitive data.
When enabled, Monocle:
- captures
application/jsonandapplication/x-www-form-urlencodedby default - stores at most
10_000bytes per request or response unless you increasemaxBodySize - shows captured payloads in the HTTP Body tab of the trace details view
Body capture should be enabled deliberately and reviewed carefully. Payloads can contain
credentials or sensitive information. Keep capture scoped to the endpoints you need, prefer the
smallest possible maxBodySize, and use redact or transform to remove anything sensitive
before it is exported.
Redaction order
captureBodies.redact applies declarative redaction rules first.
captureBodies.transform runs after that and lets you mutate or replace the captured payload programmatically.
The declarative redact rules extend Monocle's built-in safe defaults. Common secrets such as password, token, code, access_token, refresh_token, authorization, and many others are redacted automatically even if you do not list them yourself.
Advanced overrides
If you need low-level OpenTelemetry overrides, you can still configure instrumentations["@opentelemetry/instrumentation-http"].
When both are present, the low-level instrumentation config takes priority over the top-level http option.