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.

Support correlation and autocollection when servers use SPDY/http2

See original GitHub issue

I 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.

  1. If I use tagoverride instead clientAI.context.tags[operationIdKey] = operationId we miss operation id. image 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. image How can I solve this?
  2. 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?
  3. 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:open
  • Created 5 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

5reactions
eduardocrncommented, Jun 15, 2020

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?

1reaction
OsvaldoRosadocommented, Nov 27, 2018

Updating the labels and title to track support for http2/spdy out of the box.

Read more comments on GitHub >

github_iconTop 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 >

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