Skip to content

Conversation

@cratelyn
Copy link
Member

this commit makes a mechanical refactor in the interest of paving ground towards using the request body metrics middleware in the inbound proxy.

because of minor differences in how we represent protocols like gRPC in the inbound and outbound proxies, we must account for:

(a): distinct NewService<T>'s accepting Grpc<T> and Http<T> targets, respectively, each holding a single metrics Family<L>.

(b): a single NewService<T> that matches on the Permitted<T> enum to select one of two metrics Family<L>s.

see #4119 for more background on this Permitted<T> enum.

so, we should make the NewRecordBodyData agnostic to its metrics, rather than holding a concrete RequestBodyFamilies<L>.

this commit hoists the metrics out of the middleware, and into the X and ReqX extractors used in the NewService<T> and Service<T> layers, respectively.

bear particular attention to this part of the diff:

-    ReqX: ExtractParam<L, Request<ReqB>>,
-    L: linkerd_metrics::prom::encoding::EncodeLabelSet
-        + std::fmt::Debug
-        + std::hash::Hash
-        + Eq
-        + Clone
-        + Send
-        + Sync
-        + 'static,
+    ReqX: ExtractParam<BodyDataMetrics, Request<ReqB>>,

in other words, rather than using X and subsequently ReqX to extract our labels L, we expect these extractors to yield a BodyDataMetrics: one time series that should be incremented accordingly by the instrumented request.

in even simpler words: ReqX now calls familes.metrics(&labels) too.

@cratelyn cratelyn requested a review from a team as a code owner September 19, 2025 20:03
@cratelyn cratelyn marked this pull request as draft September 19, 2025 20:04
@cratelyn cratelyn marked this pull request as ready for review September 19, 2025 20:11
@cratelyn cratelyn enabled auto-merge (squash) September 19, 2025 20:54
@cratelyn cratelyn force-pushed the kate/prepare-request-body-metrics-for-inbound-proxy branch from d03e89c to 13220e8 Compare September 22, 2025 14:38
@cratelyn
Copy link
Member Author

i have rebased this atop main as of 0060a4c.

@cratelyn cratelyn self-assigned this Sep 22, 2025
cratelyn added a commit that referenced this pull request Sep 22, 2025
this commit introduces an additional layer of telemetry to the inbound
proxy's http router.

either http and grpc metrics are used, depending upon the policy that
authorized a given request.

this is based upon #4174, which refactored the
request body telemetry middleware to be metrics agnostic.

see:
* #4165
* #4166
* #4174
* #4127

Signed-off-by: katelyn martin <[email protected]>
this commit makes a mechanical refactor in the interest of paving ground
towards using the request body metrics middleware in the inbound proxy.

because of minor differences in how we represent protocols like gRPC in
the inbound and outbound proxies, we must account for:

(a): distinct `NewService<T>`'s accepting `Grpc<T>` and `Http<T>`
targets, respectively, each holding a single metrics `Family<L>`.

(b): a single `NewService<T>` that matches on the `Permitted<T>` enum to
select one of two metrics `Family<L>`s.

see #4119 for more background on this
`Permitted<T>` enum.

so, we should make the `NewRecordBodyData` agnostic to its metrics,
rather than holding a concrete `RequestBodyFamilies<L>`.

this commit hoists the metrics out of the middleware, and into the `X`
and `ReqX` extractors used in the `NewService<T>` and `Service<T>`
layers, respectively.

bear particular attention to this part of the diff:

```diff
-    ReqX: ExtractParam<L, Request<ReqB>>,
-    L: linkerd_metrics::prom::encoding::EncodeLabelSet
-        + std::fmt::Debug
-        + std::hash::Hash
-        + Eq
-        + Clone
-        + Send
-        + Sync
-        + 'static,
+    ReqX: ExtractParam<BodyDataMetrics, Request<ReqB>>,
```

in other words, rather than using `X` and subsequently `ReqX` to extract
our labels `L`, we expect these extractors to yield a `BodyDataMetrics`:
one time series that should be incremented accordingly by the
instrumented request.

in even simpler words: `ReqX` now calls `familes.metrics(&labels)` too.

Signed-off-by: katelyn martin <[email protected]>
@cratelyn cratelyn force-pushed the kate/prepare-request-body-metrics-for-inbound-proxy branch from 13220e8 to 8a313b9 Compare September 24, 2025 01:31
@cratelyn
Copy link
Member Author

this branch has been rebased atop main, now that #4181 has landed.

cratelyn added a commit that referenced this pull request Sep 24, 2025
this commit introduces an additional layer of telemetry to the inbound
proxy's http router.

either http and grpc metrics are used, depending upon the policy that
authorized a given request.

this is based upon #4174, which refactored the
request body telemetry middleware to be metrics agnostic.

see:
* #4165
* #4166
* #4174
* #4127

