Skip to content

Add first opentelemetry metric#393

Draft
Ongy wants to merge 8 commits into
erebe:mainfrom
Ongy:add-basic-metrics
Draft

Add first opentelemetry metric#393
Ongy wants to merge 8 commits into
erebe:mainfrom
Ongy:add-basic-metrics

Conversation

@Ongy

@Ongy Ongy commented Jan 3, 2025

Copy link
Copy Markdown
Contributor

No description provided.

@Ongy

Ongy commented Jan 3, 2025

Copy link
Copy Markdown
Contributor Author

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

Comment thread src/main.rs Outdated
Comment thread src/metrics/mod.rs
self.metrics.connections.add(
1,
&[
KeyValue::new("remote_host", format!("{}", remote.host)),

Copy link
Copy Markdown
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
Copy Markdown
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

erebe commented Jan 4, 2025

Copy link
Copy Markdown
Owner

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

erebe commented Feb 4, 2025

Copy link
Copy Markdown
Owner

I discovered recently that this rust crate for prometheus is managing the expiration of old metrics. If that can help you

https://docs.rs/metrics-exporter-prometheus/latest/metrics_exporter_prometheus/struct.PrometheusBuilder.html#method.idle_timeout

@erebe
erebe force-pushed the main branch 4 times, most recently from d28409f to b36e8a4 Compare February 5, 2025 07:58
@erebe
erebe force-pushed the main branch 3 times, most recently from ef0eb24 to c5ac5fb Compare March 9, 2025 16:53
@erebe
erebe force-pushed the main branch 7 times, most recently from cbecd19 to 977c385 Compare May 17, 2025 14:49
@erebe
erebe force-pushed the main branch 20 times, most recently from a8c4240 to 73c53b0 Compare June 4, 2025 06:06
@erebe
erebe force-pushed the main branch 3 times, most recently from 5ce3fb8 to c5e2981 Compare June 11, 2025 21:16
@erebe
erebe force-pushed the main branch 3 times, most recently from 9b03594 to 84e6786 Compare May 3, 2026 18:24
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