Socket
Socket
Sign inDemoInstall

jaeger-client

Package Overview
Dependencies
Maintainers
5
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jaeger-client

Jaeger binding for OpenTracing API for Node.js


Version published
Weekly downloads
417K
decreased by-16.83%
Maintainers
5
Weekly downloads
 
Created

What is jaeger-client?

The jaeger-client npm package is a Node.js client for Jaeger, an open-source, end-to-end distributed tracing system. It is used to monitor and troubleshoot microservices-based distributed systems.

What are jaeger-client's main functionalities?

Initialize Tracer

This code initializes a Jaeger tracer with a given configuration. The tracer is used to start and finish spans, which represent units of work in the system.

const initTracer = require('jaeger-client').initTracer;

const config = {
  serviceName: 'my-service',
  reporter: {
    logSpans: true,
    agentHost: 'localhost',
    agentPort: 6832,
  },
  sampler: {
    type: 'const',
    param: 1,
  },
};

const options = {
  tags: {
    'my-service.version': '1.0.0',
  },
  logger: console,
};

const tracer = initTracer(config, options);

Start and Finish a Span

This code demonstrates how to start and finish a span. Spans are used to trace the execution of operations within a service.

const span = tracer.startSpan('my-operation');

// Simulate some work
setTimeout(() => {
  span.finish();
}, 1000);

Add Tags and Logs to a Span

This code shows how to add tags and logs to a span. Tags and logs provide additional context and information about the operation being traced.

const span = tracer.startSpan('my-operation');
span.setTag('http.method', 'GET');
span.log({ event: 'request_start', message: 'Request started' });

// Simulate some work
setTimeout(() => {
  span.log({ event: 'request_end', message: 'Request ended' });
  span.finish();
}, 1000);

Inject and Extract Span Context

This code demonstrates how to inject and extract span context for distributed tracing. This allows spans to be propagated across process boundaries, enabling end-to-end tracing.

const carrier = {};
const parentSpan = tracer.startSpan('parent-operation');
tracer.inject(parentSpan, 'http_headers', carrier);

const extractedContext = tracer.extract('http_headers', carrier);
const childSpan = tracer.startSpan('child-operation', { childOf: extractedContext });

// Simulate some work
setTimeout(() => {
  childSpan.finish();
  parentSpan.finish();
}, 1000);

Other packages similar to jaeger-client

FAQs

Package last updated on 01 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc