Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure Service Bus dependency messages have no context #883

Closed
bivas6 opened this issue Jan 10, 2022 · 16 comments · Fixed by #892
Closed

Azure Service Bus dependency messages have no context #883

bivas6 opened this issue Jan 10, 2022 · 16 comments · Fixed by #892

Comments

@bivas6
Copy link

bivas6 commented Jan 10, 2022

Hi,
We're using AI to track our app, and everything works as expected except service-bus messages.
We have http endpoint which receives a request, then sends a message on the service bus.
All the logs in this function and http/s requests have the same context in the AI as the incoming http request, but the service-bus outgoing message looks like a stand-alone dependency without a parent and context.

Should I add something manually to the ServiceBusClient.send call? Is it a bug?
I can give you a small script to reproduce + screenshots from our AI UI. (edit: code and screenshots attached)

Thanks!

@orgads
Copy link
Contributor

orgads commented Jan 16, 2022

@hectorhdzg ping

@bivas6
Copy link
Author

bivas6 commented Jan 16, 2022

Code example:

const appInsights = require('applicationinsights');
const express = require('express');
const axios = require('axios');
const {ServiceBusClient} = require('@azure/service-bus');
const WebSocket = require('ws');

appInsights.setup()
    .setAutoCollectConsole(true, true)
    .setSendLiveMetrics(true)
    .start();

const connectionString = "******";
const sender = new ServiceBusClient(connectionString, {webSocketOptions: { webSocket: WebSocket }}).createSender('bivas-test');
const app = express();
app.post('/sendMessage', async (_req, res) => {
    console.log('log');
    await axios.default.get('https://google.com');
    console.log('log 2');
    await sender.sendMessages({subject: 'subject', body: {key:'value'}});
    res.sendStatus(200);
});

app.listen(3080, '0.0.0.0', () => {console.log('started')});

This is a snippet from Azure portal if I clicked the 'get to Google' dependency:
image

And this is what I see if I clicked the 'ServiceBus Message' dependency:
image

Thanks.

@orgads
Copy link
Contributor

orgads commented Jan 26, 2022

Thank you @hectorhdzg. Do you plan to publish a new release soon?

@hectorhdzg
Copy link
Member

@orgads we plan to release early next week

@bivas6
Copy link
Author

bivas6 commented Jan 31, 2022

Hi @hectorhdzg

I tried to run the example app from above with your fix in it, and the rest request doesn't hold the service-bus message as dependency, In addition, now the service-bus messages not shown at all in the AI UI.

Can you check it?

Thanks

cc: @orgads

@hectorhdzg
Copy link
Member

@bivas6 which version of service-bus package are you using?

@orgads
Copy link
Contributor

orgads commented Jan 31, 2022

@hectorhdzg 7.4.0

@hectorhdzg
Copy link
Member

hectorhdzg commented Jan 31, 2022

@bivas6, @orgads , I can see everything working fine with the code you shared and using @azure/service-bus 7.4.0, validated using a tarball generated from develop branch

image

@orgads
Copy link
Contributor

orgads commented Jan 31, 2022

I just tried again now, and it doesn't work for me.

I tried Node 16.13 and 17.4, both on Windows.

That's what I get:
image

@hectorhdzg
Copy link
Member

@orgads do you have any OpenTelemetry package as dependency in your project?

@orgads
Copy link
Contributor

orgads commented Jan 31, 2022

No. I have only the packages that I require directly. What else should I install?

@orgads
Copy link
Contributor

orgads commented Jan 31, 2022

hmmm... I tried on Linux now with Node 17.4.0, and it does show the send message request, but it is still not connected to the http request:

image

@orgads
Copy link
Contributor

orgads commented Jan 31, 2022

Sorry, these tests on linux were with version 2.2.0. With latest develop it's the same as on Windows (no ServiceBus at all).

This is my package.json (I published my own package from develop):

{
  "name": "servicebus",
  "version": "1.0.0",
  "main": "servicebus.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "description": "",
  "dependencies": {
    "@azure/service-bus": "^7.4.0",
    "applicationinsights": "npm:@audc/applicationinsights@^2.3.0",
    "axios": "^0.25.0",
    "express": "^4.17.2",
    "ws": "^8.4.2"
  }
}

@orgads
Copy link
Contributor

orgads commented Feb 3, 2022

@hectorhdzg were you able to reproduce? Can I provide you any more information?

@hectorhdzg
Copy link
Member

@orgads still no repro on my side, can you try with latest version of Application Insights SDK?, we published yesterday, can you turn logging and share the logs if you still have the problem?

@orgads
Copy link
Contributor

orgads commented Feb 3, 2022

It works!

I wonder why there was a difference between my build and the official one, but whatever.

Thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants