You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
metrics: factor out NewService for target-scoped metrics (#1117)
While working on adding a target port label to the TLS detection failure
metrics added in #1114, I realized that there was some boilerplate code
for scoping metrics based on a label from a target that was basically
repeated between `linkerd-http-metrics` and `linkerd-transport`'s
`metrics` module, and that this boilerplate code would have to be
rewritten a third time for adding target port labels to the TLS
detection metrics.
Instead of rewriting this code a third time, I factored it out into a
`NewMetrics` type in the `linkerd-metrics` crate, which given a registry
of scopes, a `NewService`, and a metrics service type that can be
constructed from the `NewService`'s service and the registry's metrics,
implements `NewService` by wrapping the inner service with a metrics
service scoped for the target's labels. The `linkerd-http-metrics`
crate's `NewHttpMetrics` and the `linkerd-transport` crate's
`metrics::MakeAccept` can both be replaced with the new `NewMetrics`
type.
Signed-off-by: Eliza Weisman <[email protected]>
0 commit comments