Skip to content

Commit

Permalink
[receiver/github] update metrics and attributes to match latest seman…
Browse files Browse the repository at this point in the history
…tics and change scraper key name (open-telemetry#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.
  • Loading branch information
adrielp authored and mterhar committed Dec 19, 2024
1 parent 8e8c6fc commit 7dded6e
Show file tree
Hide file tree
Showing 20 changed files with 725 additions and 742 deletions.
47 changes: 47 additions & 0 deletions .chloggen/gh-semconv-1.28plus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# 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: githubreceiver

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

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

# (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: |
* 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`
# 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: [user]
6 changes: 3 additions & 3 deletions receiver/githubreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ The collection interval is common to all scrapers and is set to 30 seconds by de
github:
collection_interval: <duration> #default = 30s recommended 300s
scrapers:
<scraper1>:
<scraper2>:
scraper/config-1:
scraper/config-2:
...
```

Expand All @@ -55,7 +55,7 @@ receivers:
initial_delay: 1s
collection_interval: 60s
scrapers:
github:
scraper:
metrics:
vcs.repository.contributor.count:
enabled: true
Expand Down
4 changes: 2 additions & 2 deletions receiver/githubreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestLoadConfig(t *testing.T) {
defaultConfigGitHubReceiver := factory.CreateDefaultConfig()

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

defaultConfigGitHubReceiver.(*Config).WebHook = WebHook{
Expand All @@ -67,7 +67,7 @@ func TestLoadConfig(t *testing.T) {
InitialDelay: 1 * time.Second,
},
Scrapers: map[string]internal.Config{
metadata.Type.String(): (&githubscraper.Factory{}).CreateDefaultConfig(),
githubscraper.TypeStr: (&githubscraper.Factory{}).CreateDefaultConfig(),
},
WebHook: WebHook{
ServerConfig: confighttp.ServerConfig{
Expand Down
118 changes: 49 additions & 69 deletions receiver/githubreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ metrics:
enabled: false
```
### vcs.repository.change.count
### vcs.change.count
The number of changes (pull requests) in a repository, categorized by their state (either open or merged).
Expand All @@ -24,12 +24,13 @@ The number of changes (pull requests) in a repository, categorized by their stat
| Name | Description | Values |
| ---- | ----------- | ------ |
| change.state | The state of a change (pull request) | Str: ``open``, ``merged`` |
| repository.name | The name of a VCS repository | Any Str |
| vcs.repository.url.full | The canonical URL of the repository providing the complete HTTPS address. | Any Str |
| vcs.change.state | The state of a change (pull request) | Str: ``open``, ``merged`` |
| vcs.repository.name | The name of the VCS repository. | Any Str |
### vcs.repository.change.time_open
### vcs.change.duration
The amount of time a change (pull request) has been open.
The time duration a change (pull request/merge request/changelist) has been in an open state.
| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
Expand All @@ -39,10 +40,12 @@ The amount of time a change (pull request) has been open.
| Name | Description | Values |
| ---- | ----------- | ------ |
| repository.name | The name of a VCS repository | Any Str |
| ref.name | The name of a VCS branch | Any Str |
| vcs.repository.url.full | The canonical URL of the repository providing the complete HTTPS address. | Any Str |
| vcs.repository.name | The name of the VCS repository. | Any Str |
| vcs.ref.head.name | The name of the VCS head reference (branch). | Any Str |
| vcs.change.state | The state of a change (pull request) | Str: ``open``, ``merged`` |
### vcs.repository.change.time_to_approval
### vcs.change.time_to_approval
The amount of time it took a change (pull request) to go from open to approved.
Expand All @@ -54,10 +57,11 @@ The amount of time it took a change (pull request) to go from open to approved.
| Name | Description | Values |
| ---- | ----------- | ------ |
| repository.name | The name of a VCS repository | Any Str |
| ref.name | The name of a VCS branch | Any Str |
| vcs.repository.url.full | The canonical URL of the repository providing the complete HTTPS address. | Any Str |
| vcs.repository.name | The name of the VCS repository. | Any Str |
| vcs.ref.head.name | The name of the VCS head reference (branch). | Any Str |
### vcs.repository.change.time_to_merge
### vcs.change.time_to_merge
The amount of time it took a change (pull request) to go from open to merged.
Expand All @@ -69,18 +73,11 @@ The amount of time it took a change (pull request) to go from open to merged.
| Name | Description | Values |
| ---- | ----------- | ------ |
| repository.name | The name of a VCS repository | Any Str |
| ref.name | The name of a VCS branch | Any Str |
| vcs.repository.url.full | The canonical URL of the repository providing the complete HTTPS address. | Any Str |
| vcs.repository.name | The name of the VCS repository. | Any Str |
| vcs.ref.head.name | The name of the VCS head reference (branch). | Any Str |
### vcs.repository.count
The number of repositories in an organization.
| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| {repository} | Gauge | Int |
### vcs.repository.ref.count
### vcs.ref.count
The number of refs of type branch in a repository.
Expand All @@ -92,28 +89,13 @@ The number of refs of type branch in a repository.
| Name | Description | Values |
| ---- | ----------- | ------ |
| repository.name | The name of a VCS repository | Any Str |
| ref.type | The type of ref (branch, tag). | Str: ``branch``, ``tag`` |
### vcs.repository.ref.lines_added
The number of lines added in a ref (branch) relative to the default branch (trunk).
| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| {line} | Gauge | Int |
#### Attributes
| 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.url.full | The canonical URL of the repository providing the complete HTTPS address. | Any Str |
| vcs.repository.name | The name of the VCS repository. | Any Str |
| vcs.ref.head.type | The type of the head reference (branch, tag). | Str: ``branch``, ``tag`` |
### vcs.repository.ref.lines_deleted
### vcs.ref.lines_delta
The number of lines deleted in a ref (branch) relative to the default branch (trunk).
The number of lines added/removed in a ref (branch) relative to the default branch (trunk).
| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
Expand All @@ -123,13 +105,15 @@ The number of lines deleted in a ref (branch) relative to the default branch (tr
| 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.url.full | The canonical URL of the repository providing the complete HTTPS address. | Any Str |
| vcs.repository.name | The name of the VCS repository. | Any Str |
| vcs.ref.head.name | The name of the VCS head reference (branch). | Any Str |
| vcs.ref.head.type | The type of the head reference (branch, tag). | Str: ``branch``, ``tag`` |
| vcs.line_change.type | The type of line change being measured on a ref (branch). | Str: ``added``, ``removed`` |
### vcs.repository.ref.revisions_ahead
### vcs.ref.revisions_delta
The number of revisions (commits) a ref (branch) is ahead of the default branch (trunk).
The number of revisions (commits) a ref (branch) is ahead/behind the branch from trunk (default).
| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
Expand All @@ -139,41 +123,36 @@ The number of revisions (commits) a ref (branch) is ahead of the default branch
| 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.url.full | The canonical URL of the repository providing the complete HTTPS address. | Any Str |
| vcs.repository.name | The name of the VCS repository. | Any Str |
| vcs.ref.head.name | The name of the VCS head reference (branch). | Any Str |
| vcs.ref.head.type | The type of the head reference (branch, tag). | Str: ``branch``, ``tag`` |
| vcs.revision_delta.direction | The type of revision comparison. | Str: ``ahead``, ``behind`` |
### vcs.repository.ref.revisions_behind
### vcs.ref.time
The number of revisions (commits) a ref (branch) is behind the default branch (trunk).
Time a ref (branch) created from the default branch (trunk) has existed. The `vcs.ref.head.type` attribute will always be `branch`.

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

#### Attributes

| 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.url.full | The canonical URL of the repository providing the complete HTTPS address. | Any Str |
| vcs.repository.name | The name of the VCS repository. | Any Str |
| vcs.ref.head.name | The name of the VCS head reference (branch). | Any Str |
| vcs.ref.head.type | The type of the head reference (branch, tag). | Str: ``branch``, ``tag`` |

### vcs.repository.ref.time
### vcs.repository.count

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

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| s | Gauge | Int |

#### Attributes

| 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`` |
| {repository} | Gauge | Int |

## Optional Metrics

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

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

The number of unique contributors to a repository.

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

| Name | Description | Values |
| ---- | ----------- | ------ |
| repository.name | The name of a VCS repository | Any Str |
| vcs.repository.url.full | The canonical URL of the repository providing the complete HTTPS address. | Any Str |
| vcs.repository.name | The name of the VCS repository. | Any Str |

## Resource Attributes

Expand Down
2 changes: 1 addition & 1 deletion receiver/githubreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const (

var (
scraperFactories = map[string]internal.ScraperFactory{
metadata.Type.String(): &githubscraper.Factory{},
githubscraper.TypeStr: &githubscraper.Factory{},
}

errConfigNotValid = errors.New("configuration is not valid for the github receiver")
Expand Down
6 changes: 3 additions & 3 deletions receiver/githubreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ require (
go.opentelemetry.io/otel/trace v1.32.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/net v0.32.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
gonum.org/v1/gonum v0.15.1 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a // indirect
google.golang.org/grpc v1.68.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241206012308-a4fef0638583 // indirect
google.golang.org/grpc v1.68.1 // indirect
google.golang.org/protobuf v1.35.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Expand Down
12 changes: 6 additions & 6 deletions receiver/githubreceiver/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7dded6e

Please sign in to comment.