Skip to content

Commit a2f3b3c

Browse files
authored
[receiver/github] update metrics and attributes to match latest semantics and change scraper key name (#36714)
#### Description Breaking: Updates various different metrics and attributes to match the latest semantic conventions (1.28+). Also updates the scraper key name. Most of the conventions are in 1.28 while a few attributes are merged in and will be released in 1.29. * Change the `github` scraper key to `scraper` * Add `vcs.repository.url.full` attribute * Change attribute `repository.name` to `vcs.repository.name` * Change attribute `ref.name` to `vcs.ref.head.name` * Change attribute `ref.type` to `vcs.ref.head.type` * Change attribute `change.state` to `vcs.change.state` * Add attribute `vcs.revision_delta.direction` with `ahead` and `behind` values * Change metric `vcs.repository.ref.revisions_ahead` to `vcs.ref.revisions_delta` with `vcs.revision_delta.direction=ahead` * Change metric `vcs.repository.ref.revisions_behind` to `vcs.ref.revisions_delta` with `vcs.revision_delta.direction=behind` * Change metric `vcs.repository.ref.count` to `vcs.ref.count` * Change metric `vcs.repository.ref.time` to `vcs.ref.time` * Add attribute `vcs.line_change.type` with `added` and `removed` values * Change metric `vcs.repository.ref.lines_added` to `vcs.ref.lines_delta` with `vcs.line_change.type=added` * Change metric `vcs.repository.ref.lines_removed` to `vcs.ref.lines_delta` with `vcs.line_change.type=removed` * Change metric `vcs.repository.contributor.count` to `vcs.contributor.count` * Change metric `vcs.repository.change.time_open` to `vcs.change.duration` with `vcs.change.state=open` * Change metric `vcs.repository.change.time_to_approval` to `vcs.change.time_to_approval` * Change metric `vcs.repository.change.time_to_merge` to `vcs.change.time_to_merge` * Change metric `vcs.repository.change.count` to `vcs.change.count` #### Testing In addition to the normal testing of the code, I additionally built the receiver into a collector to observe runtime behavior. #### Documentation Update generated docs and readme with scraper change.
1 parent 19f550c commit a2f3b3c

20 files changed

+725
-742
lines changed

.chloggen/gh-semconv-1.28plus.yaml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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: githubreceiver
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 to match VCS Metric Semantic Conventions and scraper key name.
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: [36714]
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+
* Change the `github` scraper key to `scraper`
20+
* Add `vcs.repository.url.full` attribute
21+
* Change attribute `repository.name` to `vcs.repository.name`
22+
* Change attribute `ref.name` to `vcs.ref.head.name`
23+
* Change attribute `ref.type` to `vcs.ref.head.type`
24+
* Change attribute `change.state` to `vcs.change.state`
25+
* Add attribute `vcs.revision_delta.direction` with `ahead` and `behind` values
26+
* Change metric `vcs.repository.ref.revisions_ahead` to `vcs.ref.revisions_delta` with `vcs.revision_delta.direction=ahead`
27+
* Change metric `vcs.repository.ref.revisions_behind` to `vcs.ref.revisions_delta` with `vcs.revision_delta.direction=behind`
28+
* Change metric `vcs.repository.ref.count` to `vcs.ref.count`
29+
* Change metric `vcs.repository.ref.time` to `vcs.ref.time`
30+
* Add attribute `vcs.line_change.type` with `added` and `removed` values
31+
* Change metric `vcs.repository.ref.lines_added` to `vcs.ref.lines_delta` with `vcs.line_change.type=added`
32+
* Change metric `vcs.repository.ref.lines_removed` to `vcs.ref.lines_delta` with `vcs.line_change.type=removed`
33+
* Change metric `vcs.repository.contributor.count` to `vcs.contributor.count`
34+
* Change metric `vcs.repository.change.time_open` to `vcs.change.duration` with `vcs.change.state=open`
35+
* Change metric `vcs.repository.change.time_to_approval` to `vcs.change.time_to_approval`
36+
* Change metric `vcs.repository.change.time_to_merge` to `vcs.change.time_to_merge`
37+
* Change metric `vcs.repository.change.count` to `vcs.change.count`
38+
39+
40+
# If your change doesn't affect end users or the exported elements of any package,
41+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
42+
# Optional: The change log or logs in which this entry should be included.
43+
# e.g. '[user]' or '[user, api]'
44+
# Include 'user' if the change is relevant to end users.
45+
# Include 'api' if there is a change to a library API.
46+
# Default: '[user]'
47+
change_logs: [user]

receiver/githubreceiver/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ The collection interval is common to all scrapers and is set to 30 seconds by de
3838
github:
3939
collection_interval: <duration> #default = 30s recommended 300s
4040
scrapers:
41-
<scraper1>:
42-
<scraper2>:
41+
scraper/config-1:
42+
scraper/config-2:
4343
...
4444
```
4545

@@ -55,7 +55,7 @@ receivers:
5555
initial_delay: 1s
5656
collection_interval: 60s
5757
scrapers:
58-
github:
58+
scraper:
5959
metrics:
6060
vcs.repository.contributor.count:
6161
enabled: true

receiver/githubreceiver/config_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func TestLoadConfig(t *testing.T) {
4141
defaultConfigGitHubReceiver := factory.CreateDefaultConfig()
4242

4343
defaultConfigGitHubReceiver.(*Config).Scrapers = map[string]internal.Config{
44-
metadata.Type.String(): (&githubscraper.Factory{}).CreateDefaultConfig(),
44+
githubscraper.TypeStr: (&githubscraper.Factory{}).CreateDefaultConfig(),
4545
}
4646

4747
defaultConfigGitHubReceiver.(*Config).WebHook = WebHook{
@@ -67,7 +67,7 @@ func TestLoadConfig(t *testing.T) {
6767
InitialDelay: 1 * time.Second,
6868
},
6969
Scrapers: map[string]internal.Config{
70-
metadata.Type.String(): (&githubscraper.Factory{}).CreateDefaultConfig(),
70+
githubscraper.TypeStr: (&githubscraper.Factory{}).CreateDefaultConfig(),
7171
},
7272
WebHook: WebHook{
7373
ServerConfig: confighttp.ServerConfig{

receiver/githubreceiver/documentation.md

+49-69
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ metrics:
1212
enabled: false
1313
```
1414
15-
### vcs.repository.change.count
15+
### vcs.change.count
1616
1717
The number of changes (pull requests) in a repository, categorized by their state (either open or merged).
1818
@@ -24,12 +24,13 @@ The number of changes (pull requests) in a repository, categorized by their stat
2424
2525
| Name | Description | Values |
2626
| ---- | ----------- | ------ |
27-
| change.state | The state of a change (pull request) | Str: ``open``, ``merged`` |
28-
| repository.name | The name of a VCS repository | Any Str |
27+
| vcs.repository.url.full | The canonical URL of the repository providing the complete HTTPS address. | Any Str |
28+
| vcs.change.state | The state of a change (pull request) | Str: ``open``, ``merged`` |
29+
| vcs.repository.name | The name of the VCS repository. | Any Str |
2930
30-
### vcs.repository.change.time_open
31+
### vcs.change.duration
3132
32-
The amount of time a change (pull request) has been open.
33+
The time duration a change (pull request/merge request/changelist) has been in an open state.
3334
3435
| Unit | Metric Type | Value Type |
3536
| ---- | ----------- | ---------- |
@@ -39,10 +40,12 @@ The amount of time a change (pull request) has been open.
3940
4041
| Name | Description | Values |
4142
| ---- | ----------- | ------ |
42-
| repository.name | The name of a VCS repository | Any Str |
43-
| ref.name | The name of a VCS branch | Any Str |
43+
| vcs.repository.url.full | The canonical URL of the repository providing the complete HTTPS address. | Any Str |
44+
| vcs.repository.name | The name of the VCS repository. | Any Str |
45+
| vcs.ref.head.name | The name of the VCS head reference (branch). | Any Str |
46+
| vcs.change.state | The state of a change (pull request) | Str: ``open``, ``merged`` |
4447
45-
### vcs.repository.change.time_to_approval
48+
### vcs.change.time_to_approval
4649
4750
The amount of time it took a change (pull request) to go from open to approved.
4851
@@ -54,10 +57,11 @@ The amount of time it took a change (pull request) to go from open to approved.
5457
5558
| Name | Description | Values |
5659
| ---- | ----------- | ------ |
57-
| repository.name | The name of a VCS repository | Any Str |
58-
| ref.name | The name of a VCS branch | Any Str |
60+
| vcs.repository.url.full | The canonical URL of the repository providing the complete HTTPS address. | Any Str |
61+
| vcs.repository.name | The name of the VCS repository. | Any Str |
62+
| vcs.ref.head.name | The name of the VCS head reference (branch). | Any Str |
5963
60-
### vcs.repository.change.time_to_merge
64+
### vcs.change.time_to_merge
6165
6266
The amount of time it took a change (pull request) to go from open to merged.
6367
@@ -69,18 +73,11 @@ The amount of time it took a change (pull request) to go from open to merged.
6973
7074
| Name | Description | Values |
7175
| ---- | ----------- | ------ |
72-
| repository.name | The name of a VCS repository | Any Str |
73-
| ref.name | The name of a VCS branch | Any Str |
76+
| vcs.repository.url.full | The canonical URL of the repository providing the complete HTTPS address. | Any Str |
77+
| vcs.repository.name | The name of the VCS repository. | Any Str |
78+
| vcs.ref.head.name | The name of the VCS head reference (branch). | Any Str |
7479
75-
### vcs.repository.count
76-
77-
The number of repositories in an organization.
78-
79-
| Unit | Metric Type | Value Type |
80-
| ---- | ----------- | ---------- |
81-
| {repository} | Gauge | Int |
82-
83-
### vcs.repository.ref.count
80+
### vcs.ref.count
8481
8582
The number of refs of type branch in a repository.
8683
@@ -92,28 +89,13 @@ The number of refs of type branch in a repository.
9289
9390
| Name | Description | Values |
9491
| ---- | ----------- | ------ |
95-
| repository.name | The name of a VCS repository | Any Str |
96-
| ref.type | The type of ref (branch, tag). | Str: ``branch``, ``tag`` |
97-
98-
### vcs.repository.ref.lines_added
99-
100-
The number of lines added in a ref (branch) relative to the default branch (trunk).
101-
102-
| Unit | Metric Type | Value Type |
103-
| ---- | ----------- | ---------- |
104-
| {line} | Gauge | Int |
105-
106-
#### Attributes
107-
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`` |
92+
| vcs.repository.url.full | The canonical URL of the repository providing the complete HTTPS address. | Any Str |
93+
| vcs.repository.name | The name of the VCS repository. | Any Str |
94+
| vcs.ref.head.type | The type of the head reference (branch, tag). | Str: ``branch``, ``tag`` |
11395
114-
### vcs.repository.ref.lines_deleted
96+
### vcs.ref.lines_delta
11597
116-
The number of lines deleted in a ref (branch) relative to the default branch (trunk).
98+
The number of lines added/removed in a ref (branch) relative to the default branch (trunk).
11799
118100
| Unit | Metric Type | Value Type |
119101
| ---- | ----------- | ---------- |
@@ -123,13 +105,15 @@ The number of lines deleted in a ref (branch) relative to the default branch (tr
123105
124106
| Name | Description | Values |
125107
| ---- | ----------- | ------ |
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`` |
108+
| vcs.repository.url.full | The canonical URL of the repository providing the complete HTTPS address. | Any Str |
109+
| vcs.repository.name | The name of the VCS repository. | Any Str |
110+
| vcs.ref.head.name | The name of the VCS head reference (branch). | Any Str |
111+
| vcs.ref.head.type | The type of the head reference (branch, tag). | Str: ``branch``, ``tag`` |
112+
| vcs.line_change.type | The type of line change being measured on a ref (branch). | Str: ``added``, ``removed`` |
129113
130-
### vcs.repository.ref.revisions_ahead
114+
### vcs.ref.revisions_delta
131115
132-
The number of revisions (commits) a ref (branch) is ahead of the default branch (trunk).
116+
The number of revisions (commits) a ref (branch) is ahead/behind the branch from trunk (default).
133117
134118
| Unit | Metric Type | Value Type |
135119
| ---- | ----------- | ---------- |
@@ -139,41 +123,36 @@ The number of revisions (commits) a ref (branch) is ahead of the default branch
139123
140124
| Name | Description | Values |
141125
| ---- | ----------- | ------ |
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`` |
126+
| vcs.repository.url.full | The canonical URL of the repository providing the complete HTTPS address. | Any Str |
127+
| vcs.repository.name | The name of the VCS repository. | Any Str |
128+
| vcs.ref.head.name | The name of the VCS head reference (branch). | Any Str |
129+
| vcs.ref.head.type | The type of the head reference (branch, tag). | Str: ``branch``, ``tag`` |
130+
| vcs.revision_delta.direction | The type of revision comparison. | Str: ``ahead``, ``behind`` |
145131
146-
### vcs.repository.ref.revisions_behind
132+
### vcs.ref.time
147133
148-
The number of revisions (commits) a ref (branch) is behind the default branch (trunk).
134+
Time a ref (branch) created from the default branch (trunk) has existed. The `vcs.ref.head.type` attribute will always be `branch`.
149135

150136
| Unit | Metric Type | Value Type |
151137
| ---- | ----------- | ---------- |
152-
| {revision} | Gauge | Int |
138+
| s | Gauge | Int |
153139

154140
#### Attributes
155141

156142
| Name | Description | Values |
157143
| ---- | ----------- | ------ |
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`` |
144+
| vcs.repository.url.full | The canonical URL of the repository providing the complete HTTPS address. | Any Str |
145+
| vcs.repository.name | The name of the VCS repository. | Any Str |
146+
| vcs.ref.head.name | The name of the VCS head reference (branch). | Any Str |
147+
| vcs.ref.head.type | The type of the head reference (branch, tag). | Str: ``branch``, ``tag`` |
161148

162-
### vcs.repository.ref.time
149+
### vcs.repository.count
163150

164-
Time a ref (branch) created from the default branch (trunk) has existed. The `ref.type` attribute will always be `branch`.
151+
The number of repositories in an organization.
165152

166153
| Unit | Metric Type | Value Type |
167154
| ---- | ----------- | ---------- |
168-
| s | Gauge | Int |
169-
170-
#### Attributes
171-
172-
| Name | Description | Values |
173-
| ---- | ----------- | ------ |
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`` |
155+
| {repository} | Gauge | Int |
177156

178157
## Optional Metrics
179158

@@ -185,7 +164,7 @@ metrics:
185164
enabled: true
186165
```
187166

188-
### vcs.repository.contributor.count
167+
### vcs.contributor.count
189168

190169
The number of unique contributors to a repository.
191170

@@ -197,7 +176,8 @@ The number of unique contributors to a repository.
197176

198177
| Name | Description | Values |
199178
| ---- | ----------- | ------ |
200-
| repository.name | The name of a VCS repository | Any Str |
179+
| vcs.repository.url.full | The canonical URL of the repository providing the complete HTTPS address. | Any Str |
180+
| vcs.repository.name | The name of the VCS repository. | Any Str |
201181

202182
## Resource Attributes
203183

receiver/githubreceiver/factory.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const (
3333

3434
var (
3535
scraperFactories = map[string]internal.ScraperFactory{
36-
metadata.Type.String(): &githubscraper.Factory{},
36+
githubscraper.TypeStr: &githubscraper.Factory{},
3737
}
3838

3939
errConfigNotValid = errors.New("configuration is not valid for the github receiver")

receiver/githubreceiver/go.mod

+3-3
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,13 @@ require (
133133
go.opentelemetry.io/otel/trace v1.32.0 // indirect
134134
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
135135
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
136-
golang.org/x/net v0.31.0 // indirect
136+
golang.org/x/net v0.32.0 // indirect
137137
golang.org/x/sys v0.28.0 // indirect
138138
golang.org/x/text v0.21.0 // indirect
139139
gonum.org/v1/gonum v0.15.1 // indirect
140140
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 // indirect
141-
google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a // indirect
142-
google.golang.org/grpc v1.68.0 // indirect
141+
google.golang.org/genproto/googleapis/rpc v0.0.0-20241206012308-a4fef0638583 // indirect
142+
google.golang.org/grpc v1.68.1 // indirect
143143
google.golang.org/protobuf v1.35.2 // indirect
144144
gopkg.in/yaml.v3 v3.0.1 // indirect
145145
)

receiver/githubreceiver/go.sum

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)