@sentry/node
Version:
Sentry Node SDK using OpenTelemetry for performance instrumentation
26 lines (25 loc) • 957 B
JavaScript
import { instrumentUndici } from "./undici-instrumentation.js";
import { defineIntegration, getClient, hasSpansEnabled } from "@sentry/core";
// src/integrations/node-fetch/index.ts
const _nativeNodeFetchIntegration = ((options = {}) => {
return {
name: "NodeFetch",
setupOnce() {
const clientOptions = getClient()?.getOptions();
instrumentUndici({
...options,
spans: _shouldInstrumentSpans(options, clientOptions)
});
}
};
});
/**
* Instrument outgoing fetch requests made through the native node `fetch` API.
* This emits (depending on the integration options) spans and breadcrumbs, as well as injecting trace propagation headers into the request.
*/
const nativeNodeFetchIntegration = defineIntegration(_nativeNodeFetchIntegration);
function _shouldInstrumentSpans(options, clientOptions = {}) {
return options.spans ?? hasSpansEnabled(clientOptions);
}
export { nativeNodeFetchIntegration };
//# sourceMappingURL=index.js.map