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

feat: Kyma stats receiver #45

Merged
merged 67 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from 62 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
ab4c9c3
kymastatsreceiver initial commit
hisarbalik Jun 25, 2024
6b4b9d8
generate
hisarbalik Jun 25, 2024
d64f0f9
add internal k8s condif library
hisarbalik Jun 26, 2024
3513ea0
refactor config library
hisarbalik Jun 26, 2024
53a05f6
fix linter issues
hisarbalik Jun 26, 2024
d2369d4
add config unit tests
hisarbalik Jun 26, 2024
77f442c
update k8s client config library
hisarbalik Jun 26, 2024
7db54e9
add kyma module scraper
hisarbalik Jun 27, 2024
89e76e0
add kyma scraper with generic metric controller
hisarbalik Jun 28, 2024
3a4dee7
add module scrape and metric emmit code
hisarbalik Jun 28, 2024
47f31f3
update metadata
hisarbalik Jun 28, 2024
dbbfc58
add kyma scraper test
hisarbalik Jun 28, 2024
a4ac1c7
add more tests
hisarbalik Jun 28, 2024
646d694
Merge branch 'main' into kymastats-receiver
hisarbalik Jun 28, 2024
9b92e2c
add factory tests
hisarbalik Jun 29, 2024
c4ae3b3
fix failieng unit tests
hisarbalik Jul 1, 2024
7e73eef
update tests
hisarbalik Jul 1, 2024
5c405a6
fix failing unit tests
hisarbalik Jul 1, 2024
fb9f768
Merge branch 'main' into kymastats-receiver
hisarbalik Jul 1, 2024
0c054b2
re-generate code
hisarbalik Jul 1, 2024
c6538d9
update readme
hisarbalik Jul 2, 2024
17f273b
fix linter issues
hisarbalik Jul 2, 2024
f3b1552
Merge remote-tracking branch 'upstream/main' into kymastats-receiver
k15r Jul 2, 2024
40f5e4a
enable thelper and tparallel linters
k15r Jul 2, 2024
6f12eb2
gci files
k15r Jul 2, 2024
86cb18c
enable testify linter
k15r Jul 2, 2024
bddee0d
rename metric names and attributes
hisarbalik Jul 2, 2024
3e839d3
Merge branch 'kymastats-receiver' of github.com:hisarbalik/openteleme…
hisarbalik Jul 2, 2024
3f498cf
fix new linter issues
hisarbalik Jul 2, 2024
34c9ec5
Simplify kyma scraper
skhalash Jul 2, 2024
576f80f
Move resources to main pkg
skhalash Jul 2, 2024
6d111b3
code review changes
hisarbalik Jul 3, 2024
b5de663
update unit tests
hisarbalik Jul 3, 2024
88ccd68
Merge branch 'main' of github.com:kyma-project/opentelemetry-collecto…
skhalash Jul 3, 2024
5183e6b
Merge branch 'kymastats-receiver' of github.com:hisarbalik/openteleme…
skhalash Jul 3, 2024
af448bb
Add new receiver in the local distro
skhalash Jul 3, 2024
c059862
Rename receiver type
skhalash Jul 3, 2024
bc3f4b2
Rename a leftover
skhalash Jul 3, 2024
d8e9488
change default resource configuration
hisarbalik Jul 3, 2024
cc9b698
resource name configuration updated
hisarbalik Jul 3, 2024
b66a378
get the module type from object kind
hisarbalik Jul 3, 2024
4f77be8
Use unstructured helpers
skhalash Jul 3, 2024
d50f1db
Extraced val computation
skhalash Jul 3, 2024
f0cd9ca
Improve var name
skhalash Jul 3, 2024
c7f66c7
add more unit tests
hisarbalik Jul 3, 2024
c01d7b1
Merge branch 'kymastats-receiver' of github.com:hisarbalik/openteleme…
hisarbalik Jul 3, 2024
251dcfc
Re-sort config fields
skhalash Jul 3, 2024
d64026f
Merge branch 'kymastats-receiver' of github.com:hisarbalik/openteleme…
skhalash Jul 3, 2024
44837ae
Minor fix
skhalash Jul 3, 2024
3c588f2
fix linter issues
hisarbalik Jul 3, 2024
1360b5c
refactor resource attributes
hisarbalik Jul 4, 2024
23286c5
fix failing unit tests
hisarbalik Jul 4, 2024
8b907f4
update metric documentation
hisarbalik Jul 4, 2024
04bd7c6
Remove unneeded config param
skhalash Jul 4, 2024
9b4bf6d
Merge branch 'kymastats-receiver' of github.com:hisarbalik/openteleme…
skhalash Jul 4, 2024
7edb0ad
Apply suggestions from code review
hisarbalik Jul 4, 2024
f3a4020
update docs
hisarbalik Jul 4, 2024
69c61d6
Merge branch 'kymastats-receiver' of github.com:hisarbalik/openteleme…
hisarbalik Jul 4, 2024
2793549
Rewrite negative tests
skhalash Jul 4, 2024
d35799a
Merge branch 'kymastats-receiver' of github.com:hisarbalik/openteleme…
skhalash Jul 4, 2024
f7fc293
Add metric test
skhalash Jul 4, 2024
d1f5b9c
Fix test
skhalash Jul 4, 2024
9d246d2
Improve test
skhalash Jul 4, 2024
0a918f2
make tidy
skhalash Jul 4, 2024
eb1fd07
make fmt
skhalash Jul 4, 2024
2cb0b86
Fix lint
skhalash Jul 4, 2024
e080e61
Fix lint
skhalash Jul 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
5 changes: 2 additions & 3 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ linters:
- prealloc
- protogetter
- tagliatelle
- testifylint
- testpackage
- thelper
- tparallel
- varnamelen
- whitespace
- wrapcheck
Expand All @@ -57,6 +54,8 @@ linters-settings:
alias:
- pkg: "k8s.io/apimachinery/pkg/apis/meta/v1"
alias: metav1
- pkg: "k8s.io/client-go/testing"
alias: clienttesting

