Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Latest commit

 

History

History

resource-detector-deployment

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

OpenTelemetry Deployment Resource Detector for Node.js

NPM version

This module provides automatic resource detector for Deployment

Installation

npm install --save opentelemetry-resource-detector-deployment

Usage

Synchronous SDK Initialization

import { detectSyncResources } from 'opentelemetry-resource-detector-sync-api';
import { deploymentSyncDetector } from 'opentelemetry-resource-detector-deployment';

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

Asynchronous SDK Initialization

import { detectResources } from '@opentelemetry/resources';
import { deploymentDetector } from 'opentelemetry-resource-detector-deployment';

( async () => {
    const resource = await detectResources({
        detectors: [deploymentDetector, /* 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
deployment.environment string process.env.NODE_ENV