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

Make metrics collection in throttle and middleware packages more flexible #11

Merged
merged 1 commit into from
Sep 5, 2024

Conversation

vasayxtx
Copy link
Member

@vasayxtx vasayxtx commented Sep 4, 2024

Now middlewares receive interfaces instead of the concrete Prometheus implementations.

This change is a breaking change. However, given the library’s current limited usage, we have decided not to bump the major version at this time.

labels := reqInfo.makeLabels()
labels[httpRequestMetricsLabelStatusCode] = strconv.Itoa(status)
c.Durations.With(labels).Observe(time.Since(startTime).Seconds())
func (pm *HTTPRequestPrometheusMetrics) IncInFlightRequests(requestInfo HTTPRequestInfoMetrics) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's add header comments for public functions

method string
routePattern string
userAgentType string
func (pm *HTTPRequestPrometheusMetrics) DecInFlightRequests(requestInfo HTTPRequestInfoMetrics) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's add header comments for public functions

// HTTPRequestInfoMetrics represents a request info for collecting metrics.
type HTTPRequestInfoMetrics struct {
Method string
RoutePattern string
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we safe here due to the combinatorics of different HTTP routes?

Copy link
Member Author

@vasayxtx vasayxtx Sep 5, 2024

Choose a reason for hiding this comment

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

No, it's supposed to be the route pattern, not the final URL.

…ible

Now middlewares receive interfaces instead of the concrete Prometheus implementations.
@vasayxtx vasayxtx merged commit 55e5fab into acronis:master Sep 5, 2024
5 checks passed
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