errcheck:
check-type-assertions: true # Reports type assertions: `a := b.(SomeStruct)`.
Expand Down
4 changes: 3 additions & 1 deletion cmd/otelkymacol/builder-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dist:

receivers:
- gomod: github.com/kyma-project/opentelemetry-collector-components/receiver/dummyreceiver v0.0.1
- gomod: github.com/kyma-project/opentelemetry-collector-components/receiver/kymastatsreceiver v0.0.1
- gomod: github.com/kyma-project/opentelemetry-collector-components/receiver/singletonreceivercreator v0.0.1

processors:
Expand All @@ -16,6 +17,7 @@ exporters:
- gomod: go.opentelemetry.io/collector/exporter/debugexporter v0.104.0

replaces:
- github.com/kyma-project/opentelemetry-collector-components/internal/k8sconfig => ../../internal/k8sconfig
- github.com/kyma-project/opentelemetry-collector-components/receiver/dummyreceiver => ../../receiver/dummyreceiver
- github.com/kyma-project/opentelemetry-collector-components/receiver/kymastatsreceiver => ../../receiver/kymastatsreceiver
- github.com/kyma-project/opentelemetry-collector-components/receiver/singletonreceivercreator => ../../receiver/singletonreceivercreator
- github.com/kyma-project/opentelemetry-collector-components/internal/k8sconfig => ../../internal/k8sconfig
2 changes: 2 additions & 0 deletions cmd/otelkymacol/components.go

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

10 changes: 7 additions & 3 deletions cmd/otelkymacol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ go 1.22.4

