[RUM] StartTransaction not writing to apm server in javascript

APM Agent language and version: Javascript, 4.5.1
Browser version: Chrome Latest

I set up apm agent on Javascript based web page. Init (), which is called at the first loading, uses the following code to check that it is normally recorded on the apm server.

init:function(){
var _apm = window.elasticApm;

var fioriUser = sap.ushell.Container.getService("UserInfo").getUser();
var sCHash = document.location.hash;
var sHash = sCHash.indexOf("&")>-1 ? sCHash.split("&")[0] : sCHash;
//10. Set User Info
_apm.setUserContext({
id: fioriUser.getId(),
username: fioriUser.getFullName(),
email: fioriUser.getEmail()
});
//20. Initialize
var agent = _apm.init({
serviceName: 'fioriNew',
serverUrl: 'https://server.url',
serviceVersion: '0.90',
pageLoadTransactionName : sHash
});
this._agent = agent;
},

After that, add the following code to the hashchange event as follows to record a new transaction whenever the browser's url changes. However, the problem is that the apm server cannot be recorded normally.

onHashChanged: function (oEvent) {
var _agent = this._agent;
var oCurrentTransaction = _agent.getCurrentTransaction();
if(oCurrentTransaction && oCurrentTransaction.ended===false){
oCurrentTransaction.end();
}
var sCHash = oEvent.target.document.location.hash;
var sHash = sCHash.indexOf("&")>-1 ? sCHash.split("&")[0] : sCHash;
_agent.startTransaction(sHash);

},
If it's a problem with my code, I would be grateful if you could tell me what the best practices are for the code.

Hi Yang,

Thanks for trying out RUM, Can you enable the debug flag in the config and share us the logs?

apm.init({debug: true})

From the code, I feel like the hash change transaction was discarded since there was no spans present on it. The debug logs would confirm it if thats the case.

Thanks,
Vignesh

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.