Categorygithub.com/open-telemetry/opentelemetry-collector-contrib/receiver/githubreceiver

# README

GitHub Receiver

Status
Stabilitydevelopment: traces
alpha: metrics
Distributionscontrib
IssuesOpen issues Closed issues
Code Owners@adrielp, @andrzej-stencel, @crobert-1, @TylerHelmuth

Table of Contents

Overview

The GitHub receiver receives data from GitHub via two methods:

  1. Scrapes version control system metrics from GitHub repositories and organizations using the GraphQL and REST APIs.
  2. Receives GitHub Actions events by serving a webhook endpoint, converting those events into traces.

Metrics - Getting Started

The current default set of metrics can be found in documentation.md.

These metrics can be used as leading indicators (capabilities) to the DORA metrics; helping provide insight into modern-day engineering practices.

The collection interval is common to all scrapers and is set to 30 seconds by default.

Note: Generally speaking, if the vendor allows for anonymous API calls, then you won't have to configure any authentication, but you may only see public repositories and organizations. You may also run into significantly more rate limiting.

github:
    collection_interval: <duration> #default = 30s recommended 300s
    scrapers:
        scraper/config-1:
        scraper/config-2:
        ...

A more complete example using the GitHub scrapers with authentication is as follows:

extensions:
    bearertokenauth/github:
        token: ${env:GH_PAT}

receivers:
    github:
        initial_delay: 1s
        collection_interval: 60s
        scrapers:
            scraper:
                metrics:
                    vcs.repository.contributor.count:
                        enabled: true
                github_org: myfancyorg
                search_query: "org:myfancyorg topic:o11yalltheway" #Recommended optional query override, defaults to "{org,user}:<github_org>"
                endpoint: "https://selfmanagedenterpriseserver.com"
                auth:
                    authenticator: bearertokenauth/github
service:
    extensions: [bearertokenauth/github]
    pipelines:
        metrics:
            receivers: [..., github]
            processors: []
            exporters: [...]

A Grafana Dashboard for metrics from this receiver is on the marketplace.

Scraping

Important:

  • The GitHub scraper does not emit metrics for branches that have not had changes since creation from the default branch (trunk).
  • Due to GitHub API limitations, it is possible for the branch time metric to change when rebases occur, recreating the commits with new timestamps.

For additional context on GitHub scraper limitations and inner workings please see the Scraping README.

Traces - Getting Started

Workflow tracing support is actively being added to the GitHub receiver. This is accomplished through the processing of GitHub Actions webhook events for workflows and jobs. The workflow_job and workflow_run event payloads are then constructed into trace telemetry.

Each GitHub Action workflow or job, along with its steps, are converted into trace spans, allowing the observation of workflow execution times, success, and failure rates.

Receiver Configuration

IMPORTANT - Ensure your WebHook endpoint is secured with a secret and a Web Application Firewall (WAF) or other security measure.

The WebHook configuration exposes the following settings:

  • endpoint: (default = localhost:8080) - The address and port to bind the WebHook to.
  • path: (default = /events) - The path for Action events to be sent to.
  • health_path: (default = /health) - The path for health checks.
  • secret: (optional) - The secret used to validates the payload.
  • required_header: (optional) - The required header key and value for incoming requests.
  • service_name: (optional) - The service name for the traces. See the Configuring Service Name section for more information.

The WebHook configuration block also accepts all the confighttp settings.

An example configuration is as follows:

receivers:
    github:
        webhook:
            endpoint: localhost:19418
            path: /events
            health_path: /health
            secret: ${env:SECRET_STRING_VAR}
            required_headers:
                WAF-Header: "value"

For tracing, all configuration is set under the webhook key. The full set of exposed configuration values can be found in config.go.

Configuring Service Name

The service_name option in the WebHook configuration can be used to set a pre-defined service.name resource attribute for all traces emitted by the receiver. This takes priority over the internal generation of the service.name. In this configuration, it would be important to create a GitHub receiver per GitHub app configured for the set of repositories that match your service.name.

