Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@opentelemetry/exporter-logs-otlp-http

Package Overview
Dependencies
Maintainers
3
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/exporter-logs-otlp-http

OpenTelemetry Collector Logs Exporter allows user to send collected logs to the OpenTelemetry Collector

  • 0.54.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1M
increased by30.71%
Maintainers
3
Weekly downloads
 
Created

What is @opentelemetry/exporter-logs-otlp-http?

@opentelemetry/exporter-logs-otlp-http is an OpenTelemetry component that allows you to export logs to an OpenTelemetry Collector or other backend that supports the OTLP (OpenTelemetry Protocol) over HTTP. This package is useful for sending log data from your application to a centralized logging system for analysis and monitoring.

What are @opentelemetry/exporter-logs-otlp-http's main functionalities?

Exporting Logs

This code demonstrates how to set up the @opentelemetry/exporter-logs-otlp-http package to export logs to an OTLP endpoint. It configures a logger provider, sets up an OTLP log exporter, and emits a log message.

const { diag, DiagConsoleLogger, DiagLogLevel } = require('@opentelemetry/api');
const { Resource } = require('@opentelemetry/resources');
const { SimpleLogRecordProcessor, LoggerProvider } = require('@opentelemetry/sdk-logs');
const { OTLPLogExporter } = require('@opentelemetry/exporter-logs-otlp-http');

// Set up diagnostic logger
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);

// Create a resource
const resource = new Resource({
  'service.name': 'my-service',
});

// Create a logger provider
const loggerProvider = new LoggerProvider({
  resource: resource,
});

// Create an OTLP log exporter
const exporter = new OTLPLogExporter({
  url: 'http://localhost:4318/v1/logs',
});

// Add a log record processor
loggerProvider.addLogRecordProcessor(new SimpleLogRecordProcessor(exporter));

// Get a logger
const logger = loggerProvider.getLogger('example-logger');

// Emit a log
logger.emit({
  severityText: 'INFO',
  body: 'This is an example log message',
});

Other packages similar to @opentelemetry/exporter-logs-otlp-http

Keywords

FAQs

Package last updated on 05 Nov 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