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 1 commit 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.

verbatim_doc_comment,
default_value = None,
)]
metrics_provider_address: Option<String>,
Copy link
Owner

@erebe erebe Jan 4, 2025

Choose a reason for hiding this comment

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

You can directly set an IpAddress in instead of a string to directly refuse invalid bind address

let fut = conn
.serve_connection(
stream,
service_fn(|req: Request<body::Incoming>| {
Copy link
Owner

Choose a reason for hiding this comment

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

you need to check that the path is /metrics to return the metrics

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

@erebe
Copy link
Owner

erebe commented Jan 4, 2025

Overall, looks ok 👍
Thanks for your effort

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