opentelemetry-resource-detector-service
TypeScript icon, indicating that this package has built-in type declarations

0.29.0 • Public • Published

OpenTelemetry Service Resource Detector for Node.js

NPM version

This module provides automatic resource detector for Service

Installation

npm install --save opentelemetry-resource-detector-service

Usage

Synchronous SDK Initialization

import { detectSyncResources } from 'opentelemetry-resource-detector-sync-api';
import { serviceSyncDetector } from 'opentelemetry-resource-detector-service';

const resource = detectSyncResources({
    detectors: [serviceSyncDetector, /* add other sync detectors here */],
});
const tracerProvider = new NodeTracerProvider({ resource });

Asynchronous SDK Initialization

import { detectResources } from '@opentelemetry/resources';
import { serviceDetector } from 'opentelemetry-resource-detector-service';

( async () => {
    const resource = await detectResources({
        detectors: [serviceDetector, /* add other async detectors here */],
    });
    const tracerProvider = new NodeTracerProvider({ resource });
    // Initialize auto instrumentation plugins and register provider.
    // Make sure you don't 'require' instrumented packages elsewhere 
    // before they are registered here
})();

Attributes

Attribute Type Source
service.name string process.env.OTEL_SERVICE_NAME. If not set, will try to read name attribute from package.json. If not set will fallback to unknown_service: concatenated with process.executable.name (according to specification)
serivce.version string version attribute from package.json
service.instance.id string (v4 UUID) Automatically generated by the detector for each invocation of the service

Readme

Keywords

Package Sidebar

Install

npm i opentelemetry-resource-detector-service

Weekly Downloads

1,877

Version

0.29.0

License

Apache-2.0

Unpacked Size

27.1 kB

Total Files

13

Last publish

Collaborators

  • aspecto-release-bot