Skip to content

Commit a5d88c9

Browse files
authored
feat(rum-core): allow sending transactions with no spans using config (#1665)
1 parent 69c76d1 commit a5d88c9

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

docs/reference/configuration.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,3 +368,9 @@ If APM Server is deployed in an origin different than the page’s origin, you w
368368
::::
369369

370370

371+
### `reportTransactionsWithoutSpans` [report-transactions-without-spans]
372+
373+
* **Type:** Boolean
374+
* **Default:** `false`
375+
376+
If you are interested also for transactions that have no spans you can set this configuration option to true. Bear in mind that sampling rate still applies even if this setting is set to `true`.

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ class Config {
9696
context: {},
9797
session: false,
9898
apmRequest: null,
99-
sendCredentials: false
99+
sendCredentials: false,
100+
reportTransactionsWithoutSpans: false
100101
}
101102

102103
this.events = new EventHandler()

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,10 @@ export default class PerformanceMonitoring {
361361
return false
362362
}
363363

364-
if (tr.sampled && tr.spans.length === 0) {
364+
const recordEmpty = this._configService.get(
365+
'reportTransactionsWithoutSpans'
366+
)
367+
if (tr.sampled && tr.spans.length === 0 && !recordEmpty) {
365368
if (__DEV__) {
366369
this._logginService.debug(
367370
`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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,23 @@ describe('PerformanceMonitoring', function () {
127127
)
128128
})
129129

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

0 commit comments

Comments
 (0)