Does SkyAPM-nodejs support to use in Opentracing way?
ArronD opened this issue · 1 comments
Hi! We are planning to add tracing to a nodejs project. Due to some reasons, we cannot use the below way to instrument our code.
require("skyapm-nodejs").start({ serviceName: "test", });
So we are wondering if SkyAPM-nodejs supports to use in Opentracing way? Just like below:
// Replace this line with the tracer implementation of your choice. const tracer = new opentracing.Tracer(); // new a SkyAPM-nodejs tracer and then we can use it const span = tracer.startSpan('http_request'); const opts = { host : 'example.com', method: 'GET', port : '80', path: '/', }; http.request(opts, res => { res.setEncoding('utf8'); res.on('error', err => { // assuming no retries, mark the span as failed span.setTag(opentracing.Tags.ERROR, true); span.log({'event': 'error', 'error.object': err, 'message': err.message, 'stack': err.stack}); span.finish(); }); res.on('data', chunk => { span.log({'event': 'data_received', 'chunk_length': chunk.length}); }); res.on('end', () => { span.log({'event': 'request_end'}); span.finish(); }); }).end();
Thank you!
Hi! We are planning to add tracing to a nodejs project. Due to some reasons, we cannot use the below way to instrument our code.
require("skyapm-nodejs").start({ serviceName: "test", });
So we are wondering if SkyAPM-nodejs supports to use in Opentracing way? Just like below:
// Replace this line with the tracer implementation of your choice.
const tracer = new opentracing.Tracer(); //any method we can new a SkyAPM-nodejs tracer ?
const span = tracer.startSpan('http_request');
const opts = {
host : 'example.com',
method: 'GET',
port : '80',
path: '/',
};
http.request(opts, res => {
res.setEncoding('utf8');
res.on('error', err => {
// assuming no retries, mark the span as failed
span.setTag(opentracing.Tags.ERROR, true);
span.log({'event': 'error', 'error.object': err, 'message': err.message, 'stack': err.stack});
span.finish();
});
res.on('data', chunk => {
span.log({'event': 'data_received', 'chunk_length': chunk.length});
});
res.on('end', () => {
span.log({'event': 'request_end'});
span.finish();
});
}).end();