I have three sample services that I am trying to instrument. Service 1 is linked to Service 2 via rest while Service 2 acts a producer for service 3 (uses AWS SQS). Service 3 is a consumer from SQS.
I have 2 different scenarios which I am trying to understand here.
Here is the code for service 2.
@Get('/sendMessage')
async sendMessage(@Headers() requestHeaders: any) {
const activeSpanContext = trace.getSpanContext(context.active());
return await this.appService.InsertMessage(activeSpanContext);
}
Scenario 1 :
Code for service 3 :
const recievedMessages = await appService.recieveMessage();
let activeSpan = trace.getSpan(context.active());
if (recievedMessages) {
for (let message of recievedMessages) {
let contextWeGot = JSON.parse(message['Body'])['ctx'];
const newCTX = trace.setSpanContext(context.active(), contextWeGot);
track.startActiveSpan('HTTP GET', {}, newCTX, async (span) => {
console.log(`Processing Message : ${message['Body']}`);
span.end();
});
}
Service Map :
Scenario 2:
Code for service 3:
const recievedMessages = await appService.recieveMessage();
let activeSpan = trace.getSpan(context.active());
if (recievedMessages) {
for (let message of recievedMessages) {
let contextWeGot = JSON.parse(message['Body'])['ctx'];
const newCTX = trace.setSpanContext(context.active(), contextWeGot);
// trace.setSpanContext(newCTX, Outerspan);
track.startActiveSpan('HTTP GET', {}, newCTX, async (span) => {
console.log(`Processing Message : ${message['Body']}`);
axios
.get('https://google.com', {
headers: {
ctx: JSON.stringify(trace.getSpanContext(context.active())),
},
})
.then((response) => {
return response.data;
});
span.end();
});
}
Service Map:
Question: When I am using just my custom span in service 3, in the service map it shows as a disconnected service, but when I include an axios call (auto-instrumented) in my custom span in service 3, service 3 is then shown as a connected service.