npm package: @spanmetric/otel-providers
Description: [![NPM Published Version][npm-version-img]][npm-url] [![NPM Last Update][npm-last-update-img]][npm-url] [![NPM Unpacked Size][npm-unpacked-size-img]][npm-url] [![NPM Downloads][npm-downloads-img]][npm-url] [![NPM Type Definitions][npm-types-img]][npm-url]
Latest version: 1.0.0

# @spanmetric/otel-providers

[![NPM Published Version][npm-version-img]][npm-url] [![NPM Last Update][npm-last-update-img]][npm-url] [![NPM Unpacked Size][npm-unpacked-size-img]][npm-url] [![NPM Downloads][npm-downloads-img]][npm-url] [![NPM Type Definitions][npm-types-img]][npm-url] [![License][license-image]][license-url]

OpenTelemetry providers with enhanced shutdown capabilities for the Spanmetric observability platform.

## Overview

`@spanmetric/otel-providers` provides custom OpenTelemetry providers that extend the standard OpenTelemetry SDK providers with enhanced shutdown functionality. These providers ensure proper cleanup of propagation, context, and trace APIs when shutting down telemetry collection.

## Features

- **Enhanced Shutdown**: Proper cleanup of OpenTelemetry APIs during shutdown
- **Web Tracer Provider**: Custom web tracer provider with improved shutdown handling
- **Logger Provider**: Custom logger provider with proper API cleanup
- **Meter Provider**: Custom meter provider with enhanced shutdown capabilities
- **TypeScript Support**: Full TypeScript support with type definitions

## Installation

```bash
npm install @spanmetric/otel-providers
```

```bash
yarn add @spanmetric/otel-providers
```

```bash
pnpm add @spanmetric/otel-providers
```

## Usage

### Web Tracer Provider

```typescript
import { SpanmetricWebTracerProvider } from '@spanmetric/otel-providers';

const provider = new SpanmetricWebTracerProvider({
  // Your configuration options
});

// Use the provider...

// Shutdown with proper cleanup
await provider.shutdown();
```

### Logger Provider

```typescript
import { SpanmetricLoggerProvider } from '@spanmetric/otel-providers';

const loggerProvider = new SpanmetricLoggerProvider({
  // Your configuration options
});

// Use the logger provider...

// Shutdown with proper cleanup
await loggerProvider.shutdown();
```

### Meter Provider

```typescript
import { SpanmetricMeterProvider } from '@spanmetric/otel-providers';

const meterProvider = new SpanmetricMeterProvider({
  // Your configuration options
});

// Use the meter provider...

// Shutdown with proper cleanup
await meterProvider.shutdown();
```

## API Reference

### SpanmetricWebTracerProvider

Extends `WebTracerProvider` from `@opentelemetry/sdk-trace-web` with enhanced shutdown capabilities.

#### Methods

- `shutdown(): Promise<void>` - Shuts down the provider and disables OpenTelemetry APIs (propagation, context, trace)

### SpanmetricLoggerProvider

Extends `LoggerProvider` from `@opentelemetry/sdk-logs` with enhanced shutdown capabilities.

**Methods:**

- `shutdown(): Promise<void>` - Shuts down the provider and disables OpenTelemetry APIs (propagation, context, trace)

### SpanmetricMeterProvider

Extends `MeterProvider` from `@opentelemetry/sdk-metrics` with enhanced shutdown capabilities.

**Methods:**

- `shutdown(): Promise<void>` - Shuts down the provider and disables OpenTelemetry APIs (propagation, context, trace)

## Key Benefits

1. **Proper Cleanup**: Ensures all OpenTelemetry APIs are properly disabled during shutdown
2. **Memory Management**: Prevents memory leaks by properly cleaning up resources
3. **Graceful Shutdown**: Provides a clean way to shut down telemetry collection
4. **Drop-in Replacement**: Can be used as a direct replacement for standard OpenTelemetry providers

## Dependencies

This package depends on:

- `@opentelemetry/api`
- `@opentelemetry/sdk-trace-web`
- `@opentelemetry/sdk-logs`
- `@opentelemetry/sdk-metrics`

## License

IDLERECORD - All Rights Reserved

## Links

- [Homepage](https://www.spanmetric.com)
- [GitHub Repository](https://github.com/spanmetric/spanmetric-js)
- [NPM Package](https://www.npmjs.com/package/@spanmetric/otel-providers)

[license-url]: https://github.com/spanmetric/spanmetric-js/blob/main/packages/otel-providers/LICENSE
[license-image]: https://img.shields.io/badge/license-IDLERECORD--All%20Rights%20Reserved-blue
[npm-url]: https://www.npmjs.com/package/@spanmetric/otel-providers
[npm-version-img]: https://img.shields.io/npm/v/%40spanmetric%2Fotel-providers?style=flat-square&logo=npm&color=%238ef7c1
[npm-last-update-img]: https://img.shields.io/npm/last-update/%40spanmetric%2Fotel-providers?color=%238ef7c1
[npm-unpacked-size-img]: https://img.shields.io/npm/unpacked-size/%40spanmetric%2Fotel-providers?color=%238ef7c1
[npm-downloads-img]: https://img.shields.io/npm/dw/%40spanmetric%2Fotel-providers?color=%238ef7c1
[npm-types-img]: https://img.shields.io/npm/types/%40spanmetric%2Fotel-providers