Support correlation and autocollection when servers use SPDY/http2
See original GitHub issueI have a call from an express-nodejs service to a next component and I would like to link nodejs dependency with next component request. I am already able to link browser dependency with express-nodejs request.
- If I use tagoverride instead clientAI.context.tags[operationIdKey] = operationId we miss operation id.
If we uncomment clientAI.context.tags[operationIdKey] = operationId we get operation id but I have read that we won´t should use this to avoid problems with handling multiple requests at the same time.
How can I solve this? - When I console log clientAI.getCorrelationContext() it get error. Same issue here https://github.com/Microsoft/ApplicationInsights-node.js/issues/323#issue-257545223 but I´m not able to solve it even if I change the import of the appinsighs to the first. Any idea?
- How can I get the dependency id from this express-node js service to pass throw the http call to the next component in the request-id header to be able to have the end to end correlation working?
This is part of my code:
./init/initApplicationInsights
const config = require('../config');
const appInsights = require('applicationinsights');
module.exports = function initApplicationInsights() {
if (config.INSTRUMENTATION_KEY) {
appInsights.setup(config.INSTRUMENTATION_KEY)
.setAutoDependencyCorrelation(true)
.setAutoCollectRequests(false)
.setAutoCollectPerformance(true)
.setAutoCollectExceptions(true)
.setAutoCollectDependencies(false)
.setAutoCollectConsole(true)
.setUseDiskRetryCaching(true);
appInsights.defaultClient.context.tags[appInsights.defaultClient.context.keys.cloudRole] =
'fes-air-availability';
appInsights.start();
return appInsights.defaultClient;
}
return null;
};
app.js
const clientAI = require('./init/initApplicationInsights')();
const requestId = req.headers["request-id"];
const operationId = requestId.substr(1, requestId.indexOf('.')-1);
console.log("requestId " + requestId); // |OjuCU.ClP5n
console.log("operationId " + operationId); // OjuCU
const operationIdKey = clientAI.context.keys.operationId;
//clientAI.context.tags[operationIdKey] = operationId;
clientAI.trackDependency({
name: 'cs-airavailability',
target: airAvailabilityEndpoint,
duration: endRequest[1] / 1000000,
tagOverrides:{"ai.operation.id": operationId},
tagOverrides:{"ai.operation.parentId": requestId},
});
clientAI.trackRequest({
name: 'get /airavailability',
url: requestURL,
duration: startDuration[1] / 1000000,
resultCode:200,
success:true,
tagOverrides:{"ai.operation.id": operationId},
tagOverrides:{"ai.operation.parentId": requestId},
});
Thank
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Auto Collection of Murfreesboro, Inc | Luxury Dealer ...
Auto Collection of Murfreesboro, TN offers a wide selection of pre-owned luxury vehicles. From $30000 to $300000. Call or visit us today (615)...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hello guys, I don’t know if this problem has already been solved. But do we have anything new for http2 support for automatic correlation?
Updating the labels and title to track support for http2/spdy out of the box.