Socket
Socket
Sign inDemoInstall

@opentelemetry/instrumentation-winston

Package Overview
Dependencies
Maintainers
3
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/instrumentation-winston

OpenTelemetry instrumentation for winston


Version published
Weekly downloads
890K
increased by6.65%
Maintainers
3
Weekly downloads
 
Created

What is @opentelemetry/instrumentation-winston?

@opentelemetry/instrumentation-winston is an npm package that provides automatic instrumentation for the Winston logging library, enabling the collection of telemetry data such as traces and metrics. This helps in monitoring and debugging applications by providing insights into the logging behavior.

What are @opentelemetry/instrumentation-winston's main functionalities?

Automatic Trace Context Injection

This feature automatically injects trace context into Winston log messages, allowing you to correlate logs with traces. The code sample demonstrates how to enable the instrumentation and create a Winston logger that includes trace context in its log messages.

const { WinstonInstrumentation } = require('@opentelemetry/instrumentation-winston');
const winston = require('winston');

const instrumentation = new WinstonInstrumentation();
instrumentation.enable();

const logger = winston.createLogger({
  transports: [
    new winston.transports.Console()
  ]
});

logger.info('This is an info message');

Custom Log Format with Trace Context

This feature allows you to customize the log format to include trace context information. The code sample shows how to create a custom log format that includes a timestamp and other metadata, which can be useful for detailed log analysis.

const { WinstonInstrumentation } = require('@opentelemetry/instrumentation-winston');
const winston = require('winston');

const instrumentation = new WinstonInstrumentation();
instrumentation.enable();

const logger = winston.createLogger({
  format: winston.format.combine(
    winston.format.timestamp(),
    winston.format.printf(({ level, message, timestamp, ...meta }) => {
      return `${timestamp} [${level}]: ${message} ${JSON.stringify(meta)}`;
    })
  ),
  transports: [
    new winston.transports.Console()
  ]
});

logger.info('This is an info message');

Other packages similar to @opentelemetry/instrumentation-winston

Keywords

FAQs

Package last updated on 03 Apr 2024

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