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 first opentelemetry metric #393

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

Ongy
Copy link
Contributor

@Ongy Ongy commented Jan 3, 2025

No description provided.

@Ongy
Copy link
Contributor Author

Ongy commented Jan 3, 2025

@erebe first draft PR for the metrics provider. This is mostly to make sure the general style fits your expectations, though could already be merged as is.

This is the ~MVP of getting some prometheus metrics with the opentelemetry tooling.
I've mostly chosen opentelemetry for familiarity, but I think it's generally good tooling.

The main potentially contentious point I see: This tooling is quite beta/alpha stage in the rust ecosystem.
Otherwise, I don't regularly work in rust, so my code might be atrocious, but I think it's reasonable.

src/main.rs Outdated Show resolved Hide resolved
self.metrics.connections.add(
1,
&[
KeyValue::new("remote_host", format!("{}", remote.host)),
Copy link
Owner

Choose a reason for hiding this comment

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

We should avoid setting remote_host and port as label as it will make too much cardinality for prometheus, and create a data leak for us.

If a user request random host / port our metrics are going to fill the available memory of wstunnel until it OOM as they are never cleaned.

metrics should not jeopardize the stability of the system
https://stackoverflow.com/a/69167162

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll have to think about this a bit.

I see why you say that, and agree with the point you make.
OTOH, I need the cardinality to get the information I need. So I'll have to think about some way to customize this.
In my case, k8s and multiple replicas make an OOM less serious.

@erebe
Copy link
Owner

erebe commented Jan 4, 2025

Overall, looks ok 👍
Thanks for your effort

@Ongy Ongy force-pushed the add-basic-metrics branch from 79824d2 to ae52331 Compare January 7, 2025 09:52
@Ongy Ongy force-pushed the add-basic-metrics branch 2 times, most recently from a3375f3 to d065bfa Compare January 7, 2025 10:20
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.

2 participants