-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add metrics to SaneHTTPClient #4471
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
Conversation
1. Increment counter for URL 2. Time the latency 3. Increment counter for non-200 calls Added Tests
// Limit path length to avoid extremely long paths creating high cardinality | ||
if len(sanitized.Path) > 100 { | ||
sanitized.Path = sanitized.Path[:100] + "..." | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need suggestions, if we need to do this trimming or not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻 I think this is good. ...Pretty sure other metrics systems do this by default too (though it's been a while since I used like, Datadog)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG! Thanks for the quick turnaround 🙏🏻
prometheus.CounterOpts{ | ||
Namespace: MetricsNamespace, | ||
Subsystem: "http_client", | ||
Name: "requests_total", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's prefix all these w/ http_
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or, if Subsystem
up there already namespaces it, then this is fine 👌🏻 (I am not a prometheus expert haha)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Namespace, Subsystem, and Name are components of the fully-qualified
As per this doc, subsystem is already prefixing the metric. So I guess the metric title would look something like trufflehog_http_client_requests_total
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK that's perfect 👍🏻
// Limit path length to avoid extremely long paths creating high cardinality | ||
if len(sanitized.Path) > 100 { | ||
sanitized.Path = sanitized.Path[:100] + "..." | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻 I think this is good. ...Pretty sure other metrics systems do this by default too (though it's been a while since I used like, Datadog)
Note: Claude code helped me in writing tests.
Checklist:
make test-community
)?make lint
this requires golangci-lint)?