Signed-off-by: katelyn martin <[email protected]>
cratelyn added a commit that referenced this pull request Sep 24, 2025
this commit introduces an additional layer of telemetry to the inbound
proxy's http router.

either http and grpc metrics are used, depending upon the policy that
authorized a given request.

this is based upon #4174, which refactored the
request body telemetry middleware to be metrics agnostic.

see:
* #4165
* #4166
* #4174
* #4127
* #4186

Signed-off-by: katelyn martin <[email protected]>
cratelyn added a commit that referenced this pull request Sep 24, 2025
this commit introduces an additional layer of telemetry to the inbound
proxy's http router.

either http and grpc metrics are used, depending upon the policy that
authorized a given request.

this is based upon #4174, which refactored the
request body telemetry middleware to be metrics agnostic.

see:
* #4188
* #4187
* #4186
* #4174
* #4165
* #4166
* #4127

Signed-off-by: katelyn martin <[email protected]>
cratelyn added a commit that referenced this pull request Sep 24, 2025
this commit introduces an additional layer of telemetry to the inbound
proxy's http router.

either http and grpc metrics are used, depending upon the policy that
authorized a given request.

this is based upon #4174, which refactored the
request body telemetry middleware to be metrics agnostic.

see:
* #4188
* #4187
* #4186
* #4174
* #4165
* #4166
* #4127

Signed-off-by: katelyn martin <[email protected]>
@cratelyn cratelyn merged commit b8eae44 into main Sep 24, 2025
15 checks passed
@cratelyn cratelyn deleted the kate/prepare-request-body-metrics-for-inbound-proxy branch September 24, 2025 17:59
cratelyn added a commit that referenced this pull request Sep 24, 2025
this commit introduces an additional layer of telemetry to the inbound
proxy's http router.

either http and grpc metrics are used, depending upon the policy that
authorized a given request.

this is based upon #4174, which refactored the
request body telemetry middleware to be metrics agnostic.

see:
* #4188
* #4187
* #4186
* #4174
* #4165
* #4166
* #4127

Signed-off-by: katelyn martin <[email protected]>
cratelyn added a commit that referenced this pull request Sep 24, 2025
this commit introduces an additional layer of telemetry to the inbound
proxy's http router.

either http and grpc metrics are used, depending upon the policy that
authorized a given request.

this is based upon #4174, which refactored the
request body telemetry middleware to be metrics agnostic.

see:
* #4188
* #4187
* #4186
* #4174
* #4165
* #4166
* #4127

Signed-off-by: katelyn martin <[email protected]>
cratelyn added a commit that referenced this pull request Sep 26, 2025
this commit introduces an additional layer of telemetry to the inbound
proxy's http router.

either http and grpc metrics are used, depending upon the policy that
authorized a given request.

this is based upon #4174, which refactored the
request body telemetry middleware to be metrics agnostic.

see:
* #4189
* #4188
* #4187
* #4186
* #4174
* #4165
* #4166
* #4127

Signed-off-by: katelyn martin <[email protected]>
cratelyn added a commit that referenced this pull request Sep 26, 2025
in #4174, we refactored this middleware so that it
is now agnostic to the particular metrics structure used by the
extractor, meaning that the constructor no longer accepts a
`RequestBodyFamilies<L>` parameter.

in the wake of this change, our request body frame size metrics
middleware has a constructor with a type signature like `X -> impl
Layer`.

elsewhere throughout the project, constructors that accept an extractor
and return a `svc::Layer` are typically called `layer_via()`.

this commit renames `NewRecordBodyData::new()` to
`NewRecordBodyData::layer_via()`.

Signed-off-by: katelyn martin <[email protected]>
cratelyn added a commit that referenced this pull request Sep 30, 2025
in #4174, we refactored this middleware so that it
is now agnostic to the particular metrics structure used by the
extractor, meaning that the constructor no longer accepts a
`RequestBodyFamilies<L>` parameter.

in the wake of this change, our request body frame size metrics
middleware has a constructor with a type signature like `X -> impl
Layer`.

elsewhere throughout the project, constructors that accept an extractor
and return a `svc::Layer` are typically called `layer_via()`.

this commit renames `NewRecordBodyData::new()` to
`NewRecordBodyData::layer_via()`.

Signed-off-by: katelyn martin <[email protected]>
cratelyn added a commit that referenced this pull request Sep 30, 2025
in #4174, we refactored this middleware so that it
is now agnostic to the particular metrics structure used by the
extractor, meaning that the constructor no longer accepts a
`RequestBodyFamilies<L>` parameter.

in the wake of this change, our request body frame size metrics
middleware has a constructor with a type signature like `X -> impl
Layer`.

elsewhere throughout the project, constructors that accept an extractor
and return a `svc::Layer` are typically called `layer_via()`.

this commit renames `NewRecordBodyData::new()` to
`NewRecordBodyData::layer_via()`.

Signed-off-by: katelyn martin <[email protected]>
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.

3 participants