This repository was archived by the owner on Nov 10, 2022. It is now read-only.
Best way to maintain traceability between services #83
Unanswered
deepakkhetwal
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have azure function sending spancontext to kafka and then at receiver end, I have another azure function receiving that span context. My intention is to set distributed tracing between azure function calls, having a common traceid for single request. Below is where I am getting error
const span = tracer.startSpan("received_loan_request",{},traceContext);
Error details -
context.getValue is not a function
at Object.isInstrumentationSuppressed (C:\Work\kubernetes-open-telemetry\FnReceiveLoanProj\node_modules@opentelemetry\api\build\src\context\context.js:100:28)
and here is my tracecontext object looks like -
{traceId: '75e26ae5690b0f2c2eef8264f57f8b65', spanId: '8dc612fc8aa24a72', traceFlags: 1}
spanId:'8dc612fc8aa24a72'
traceFlags:1
traceId:'75e26ae5690b0f2c2eef8264f57f8b65'
proto:Object
Library I am using -
"@opentelemetry/api": "^0.18.0",
"@opentelemetry/exporter-collector": "^0.18.0",
"@opentelemetry/tracing": "^0.18.0",
Complete consumer code
var string_decode = require('string_decoder').StringDecoder;
function CreateGuid() {
function _p8(s) {
var p = (Math.random().toString(16)+"000000000").substr(2,8);
return s ? "-" + p.substr(0,4) + "-" + p.substr(4,4) : p ;
}
return _p8() + _p8(true) + _p8(true) + _p8();
}
module.exports = async function (inputContext, loanReceivedEvent) {
const dec = new string_decode('utf-8');
let event_str = dec.write(loanReceivedEvent);
let request = JSON.parse(event_str);
const traceContext = request.trace;
var output = {
"LoanId": CreateGuid(),
"FirstName": "John",
"LastName": "Smith",
"InputMessage": event_str
}
const {context, trace, setSpan, getSpan } = require("@opentelemetry/api");
const { BasicTracerProvider, SimpleSpanProcessor, ConsoleSpanExporter } = require('@opentelemetry/tracing');
const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector');
const collectorOptions = {
serviceName: 'fnloan-initiator',
url: 'http://aks-otlp-collector-collector.opentelemetry-poc.svc.cluster.local:55681/v1/trace', // url is optional and can be omitted - default is http://localhost:55681/v1/trace
};
const provider = new BasicTracerProvider();
const exporter = new CollectorTraceExporter(collectorOptions);
provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
trace.setGlobalTracerProvider(provider);
const tracer = trace.getTracer('fn-receive-loan');
const span = tracer.startSpan("received_loan_request",{},traceContext); // error is coming here
span.addEvent('Recieved Loan Request');
Please advise, if that's not the right the right apporach, what's the best way to propagate context
Beta Was this translation helpful? Give feedback.
All reactions