From ff5675e2988159771865edac07a81c2186735ad6 Mon Sep 17 00:00:00 2001 From: Matthew Hawkins Date: Tue, 15 Oct 2024 11:14:23 -0600 Subject: [PATCH] Add router metrics for Connectors telemetry configuration --- apollo-router/src/configuration/metrics.rs | 4 +++ ...__test__metrics@telemetry.router.yaml.snap | 2 ++ .../testdata/metrics/telemetry.router.yaml | 32 ++++++++++++++++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/apollo-router/src/configuration/metrics.rs b/apollo-router/src/configuration/metrics.rs index 5b497b94d8..b4a89d6476 100644 --- a/apollo-router/src/configuration/metrics.rs +++ b/apollo-router/src/configuration/metrics.rs @@ -341,6 +341,8 @@ impl InstrumentData { "$..events.supergraph", opt.events.subgraph, "$..events.subgraph", + opt.events.connector, + "$..events.connector", opt.instruments, "$..instruments", opt.instruments.router, @@ -349,6 +351,8 @@ impl InstrumentData { "$..instruments.supergraph", opt.instruments.subgraph, "$..instruments.subgraph", + opt.instruments.connector, + "$..instruments.connector", opt.instruments.graphql, "$..instruments.graphql", opt.instruments.default_attribute_requirement_level, diff --git a/apollo-router/src/configuration/snapshots/apollo_router__configuration__metrics__test__metrics@telemetry.router.yaml.snap b/apollo-router/src/configuration/snapshots/apollo_router__configuration__metrics__test__metrics@telemetry.router.yaml.snap index 50a0d132d5..eadb995095 100644 --- a/apollo-router/src/configuration/snapshots/apollo_router__configuration__metrics__test__metrics@telemetry.router.yaml.snap +++ b/apollo-router/src/configuration/snapshots/apollo_router__configuration__metrics__test__metrics@telemetry.router.yaml.snap @@ -8,10 +8,12 @@ expression: "&metrics.non_zero()" - value: 1 attributes: opt.events: true + opt.events.connector: true opt.events.router: true opt.events.subgraph: true opt.events.supergraph: true opt.instruments: true + opt.instruments.connector: true opt.instruments.default_attribute_requirement_level: false opt.instruments.graphql: true opt.instruments.router: true diff --git a/apollo-router/src/configuration/testdata/metrics/telemetry.router.yaml b/apollo-router/src/configuration/testdata/metrics/telemetry.router.yaml index b4f9a19dd7..d98953bd4a 100644 --- a/apollo-router/src/configuration/testdata/metrics/telemetry.router.yaml +++ b/apollo-router/src/configuration/testdata/metrics/telemetry.router.yaml @@ -99,6 +99,20 @@ telemetry: subgraph_response_data: "$.products[*].price1" attributes: subgraph.name: true + connector: + acme.user.not.found: + value: unit + type: counter + unit: count + description: "Count of 404 responses from the user API" + condition: + all: + - eq: + - 404 + - connector_http_response_status: code + - eq: + - "user_api" + - connector_source: name graphql: list.length: true field.execution: true @@ -174,4 +188,20 @@ telemetry: attributes: subgraph.name: true response_status: - subgraph_response_status: code \ No newline at end of file + subgraph_response_status: code + connector: + # Standard events + request: off + response: info + error: error + + # Custom events + connector.response: + message: "Connector response" + level: info + on: response + attributes: + connector.http.method: true + connector.url.template: true + response_status: + connector_http_response_status: code \ No newline at end of file