require (
github.com/kyma-project/opentelemetry-collector-components/receiver/dummyreceiver v0.0.1
github.com/kyma-project/opentelemetry-collector-components/receiver/kymastatsreceiver v0.0.1
github.com/kyma-project/opentelemetry-collector-components/receiver/singletonreceivercreator v0.0.1
go.opentelemetry.io/collector/component v0.104.0
go.opentelemetry.io/collector/confmap v0.104.0
Expand Down Expand Up @@ -47,7 +48,7 @@ require (
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/imdario/mergo v0.3.6 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
Expand Down Expand Up @@ -80,6 +81,7 @@ require (
go.opentelemetry.io/collector/config/configtelemetry v0.104.0 // indirect
go.opentelemetry.io/collector/consumer v0.104.0 // indirect
go.opentelemetry.io/collector/featuregate v1.11.0 // indirect
go.opentelemetry.io/collector/filter v0.104.0 // indirect
go.opentelemetry.io/collector/pdata v1.11.0 // indirect
go.opentelemetry.io/collector/semconv v0.104.0 // indirect
go.opentelemetry.io/collector/service v0.104.0 // indirect
Expand Down Expand Up @@ -127,8 +129,10 @@ require (
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace github.com/kyma-project/opentelemetry-collector-components/internal/k8sconfig => ../../internal/k8sconfig

replace github.com/kyma-project/opentelemetry-collector-components/receiver/dummyreceiver => ../../receiver/dummyreceiver

replace github.com/kyma-project/opentelemetry-collector-components/receiver/singletonreceivercreator => ../../receiver/singletonreceivercreator
replace github.com/kyma-project/opentelemetry-collector-components/receiver/kymastatsreceiver => ../../receiver/kymastatsreceiver

replace github.com/kyma-project/opentelemetry-collector-components/internal/k8sconfig => ../../internal/k8sconfig
replace github.com/kyma-project/opentelemetry-collector-components/receiver/singletonreceivercreator => ../../receiver/singletonreceivercreator
7 changes: 5 additions & 2 deletions cmd/otelkymacol/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k=
github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY=
github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28=
github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
Expand Down Expand Up @@ -230,6 +230,8 @@ go.opentelemetry.io/collector/extension/zpagesextension v0.104.0 h1:rJ9Sw6DR27s6
go.opentelemetry.io/collector/extension/zpagesextension v0.104.0/go.mod h1:85Exj8r237PIvaXL1a/S0KeVNnm3kQNpVXtu0O2Zk5k=
go.opentelemetry.io/collector/featuregate v1.11.0 h1:Z7puIymKoQRm3oNM/NH8reWc2zRPz2PNaJvuokh0lQY=
go.opentelemetry.io/collector/featuregate v1.11.0/go.mod h1:PsOINaGgTiFc+Tzu2K/X2jP+Ngmlp7YKGV1XrnBkH7U=
go.opentelemetry.io/collector/filter v0.104.0 h1:6BkLJuqWtWFdXHEgbn4TpK5d7Ha5aMdDhLmdvZ6VHxk=
go.opentelemetry.io/collector/filter v0.104.0/go.mod h1:l9+6CTcA0wHOg+J3HSereMuXy47cHPGiHevCun0SbNM=
go.opentelemetry.io/collector/otelcol v0.104.0 h1:RnMx7RaSFmX4dq/l3wbXWwcUnFK7RU19AM/0FbMr0Ig=
go.opentelemetry.io/collector/otelcol v0.104.0/go.mod h1:hWFRiHIKT3zbUx6SRevusPRa6mfm+70bPG5CK0glqSU=
go.opentelemetry.io/collector/pdata v1.11.0 h1:rzYyV1zfTQQz1DI9hCiaKyyaczqawN75XO9mdXmR/hE=
Expand Down Expand Up @@ -392,6 +394,7 @@ gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down
3 changes: 2 additions & 1 deletion internal/components/components_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestDefaultComponents(t *testing.T) {
factories, err := Components()
assert.NoError(t, err)
require.NoError(t, err)

exts := factories.Extensions
for k, v := range exts {
Expand Down
20 changes: 20 additions & 0 deletions internal/k8sconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"net/http"
"os"

"k8s.io/client-go/dynamic"

"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
Expand Down Expand Up @@ -126,3 +128,21 @@ func MakeClient(apiConf APIConfig) (kubernetes.Interface, error) {

return client, nil
}

func MakeDynamicClient(apiConf APIConfig) (dynamic.Interface, error) {
if err := apiConf.Validate(); err != nil {
return nil, err
}

authConf, err := CreateRestConfig(apiConf)
if err != nil {
return nil, err
}

client, err := dynamic.NewForConfig(authConf)
if err != nil {
return nil, err
}

return client, nil
}
Loading
Loading