Skip to content

Commit 9c94642

Browse files
authored
feat(types): Add TransactionNameChange interface (#5714)
This PR adds types for the `TransactionNameChange` interface: ```ts export interface TransactionInfo { source: TransactionSource; changes: TransactionNameChange[]; propagations: number; }; /** * Object representing metadata about when a transaction name was changed. */ export interface TransactionNameChange { /** * Unix timestamp when the name was changed. Same type as the start and * end timestamps of a transaction and span. */ timestamp: number; /** New source applied for transaction name change */ source: TransactionSource; /** Number of propagations since start of transaction */ propagations: number; } ``` `TransactionNameChange` is an object that describes a point in time when a transaction name was changed. It contains a Unix timestamp (matching with span/transaction start/end timestamps), the transaction source for the changed name, and the number of propagations (when dynamic sampling context was sent to another SDK - through meta tag/http header) that happened since that transaction name change.
1 parent 1c566b5 commit 9c94642

File tree

12 files changed

+53
-1
lines changed

12 files changed

+53
-1
lines changed

packages/nextjs/test/integration/test/server/tracing200.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ module.exports = async ({ url: urlBase, argv }) => {
1818
transaction: 'GET /api/users',
1919
transaction_info: {
2020
source: 'route',
21+
changes: [],
22+
propagations: 0,
2123
},
2224
type: 'transaction',
2325
request: {

packages/nextjs/test/integration/test/server/tracing500.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ module.exports = async ({ url: urlBase, argv }) => {
1717
transaction: 'GET /api/broken',
1818
transaction_info: {
1919
source: 'route',
20+
changes: [],
21+
propagations: 0,
2022
},
2123
type: 'transaction',
2224
request: {

packages/nextjs/test/integration/test/server/tracingHttp.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ module.exports = async ({ url: urlBase, argv }) => {
3131
transaction: 'GET /api/http',
3232
transaction_info: {
3333
source: 'route',
34+
changes: [],
35+
propagations: 0,
3436
},
3537
type: 'transaction',
3638
request: {

packages/nextjs/test/integration/test/server/tracingServerGetInitialProps.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ module.exports = async ({ url: urlBase, argv }) => {
1616
transaction: '/[id]/withInitialProps',
1717
transaction_info: {
1818
source: 'route',
19+
changes: [],
20+
propagations: 0,
1921
},
2022
type: 'transaction',
2123
request: {

packages/nextjs/test/integration/test/server/tracingServerGetServerSideProps.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ module.exports = async ({ url: urlBase, argv }) => {
1616
transaction: '/[id]/withServerSideProps',
1717
transaction_info: {
1818
source: 'route',
19+
changes: [],
20+
propagations: 0,
1921
},
2022
type: 'transaction',
2123
request: {

packages/node-integration-tests/suites/express/tracing/test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ test('should set a correct transaction name for routes specified in RegEx', asyn
3838
transaction: 'GET /\\/test\\/regex/',
3939
transaction_info: {
4040
source: 'route',
41+
changes: [],
42+
propagations: 0,
4143
},
4244
contexts: {
4345
trace: {
@@ -66,6 +68,8 @@ test.each([['array1'], ['array5']])(
6668
transaction: 'GET /test/array1,/\\/test\\/array[2-9]',
6769
transaction_info: {
6870
source: 'route',
71+
changes: [],
72+
propagations: 0,
6973
},
7074
contexts: {
7175
trace: {
@@ -102,6 +106,8 @@ test.each([
102106
transaction: 'GET /test/arr/:id,/\\/test\\/arr[0-9]*\\/required(path)?(\\/optionalPath)?\\/(lastParam)?',
103107
transaction_info: {
104108
source: 'route',
109+
changes: [],
110+
propagations: 0,
105111
},
106112
contexts: {
107113
trace: {

packages/remix/test/integration/test/server/loader.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ describe.each(['builtin', 'express'])('Remix API Loaders with adapter = %s', ada
5555
transaction: 'routes/loader-json-response/$id',
5656
transaction_info: {
5757
source: 'route',
58+
changes: [],
59+
propagations: 0,
5860
},
5961
spans: [
6062
{

packages/tracing/src/transaction.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ export class Transaction extends SpanClass implements TransactionInterface {
4545
this.metadata = {
4646
...transactionContext.metadata,
4747
spanMetadata: {},
48+
changes: [],
49+
propagations: 0,
4850
};
4951

5052
this._trimEnd = transactionContext.trimEnd;
@@ -156,6 +158,8 @@ export class Transaction extends SpanClass implements TransactionInterface {
156158
...(metadata.source && {
157159
transaction_info: {
158160
source: metadata.source,
161+
changes: metadata.changes,
162+
propagations: metadata.propagations,
159163
},
160164
}),
161165
};

packages/tracing/test/span.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,8 @@ describe('Span', () => {
503503
expect.not.objectContaining({
504504
transaction_info: {
505505
source: expect.any(String),
506+
changes: [],
507+
propagations: 0,
506508
},
507509
}),
508510
);
@@ -522,6 +524,8 @@ describe('Span', () => {
522524
expect.objectContaining({
523525
transaction_info: {
524526
source: 'url',
527+
changes: [],
528+
propagations: 0,
525529
},
526530
}),
527531
);

packages/types/src/event.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { CaptureContext } from './scope';
1111
import { SdkInfo } from './sdkinfo';
1212
import { Severity, SeverityLevel } from './severity';
1313
import { Span } from './span';
14-
import { TransactionSource } from './transaction';
14+
import { TransactionNameChange, TransactionSource } from './transaction';
1515
import { User } from './user';
1616

1717
/** JSDoc */
@@ -49,6 +49,8 @@ export interface Event {
4949
sdkProcessingMetadata?: { [key: string]: any };
5050
transaction_info?: {
5151
source: TransactionSource;
52+
changes: TransactionNameChange[];
53+
propagations: number;
5254
};
5355
}
5456

packages/types/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export type {
7373
TransactionMetadata,
7474
TransactionSamplingMethod,
7575
TransactionSource,
76+
TransactionNameChange,
7677
} from './transaction';
7778
export type {
7879
DurationUnit,

packages/types/src/transaction.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,12 @@ export interface TransactionMetadata {
150150

151151
/** Metadata for the transaction's spans, keyed by spanId */
152152
spanMetadata: { [spanId: string]: { [key: string]: unknown } };
153+
154+
/** Metadata representing information about transaction name changes */
155+
changes: TransactionNameChange[];
156+
157+
/** The total number of propagations that happened */
158+
propagations: number;
153159
}
154160

155161
/**
@@ -169,3 +175,20 @@ export type TransactionSource =
169175
| 'component'
170176
/** Name of a background task (e.g. a Celery task) */
171177
| 'task';
178+
179+
/**
180+
* Object representing metadata about when a transaction name was changed.
181+
*/
182+
export interface TransactionNameChange {
183+
/**
184+
* Unix timestamp when the name was changed. Same type as the start and
185+
* end timestamps of a transaction and span.
186+
*/
187+
timestamp: number;
188+
189+
/** New source applied for transaction name change */
190+
source: TransactionSource;
191+
192+
/** Number of propagations since start of transaction */
193+
propagations: number;
194+
}

0 commit comments

Comments
 (0)