opentelemetry-resource-detector-git
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 Git Version Control System. This resource is not part of open telemetry semantic conventions specification for resources.

The detector is doing best effort to extract git info, including these cases:

  • Git info from common CI environment variables.
  • Docker environment where .git db is present (copied to image or mounted into the container) but git cli is not installed on the image.
  • Docker environment where .git db is missing, but node_modules is copied to image from source environment where .git db was available

Installation

npm install --save opentelemetry-resource-detector-git

Usage

Synchronous SDK Initialization

import { detectSyncResources } from 'opentelemetry-resource-detector-sync-api';
import { gitSyncDetector } from 'opentelemetry-resource-detector-git';

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

Asynchronous SDK Initialization

import { detectResources } from '@opentelemetry/resources';
import { gitDetector } from 'opentelemetry-resource-detector-git';

( async () => {
    const resource = await detectResources({
        detectors: [gitDetector, /* 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
vcs.system string If this repo is identified as git repo, this attribute will be set to constant value 'git'
vcs.commit.id string (full SHA-1 object name) sha-1 of the current git HEAD. This value uniquely identifies the git commit of the codebase
vcs.clone.id string (v4 UUID) Unique id for the clone of the git repo
vcs.branch.name string name of the current active branch

Readme

Keywords

Package Sidebar

Install

npm i opentelemetry-resource-detector-git

Weekly Downloads

1,246

Version

0.29.0

License

Apache-2.0

Unpacked Size

53.7 kB

Total Files

31

Last publish

Collaborators

  • aspecto-release-bot