This document describes how to report the data of a Node.js application with the native Jaeger SDK.
Directions
Step 1. Get the endpoint and token
Log in to the APM console, enter the Application monitoring > Application list page, click Access application, and select the Node.js language and Jaeger data collection method. Then, get the endpoint and token in the step of access method selection. Step 2. Install dependencies
Install dependencies by using npm.
Step 3. Import the SDK and report data
1. Import the SDK. Below is a sample:
const initTracer = require('jaeger-client').initTracer;
const config = {
serviceName: 'service-name',
sampler: {
type: 'const',
param: 1,
},
reporter: {
logSpans: true,
collectorEndpoint: 'http://ap-guangzhou.apm.tencentcs.com:14268/api/traces',
},
};
const options = {
tags: {
token: 'Vds************CrKck'
},
};
Note:
Node.js uses API to directly report data, so there is no need to start the Jaeger agent. Select the endpoint of your network environment and add the suffix /api/traces
to form the actual endpoint.
2. Report data. Below is a sample:
const tracer = initTracer(config, options);
const span = tracer.startSpan('spanStart');
span.setTag('span.kind', 'server');
span.setTag('tagName', 'tagValue');
span.log({ event: 'timestamp', value: Date.now() });
span.finish();
Was this page helpful?