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

Add crd metrics usage information #2825

Merged
merged 20 commits into from
May 30, 2024

Conversation

rubenvp8510
Copy link
Contributor

@rubenvp8510 rubenvp8510 commented Apr 7, 2024

Description:

Add a new package that collect different metrics about the collectors on the cluster.

Link to tracking Issue(s):

Testing:

Documentation:

@rubenvp8510 rubenvp8510 requested a review from a team as a code owner April 7, 2024 21:16
@jaronoff97
Copy link
Contributor

@rubenvp8510 thanks for opening this up. Could you open an issue first so we could discuss how we could improve the observability about the operator?

@pavolloffay
Copy link
Member

Also changelog is missing

@rubenvp8510
Copy link
Contributor Author

@jaronoff97 Created the issue and linked here. @pavolloffay Added changelog.

.chloggen/usage_metrics.yaml Show resolved Hide resolved
pkg/featuregate/featuregate.go Outdated Show resolved Hide resolved
pkg/crdmetrics/collector.go Outdated Show resolved Hide resolved
pkg/crdmetrics/collector.go Outdated Show resolved Hide resolved
pkg/crdmetrics/collector.go Outdated Show resolved Hide resolved
@rubenvp8510 rubenvp8510 requested a review from a team as a code owner May 7, 2024 05:07
@rubenvp8510 rubenvp8510 force-pushed the usage_metrics branch 8 times, most recently from 8956946 to 37e2e95 Compare May 7, 2024 05:36
@rubenvp8510
Copy link
Contributor Author

rubenvp8510 commented May 15, 2024

Hello @pavolloffay @jaronoff97 sorry for the delay on this PR

This is how the metrics looks like with the latest changes

# HELP opentelemetry_collector_exporters 
# TYPE opentelemetry_collector_exporters gauge
opentelemetry_collector_exporters{collector_name="simplest",namespace="default",otel_scope_name="crd-metrics",otel_scope_version="",type="debug"} 1
# HELP opentelemetry_collector_info 
# TYPE opentelemetry_collector_info gauge
opentelemetry_collector_info{collector_name="operator-check",namespace="default",otel_scope_name="crd-metrics",otel_scope_version="",type="deployment"} 0
opentelemetry_collector_info{collector_name="simplest",namespace="default",otel_scope_name="crd-metrics",otel_scope_version="",type="deployment"} 1
# HELP opentelemetry_collector_processors 
# TYPE opentelemetry_collector_processors gauge
opentelemetry_collector_processors{collector_name="simplest",namespace="default",otel_scope_name="crd-metrics",otel_scope_version="",type="batch"} 1
opentelemetry_collector_processors{collector_name="simplest",namespace="default",otel_scope_name="crd-metrics",otel_scope_version="",type="memory_limiter"} 1
# HELP opentelemetry_collector_receivers 
# TYPE opentelemetry_collector_receivers gauge
opentelemetry_collector_receivers{collector_name="simplest",namespace="default",otel_scope_name="crd-metrics",otel_scope_version="",type="otlp"} 1

Let me know if this is satisfactory and if you have more observations on this PR. Thank you very much for all the reviews!

At the end I use a gauge and the webhooks to detect creation/deletion/update, as Pavol suggested. It is a clean solution IMHO.

apis/v1beta1/metrics.go Outdated Show resolved Hide resolved
config/manager/kustomization.yaml Outdated Show resolved Hide resolved
apis/v1beta1/metrics.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
@rubenvp8510 rubenvp8510 force-pushed the usage_metrics branch 2 times, most recently from 3225b3a to 9e4448b Compare May 16, 2024 01:40
@rubenvp8510
Copy link
Contributor Author

@pavolloffay All comments already addressed!

Copy link
Member

@pavolloffay pavolloffay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I would like to see some tests for the Metrics

pkg/constants/env.go Outdated Show resolved Hide resolved
@rubenvp8510
Copy link
Contributor Author

@pavolloffay this is ready for another review. Thank you!

@rubenvp8510
Copy link
Contributor Author

@rubenvp8510 would you be able to book a follow up to this for updating docs about how to enable/use these metrics?

Done here: #2999 I'll update the docs.

rubenvp8510 and others added 20 commits May 30, 2024 08:29
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Co-authored-by: Israel Blancas <iblancasa@gmail.com>
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
@rubenvp8510
Copy link
Contributor Author

@jaronoff97 @pavolloffay Can we merge this PR? is ready :)

@jaronoff97
Copy link
Contributor

@rubenvp8510 waiting on one more approval to merge something of this size :) I'm reaching out to folks to be sure its reviewed.

@jaronoff97 jaronoff97 merged commit dac4774 into open-telemetry:main May 30, 2024
33 checks passed
@jaronoff97
Copy link
Contributor

@rubenvp8510 thank you for your work here!! 🙇

ItielOlenick pushed a commit to ItielOlenick/opentelemetry-operator that referenced this pull request Jun 6, 2024
* Add crd metrics usage information

Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>

* Add mode metric

Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>

* Refactor CR metrics

Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>

* Add annotation to avoid generate Metrics

Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>

* Add unit tests

Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>

* remove space

Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>

* remove global provider

Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>

* Update main.go

Co-authored-by: Israel Blancas <iblancasa@gmail.com>

* revert kusttomization.yaml

Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>

* rename some constants

Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>

* Add connectors metrics

Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>

* Update chlog

Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>

* merge new with init, rename some functions, improve changelog entry

Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>

* improve todo comment

Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>

* fix tests

Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>

* set flag to default false

Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>

* fix lint issues

Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>

* breaking line

Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>

* Use api reader to avoid cache issues

Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>

* Add info metric to changelog entry

Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>

---------

Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Co-authored-by: Israel Blancas <iblancasa@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Metrics about how opentelemetry collector is used
5 participants