@bugsnag/core-performance
Advanced tools
Comparing version 2.8.0 to 2.8.1-alpha.0
@@ -21,9 +21,10 @@ import { BatchProcessor } from './batch-processor.js'; | ||
const plugins = options.plugins(spanFactory, spanContextStorage); | ||
return Object.assign({ start: (config) => { | ||
return { | ||
start: (config) => { | ||
const configuration = validateConfig(config, options.schema); | ||
// Correlate errors with span by monkey patching _notify on the error client | ||
// and utilizing the setTraceCorrelation method on the event | ||
if (configuration.bugsnag && typeof configuration.bugsnag.Event.prototype.setTraceCorrelation === 'function' && configuration.bugsnag._client) { | ||
const originalNotify = configuration.bugsnag._client._notify; | ||
configuration.bugsnag._client._notify = function (...args) { | ||
if (configuration.bugsnag && typeof configuration.bugsnag.Event.prototype.setTraceCorrelation === 'function' && configuration.bugsnag.Client) { | ||
const originalNotify = configuration.bugsnag.Client.prototype._notify; | ||
configuration.bugsnag.Client.prototype._notify = function (...args) { | ||
const currentSpanContext = spanContextStorage.current; | ||
@@ -68,3 +69,4 @@ if (currentSpanContext && typeof args[0].setTraceCorrelation === 'function') { | ||
} | ||
}, startSpan: (name, spanOptions) => { | ||
}, | ||
startSpan: (name, spanOptions) => { | ||
const cleanOptions = spanFactory.validateSpanOptions(name, spanOptions); | ||
@@ -74,3 +76,4 @@ const span = spanFactory.startSpan(cleanOptions.name, cleanOptions.options); | ||
return spanFactory.toPublicApi(span); | ||
}, startNetworkSpan: (networkSpanOptions) => { | ||
}, | ||
startNetworkSpan: (networkSpanOptions) => { | ||
const spanInternal = spanFactory.startNetworkSpan(networkSpanOptions); | ||
@@ -80,7 +83,11 @@ const span = spanFactory.toPublicApi(spanInternal); | ||
// once we release the setAttribute API we can simply return the span | ||
const networkSpan = Object.assign(Object.assign({}, span), { end: (endOptions) => { | ||
const networkSpan = { | ||
...span, | ||
end: (endOptions) => { | ||
spanFactory.endSpan(spanInternal, timeToNumber(options.clock, endOptions.endTime), { 'http.status_code': endOptions.status }); | ||
} }); | ||
} | ||
}; | ||
return networkSpan; | ||
}, getPlugin: (Constructor) => { | ||
}, | ||
getPlugin: (Constructor) => { | ||
for (const plugin of plugins) { | ||
@@ -91,5 +98,8 @@ if (plugin instanceof Constructor) { | ||
} | ||
}, get currentSpanContext() { | ||
}, | ||
get currentSpanContext() { | ||
return spanContextStorage.current; | ||
} }, (options.platformExtensions && options.platformExtensions(spanFactory, spanContextStorage))); | ||
}, | ||
...(options.platformExtensions && options.platformExtensions(spanFactory, spanContextStorage)) | ||
}; | ||
} | ||
@@ -96,0 +106,0 @@ function createNoopClient() { |
@@ -25,3 +25,8 @@ import { spanToJson } from './span.js'; | ||
body: deliveryPayload, | ||
headers: Object.assign({ 'Bugsnag-Api-Key': this.configuration.apiKey, 'Content-Type': 'application/json' }, (this.configuration.samplingProbability !== undefined ? {} : { 'Bugsnag-Span-Sampling': this.generateSamplingHeader(spans) })) | ||
headers: { | ||
'Bugsnag-Api-Key': this.configuration.apiKey, | ||
'Content-Type': 'application/json', | ||
// Do not set 'Bugsnag-Span-Sampling' if the SDK is configured with samplingProbability | ||
...(this.configuration.samplingProbability !== undefined ? {} : { 'Bugsnag-Span-Sampling': this.generateSamplingHeader(spans) }) | ||
} | ||
}; | ||
@@ -28,0 +33,0 @@ } |
@@ -55,3 +55,3 @@ import { SpanAttributes } from './attributes.js'; | ||
const cleanOptions = this.validateSpanOptions(spanName, options); | ||
const spanInternal = this.startSpan(cleanOptions.name, Object.assign(Object.assign({}, cleanOptions.options), { makeCurrentContext: false })); | ||
const spanInternal = this.startSpan(cleanOptions.name, { ...cleanOptions.options, makeCurrentContext: false }); | ||
spanInternal.setAttribute('bugsnag.span.category', 'network'); | ||
@@ -58,0 +58,0 @@ spanInternal.setAttribute('http.method', options.method); |
@@ -14,4 +14,6 @@ import type { Plugin } from './plugin'; | ||
}; | ||
_client?: { | ||
_notify: (event: BugsnagErrorEvent) => void; | ||
Client?: { | ||
prototype: { | ||
_notify: (event: BugsnagErrorEvent) => void; | ||
}; | ||
}; | ||
@@ -18,0 +20,0 @@ } |
@@ -14,3 +14,3 @@ import type { Configuration, Logger } from './config'; | ||
export declare const isStringArray: (value: unknown) => value is string[]; | ||
export declare const isStringOrRegExpArray: (value: unknown) => value is (string | RegExp)[]; | ||
export declare const isStringOrRegExpArray: (value: unknown) => value is Array<string | RegExp>; | ||
export declare function isPersistedProbability(value: unknown): value is PersistedProbability; | ||
@@ -17,0 +17,0 @@ export declare const isSpanContext: (value: unknown) => value is SpanContext; |
{ | ||
"name": "@bugsnag/core-performance", | ||
"version": "2.8.0", | ||
"version": "2.8.1-alpha.0", | ||
"description": "Core performance client", | ||
@@ -38,3 +38,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "39754ecb88063ec84edb031202820545950725de" | ||
"gitHead": "904470ce3230f19ce28f858efe5cf6b0f18cecf1" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
93723
1653
1