Skip to content

Commit 505d8d5

Browse files
committed
feat(rum-core): allow sending route-change transactions with no spans
1 parent bf696ae commit 505d8d5

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

packages/rum-core/src/common/config-service.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ class Config {
9595
context: {},
9696
session: false,
9797
apmRequest: null,
98-
sendCredentials: false
98+
sendCredentials: false,
99+
sendAllRouteChanges: false
99100
}
100101

101102
this.events = new EventHandler()

packages/rum-core/src/performance-monitoring/performance-monitoring.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ import {
4848
OUTCOME_SUCCESS,
4949
OUTCOME_UNKNOWN,
5050
QUEUE_ADD_TRANSACTION,
51-
TRANSACTION_IGNORE
51+
TRANSACTION_IGNORE,
52+
ROUTE_CHANGE
5253
} from '../common/constants'
5354
import {
5455
truncateModel,
@@ -362,6 +363,12 @@ export default class PerformanceMonitoring {
362363
}
363364

364365
if (tr.sampled && tr.spans.length === 0) {
366+
if (
367+
tr.type === ROUTE_CHANGE &&
368+
this._configService.get('sendAllRouteChanges')
369+
) {
370+
return true
371+
}
365372
if (__DEV__) {
366373
this._logginService.debug(
367374
`transaction(${tr.id}, ${tr.name}) was discarded! Transaction does not have any spans`

packages/rum-core/test/performance-monitoring/performance-monitoring.spec.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,20 @@ describe('PerformanceMonitoring', function () {
127127
)
128128
})
129129

130+
it('should allow route-change transactions with no spans if enabled by configuration', () => {
131+
spyOn(logger, 'debug').and.callThrough()
132+
configService.setConfig({ ...agentConfig, sendAllRouteChanges: true })
133+
const transaction1 = new Transaction('/route/:id', 'route-change', {
134+
id: 1,
135+
startTime: 0,
136+
managed: true
137+
})
138+
transaction1.end(600)
139+
expect(transaction1.duration()).toBe(600)
140+
expect(performanceMonitoring.filterTransaction(transaction1)).toBe(true)
141+
expect(logger.debug).not.toHaveBeenCalled()
142+
})
143+
130144
it('should initialize and add transaction to the queue', async () => {
131145
performanceMonitoring.init()
132146
spyOn(apmServer, 'addTransaction')

0 commit comments

Comments
 (0)