However, a more efficient approach would be to leverage the default generation of service.name by configuring Custom Properties in each GitHub repository. To do that simply add a service_name key with the desired value in each repository and all events sent to the GitHub receiver will properly associate with that service.name. Alternatively, the service_name will be derived from the repository name.

The precedence for setting the service.name resource attribute is as follows:

  1. service_name configuration in the WebHook configuration.
  2. service_name key in the repository's Custom Properties per repository.
  3. service_name derived from the repository name.
  4. service.name set to unknown_service per the semantic conventions as a fall back.

Configuring A GitHub App

To configure a GitHub App, you will need to create a new GitHub App within your organization. Refer to the general GitHub App documentation for how to create a GitHub App. During the subscription phase, subscribe to workflow_run and workflow_job events.

NOTE: Only workflow_run events are supported in created traces at this time.

# Functions

NewFactory creates a factory for the github receiver.

# Constants

GitHub's Path in workflow_run.
model.go contains specific attributes from the 1.28 and 1.29 releases of SemConv.
GitHub's Run Sender Login.
equivalent to GitHub's `conclusion`.
model.go contains specific attributes from the 1.28 and 1.29 releases of SemConv.
model.go contains specific attributes from the 1.28 and 1.29 releases of SemConv.
model.go contains specific attributes from the 1.28 and 1.29 releases of SemConv.
model.go contains specific attributes from the 1.28 and 1.29 releases of SemConv.
model.go contains specific attributes from the 1.28 and 1.29 releases of SemConv.
equivalent to GitHub's `html_url`.
GitHub's Task Sender Login.
equivalent to GitHub's `conclusion`.
model.go contains specific attributes from the 1.28 and 1.29 releases of SemConv.
model.go contains specific attributes from the 1.28 and 1.29 releases of SemConv.
model.go contains specific attributes from the 1.28 and 1.29 releases of SemConv.
model.go contains specific attributes from the 1.28 and 1.29 releases of SemConv.
model.go contains specific attributes from the 1.28 and 1.29 releases of SemConv.
GitHub's Installation ID.
github.reference.workflow acts as a template attribute where it'll be joined with a `name` and a `version` value.
GitHub's Run Attempt.
GitHub's Triggering Actor Username.
vcs.change.id.
vcs.change.state with enum values of open, closed, or merged.
model.go contains specific attributes from the 1.28 and 1.29 releases of SemConv.
model.go contains specific attributes from the 1.28 and 1.29 releases of SemConv.
model.go contains specific attributes from the 1.28 and 1.29 releases of SemConv.
vcs.change.title.
vcs.line_change.type with enum values of added or removed.
model.go contains specific attributes from the 1.28 and 1.29 releases of SemConv.
model.go contains specific attributes from the 1.28 and 1.29 releases of SemConv.
vcs.ref.base.name.
vcs.ref.base.revision.
vcs.ref.base.type with enum values of branch or tag.
model.go contains specific attributes from the 1.28 and 1.29 releases of SemConv.
model.go contains specific attributes from the 1.28 and 1.29 releases of SemConv.
vcs.ref.head.name.
vcs.ref.head.revision.
GitHub's Head Revision Author Email.
GitHub's Head Revision Author Name.
vcs.ref.head.type with enum values of branch or tag.
model.go contains specific attributes from the 1.28 and 1.29 releases of SemConv.
model.go contains specific attributes from the 1.28 and 1.29 releases of SemConv.
vcs.ref.type with enum values of branch or tag.
model.go contains specific attributes from the 1.28 and 1.29 releases of SemConv.
model.go contains specific attributes from the 1.28 and 1.29 releases of SemConv.
vcs.repository.name.
GitHub's Owner Login.
vcs.revision_delta.direction with enum values of behind or ahead.
model.go contains specific attributes from the 1.28 and 1.29 releases of SemConv.
model.go contains specific attributes from the 1.28 and 1.29 releases of SemConv.
GitHub.

# Structs

Config that is exposed to this github receiver through the OTEL config.yaml.
No description provided by the author
No description provided by the author