question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Capture route change transactions

See original GitHub issue

There are multiple approaches for capturing the route change transactions:

  1. Instrumenting the history API
  2. Providing framework-specific instrumentation

The first solution would provide support for a wide range of frameworks (potentially with some work on the user side) but we don’t have access to the route name, we only have the URL which might contain IDs. To solve this issue we can provide onStart and onEnd event listeners in the config options for transaction start and transaction end respectively, as an example consider the following:

Please note that users don’t need to provide both event listeners.

apm.init({
   onStart: (transaction)=>{ 
      transaction.name= 'transactions-name' 
      return transaction
   },
   onEnd: (transaction)=>{ 
      transaction.name= 'transactions-name' 
      return transaction
   }
})

The drawback for the second approach is that we need to provide instrumentation for each framework.

Potential pitfalls for react-route:

  • Multiple routes could match with any route change, but we should only create one transaction for the whole route change (need to investigate this kind of use-cases)

Currently, I think we should take both approaches, the first approach would serve as a base for the second approach. i.e. a framework specific instrumentation can register event listeners for transactions and fix the transaction name if necessary.

Update: The above event listeners are not useful for instrumenting react-router therefore we should provide react specific instrumentation.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
hmdhkcommented, May 23, 2019

@tbragin , at first we decided to take framework-agnostic approach but in a lot of cases usage would be harder for user, so we will have to provide framework specific integrations. We’re starting with React, but Angular will follow after that.

0reactions
hmdhkcommented, Jul 18, 2019

@freezy, Thanks for reaching out!

if your application is using the history API to manage route changes, the lates version of the RUM agent should already capture route changes automatically. However, we can not capture the correct route name at the level we instrument the history API, therefore, you should use the Filter API to set the correct route name on the transaction before it is sent to the APM server.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Transaction to create and change route - SAP Community
You may create a Z Table-Route Master table (To capture charactrstics of routes) & another Z table- For mapping of customers from the...
Read more >
How to correctly handle route changes when using react ...
I have a react-router-dom router with following structure: ... ... <BrowserRouter> ... <Switch> <Route exact path="/" component={Landing} ...
Read more >
How to detect route change in Angular with examples
Steps to detect route change in Angular. 1. Import Router, Event, NavigationStart, NavigationEnd, NavigationError from '@angular/router'. 2.
Read more >
GoldenGate Capture Route tips - Burleson Consulting
GoldenGate Capture Route tips. ... This scenario requires manual changes for reading the transaction logs from archived log files.
Read more >
Supported Technologies | APM Real User Monitoring ... - Elastic
Single Page Applicationsedit ... All history pushState events will be captured as transactions. Most of these transactions can be enhanced by using framework ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found