# opentelemetry-resource-detector-git

> open telemetry resource detector for git

Latest version **0.30.0** (published 2024-05-21) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install opentelemetry-resource-detector-git
pnpm add opentelemetry-resource-detector-git
yarn add opentelemetry-resource-detector-git
bun add opentelemetry-resource-detector-git
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.30.0 |
| Published | 2024-05-21 |
| First published | 2021-06-17 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 49.6 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | yes |
| GitHub stars | 168 |
| Maintainers | aspecto-release-bot |
| Keywords | opentelemetry |

## Links

- npm: https://www.npmjs.com/package/opentelemetry-resource-detector-git
- Repository: https://github.com/aspecto-io/opentelemetry-ext-js
- Issues: https://github.com/aspecto-io/opentelemetry-ext-js/issues
- npm.io page: https://npm.io/package/opentelemetry-resource-detector-git

## Dependencies (4)

- [uuid](https://npm.io/package/uuid.md) ^8.3.2
- [@opentelemetry/resources](https://npm.io/package/@opentelemetry/resources.md) ~1.24.1
- [@opentelemetry/semantic-conventions](https://npm.io/package/@opentelemetry/semantic-conventions.md) ^1.24.1
- [opentelemetry-resource-detector-sync-api](https://npm.io/package/opentelemetry-resource-detector-sync-api.md) ^0.30.0

## Recent versions

- 0.30.0 (latest) — 2024-05-21
- 0.0.0-2024-05-16--12-47 (alpha) — 2024-05-16
- 0.5.0-rc.1 (dev) — 2021-06-17
- 0.29.0 — 2023-10-17
- 0.0.0-2023-10-17--13-06 — 2023-10-17
- 0.0.0-2023-07-26--14-48 — 2023-07-26
- 0.28.0 — 2022-07-11
- 0.0.0-2022-07-11--08-09 — 2022-07-11
- 0.27.1 — 2022-06-06
- 0.27.0 — 2022-06-02
- 0.0.0-2022-04-13--14-32 — 2022-04-13
- 0.0.0-2021-12-26--12-31 — 2021-12-26
- 0.0.0-2021-12-26--12-22 — 2021-12-26
- 0.0.0-2021-12-22--14-33 — 2021-12-22
- 0.0.0-2021-12-21--15-57 — 2021-12-21
- … 22 more at https://npm.io/package/opentelemetry-resource-detector-git/versions

## README

# OpenTelemetry Service Resource Detector for Node.js
[![NPM version](https://img.shields.io/npm/v/opentelemetry-resource-detector-git.svg)](https://www.npmjs.com/package/opentelemetry-resource-detector-git)

This module provides automatic resource detector for Git Version Control System. This resource is not part of [open telemetry semantic conventions specification for resources](https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/resource/semantic_conventions).

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

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

##  Usage

### Synchronous SDK Initialization
```js
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
```js
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)](https://git-scm.com/docs/gitrevisions#Documentation/gitrevisions.txt-emltsha1gtemegemdae86e1950b1277e545cee180551750029cfe735ememdae86eem) | sha-1 of the current git HEAD. This value uniquely identifies the git commit of the codebase |
| `vcs.clone.id` | [string (v4 UUID)](https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_(random)) | Unique id for the clone of the git repo |
| `vcs.branch.name` | string | name of the current active branch |

---
_Source: https://npm.io/package/opentelemetry-resource-detector-git · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
