Skip to content

Commit c5041e6

Browse files
authored
Rename default server metrics (#4544)
## Motivation and Context <!--- Why is this change required? What problem does it solve? --> <!--- If it fixes an open issue, please link to the issue here --> ## Description <!--- Describe your changes in detail --> ## Testing <!--- Please describe in detail how you tested your changes --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> ## Checklist <!--- If a checkbox below is not applicable, then please DELETE it rather than leaving it unchecked --> - [ ] For changes to the smithy-rs codegen or runtime crates, I have created a changelog entry Markdown file in the `.changelog` directory, specifying "client," "server," or both in the `applies_to` key. - [ ] For changes to the AWS SDK, generated SDK code, or SDK runtime crates, I have created a changelog entry Markdown file in the `.changelog` directory, specifying "aws-sdk-rust" in the `applies_to` key. ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
1 parent fa1e846 commit c5041e6

File tree

5 files changed

+25
-29
lines changed

5 files changed

+25
-29
lines changed

examples/pokemon-service/tests/snapshots/metrics_test__metrics_content_via_tcp.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
source: pokemon-service/tests/metrics_test.rs
33
expression: metrics_output
44
---
5-
{"_aws":{"CloudWatchMetrics":[{"Namespace":"Ns","Dimensions":[[]],"Metrics":[{"Name":"found"},{"Name":"outstanding_requests"},{"Name":"http_status_code"},{"Name":"error"},{"Name":"fault"},{"Name":"operation_time","Unit":"Milliseconds"}]}],"Timestamp":"[timestamp]},"found":1,"outstanding_requests":1,"http_status_code":200,"error":0,"fault":0,"operation_time":"[operation_time],"test_request_metric":"test request metric","test_response_metric":"test response metric","requested_pokemon_name":"pikachu","service_name":"PokemonService","service_version":"2024-03-18","operation_name":"GetPokemonSpecies","request_id":"[request_id]}
6-
{"_aws":{"CloudWatchMetrics":[{"Namespace":"Ns","Dimensions":[[]],"Metrics":[{"Name":"authenticated"},{"Name":"outstanding_requests"},{"Name":"http_status_code"},{"Name":"error"},{"Name":"fault"},{"Name":"operation_time","Unit":"Milliseconds"}]}],"Timestamp":"[timestamp]},"authenticated":0,"outstanding_requests":1,"http_status_code":401,"error":1,"fault":0,"operation_time":"[operation_time],"test_request_metric":"test request metric","test_response_metric":"test response metric","user":"ash","service_name":"PokemonService","service_version":"2024-03-18","operation_name":"GetStorage","request_id":"[request_id]}
7-
{"_aws":{"CloudWatchMetrics":[{"Namespace":"Ns","Dimensions":[[]],"Metrics":[{"Name":"supported_region"},{"Name":"outstanding_requests"},{"Name":"http_status_code"},{"Name":"error"},{"Name":"fault"},{"Name":"operation_time","Unit":"Milliseconds"}]}],"Timestamp":"[timestamp]},"supported_region":0,"outstanding_requests":1,"http_status_code":500,"error":0,"fault":1,"operation_time":"[operation_time],"test_request_metric":"test request metric","test_response_metric":"test response metric","requested_region":"trigger500","service_name":"PokemonService","service_version":"2024-03-18","operation_name":"CapturePokemon","request_id":"[request_id]}
5+
{"_aws":{"CloudWatchMetrics":[{"Namespace":"Ns","Dimensions":[[]],"Metrics":[{"Name":"found"},{"Name":"outstanding_requests"},{"Name":"http_status_code"},{"Name":"error"},{"Name":"fault"},{"Name":"operation_time","Unit":"Milliseconds"}]}],"Timestamp":"[timestamp]},"found":1,"outstanding_requests":1,"http_status_code":200,"error":0,"fault":0,"operation_time":"[operation_time],"test_request_metric":"test request metric","test_response_metric":"test response metric","requested_pokemon_name":"pikachu","service":"PokemonService","service_version":"2024-03-18","operation":"GetPokemonSpecies","request_id":"[request_id]}
6+
{"_aws":{"CloudWatchMetrics":[{"Namespace":"Ns","Dimensions":[[]],"Metrics":[{"Name":"authenticated"},{"Name":"outstanding_requests"},{"Name":"http_status_code"},{"Name":"error"},{"Name":"fault"},{"Name":"operation_time","Unit":"Milliseconds"}]}],"Timestamp":"[timestamp]},"authenticated":0,"outstanding_requests":1,"http_status_code":401,"error":1,"fault":0,"operation_time":"[operation_time],"test_request_metric":"test request metric","test_response_metric":"test response metric","user":"ash","service":"PokemonService","service_version":"2024-03-18","operation":"GetStorage","request_id":"[request_id]}
7+
{"_aws":{"CloudWatchMetrics":[{"Namespace":"Ns","Dimensions":[[]],"Metrics":[{"Name":"supported_region"},{"Name":"outstanding_requests"},{"Name":"http_status_code"},{"Name":"error"},{"Name":"fault"},{"Name":"operation_time","Unit":"Milliseconds"}]}],"Timestamp":"[timestamp]},"supported_region":0,"outstanding_requests":1,"http_status_code":500,"error":0,"fault":1,"operation_time":"[operation_time],"test_request_metric":"test request metric","test_response_metric":"test response metric","requested_region":"trigger500","service":"PokemonService","service_version":"2024-03-18","operation":"CapturePokemon","request_id":"[request_id]}

rust-runtime/aws-smithy-http-server-metrics/src/default.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ impl Debug for DefaultMetrics {
5353
#[metrics]
5454
#[derive(Debug, Default)]
5555
pub struct DefaultRequestMetrics {
56-
pub(crate) service_name: Option<String>,
56+
pub(crate) service: Option<String>,
5757
pub(crate) service_version: Option<String>,
58-
pub(crate) operation_name: Option<String>,
58+
pub(crate) operation: Option<String>,
5959
pub(crate) request_id: Option<String>,
6060
pub(crate) outstanding_requests: Option<usize>,
6161
}
@@ -82,8 +82,8 @@ pub struct DefaultResponseMetrics {
8282
pub struct DefaultRequestMetricsConfig {
8383
pub(crate) disable_all: bool,
8484
pub(crate) disable_request_id: bool,
85-
pub(crate) disable_operation_name: bool,
86-
pub(crate) disable_service_name: bool,
85+
pub(crate) disable_operation: bool,
86+
pub(crate) disable_service: bool,
8787
pub(crate) disable_service_version: bool,
8888
pub(crate) disable_outstanding_requests: bool,
8989
}

rust-runtime/aws-smithy-http-server-metrics/src/layer/builder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ macro_rules! impl_disable_methods {
5151
}
5252

5353
/// Disable the `operation_name` metric
54-
pub fn disable_default_operation_name_metric(mut self) -> Self {
55-
self.default_req_metrics_config.disable_operation_name = true;
54+
pub fn disable_default_operation_metric(mut self) -> Self {
55+
self.default_req_metrics_config.disable_operation = true;
5656
self
5757
}
5858

5959
/// Disable the `service_name` metric
60-
pub fn disable_default_service_name_metric(mut self) -> Self {
61-
self.default_req_metrics_config.disable_service_name = true;
60+
pub fn disable_default_service_metric(mut self) -> Self {
61+
self.default_req_metrics_config.disable_service = true;
6262
self
6363
}
6464

rust-runtime/aws-smithy-http-server-metrics/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
//! vec![
4949
//! vec![],
5050
//! vec![
51-
//! "service_name".to_string(),
51+
//! "service".to_string(),
5252
//! "service_version".to_string(),
53-
//! "operation_name".to_string(),
53+
//! "operation".to_string(),
5454
//! ],
5555
//! ],
5656
//! )
@@ -162,9 +162,9 @@
162162
//!
163163
//! | Metric | Description |
164164
//! |--------|-------------|
165-
//! | `service_name` | Name of the service |
165+
//! | `service` | Name of the service |
166166
//! | `service_version` | Version of the service |
167-
//! | `operation_name` | Name of the operation being invoked |
167+
//! | `operation` | Name of the operation being invoked |
168168
//! | `request_id` | Unique identifier for the request |
169169
//! | `outstanding_requests` | Number of concurrent requests counting any operation being processing in that moment |
170170
//!

rust-runtime/aws-smithy-http-server-metrics/src/plugin.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ where
169169
fn apply(&self, inner: T) -> Self::Output {
170170
DefaultMetricsPluginService {
171171
inner,
172-
service_name: Ser::ID.name(),
172+
service: Ser::ID.name(),
173173
service_version: Ser::VERSION,
174-
operation_name: Op::ID.name(),
174+
operation: Op::ID.name(),
175175
}
176176
}
177177
}
@@ -184,9 +184,9 @@ where
184184
#[derive(Debug)]
185185
pub struct DefaultMetricsPluginService<Ser> {
186186
inner: Ser,
187-
service_name: &'static str,
187+
service: &'static str,
188188
service_version: Option<&'static str>,
189-
operation_name: &'static str,
189+
operation: &'static str,
190190
}
191191

192192
impl<Ser> Clone for DefaultMetricsPluginService<Ser>
@@ -196,8 +196,8 @@ where
196196
fn clone(&self) -> Self {
197197
Self {
198198
inner: self.inner.clone(),
199-
operation_name: self.operation_name,
200-
service_name: self.service_name,
199+
operation: self.operation,
200+
service: self.service,
201201
service_version: self.service_version,
202202
}
203203
}
@@ -212,9 +212,9 @@ where
212212
/// Assigns None to those that need information from the outer metrics layer to be set
213213
fn get_default_request_metrics(&self, req: &HttpRequest) -> DefaultRequestMetrics {
214214
DefaultRequestMetrics {
215-
service_name: Some(self.service_name.to_string()),
215+
service: Some(self.service.to_string()),
216216
service_version: self.service_version.map(|n| n.to_string()),
217-
operation_name: Some(self.operation_name.to_string()),
217+
operation: Some(self.operation.to_string()),
218218
request_id: req
219219
.extensions()
220220
.get::<ServerRequestId>()
@@ -343,15 +343,11 @@ fn extend_default_request_metrics(
343343
);
344344

345345
DefaultRequestMetrics {
346-
service_name: metrics
347-
.service_name
348-
.filter(|_| !config.disable_service_name),
346+
service: metrics.service.filter(|_| !config.disable_service),
349347
service_version: metrics
350348
.service_version
351349
.filter(|_| !config.disable_service_version),
352-
operation_name: metrics
353-
.operation_name
354-
.filter(|_| !config.disable_operation_name),
350+
operation: metrics.operation.filter(|_| !config.disable_operation),
355351
request_id: metrics.request_id.filter(|_| !config.disable_request_id),
356352
outstanding_requests,
357353
}

0 commit comments

Comments
 (0)