Skip to content

Commit

Permalink
TRACING-4435 added custom class
Browse files Browse the repository at this point in the history
  • Loading branch information
yash-sumo committed Oct 22, 2024
1 parent 13d3b22 commit 934babd
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@ interface InitializeOptions {
getOverriddenServiceName?: (span: Span) => string;
}

class MyHttpInstrumentation extends HttpInstrumentation {
instrumentationName = 'my-custom-instrumentation';
instrumentationVersion = '1.0.0';
enable() {
// custom enable logic
}
disable() {
// custom disable logic
}
}

const useWindow = typeof window === 'object' && window != null;

let contextManager: SumoLogicContextManager | undefined;
Expand Down Expand Up @@ -228,6 +239,12 @@ export const initialize = ({
}
};

const httpInstrumentation = new HttpInstrumentation();
httpInstrumentation.setConfig({
enabled: true,
ignoreIncomingRequestHook: () => true,
});

const registerInstrumentations = () => {
disableInstrumentations();
logsExporter.enable();
Expand All @@ -236,6 +253,7 @@ export const initialize = ({
registerOpenTelemetryInstrumentations({
tracerProvider: provider,
instrumentations: [
httpInstrumentation,
new LongTaskInstrumentation({
enabled: false,
}),
Expand Down Expand Up @@ -265,10 +283,6 @@ export const initialize = ({
propagateTraceHeaderCorsUrls,
ignoreUrls,
}),
new HttpInstrumentation({
enabled: true,
ignoreIncomingRequestHook: () => true,
} as any),
],
});
};
Expand Down

0 comments on commit 934babd

Please sign in to comment.