This action exports Github CI/CD workflows to any endpoint compatible with OpenTelemetry.
This is a fork of otel-export-trace-action with more features and better support.
We provide sample code for popular platforms. If you feel one is missing, please open an issue.
Code Sample | File |
---|---|
Inside an existing workflow | build.yml |
From a private repository | private.yml |
Axiom | axiom.yml |
New Relic | newrelic.yml |
Honeycomb | honeycomb.yml |
Dash0 | dash0.yml |
Jaeger | WIP |
Grafana | WIP |
on:
workflow_run:
workflows:
# The name of the workflow(s) that triggers the export
- "Build"
types: [completed]
jobs:
otel-cicd-actions:
runs-on: ubuntu-latest
steps:
- uses: corentinmusard/otel-cicd-action@v1
with:
otlpEndpoint: grpc://api.honeycomb.io:443/
otlpHeaders: ${{ secrets.OTLP_HEADERS }}
githubToken: ${{ secrets.GITHUB_TOKEN }}
runId: ${{ github.event.workflow_run.id }}
jobs:
build:
# ... existing code
otel-cicd-action:
if: always()
name: OpenTelemetry Export Trace
runs-on: ubuntu-latest
needs: [build] # must run when all jobs are completed
steps:
- name: Export workflow
uses: corentinmusard/otel-cicd-action@v1
with:
otlpEndpoint: grpc://api.honeycomb.io:443/
otlpHeaders: ${{ secrets.OTLP_HEADERS }}
githubToken: ${{ secrets.GITHUB_TOKEN }}
If you are using a private repository, you need to set the following permissions in your workflow file. It can be done at the global level or at the job level.
permissions:
contents: read # To access the private repository
actions: read # To read workflow runs
pull-requests: read # To read PR labels
name | description | required | default | example |
---|---|---|---|---|
otlpEndpoint | The destination endpoint to export OpenTelemetry traces to. It supports https:// , http:// and grpc:// endpoints. |
true | https://api.axiom.co/v1/traces |
|
otlpHeaders | Headers to add to the OpenTelemetry exporter . | true | x-honeycomb-team=YOUR_API_KEY,x-honeycomb-dataset=YOUR_DATASET |
|
otelServiceName | OpenTelemetry service name | false | <The name of the exported workflow> |
Build CI |
githubToken | The repository token with Workflow permissions. Required for private repos | false | ${{ secrets.GITHUB_TOKEN }} |
|
runId | Workflow Run ID to Export | false | env.GITHUB_RUN_ID | ${{ github.event.workflow_run.id }} |
name | description |
---|---|
traceId | The OpenTelemetry Trace ID of the root span |
Look at Sample OpenTelemetry Output for the list of attributes and their values.
Combined with OpenTelemetry Upload Trace Artifact this action will Download the OTLP Trace Log Artifact uploaded from the Workflow Run and export it.
pr-workflow.yml
name: "PR check"
on:
pull_request:
branches: [main]
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- name: Install Dependencies
run: npm ci --ignore-scripts
- name: run tests
run: npm run test:ci
- uses: inception-health/otel-upload-test-artifact-action@v1
if: always()
with:
jobName: "build-and-test"
stepName: "run tests"
path: "junit.xml"
type: "junit"
githubToken: ${{ secrets.GITHUB_TOKEN }}
otel-cicd.yml
name: OpenTelemetry Export Traces
on:
workflow_run:
workflows: ["PR check"]
types: [completed]
jobs:
otel-cicd-action:
runs-on: ubuntu-latest
steps:
- name: Export Workflow Traces
uses: corentinmusard/otel-cicd-action@v1
with:
otlpEndpoint: grpc://api.honeycomb.io:443/
otlpHeaders: ${{ secrets.OTLP_HEADERS }}
githubToken: ${{ secrets.GITHUB_TOKEN }}
runId: ${{ github.event.workflow_run.id }}