Skip to content

Commit f45595c

Browse files
committed
feat(tracing): Change resource span op name and add tags
1 parent 5ed3135 commit f45595c

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

packages/eslint-config-sdk/src/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ module.exports = {
3939
// Enforce type annotations to maintain consistency. This is especially important as
4040
// we have a public API, so we want changes to be very explicit.
4141
'@typescript-eslint/typedef': ['error', { arrowParameter: false }],
42+
43+
// Although for most codebases inferencing the return type is fine, we explicitly ask to annotate
44+
// all functions with a return type. This is so that intent is as clear as possible. We are guarding against
45+
// cases where you accidently refactor a function's return type to be the wrong type.
4246
'@typescript-eslint/explicit-function-return-type': ['error', { allowExpressions: true }],
4347

4448
// Consistent ordering of fields, methods and constructors for classes should be enforced

packages/tracing/src/browser/metrics.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable max-lines */
12
/* eslint-disable @typescript-eslint/no-explicit-any */
23
import { SpanContext } from '@sentry/types';
34
import { getGlobalObject, logger } from '@sentry/utils';
@@ -214,7 +215,7 @@ function addMeasureSpans(
214215
/** Create resource related spans */
215216
function addResourceSpans(
216217
transaction: Transaction,
217-
entry: Record<string, any>,
218+
entry: Record<string, unknown>,
218219
resourceName: string,
219220
startTime: number,
220221
duration: number,
@@ -226,14 +227,26 @@ function addResourceSpans(
226227
return undefined;
227228
}
228229

230+
const tags: Record<string, string> = {};
231+
if (entry.transferSize) {
232+
tags.transferSize = (entry.transferSize as number).toString();
233+
}
234+
if (entry.encodedBodySize) {
235+
tags.encodedBodySize = (entry.encodedBodySize as number).toString();
236+
}
237+
if (entry.decodedBodySize) {
238+
tags.decodedBodySize = (entry.decodedBodySize as number).toString();
239+
}
240+
229241
const startTimestamp = timeOrigin + startTime;
230242
const endTimestamp = startTimestamp + duration;
231243

232244
_startChild(transaction, {
233-
description: `${entry.initiatorType} ${resourceName}`,
245+
description: resourceName,
234246
endTimestamp,
235-
op: 'resource',
247+
op: entry.initiatorType && entry.initiatorType !== '' ? `resource.${entry.initiatorType}` : 'resource',
236248
startTimestamp,
249+
tags,
237250
});
238251

239252
return endTimestamp;

0 commit comments

Comments
 (0)