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] add branch time, commit, and line metrics #32812

Merged
merged 32 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
a4cce65
[receiver/gitproviderreceiver] add branch age and commit metrics
adrielp Apr 30, 2024
64f3884
[feat] add line addition and other metrics
adrielp May 2, 2024
b906a06
[chore] gen changlog and update readme
adrielp May 2, 2024
b4b579b
[chore] set go.mod in receiver to v1.21.0
adrielp May 2, 2024
f2db263
[chore] run make crosslink
adrielp May 2, 2024
b7317df
[chore] run make gotidy
adrielp May 2, 2024
8c24669
[chore] update metric types to match semantic conventions
adrielp May 3, 2024
ae25cdb
[chore] slight refactor with var and function renaming
adrielp May 4, 2024
c82c97b
Merge branch 'main' into branch-metrics
adrielp May 4, 2024
eb6ab5e
[chore] rerun tidy after merge conflicts
adrielp May 4, 2024
a312f79
[chore] slight refactor and comment updates, addded additional tests
adrielp May 4, 2024
04aee28
[chore] limitations docs and cleanup
adrielp May 4, 2024
d8bf63d
Merge branch 'main' into branch-metrics
adrielp May 4, 2024
dbe9865
[chore] update comments, add docs, remove uncalled code
adrielp May 9, 2024
5db15e3
[chore] Update receiver/gitproviderreceiver/internal/scraper/githubsc…
adrielp May 9, 2024
1084ac3
[chore] Apply suggestions from code review
adrielp May 9, 2024
23fae24
[chore] update changelog to reflect the updated metric names
adrielp May 9, 2024
3c5afdc
Merge branch 'main' into branch-metrics
adrielp May 9, 2024
415a590
[chore] re-tidy after merge
adrielp May 9, 2024
cf1f39d
[chore] adjust comments, docs, and descriptions based on feedback
adrielp May 9, 2024
194c68c
Merge branch 'main' into branch-metrics
adrielp May 9, 2024
f0370b5
[chore] update comment and readme based on feedback
adrielp May 10, 2024
753257a
[chore] slight metric description re-wording
adrielp May 10, 2024
6211eea
Merge branch 'main' into branch-metrics
adrielp May 21, 2024
263971b
[chore] resolve conflicts and re-tidy
adrielp May 21, 2024
03c7bc2
[chore] update logging statements and add mutex lock
adrielp May 21, 2024
093e09d
Merge branch 'main' into branch-metrics
adrielp May 21, 2024
75c1214
[chore] rerun tidy's after merge conflict resolution
adrielp May 21, 2024
e33b48b
Merge branch 'main' into branch-metrics
adrielp May 29, 2024
0a6d211
[chore] run checks and tidy's after resolving conflicts
adrielp May 29, 2024
a03fed2
Merge branch 'main' into branch-metrics
adrielp Jun 4, 2024
51686bb
[chore] update go.mod and go.sum files
adrielp Jun 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .chloggen/branch-metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Use this changelog template to create an entry for release notes.

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

# 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: Adds branch commit and line based metrics

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

# (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: |
Adds the following branch based metrics.
* git.repository.branch.time
* git.repository.branch.commit.aheadby_count
* git.repository.branch.commit.behindby_count
* git.repository.branch.line.deletion_count
* git.repository.branch.line.addition_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: []
9 changes: 6 additions & 3 deletions receiver/gitproviderreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ These default metrics can be used as leading indicators to the DORA metrics; hel
The current metrics available via scraping from GitHub are:

- [x] Repository count
- [ ] Repository branch time
- [x] Repository branch 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
- [ ] Repository pull request deployment time
- [x] Repository pull request time to approval
- [x] Repository pull request count | stores an attribute of `pull_request.state` equal to `open` or `merged`

Expand Down
75 changes: 75 additions & 0 deletions receiver/gitproviderreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,36 @@ metrics:
enabled: false
```

### git.repository.branch.commit.aheadby_count

Number of commits a branch is ahead of the default branch.

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| {commit} | 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 |

### git.repository.branch.commit.behindby_count

Number of commits a branch is behing the default branch.

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| {commit} | 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 |

### git.repository.branch.count

Number of branches in a repository
Expand All @@ -26,6 +56,51 @@ Number of branches in a repository
| ---- | ----------- | ------ |
| repository.name | The name of a Git repository | Any Str |

### git.repository.branch.line.addition_count

Count of lines added to code in a branch

| 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 |

### git.repository.branch.line.deletion_count

Count of lines deleted from code in a branch

| 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 |

### git.repository.branch.time

Time the branch has existed.

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| 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 |

### git.repository.count

Number of repositories in an organization
Expand Down
29 changes: 19 additions & 10 deletions receiver/gitproviderreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ require (
github.com/Khan/genqlient v0.7.0
github.com/google/go-cmp v0.6.0
github.com/google/go-github/v61 v61.0.0
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden v0.99.0
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.99.0
adrielp marked this conversation as resolved.
Show resolved Hide resolved
github.com/stretchr/testify v1.9.0
go.opentelemetry.io/collector/component v0.99.1-0.20240503221155-67d37183e6ac
go.opentelemetry.io/collector/config/confighttp v0.99.1-0.20240503221155-67d37183e6ac
Expand All @@ -25,13 +27,13 @@ require (
require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
Expand All @@ -46,24 +48,25 @@ require (
github.com/knadh/koanf/maps v0.1.1 // indirect
github.com/knadh/koanf/providers/confmap v0.1.0 // indirect
github.com/knadh/koanf/v2 v2.1.1 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/lufia/plan9stats v0.0.0-20240408141607-282e7b5d6b74 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.99.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
github.com/prometheus/client_golang v1.19.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.53.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/rs/cors v1.10.1 // indirect
github.com/rs/cors v1.11.0 // indirect
github.com/shirou/gopsutil/v3 v3.24.3 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/spf13/cobra v1.8.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/tklauser/go-sysconf v0.3.13 // indirect
github.com/tklauser/numcpus v0.7.0 // indirect
github.com/vektah/gqlparser/v2 v2.5.11 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.opencensus.io v0.24.0 // indirect
Expand Down Expand Up @@ -105,14 +108,20 @@ require (
go.opentelemetry.io/otel/sdk/metric v1.26.0 // indirect
go.opentelemetry.io/proto/otlp v1.2.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/exp v0.0.0-20240409090435-93d18d7e34b8 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
gonum.org/v1/gonum v0.15.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240429193739-8cf5692501f6 // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.34.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil

replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest

replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden
38 changes: 21 additions & 17 deletions receiver/gitproviderreceiver/go.sum

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

Loading
Loading