opentelemetry-resource-detector-git
v0.30.0
Published
open telemetry resource detector for git
Downloads
119,555
Readme
OpenTelemetry Service Resource Detector for Node.js
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) butgit
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 |