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

[receiver/gitproviderreceiver] rename metrics to match new conventions #34278

Merged
merged 13 commits into from
Aug 13, 2024
Merged
43 changes: 43 additions & 0 deletions .chloggen/gpr-metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: gitproviderreceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Update metric names and attributes to match the newest Semantic Conventions for VCS.

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [34278]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext: |
Attribute Changes:
- `branch.name` is now `ref.name`
- Added a `ref.type` attribute
- `pull_request.state` is now `change.state`
Metric Changes:
- `git.repository.count` is now `vcs.repository.count`
- `git.repository.branch.count` is now `vcs.repository.ref.count`
- `git.repository.branch.time` is now `vcs.repository.ref.time
- `git.repository.branch.commit.aheadby.count` is now `vcs.repository.ref.revisions_ahead`
- `git.repository.branch.commit.behindby.count` is now `vcs.repository.ref.revisions_behind
- `git.repository.branch.line.addition.count` is now `vcs.repository.ref.lines_added`
- `git.repository.branch.line.deletion.count` is now `vcs.repository.ref.lines_deleted`
- `git.repository.pull_request.time_open` is now `vcs.change.time_open`
- `git.repository.pull_request.time_to_merge` is now `vcs.change.time_to_merge`
- `git.repository.pull_request.time_to_approval` is now `vcs.change.time_to_approval`
- `git.repository.pull_request.count` is now `vcs.change.count`

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
39 changes: 11 additions & 28 deletions receiver/gitproviderreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@adrielp](https://www.github.com/adrielp), [@andrzej-stencel](https://www.github.com/andrzej-stencel) |

[development]: https://github.com/open-telemetry/opentelemetry-collector#development
<!-- end autogenerated section -->
<!-- end autogenerated section -->

The Git Provider receiver scrapes data from Git vendors.
The Git Provider receiver scrapes data from Version Control Systems (VCS) that use Git as their underlying technology.
adrielp marked this conversation as resolved.
Show resolved Hide resolved

As a starting point, this receiver can infer many of the same core git metrics across vendors, while being able to receive additional data specific to vendors.
As a starting point, this receiver can infer many of the same core VCS metrics across vendors, while being able to receive additional data specific to vendors.

The current default set of metrics common across all vendors can be found in [documentation.md](./documentation.md).

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

[doracap]: https://dora.dev/capabilities/
[dorafour]: https://dora.dev/guides/dora-metrics-four-keys/

## Getting Started

Expand All @@ -36,7 +39,7 @@ gitprovider:
...
```

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

```yaml
extensions:
Expand All @@ -50,7 +53,7 @@ receivers:
scrapers:
github:
metrics:
git.repository.contributor.count:
vcs.repository.contributor.count:
adrielp marked this conversation as resolved.
Show resolved Hide resolved
enabled: true
github_org: myfancyorg
search_query: "org:myfancyorg topic:o11yalltheway" #Recommended optional query override, defaults to "{org,user}:<github_org>"
Expand All @@ -75,11 +78,11 @@ found [here](https://grafana.com/grafana/dashboards/20976-engineering-effectiven
The available scrapers are:
| Scraper | Description |
|----------|-------------------------|
| [github] | Git Metrics from [GitHub](https://github.com/) |
| [github] | VCS Metrics from [GitHub](https://github.com/) |

## GitHub Scraper

> Important:
> 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
Expand All @@ -90,23 +93,3 @@ For additional context on GitHub scraper limitations and inner workings please
see the [GitHub Scraper README][ghsread].

[ghsread]: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/receiver/gitproviderreceiver/internal/scraper/githubscraper/README.md#github-limitations


The current metrics available via scraping from GitHub are:

- [x] Repository count
- [x] Repository contributor count
- [x] Repository branch count
- [x] Repository branch time
- [x] Repository branch commit aheadby count
- [x] Repository branch commit behindby count
- [x] Repository branch line addition count
- [x] Repository branch line deletion count
- [x] Repository pull request open time
- [x] Repository pull request time to merge
- [x] Repository pull request time to approval
- [x] Repository pull request count | stores an attribute of `pull_request.state` equal to `open` or `merged`

> Note: Some metrics may be disabled by default and have to be explicitly enabled.
> For example, the repository contributor count metric is one such metric. This is
> because this metric relies on the REST API which is subject to lower rate limits.
126 changes: 66 additions & 60 deletions receiver/gitproviderreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,151 +12,156 @@ metrics:
enabled: false
```

### git.repository.branch.commit.aheadby.count
### vcs.repository.change.count

The number of commits a branch is ahead of the default branch (trunk).
The number of changes (pull requests) in a repository, categorized by their state (either open or merged).

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| {commit} | Gauge | Int |
| {change} | Gauge | Int |

#### Attributes

| Name | Description | Values |
| ---- | ----------- | ------ |
| repository.name | The name of a Git repository | Any Str |
| branch.name | The name of a Git branch | Any Str |
| change.state | The state of a change (pull request) | Str: ``open``, ``merged`` |
| repository.name | The name of a VCS repository | Any Str |

### git.repository.branch.commit.behindby.count
### vcs.repository.change.time_open

The number of commits a branch is behind the default branch (trunk).
The amount of time a change (pull request) has been open.

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| {commit} | Gauge | Int |
| s | Gauge | Int |

#### Attributes

| Name | Description | Values |
| ---- | ----------- | ------ |
| repository.name | The name of a Git repository | Any Str |
| branch.name | The name of a Git branch | Any Str |
| repository.name | The name of a VCS repository | Any Str |
| ref.name | The name of a VCS branch | Any Str |

### git.repository.branch.count
### vcs.repository.change.time_to_approval

The number of branches in a repository.
The amount of time it took a change (pull request) to go from open to approved.

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| {branch} | Gauge | Int |
| s | Gauge | Int |

#### Attributes

| Name | Description | Values |
| ---- | ----------- | ------ |
| repository.name | The name of a Git repository | Any Str |
| repository.name | The name of a VCS repository | Any Str |
| ref.name | The name of a VCS branch | Any Str |

### git.repository.branch.line.addition.count
### vcs.repository.change.time_to_merge

The number of lines added in a branch relative to the default branch (trunk).
The amount of time it took a change (pull request) to go from open to merged.

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| {line} | Gauge | Int |
| s | Gauge | Int |

#### Attributes

| Name | Description | Values |
| ---- | ----------- | ------ |
| repository.name | The name of a Git repository | Any Str |
| branch.name | The name of a Git branch | Any Str |
| repository.name | The name of a VCS repository | Any Str |
| ref.name | The name of a VCS branch | Any Str |

### git.repository.branch.line.deletion.count
### vcs.repository.count

The number of lines deleted in a branch relative to the default branch (trunk).
The number of repositories in an organization.

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| {line} | Gauge | Int |

#### Attributes

| Name | Description | Values |
| ---- | ----------- | ------ |
| repository.name | The name of a Git repository | Any Str |
| branch.name | The name of a Git branch | Any Str |
| {repository} | Gauge | Int |

### git.repository.branch.time
### vcs.repository.ref.count

Time a branch created from the default branch (trunk) has existed.
The number of refs of type branch in a repository.

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| s | Gauge | Int |
| {ref} | Gauge | Int |

#### Attributes

| Name | Description | Values |
| ---- | ----------- | ------ |
| repository.name | The name of a Git repository | Any Str |
| branch.name | The name of a Git branch | Any Str |
| repository.name | The name of a VCS repository | Any Str |
| ref.type | The type of ref (branch, tag). | Str: ``branch``, ``tag`` |

### git.repository.count
### vcs.repository.ref.lines_added

The number of repositories in an organization.
The number of lines added in a ref (branch) relative to the default branch (trunk).

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| {repository} | Gauge | Int |
| {line} | Gauge | Int |

#### Attributes

### git.repository.pull_request.count
| Name | Description | Values |
| ---- | ----------- | ------ |
| repository.name | The name of a VCS repository | Any Str |
| ref.name | The name of a VCS branch | Any Str |
| ref.type | The type of ref (branch, tag). | Str: ``branch``, ``tag`` |

### vcs.repository.ref.lines_deleted

The number of pull requests in a repository, categorized by their state (either open or merged).
The number of lines deleted in a ref (branch) relative to the default branch (trunk).

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| {pull_request} | Gauge | Int |
| {line} | Gauge | Int |

#### Attributes

| Name | Description | Values |
| ---- | ----------- | ------ |
| pull_request.state | The state of a pull request | Str: ``open``, ``merged`` |
| repository.name | The name of a Git repository | Any Str |
| repository.name | The name of a VCS repository | Any Str |
| ref.name | The name of a VCS branch | Any Str |
| ref.type | The type of ref (branch, tag). | Str: ``branch``, ``tag`` |

### git.repository.pull_request.time_open
### vcs.repository.ref.revisions_ahead

The amount of time a pull request has been open.
The number of revisions (commits) a ref (branch) is ahead of the default branch (trunk).

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| s | Gauge | Int |
| {revision} | Gauge | Int |

#### Attributes

| Name | Description | Values |
| ---- | ----------- | ------ |
| repository.name | The name of a Git repository | Any Str |
| branch.name | The name of a Git branch | Any Str |
| repository.name | The name of a VCS repository | Any Str |
| ref.name | The name of a VCS branch | Any Str |
| ref.type | The type of ref (branch, tag). | Str: ``branch``, ``tag`` |

### git.repository.pull_request.time_to_approval
### vcs.repository.ref.revisions_behind

The amount of time it took a pull request to go from open to approved.
The number of revisions (commits) a ref (branch) is behind the default branch (trunk).

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| s | Gauge | Int |
| {revision} | Gauge | Int |

#### Attributes

| Name | Description | Values |
| ---- | ----------- | ------ |
| repository.name | The name of a Git repository | Any Str |
| branch.name | The name of a Git branch | Any Str |
| repository.name | The name of a VCS repository | Any Str |
| ref.name | The name of a VCS branch | Any Str |
| ref.type | The type of ref (branch, tag). | Str: ``branch``, ``tag`` |

### git.repository.pull_request.time_to_merge
### vcs.repository.ref.time

The amount of time it took a pull request to go from open to merged.
Time a ref (branch) created from the default branch (trunk) has existed. The `ref.type` attribute will always be `branch`.

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
Expand All @@ -166,8 +171,9 @@ The amount of time it took a pull request to go from open to merged.

| Name | Description | Values |
| ---- | ----------- | ------ |
| repository.name | The name of a Git repository | Any Str |
| branch.name | The name of a Git branch | Any Str |
| repository.name | The name of a VCS repository | Any Str |
| ref.name | The name of a VCS branch | Any Str |
| ref.type | The type of ref (branch, tag). | Str: ``branch``, ``tag`` |

## Optional Metrics

Expand All @@ -179,7 +185,7 @@ metrics:
enabled: true
```

### git.repository.contributor.count
### vcs.repository.contributor.count

The number of unique contributors to a repository.

Expand All @@ -191,11 +197,11 @@ The number of unique contributors to a repository.

| Name | Description | Values |
| ---- | ----------- | ------ |
| repository.name | The name of a Git repository | Any Str |
| repository.name | The name of a VCS repository | Any Str |

## Resource Attributes

| Name | Description | Values | Enabled |
| ---- | ----------- | ------ | ------- |
| git.vendor.name | The name of the Git vendor/provider (ie. GitHub / GitLab) | Any Str | true |
| organization.name | Git Organization or Project Name | Any Str | true |
| organization.name | VCS Organization | Any Str | true |
| vcs.vendor.name | The name of the VCS vendor/provider (ie. GitHub) | Any Str | true |
4 changes: 2 additions & 2 deletions receiver/gitproviderreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ require (
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/collector v0.105.1-0.20240726220702-a6287aca1a43 // indirect
go.opentelemetry.io/collector/client v0.0.0-20240726175034-c3a11297650a // indirect
go.opentelemetry.io/collector/client v0.0.0-20240726220702-a6287aca1a43 // indirect
go.opentelemetry.io/collector/config/configauth v0.105.1-0.20240726220702-a6287aca1a43 // indirect
go.opentelemetry.io/collector/config/configcompression v1.12.1-0.20240726220702-a6287aca1a43 // indirect
go.opentelemetry.io/collector/config/configopaque v1.12.1-0.20240726220702-a6287aca1a43 // indirect
Expand Down Expand Up @@ -123,7 +123,7 @@ require (
golang.org/x/text v0.16.0 // indirect
gonum.org/v1/gonum v0.15.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240725223205-93522f1f2a9f // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading