Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,3 +368,9 @@ If APM Server is deployed in an origin different than the page’s origin, you w
::::


### `sendAllRouteChanges` [send-all-route-changes]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be a request to add the same logic to user-click events as well, lets make this flag generic? reportAllTraces something along these lines ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At 1st I thought maybe to filter by transaction type. I don't have a strong opinion. Do we want a single or more fine grained control?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My suggestion is recordEmptyTransactions. Empty meaning with no spans. WDYT?


* **Type:** Boolean
* **Default:** `false`

This allows the agent to send all `route-change` transactions regardless if it contains any spans or not. This is usefull if you want to keep track of all the navigations your app is doing.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to call out how sampling plays a role in here as well.

3 changes: 2 additions & 1 deletion packages/rum-core/src/common/config-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ class Config {
context: {},
session: false,
apmRequest: null,
sendCredentials: false
sendCredentials: false,
sendAllRouteChanges: false
}

this.events = new EventHandler()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ import {
OUTCOME_SUCCESS,
OUTCOME_UNKNOWN,
QUEUE_ADD_TRANSACTION,
TRANSACTION_IGNORE
TRANSACTION_IGNORE,
ROUTE_CHANGE
} from '../common/constants'
import {
truncateModel,
Expand Down Expand Up @@ -362,6 +363,12 @@ export default class PerformanceMonitoring {
}

if (tr.sampled && tr.spans.length === 0) {
if (
tr.type === ROUTE_CHANGE &&
this._configService.get('sendAllRouteChanges')
) {
return true
}
if (__DEV__) {
this._logginService.debug(
`transaction(${tr.id}, ${tr.name}) was discarded! Transaction does not have any spans`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,20 @@ describe('PerformanceMonitoring', function () {
)
})

it('should allow route-change transactions with no spans if enabled by configuration', () => {
spyOn(logger, 'debug').and.callThrough()
configService.setConfig({ ...agentConfig, sendAllRouteChanges: true })
const transaction1 = new Transaction('/route/:id', 'route-change', {
id: 1,
startTime: 0,
managed: true
})
transaction1.end(600)
expect(transaction1.duration()).toBe(600)
expect(performanceMonitoring.filterTransaction(transaction1)).toBe(true)
expect(logger.debug).not.toHaveBeenCalled()
})

it('should initialize and add transaction to the queue', async () => {
performanceMonitoring.init()
spyOn(apmServer, 'addTransaction')
Expand Down
Loading