@opentelemetry/resource-detector-github
v0.34.1
Published
OpenTelemetry SDK resource detector for GitHub
Readme
OpenTelemetry Resource Detector for GitHub Actions
Resource detector for GitHub Actions.
Detects GITHUB_* environment variables specified here and adds as attributes on a resource.
This is useful for collecting telemetry in GitHub Actions-powered CI/CD workflows.
The OpenTelemetry Resource is an immutable representation of the entity producing telemetry. For example, a process producing telemetry that is running in a container on Kubernetes has a Pod name, it is in a namespace and possibly is part of a Deployment which also has a name. All three of these attributes can be included in the Resource.
Compatible with OpenTelemetry JS API and SDK 1.0+.
Installation
npm install --save @opentelemetry/resource-detector-githubUsage
const { gitHubDetector } = require('@opentelemetry/resource-detector-github')
async function run() {
// Initialize GitHub Resource Detector
const resource = await gitHubDetector.detect();
};
run()Available detectors
GitHub Detector
| Resource Attribute | Description |
| --------------------- | ------------------------------------------------------------------------------------- |
| cicd.pipeline.name | Value of Process Environment Variable GITHUB_WORKFLOW |
| cicd.pipeline.run.id | Value of Process Environment Variable GITHUB_RUN_ID |
| vcs.ref.base.name | Value of Process Environment Variable GITHUB_BASE_REF |
| vcs.ref.head.name | Value of Process Environment Variable GITHUB_HEAD_REF, falling back to GITHUB_REF |
| vcs.ref.head.revision | Value of Process Environment Variable GITHUB_SHA |
| github.actor | Value of Process Environment Variable GITHUB_ACTOR |
| github.run_number | Value of Process Environment Variable GITHUB_RUN_NUMBER |
The cicd.* and vcs.* attributes follow the CI/CD and VCS
semantic conventions. github.actor and github.run_number are kept as custom attributes because
the semantic conventions do not currently define an equivalent for either.
GITHUB_HEAD_REF is only set for pull request events; for those events GITHUB_REF holds the
synthetic merge ref (for example refs/pull/1/merge) rather than the branch being merged, so
GITHUB_HEAD_REF is preferred when present.
Useful links
- GitHub Action Environment Variables
- For more information on OpenTelemetry, visit: https://opentelemetry.io/
- For more about OpenTelemetry JavaScript: https://github.com/open-telemetry/opentelemetry-js
- For help or feedback on this project, join us in GitHub Discussions
License
Apache 2.0 - See LICENSE for more information.
