Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add labels to PR #18

Merged

Conversation

brett-anderson
Copy link

@brett-anderson brett-anderson commented Jun 10, 2024

This adds the labels from a PR to the trace span.

Here is an example from testing:

labels

@brett-anderson brett-anderson changed the title Add labels to PR feat: Add labels to PR Jun 10, 2024
@corentinmusard corentinmusard added enhancement New feature or request test labels Jun 12, 2024
@corentinmusard
Copy link
Owner

@brett-anderson Wait how did you manage to make it work?

From the CI/CD run, we can see that no github.pull_requests attributes are recorded.
Also, the pull_request field from the github api is empty: https://api.github.com/repos/corentinmusard/otel-cicd-action/actions/runs/9488555603

@brett-anderson
Copy link
Author

@brett-anderson Wait how did you manage to make it work?

From the CI/CD run, we can see that no github.pull_requests attributes are recorded. Also, the pull_request field from the github api is empty: https://api.github.com/repos/corentinmusard/otel-cicd-action/actions/runs/9488555603

I used it inline with the workflow that I'm tracing, perhaps that is how it is working?

This is an example of what the workflow looks like:

name: CI

on:
  pull_request:
    types:
      - opened
      - synchronize
      - reopened
      - labeled
      - unlabeled

jobs:
  ci:
    uses: wrapbook/app-ci/.github/workflows/ci.yml@main
    secrets: inherit

  otel-export-trace:
    name: OpenTelemetry Export Trace
    if: always()
    runs-on: ubuntu-latest
    needs: ci
    steps:
      - name: Export Workflow Trace
        uses: wrapbook/otel-cicd-action@add-ignored-steps
        with:
          otlpEndpoint: grpc://api.honeycomb.io:443/
          otlpHeaders: x-honeycomb-team=${{ secrets.HONEYCOMB_GHA_CI_APIKEY }}
          otelServiceName: otel-export-trace
          githubToken: ${{ secrets.GITHUB_TOKEN }}

@brett-anderson
Copy link
Author

@corentinmusard I've now moved this to a triggered workflow, new workflow looks like this:

on:
  workflow_run:
    workflows: ["CI"]
    types:
      - completed

jobs:
  trace_ci:
    runs-on: ubuntu-latest
    steps:
      - name: Trace CI
        uses: wrapbook/otel-cicd-action@add-ignored-steps
        with:
          otlpEndpoint: grpc://api.honeycomb.io:443/
          otlpHeaders: x-honeycomb-team=${{ secrets.HONEYCOMB_GHA_CI_APIKEY }}
          otelServiceName: ci-v2
          githubToken: ${{ secrets.GITHUB_TOKEN }}
          runId: ${{ github.event.workflow_run.id }}

I am still having the labels show up:
image

Maybe because this PR is created outside of the repo? I could try re-creating it within the repo to see if that adds the pull request to the context.

@corentinmusard corentinmusard merged commit 7f42098 into corentinmusard:main Nov 8, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants