Skip to content

Conversation

@untitaker
Copy link
Member

@untitaker untitaker commented Dec 4, 2025

Improves performance over synchronous syscalls on the main thread.

@untitaker untitaker marked this pull request as ready for review December 5, 2025 16:42
@untitaker untitaker requested a review from a team as a code owner December 5, 2025 16:42
Copy link
Collaborator

@fpacifici fpacifici left a comment

Choose a reason for hiding this comment

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

Please consider addressing the comments before merging

typing:
name: "mypy typing"
runs-on: ubuntu-latest
timeout-minutes: 5
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is this about ?

Copy link
Member Author

Choose a reason for hiding this comment

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

mypy takes longer than 5 minutes now. I don't know why but this timeout just made the PR fail.


match metric.ty {
MetricType::Counter => {
let counter = metrics::counter!(key, &labels);
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does this macro do ? It seems it would be executed every time we produce a metric.

Copy link
Member Author

@untitaker untitaker Dec 8, 2025

Choose a reason for hiding this comment

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

that's what it does, produce metrics. it's part of the metrics crate. what it does internally (blocking udp send or preaggregate, or async) is an impl detail of the metrics crate, but it sure seems fast.

Comment on lines 55 to 69
let addr_str = format!("{}:{}", host, port);
let socket_addrs: Vec<SocketAddr> = match addr_str.to_socket_addrs() {
Ok(addrs) => addrs.collect(),
Err(e) => {
error!("Failed to resolve metrics address {}: {}", addr_str, e);
return;
}
};

if init(recorder).is_err() {
warn!("Warning: Metrics recorder already initialized, skipping");
let statsd_addr = match socket_addrs.first() {
Some(addr) => *addr,
None => {
error!("Could not resolve metrics address into a socket address");
return;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

IS this all meant to just turn the host into an ip address ?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes it was bullshit from earlier attempts to get the thing working. not necessary

recorder = recorder.with_tag(key, value);
}
}
let host = metric_config.host();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should find a way to unit test this logic.

@untitaker untitaker enabled auto-merge (squash) December 8, 2025 14:03
@untitaker untitaker merged commit 38b3ce4 into main Dec 8, 2025
20 checks passed
.tags
.iter()
.map(|(k, v)| {
let key = k.map(|k| format!("{}", k)).unwrap_or_default();
Copy link

Choose a reason for hiding this comment

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

Bug: Empty tag key when metric tag key is None

When a metric tag has a None key, unwrap_or_default() produces an empty string "" as the tag key. This results in metrics being sent with empty tag keys, which is invalid for most metrics backends (including statsd/Datadog). Empty tag keys can cause parsing errors, data corruption, or silent metric dropping. Tags with None keys could be filtered out entirely instead.

Fix in Cursor Fix in Web

Copy link
Member Author

Choose a reason for hiding this comment

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

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