From 94441e9e46a6ad6716aa5bdebfc1690e525c8c38 Mon Sep 17 00:00:00 2001 From: Corentin Musard Date: Wed, 1 May 2024 16:54:15 +0200 Subject: [PATCH 1/5] cleanup --- .github/dependabot.yml | 12 ---- .github/workflows/build-main.yml | 48 -------------- .../{code-quality-pr-check.yml => build.yml} | 28 ++++---- .github/workflows/dependabot-update-dist.yml | 26 -------- .github/workflows/merge-gatekeeper.yml | 18 ----- .github/workflows/otel-cicd.yml | 21 ++++++ .github/workflows/otel-export-trace.yml | 21 ------ .github/workflows/version-update.yml | 13 ---- README.md | 66 +++++++++++-------- 9 files changed, 73 insertions(+), 180 deletions(-) delete mode 100644 .github/dependabot.yml delete mode 100644 .github/workflows/build-main.yml rename .github/workflows/{code-quality-pr-check.yml => build.yml} (76%) delete mode 100644 .github/workflows/dependabot-update-dist.yml delete mode 100644 .github/workflows/merge-gatekeeper.yml create mode 100644 .github/workflows/otel-cicd.yml delete mode 100644 .github/workflows/otel-export-trace.yml delete mode 100644 .github/workflows/version-update.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index ce161e3..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,12 +0,0 @@ -version: 2 -updates: - - package-ecosystem: npm - directory: "/" - schedule: - interval: weekly - time: "10:00" - timezone: America/Chicago - pull-request-branch-name: - separator: "-" - open-pull-requests-limit: 20 - target-branch: "main" diff --git a/.github/workflows/build-main.yml b/.github/workflows/build-main.yml deleted file mode 100644 index 0179054..0000000 --- a/.github/workflows/build-main.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: "Build Main" -on: - push: - paths: - - "src/**" - - "dist/**" - - "package-lock.json" - - "package.json" - - "action.yml" - - ".github/workflows/build-main.yml" - branches: - - main - -jobs: - lint-and-test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: "16" - cache: "npm" - - name: Install Dependencies - run: npm ci --ignore-scripts - - name: lint - run: npm run lint:ci - - name: format check - run: npm run format:ci - - name: run tests - run: npm run test:ci - - uses: inception-health/otel-upload-test-artifact-action@v1 - if: always() - with: - jobName: "lint-and-test" - stepName: "run tests" - path: "junit.xml" - type: "junit" - githubToken: ${{ secrets.GITHUB_TOKEN }} - release-please: - runs-on: ubuntu-latest - needs: [lint-and-test] - steps: - - id: release - uses: GoogleCloudPlatform/release-please-action@v2 - with: - token: "${{ secrets.BUILD_PAT }}" - release-type: node - package-name: otel-export-trace diff --git a/.github/workflows/code-quality-pr-check.yml b/.github/workflows/build.yml similarity index 76% rename from .github/workflows/code-quality-pr-check.yml rename to .github/workflows/build.yml index fbd09c9..df08522 100644 --- a/.github/workflows/code-quality-pr-check.yml +++ b/.github/workflows/build.yml @@ -1,22 +1,18 @@ -name: "code quality PR check" +name: "Build" on: - pull_request: - paths: - - "src/**" - - "package-lock.json" - - "tests/**" - - "dist/**" - - "tsconfig.json" - - .github/workflows/code-quality-pr-check.yml + push: branches: [main] + pull_request: + merge_group: + branches: ["**"] jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: "16" cache: "npm" @@ -38,8 +34,8 @@ jobs: os: ["ubuntu-latest", "windows-latest", "macos-latest"] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: "16" cache: "npm" @@ -61,12 +57,12 @@ jobs: name: OpenTelemetry Export Trace runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: export trace uses: ./ with: - otlpEndpoint: "TEST" - otlpHeaders: "TEST" + otlpEndpoint: UNUSED + otlpHeaders: UNUSED githubToken: ${{ secrets.GITHUB_TOKEN }} env: OTEL_CONSOLE_ONLY: "true" diff --git a/.github/workflows/dependabot-update-dist.yml b/.github/workflows/dependabot-update-dist.yml deleted file mode 100644 index 09ad1a4..0000000 --- a/.github/workflows/dependabot-update-dist.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: dependabot-update-dist - -on: - pull_request: - branches: - - main - -jobs: - update-dist: - if: ${{ startsWith(github.head_ref, 'dependabot-') }} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: "16" - cache: "npm" - - name: npm ci - run: npm ci --ignore-scripts - - name: tsc - run: npm run package - - name: commit dist - uses: stefanzweifel/git-auto-commit-action@v4 - with: - commit_message: Add dist artifacts - file_pattern: dist diff --git a/.github/workflows/merge-gatekeeper.yml b/.github/workflows/merge-gatekeeper.yml deleted file mode 100644 index af2dd4a..0000000 --- a/.github/workflows/merge-gatekeeper.yml +++ /dev/null @@ -1,18 +0,0 @@ ---- -name: Merge Gatekeeper - -on: - pull_request: - branches: - - main - - master - -jobs: - merge-gatekeeper: - runs-on: ubuntu-latest - timeout-minutes: 5 - steps: - - name: Run Merge Gatekeeper - uses: upsidr/merge-gatekeeper@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/otel-cicd.yml b/.github/workflows/otel-cicd.yml new file mode 100644 index 0000000..a76bd86 --- /dev/null +++ b/.github/workflows/otel-cicd.yml @@ -0,0 +1,21 @@ +name: OpenTelemetry Export Traces + +on: + workflow_run: + workflows: + - "Build" + types: [completed] + +jobs: + otel-export-traces: + name: OpenTelemetry Export Traces + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Export traces + uses: ./ + with: + otlpEndpoint: ${{ secrets.OTLP_ENDPOINT }} + otlpHeaders: ${{ secrets.OTLP_HEADERS }} + githubToken: ${{ secrets.GITHUB_TOKEN }} + runId: ${{ github.event.workflow_run.id }} diff --git a/.github/workflows/otel-export-trace.yml b/.github/workflows/otel-export-trace.yml deleted file mode 100644 index 1e4f058..0000000 --- a/.github/workflows/otel-export-trace.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: OpenTelemetry Export Trace - -on: - workflow_run: - workflows: - - "Build Main" - types: [completed] - -jobs: - otel-export-trace: - name: OpenTelemetry Export Trace - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: export trace - uses: ./ - with: - otlpEndpoint: grpc://api.honeycomb.io:443/ - otlpHeaders: ${{ secrets.DELIVERY_OTLP_HEADERS }} - githubToken: ${{ secrets.GITHUB_TOKEN }} - runId: ${{ github.event.workflow_run.id }} diff --git a/.github/workflows/version-update.yml b/.github/workflows/version-update.yml deleted file mode 100644 index 77b7271..0000000 --- a/.github/workflows/version-update.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: Keep the versions up-to-date - -on: - release: - types: [published, edited] - -jobs: - actions-tagger: - runs-on: windows-latest - steps: - - uses: Actions-R-Us/actions-tagger@latest - with: - publish_latest_tag: true diff --git a/README.md b/README.md index 163056b..98f7909 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,14 @@ -# Open Telemetry Trace Exporter Action +# Open Telemetry CI/CD Action -This action will export GitHub Workflow telemetry data using OTLP to a configurable endpoint. +This action export GitHub Workflow telemetry data using OTLP to a configurable endpoint. + +This is a fork of [inception-health/otel-export-trace-action](https://github.com/inception-health/otel-export-trace-action) with the goal of maintaining the action and adding more features. ## Usage -### On workflow_run Event +### On workflow_run event (recommended) + +`my-workflow` should be the name of the workflow you want to export. ```yaml name: OpenTelemetry Export Trace @@ -28,7 +32,7 @@ jobs: runId: ${{ github.event.workflow_run.id }} ``` -### On Current Workflow +### Inside an existing workflow ```yaml name: OpenTelemetry Export Trace @@ -54,7 +58,30 @@ jobs: githubToken: ${{ secrets.GITHUB_TOKEN }} ``` -### With Junit Tracing +### Action Inputs + +| name | description | required | default | +| --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------------------------- | +| otlpEndpoint | The destination endpoint to export OpenTelemetry traces to. It supports `https://` and `grpc://` endpoints. | true | | +| otlpHeaders | Network Headers for the destination endpoint to export OpenTelemetry traces to. Ex. `x-honeycomb-team=YOUR_API_KEY,x-honeycomb-dataset=YOUR_DATASET`. | true | | +| otelServiceName | OpenTelemetry service name | false | `` | +| githubToken | The repository token with Workflow permissions. Not required for public repos | false | | +| runId | Workflow Run ID to Export | false | env.GITHUB_RUN_ID | + +### Action Outputs + +| name | description | +| ------- | ----------------------------------------- | +| traceId | The OpenTelemetry Trace ID for this Trace | + +## Honeycomb Example Trace + +![HoneyComb Example](./docs/honeycomb-example.png) + +_with JUnit traces_ +![HoneyComb Junit Example](./docs/honeycomb-junit-example.png) + +## With Junit Tracing Combined with [OpenTelemetry Upload Trace Artifact](https://github.com/marketplace/actions/opentelemetry-upload-trace-artifact) this action will Download the OTLP Trace Log Artifact uploaded from the Workflow Run and export it. @@ -111,22 +138,6 @@ jobs: runId: ${{ github.event.workflow_run.id }} ``` -### Action Inputs - -| name | description | required | default | -| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ----------------- | -| otlpEndpoint | The destination endpoint to export OpenTelemetry traces to | true | | -| otlpHeaders | Network Headers for the destination endpoint to export OpenTelemetry traces to. Ex. `x-honeycomb-team=YOUR_API_KEY,x-honeycomb-dataset=YOUR_DATASET` | true | | -| otelServiceName | OpenTelemetry service name | false | | -| githubToken | The repository token with Workflow permissions. Not required for public repos | false | | -| runId | Workflow Run ID to Export | false | env.GITHUB_RUN_ID | - -### Action Outputs - -| name | description | -| ------- | ----------------------------------------- | -| traceId | The OpenTelemetry Trace ID for this Trace | - ## Trace Unique Fields | name | type | description | @@ -194,9 +205,12 @@ jobs: | github.job.step.started_at | string | Github Step Run started_at | | github.job.step.completed_at | string | Github Step Run completed_at | -## Honeycomb Example Trace - -![HoneyComb Example](./docs/honeycomb-example.png) +## Development setup -_with JUnit traces_ -![HoneyComb Junit Example](./docs/honeycomb-junit-example.png) +```sh +# temporary fix +export NODE_OPTIONS=--openssl-legacy-provider +npm run prepare +npm i +npm run dev +``` From 4058c6fc211e5b4f5e842a6885d0949dc3807141 Mon Sep 17 00:00:00 2001 From: Corentin Musard Date: Wed, 1 May 2024 17:00:32 +0200 Subject: [PATCH 2/5] fix tests --- src/tracing/trace.test.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/tracing/trace.test.ts b/src/tracing/trace.test.ts index 71d9286..4891c48 100644 --- a/src/tracing/trace.test.ts +++ b/src/tracing/trace.test.ts @@ -106,4 +106,14 @@ describe("createTracerProvider", () => { const spanProcessor = subject.getActiveSpanProcessor(); expect(spanProcessor).toBeDefined(); }); + + it("supports https", () => { + subject = createTracerProvider( + "https://localhost", + "test=foo", + mockWorkflowRunJobs + ); + const spanProcessor = subject.getActiveSpanProcessor(); + expect(spanProcessor).toBeDefined(); + }); }); From fc04a059c3ae13db898f2188658156bacbfac448 Mon Sep 17 00:00:00 2001 From: Corentin Musard Date: Wed, 1 May 2024 17:25:25 +0200 Subject: [PATCH 3/5] cleanup --- .github/workflows/otel-cicd.yml | 2 +- CHANGELOG.md | 27 --------------------------- README.md | 1 + 3 files changed, 2 insertions(+), 28 deletions(-) diff --git a/.github/workflows/otel-cicd.yml b/.github/workflows/otel-cicd.yml index a76bd86..5f6b41b 100644 --- a/.github/workflows/otel-cicd.yml +++ b/.github/workflows/otel-cicd.yml @@ -3,7 +3,7 @@ name: OpenTelemetry Export Traces on: workflow_run: workflows: - - "Build" + - "build" types: [completed] jobs: diff --git a/CHANGELOG.md b/CHANGELOG.md index d83300d..825c32f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,28 +1 @@ # Changelog - -## [1.8.0](https://www.github.com/inception-health/otel-export-trace-action/compare/v1.7.0...v1.8.0) (2023-03-07) - - -### Features - -* add pull_requests attributes ([#30](https://www.github.com/inception-health/otel-export-trace-action/issues/30)) ([083bce1](https://www.github.com/inception-health/otel-export-trace-action/commit/083bce13bd12677eb6914a59271b253ec1eac35e)) - -## [1.7.0](https://www.github.com/inception-health/otel-export-trace-action/compare/v1.6.0...v1.7.0) (2023-01-25) - - -### Features - -* **#31:** Omit spans for skipped and canceled jobs ([#33](https://www.github.com/inception-health/otel-export-trace-action/issues/33)) ([8ef4ea0](https://www.github.com/inception-health/otel-export-trace-action/commit/8ef4ea0ab7a65ffa2ddfcb8ef9f39b3417b57f15)) - - -### Bug Fixes - -* build ([#35](https://www.github.com/inception-health/otel-export-trace-action/issues/35)) ([4ea5bca](https://www.github.com/inception-health/otel-export-trace-action/commit/4ea5bca9c404a0e219662adf190585af9dc23566)) - -## [1.6.0](https://www.github.com/inception-health/otel-export-trace-action/compare/v1.5.8...v1.6.0) (2022-07-26) - - -### Features - -* **#12:** add otel service name as an input or env var ([3ed67f9](https://www.github.com/inception-health/otel-export-trace-action/commit/3ed67f9c65770a55a98fa24fe0e9e110328690eb)) -* **#12:** add otel service name as an input or env var ([#13](https://www.github.com/inception-health/otel-export-trace-action/issues/13)) ([3ed67f9](https://www.github.com/inception-health/otel-export-trace-action/commit/3ed67f9c65770a55a98fa24fe0e9e110328690eb)), closes [#12](https://www.github.com/inception-health/otel-export-trace-action/issues/12) diff --git a/README.md b/README.md index 98f7909..33434b3 100644 --- a/README.md +++ b/README.md @@ -213,4 +213,5 @@ export NODE_OPTIONS=--openssl-legacy-provider npm run prepare npm i npm run dev +npm run test ``` From 16c02befd3b03d98b6d000db5c12ecdd1203a3f3 Mon Sep 17 00:00:00 2001 From: Corentin Musard Date: Wed, 1 May 2024 17:28:57 +0200 Subject: [PATCH 4/5] fix --- .github/workflows/build.yml | 6 ++---- .github/workflows/otel-cicd.yml | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index df08522..8084c74 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -61,8 +61,6 @@ jobs: - name: export trace uses: ./ with: - otlpEndpoint: UNUSED - otlpHeaders: UNUSED + otlpEndpoint: ${{ secrets.OTLP_ENDPOINT }} + otlpHeaders: ${{ secrets.OTLP_HEADERS }} githubToken: ${{ secrets.GITHUB_TOKEN }} - env: - OTEL_CONSOLE_ONLY: "true" diff --git a/.github/workflows/otel-cicd.yml b/.github/workflows/otel-cicd.yml index 5f6b41b..46fdb19 100644 --- a/.github/workflows/otel-cicd.yml +++ b/.github/workflows/otel-cicd.yml @@ -3,7 +3,7 @@ name: OpenTelemetry Export Traces on: workflow_run: workflows: - - "build" + - "fixme" types: [completed] jobs: From ba3f6c18dbd9388a2c4a3758870e6efed1895a74 Mon Sep 17 00:00:00 2001 From: Corentin Musard Date: Wed, 1 May 2024 17:44:44 +0200 Subject: [PATCH 5/5] fix --- .github/workflows/build.yml | 4 ++-- .github/workflows/otel-cicd.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8084c74..358fcd9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -54,11 +54,11 @@ jobs: otel-export-trace: needs: [tests, build] if: always() - name: OpenTelemetry Export Trace + name: OpenTelemetry Export Traces runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: export trace + - name: Export traces uses: ./ with: otlpEndpoint: ${{ secrets.OTLP_ENDPOINT }} diff --git a/.github/workflows/otel-cicd.yml b/.github/workflows/otel-cicd.yml index 46fdb19..a76bd86 100644 --- a/.github/workflows/otel-cicd.yml +++ b/.github/workflows/otel-cicd.yml @@ -3,7 +3,7 @@ name: OpenTelemetry Export Traces on: workflow_run: workflows: - - "fixme" + - "Build" types: [completed] jobs: