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

@opentelemetry/otlp-exporter-base

Package Overview
Dependencies
Maintainers
3
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/otlp-exporter-base

OpenTelemetry OTLP Exporter base (for internal use only)

  • 0.56.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.3M
decreased by-15.12%
Maintainers
3
Weekly downloads
 
Created

What is @opentelemetry/otlp-exporter-base?

@opentelemetry/otlp-exporter-base is a foundational package for OpenTelemetry that provides base classes and utilities for creating OTLP (OpenTelemetry Protocol) exporters. These exporters are used to send telemetry data such as traces and metrics to an OTLP endpoint.

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

BaseExporter

The BaseExporter class provides a foundation for creating custom OTLP exporters. You can extend this class to implement your own logic for sending telemetry data.

const { BaseExporter } = require('@opentelemetry/otlp-exporter-base');

class MyCustomExporter extends BaseExporter {
  constructor(config) {
    super(config);
  }

  onInit(config) {
    // Initialize exporter with config
  }

  onShutdown() {
    // Cleanup resources
  }

  send(objects, onSuccess, onError) {
    // Send telemetry data
    onSuccess();
  }
}

const exporter = new MyCustomExporter({});

OTLPExporterConfig

The OTLPExporterConfig class is used to configure the OTLP exporter. It allows you to set properties such as the endpoint URL and headers for authentication.

const { OTLPExporterConfig } = require('@opentelemetry/otlp-exporter-base');

const config = new OTLPExporterConfig({
  url: 'http://localhost:4317',
  headers: {
    'Authorization': 'Bearer token'
  }
});

console.log(config);

Exporting Traces

This example demonstrates how to create a custom trace exporter by extending the BaseExporter class. The send method is implemented to handle the export of trace data.

const { BaseExporter } = require('@opentelemetry/otlp-exporter-base');
const { ReadableSpan } = require('@opentelemetry/sdk-trace-base');

class TraceExporter extends BaseExporter {
  send(spans, onSuccess, onError) {
    // Convert spans to OTLP format and send
    onSuccess();
  }
}

const exporter = new TraceExporter({});
const span = new ReadableSpan({
  name: 'example-span',
  startTime: Date.now(),
  endTime: Date.now() + 1000
});

exporter.export([span], () => console.log('Export successful'), (err) => console.error('Export failed', err));

Other packages similar to @opentelemetry/otlp-exporter-base

Keywords

FAQs

Package last updated on 04 Dec 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