Skip to content

Commit

Permalink
tracing: ignore head/options method + specific urls by default
Browse files Browse the repository at this point in the history
  • Loading branch information
vmarchaud committed Mar 5, 2019
1 parent 7d56cca commit 152d598
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/features/tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ export interface TracingConfig {
ignoreOutgoingUrls?: Array<IgnoreMatcher<httpModule.ClientRequest>>
}

const httpMethodToIgnore = [
'options',
'head'
]
const defaultTracingConfig: TracingConfig = {
enabled: false,
outbound: false,
Expand All @@ -57,7 +61,18 @@ const enabledTracingConfig: TracingConfig = {
enabled: true,
outbound: false,
samplingRate: 0.5,
ignoreIncomingPaths: [],
ignoreIncomingPaths: [
(url, request) => {
const method = (request.method || 'GET').toLowerCase()
return httpMethodToIgnore.indexOf(method) > -1
},
/(.*).js/,
/(.*).css/,
/(.*).png/,
/(.*).ico/,
/(.*).svg/,
/webpack/
],
ignoreOutgoingUrls: [],
detailedDatabasesCalls: false
}
Expand Down Expand Up @@ -90,10 +105,10 @@ export class TracingFeature implements Feature {
this.options.serviceName = process.env.name
}
if (config.tracing.ignoreOutgoingUrls === undefined) {
config.tracing.ignoreOutgoingUrls = []
config.tracing.ignoreOutgoingUrls = enabledTracingConfig.ignoreOutgoingUrls
}
if (config.tracing.ignoreIncomingPaths === undefined) {
config.tracing.ignoreIncomingPaths = []
config.tracing.ignoreIncomingPaths = enabledTracingConfig.ignoreIncomingPaths
}
this.exporter = new CustomCensusExporter(this.options)
if (this.tracer && this.tracer.active) {
Expand Down

0 comments on commit 152d598

Please sign in to comment.