Skip to content

Commit 8b80eab

Browse files
committed
refactor: Rename error instrumentation fn name for filtering out
1 parent 6982c95 commit 8b80eab

File tree

3 files changed

+24
-25
lines changed

3 files changed

+24
-25
lines changed

packages/instrumentation-exception/src/browser/instrumentations/HyperDXErrorInstrumentation.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,23 @@ export const ERROR_INSTRUMENTATION_VERSION = '1';
2929
export class HyperDXErrorInstrumentation extends InstrumentationBase {
3030
private readonly _consoleErrorHandler = (original: Console['error']) => {
3131
return (...args: any[]) => {
32-
this.report('console.error', args);
32+
this.hdxReport('console.error', args);
3333
return original.apply(this, args);
3434
};
3535
};
3636

3737
private readonly _unhandledRejectionListener = (
3838
event: PromiseRejectionEvent,
3939
) => {
40-
this.report('unhandledrejection', event.reason);
40+
this.hdxReport('unhandledrejection', event.reason);
4141
};
4242

4343
private readonly _errorListener = (event: ErrorEvent) => {
44-
this.report('onerror', event);
44+
this.hdxReport('onerror', event);
4545
};
4646

4747
private readonly _documentErrorListener = (event: ErrorEvent) => {
48-
this.report('eventListener.error', event);
48+
this.hdxReport('eventListener.error', event);
4949
};
5050

5151
constructor(config: InstrumentationConfig) {
@@ -83,7 +83,7 @@ export class HyperDXErrorInstrumentation extends InstrumentationBase {
8383
);
8484
}
8585

86-
protected reportError(source: string, err: Error): void {
86+
protected hdxReportError(source: string, err: Error): void {
8787
const msg = err.message || err.toString();
8888
if (!useful(msg) && !err.stack) {
8989
return;
@@ -92,7 +92,7 @@ export class HyperDXErrorInstrumentation extends InstrumentationBase {
9292
recordException(err, {}, this.tracer);
9393
}
9494

95-
protected reportString(
95+
protected hdxReportString(
9696
source: string,
9797
message: string,
9898
firstError?: Error,
@@ -109,15 +109,15 @@ export class HyperDXErrorInstrumentation extends InstrumentationBase {
109109
recordException(e, {}, this.tracer);
110110
}
111111

112-
protected reportErrorEvent(source: string, ev: ErrorEvent): void {
112+
protected hdxReportErrorEvent(source: string, ev: ErrorEvent): void {
113113
if (ev.error) {
114-
this.report(source, ev.error);
114+
this.hdxReport(source, ev.error);
115115
} else if (ev.message) {
116-
this.report(source, ev.message);
116+
this.hdxReport(source, ev.message);
117117
}
118118
}
119119

120-
protected reportEvent(source: string, ev: Event): void {
120+
protected hdxReportEvent(source: string, ev: Event): void {
121121
// FIXME consider other sources of global 'error' DOM callback - what else can be captured here?
122122
if (!ev.target && !useful(ev.type)) {
123123
return;
@@ -136,7 +136,7 @@ export class HyperDXErrorInstrumentation extends InstrumentationBase {
136136
recordException(ev, {}, this.tracer, span);
137137
}
138138

139-
public report(
139+
protected hdxReport(
140140
source: string,
141141
arg: string | Event | ErrorEvent | Array<any>,
142142
): void {
@@ -147,23 +147,23 @@ export class HyperDXErrorInstrumentation extends InstrumentationBase {
147147
arg = arg[0];
148148
}
149149
if (arg instanceof Error) {
150-
this.reportError(source, arg);
150+
this.hdxReportError(source, arg);
151151
} else if (arg instanceof ErrorEvent) {
152-
this.reportErrorEvent(source, arg);
152+
this.hdxReportErrorEvent(source, arg);
153153
} else if (arg instanceof Event) {
154-
this.reportEvent(source, arg);
154+
this.hdxReportEvent(source, arg);
155155
} else if (typeof arg === 'string') {
156-
this.reportString(source, arg);
156+
this.hdxReportString(source, arg);
157157
} else if (arg instanceof Array) {
158158
// if any arguments are Errors then add the stack trace even though the message is handled differently
159159
const firstError = arg.find((x) => x instanceof Error);
160-
this.reportString(
160+
this.hdxReportString(
161161
source,
162162
arg.map((x) => stringifyValue(x)).join(' '),
163163
firstError,
164164
);
165165
} else {
166-
this.reportString(source, stringifyValue(arg)); // FIXME or JSON.stringify?
166+
this.hdxReportString(source, stringifyValue(arg)); // FIXME or JSON.stringify?
167167
}
168168
}
169169
}

packages/instrumentation-exception/src/browser/integrations/__tests__/hyperdx.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ describe('hyperdxIntegration', () => {
5555
{
5656
filename:
5757
'https://www.hyperdx.io/_next/static/chunks/somefile.js',
58-
function: 'Lx.report',
58+
function: 'hdxReport',
5959
lineno: 1,
6060
colno: 88323,
6161
},
6262
{
6363
filename:
6464
'https://www.hyperdx.io/_next/static/chunks/somefile.js',
65-
function: 'Lx.reportString',
65+
function: 'hdxReportString',
6666
lineno: 1,
6767
colno: 88323,
6868
},

packages/instrumentation-exception/src/browser/integrations/hyperdx.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,19 @@ export const _hyperdxIntegration = ((options: HyperDXOptions = {}) => {
3030
continue;
3131
// remove frames caused by SDK
3232
} else if (
33-
frame.function?.endsWith('.reportString') ||
34-
frame.function?.endsWith('.reportError') ||
35-
frame.function?.endsWith('.reportErrorEvent') ||
36-
frame.function?.endsWith('.reportEvent')
33+
frame.function?.endsWith('hdxReportString') ||
34+
frame.function?.endsWith('hdxReportError') ||
35+
frame.function?.endsWith('hdxReportErrorEvent') ||
36+
frame.function?.endsWith('hdxReportEvent')
3737
) {
3838
continue;
3939
// console.errors are caught and reported by the SDK in this sequence:
4040
// anon fn -> reportString -> report
4141
// this condition removes the anon fn after .reportString ans .report frames
42-
} else if (frame.function?.endsWith('.report')) {
42+
} else if (frame.function?.endsWith('hdxReport')) {
4343
shouldRemoveNextFrameIfSameFile = frame.filename;
4444
continue;
4545
} else if (
46-
frame.function?.length <= 1 &&
4746
shouldRemoveNextFrameIfSameFile &&
4847
frame.filename === shouldRemoveNextFrameIfSameFile
4948
) {

0 commit comments

Comments
 (0)