Skip to content

Commit bf30c79

Browse files
authored
[receiver/gitproviderreceiver] rename metrics to match new conventions (#34278)
**Description:** Updated metrics and attributes to match newest semantic conventions for [VCSs added in the registry](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/attributes-registry/vcs.md). Attribute Changes: - `branch.name` is now `ref.name` - Added a `ref.type` attribute - `pull_request.state` is now `change.state` - `git.vendor.name` is now `vcs.vendor.name` Metric Changes: - `git.repository.count` is now `vcs.repository.count` - `git.repository.contributor.count` is now `vcs.repository.contributor.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`
1 parent 40e16d6 commit bf30c79

File tree

17 files changed

+802
-695
lines changed

17 files changed

+802
-695
lines changed

.chloggen/gpr-metrics.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: gitproviderreceiver
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Update metric names and attributes to match the newest Semantic Conventions for VCS.
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [34278]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext: |
19+
Attribute Changes:
20+
- `branch.name` is now `ref.name`
21+
- Added a `ref.type` attribute
22+
- `pull_request.state` is now `change.state`
23+
- `git.vendor.name` is now `vcs.vendor.name`
24+
Metric Changes:
25+
- `git.repository.count` is now `vcs.repository.count`
26+
- `git.repository.contributor.count` is now `vcs.repository.contributor.count`
27+
- `git.repository.branch.count` is now `vcs.repository.ref.count`
28+
- `git.repository.branch.time` is now `vcs.repository.ref.time
29+
- `git.repository.branch.commit.aheadby.count` is now `vcs.repository.ref.revisions_ahead`
30+
- `git.repository.branch.commit.behindby.count` is now `vcs.repository.ref.revisions_behind
31+
- `git.repository.branch.line.addition.count` is now `vcs.repository.ref.lines_added`
32+
- `git.repository.branch.line.deletion.count` is now `vcs.repository.ref.lines_deleted`
33+
- `git.repository.pull_request.time_open` is now `vcs.change.time_open`
34+
- `git.repository.pull_request.time_to_merge` is now `vcs.change.time_to_merge`
35+
- `git.repository.pull_request.time_to_approval` is now `vcs.change.time_to_approval`
36+
- `git.repository.pull_request.count` is now `vcs.change.count`
37+
38+
# If your change doesn't affect end users or the exported elements of any package,
39+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
40+
# Optional: The change log or logs in which this entry should be included.
41+
# e.g. '[user]' or '[user, api]'
42+
# Include 'user' if the change is relevant to end users.
43+
# Include 'api' if there is a change to a library API.
44+
# Default: '[user]'
45+
change_logs: []

receiver/gitproviderreceiver/README.md

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@
99
| [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) |
1010

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

14-
The Git Provider receiver scrapes data from Git vendors.
14+
The Git Provider receiver scrapes data from Version Control Systems (VCS) that use Git as their underlying technology.
1515

16-
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.
16+
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.
1717

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

20-
These default metrics can be used as leading indicators to the DORA metrics; helping provide insight into modern-day engineering practices.
20+
These VCS metrics can be used as leading indicators ([capabilities][doracap]) to the [DORA][dorafour] metrics; helping provide insight into modern-day engineering practices.
21+
22+
[doracap]: https://dora.dev/capabilities/
23+
[dorafour]: https://dora.dev/guides/dora-metrics-four-keys/
2124

2225
## Getting Started
2326

@@ -36,7 +39,7 @@ gitprovider:
3639
...
3740
```
3841

39-
A more complete example using the GitHub & GitLab scrapers with authentication is as follows:
42+
A more complete example using the GitHub scrapers with authentication is as follows:
4043

4144
```yaml
4245
extensions:
@@ -50,7 +53,7 @@ receivers:
5053
scrapers:
5154
github:
5255
metrics:
53-
git.repository.contributor.count:
56+
vcs.repository.contributor.count:
5457
enabled: true
5558
github_org: myfancyorg
5659
search_query: "org:myfancyorg topic:o11yalltheway" #Recommended optional query override, defaults to "{org,user}:<github_org>"
@@ -75,11 +78,11 @@ found [here](https://grafana.com/grafana/dashboards/20976-engineering-effectiven
7578
The available scrapers are:
7679
| Scraper | Description |
7780
|----------|-------------------------|
78-
| [github] | Git Metrics from [GitHub](https://github.com/) |
81+
| [github] | VCS Metrics from [GitHub](https://github.com/) |
7982
8083
## GitHub Scraper
8184
82-
> Important:
85+
> Important:
8386
> * The GitHub scraper does not emit metrics for branches that have not had
8487
> changes since creation from the default branch (trunk).
8588
> * Due to GitHub API limitations, it is possible for the branch time metric to
@@ -90,23 +93,3 @@ For additional context on GitHub scraper limitations and inner workings please
9093
see the [GitHub Scraper README][ghsread].
9194
9295
[ghsread]: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/receiver/gitproviderreceiver/internal/scraper/githubscraper/README.md#github-limitations
93-
94-
95-
The current metrics available via scraping from GitHub are:
96-
97-
- [x] Repository count
98-
- [x] Repository contributor count
99-
- [x] Repository branch count
100-
- [x] Repository branch time
101-
- [x] Repository branch commit aheadby count
102-
- [x] Repository branch commit behindby count
103-
- [x] Repository branch line addition count
104-
- [x] Repository branch line deletion count
105-
- [x] Repository pull request open time
106-
- [x] Repository pull request time to merge
107-
- [x] Repository pull request time to approval
108-
- [x] Repository pull request count | stores an attribute of `pull_request.state` equal to `open` or `merged`
109-
110-
> Note: Some metrics may be disabled by default and have to be explicitly enabled.
111-
> For example, the repository contributor count metric is one such metric. This is
112-
> because this metric relies on the REST API which is subject to lower rate limits.

receiver/gitproviderreceiver/documentation.md

Lines changed: 66 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -12,151 +12,156 @@ metrics:
1212
enabled: false
1313
```
1414
15-
### git.repository.branch.commit.aheadby.count
15+
### vcs.repository.change.count
1616
17-
The number of commits a branch is ahead of the default branch (trunk).
17+
The number of changes (pull requests) in a repository, categorized by their state (either open or merged).
1818
1919
| Unit | Metric Type | Value Type |
2020
| ---- | ----------- | ---------- |
21-
| {commit} | Gauge | Int |
21+
| {change} | Gauge | Int |
2222
2323
#### Attributes
2424
2525
| Name | Description | Values |
2626
| ---- | ----------- | ------ |
27-
| repository.name | The name of a Git repository | Any Str |
28-
| branch.name | The name of a Git branch | Any Str |
27+
| change.state | The state of a change (pull request) | Str: ``open``, ``merged`` |
28+
| repository.name | The name of a VCS repository | Any Str |
2929
30-
### git.repository.branch.commit.behindby.count
30+
### vcs.repository.change.time_open
3131
32-
The number of commits a branch is behind the default branch (trunk).
32+
The amount of time a change (pull request) has been open.
3333
3434
| Unit | Metric Type | Value Type |
3535
| ---- | ----------- | ---------- |
36-
| {commit} | Gauge | Int |
36+
| s | Gauge | Int |
3737
3838
#### Attributes
3939
4040
| Name | Description | Values |
4141
| ---- | ----------- | ------ |
42-
| repository.name | The name of a Git repository | Any Str |
43-
| branch.name | The name of a Git branch | Any Str |
42+
| repository.name | The name of a VCS repository | Any Str |
43+
| ref.name | The name of a VCS branch | Any Str |
4444
45-
### git.repository.branch.count
45+
### vcs.repository.change.time_to_approval
4646
47-
The number of branches in a repository.
47+
The amount of time it took a change (pull request) to go from open to approved.
4848
4949
| Unit | Metric Type | Value Type |
5050
| ---- | ----------- | ---------- |
51-
| {branch} | Gauge | Int |
51+
| s | Gauge | Int |
5252
5353
#### Attributes
5454
5555
| Name | Description | Values |
5656
| ---- | ----------- | ------ |
57-
| repository.name | The name of a Git repository | Any Str |
57+
| repository.name | The name of a VCS repository | Any Str |
58+
| ref.name | The name of a VCS branch | Any Str |
5859
59-
### git.repository.branch.line.addition.count
60+
### vcs.repository.change.time_to_merge
6061
61-
The number of lines added in a branch relative to the default branch (trunk).
62+
The amount of time it took a change (pull request) to go from open to merged.
6263
6364
| Unit | Metric Type | Value Type |
6465
| ---- | ----------- | ---------- |
65-
| {line} | Gauge | Int |
66+
| s | Gauge | Int |
6667
6768
#### Attributes
6869
6970
| Name | Description | Values |
7071
| ---- | ----------- | ------ |
71-
| repository.name | The name of a Git repository | Any Str |
72-
| branch.name | The name of a Git branch | Any Str |
72+
| repository.name | The name of a VCS repository | Any Str |
73+
| ref.name | The name of a VCS branch | Any Str |
7374
74-
### git.repository.branch.line.deletion.count
75+
### vcs.repository.count
7576
76-
The number of lines deleted in a branch relative to the default branch (trunk).
77+
The number of repositories in an organization.
7778
7879
| Unit | Metric Type | Value Type |
7980
| ---- | ----------- | ---------- |
80-
| {line} | Gauge | Int |
81-
82-
#### Attributes
83-
84-
| Name | Description | Values |
85-
| ---- | ----------- | ------ |
86-
| repository.name | The name of a Git repository | Any Str |
87-
| branch.name | The name of a Git branch | Any Str |
81+
| {repository} | Gauge | Int |
8882
89-
### git.repository.branch.time
83+
### vcs.repository.ref.count
9084
91-
Time a branch created from the default branch (trunk) has existed.
85+
The number of refs of type branch in a repository.
9286
9387
| Unit | Metric Type | Value Type |
9488
| ---- | ----------- | ---------- |
95-
| s | Gauge | Int |
89+
| {ref} | Gauge | Int |
9690
9791
#### Attributes
9892
9993
| Name | Description | Values |
10094
| ---- | ----------- | ------ |
101-
| repository.name | The name of a Git repository | Any Str |
102-
| branch.name | The name of a Git branch | Any Str |
95+
| repository.name | The name of a VCS repository | Any Str |
96+
| ref.type | The type of ref (branch, tag). | Str: ``branch``, ``tag`` |
10397
104-
### git.repository.count
98+
### vcs.repository.ref.lines_added
10599
106-
The number of repositories in an organization.
100+
The number of lines added in a ref (branch) relative to the default branch (trunk).
107101
108102
| Unit | Metric Type | Value Type |
109103
| ---- | ----------- | ---------- |
110-
| {repository} | Gauge | Int |
104+
| {line} | Gauge | Int |
105+
106+
#### Attributes
111107
112-
### git.repository.pull_request.count
108+
| Name | Description | Values |
109+
| ---- | ----------- | ------ |
110+
| repository.name | The name of a VCS repository | Any Str |
111+
| ref.name | The name of a VCS branch | Any Str |
112+
| ref.type | The type of ref (branch, tag). | Str: ``branch``, ``tag`` |
113+
114+
### vcs.repository.ref.lines_deleted
113115
114-
The number of pull requests in a repository, categorized by their state (either open or merged).
116+
The number of lines deleted in a ref (branch) relative to the default branch (trunk).
115117
116118
| Unit | Metric Type | Value Type |
117119
| ---- | ----------- | ---------- |
118-
| {pull_request} | Gauge | Int |
120+
| {line} | Gauge | Int |
119121
120122
#### Attributes
121123
122124
| Name | Description | Values |
123125
| ---- | ----------- | ------ |
124-
| pull_request.state | The state of a pull request | Str: ``open``, ``merged`` |
125-
| repository.name | The name of a Git repository | Any Str |
126+
| repository.name | The name of a VCS repository | Any Str |
127+
| ref.name | The name of a VCS branch | Any Str |
128+
| ref.type | The type of ref (branch, tag). | Str: ``branch``, ``tag`` |
126129
127-
### git.repository.pull_request.time_open
130+
### vcs.repository.ref.revisions_ahead
128131
129-
The amount of time a pull request has been open.
132+
The number of revisions (commits) a ref (branch) is ahead of the default branch (trunk).
130133
131134
| Unit | Metric Type | Value Type |
132135
| ---- | ----------- | ---------- |
133-
| s | Gauge | Int |
136+
| {revision} | Gauge | Int |
134137
135138
#### Attributes
136139
137140
| Name | Description | Values |
138141
| ---- | ----------- | ------ |
139-
| repository.name | The name of a Git repository | Any Str |
140-
| branch.name | The name of a Git branch | Any Str |
142+
| repository.name | The name of a VCS repository | Any Str |
143+
| ref.name | The name of a VCS branch | Any Str |
144+
| ref.type | The type of ref (branch, tag). | Str: ``branch``, ``tag`` |
141145
142-
### git.repository.pull_request.time_to_approval
146+
### vcs.repository.ref.revisions_behind
143147
144-
The amount of time it took a pull request to go from open to approved.
148+
The number of revisions (commits) a ref (branch) is behind the default branch (trunk).
145149
146150
| Unit | Metric Type | Value Type |
147151
| ---- | ----------- | ---------- |
148-
| s | Gauge | Int |
152+
| {revision} | Gauge | Int |
149153
150154
#### Attributes
151155
152156
| Name | Description | Values |
153157
| ---- | ----------- | ------ |
154-
| repository.name | The name of a Git repository | Any Str |
155-
| branch.name | The name of a Git branch | Any Str |
158+
| repository.name | The name of a VCS repository | Any Str |
159+
| ref.name | The name of a VCS branch | Any Str |
160+
| ref.type | The type of ref (branch, tag). | Str: ``branch``, ``tag`` |
156161
157-
### git.repository.pull_request.time_to_merge
162+
### vcs.repository.ref.time
158163
159-
The amount of time it took a pull request to go from open to merged.
164+
Time a ref (branch) created from the default branch (trunk) has existed. The `ref.type` attribute will always be `branch`.
160165

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

167172
| Name | Description | Values |
168173
| ---- | ----------- | ------ |
169-
| repository.name | The name of a Git repository | Any Str |
170-
| branch.name | The name of a Git branch | Any Str |
174+
| repository.name | The name of a VCS repository | Any Str |
175+
| ref.name | The name of a VCS branch | Any Str |
176+
| ref.type | The type of ref (branch, tag). | Str: ``branch``, ``tag`` |
171177

172178
## Optional Metrics
173179

@@ -179,7 +185,7 @@ metrics:
179185
enabled: true
180186
```
181187

182-
### git.repository.contributor.count
188+
### vcs.repository.contributor.count
183189

184190
The number of unique contributors to a repository.
185191

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

192198
| Name | Description | Values |
193199
| ---- | ----------- | ------ |
194-
| repository.name | The name of a Git repository | Any Str |
200+
| repository.name | The name of a VCS repository | Any Str |
195201

196202
## Resource Attributes
197203

198204
| Name | Description | Values | Enabled |
199205
| ---- | ----------- | ------ | ------- |
200-
| git.vendor.name | The name of the Git vendor/provider (ie. GitHub / GitLab) | Any Str | true |
201-
| organization.name | Git Organization or Project Name | Any Str | true |
206+
| organization.name | VCS Organization | Any Str | true |
207+
| vcs.vendor.name | The name of the VCS vendor/provider (ie. GitHub) | Any Str | true |

receiver/gitproviderreceiver/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ require (
116116
go.uber.org/multierr v1.11.0 // indirect
117117
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
118118
golang.org/x/net v0.28.0 // indirect
119-
golang.org/x/sys v0.23.0 // indirect
119+
golang.org/x/sys v0.24.0 // indirect
120120
golang.org/x/text v0.17.0 // indirect
121121
gonum.org/v1/gonum v0.15.0 // indirect
122122
google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094 // indirect
123-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
123+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240808171019-573a1156607a // indirect
124124
google.golang.org/grpc v1.65.0 // indirect
125125
google.golang.org/protobuf v1.34.2 // indirect
126126
gopkg.in/yaml.v3 v3.0.1 // indirect

0 commit comments

Comments
 (0)