From 4c49967d9cb8c41f63740e763949e964cd260eca Mon Sep 17 00:00:00 2001 From: Gus Eggert Date: Mon, 27 Mar 2023 14:58:12 -0400 Subject: [PATCH] feat: add client-side metrics for routing-v1 client --- routing/delegated.go | 5 +++++ test/cli/delegated_routing_http_test.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/routing/delegated.go b/routing/delegated.go index 1e8d7efa0..a32c5c091 100644 --- a/routing/delegated.go +++ b/routing/delegated.go @@ -221,6 +221,11 @@ func httpRoutingFromConfig(conf config.Router, extraHTTP *ExtraHTTPParams) (rout contentrouter.WithMaxProvideConcurrency(params.MaxProvideConcurrency), ) + err = view.Register(drclient.OpenCensusViews...) + if err != nil { + return nil, fmt.Errorf("registering HTTP delegated routing views: %w", err) + } + return &httpRoutingWrapper{ ContentRouting: cr, ProvideManyRouter: cr, diff --git a/test/cli/delegated_routing_http_test.go b/test/cli/delegated_routing_http_test.go index 446ea5150..8cf3368fa 100644 --- a/test/cli/delegated_routing_http_test.go +++ b/test/cli/delegated_routing_http_test.go @@ -118,4 +118,9 @@ func TestHTTPDelegatedRouting(t *testing.T) { assert.Equal(t, prov, res.Stdout.Trimmed()) }) + t.Run("HTTP client should emit OpenCensus metrics", func(t *testing.T) { + resp := node.APIClient().Get("/debug/metrics/prometheus") + assert.Contains(t, resp.Body, "routing_http_client_length_count") + }) + }