Skip to content

Conversation

@jasgin
Copy link
Contributor

@jasgin jasgin commented Dec 22, 2025

Motivation and Context

Description

See rendered preview

Testing

Checklist

  • 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.

@jasgin jasgin requested review from a team as code owners December 22, 2025 00:46
@github-actions
Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

Copy link
Collaborator

@rcoh rcoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall seems good.

The RFC could definitely be fleshed out a bit more — I don't totally get how it will work with operation specific metrics etc.

#[smithy_metrics(extension)]
#[metrics(flatten)]
operation_metrics: OperationMetrics,
custom_metric: Option<String>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a custom request level metric right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes


The focal struct that users can add to their service as a tower `Layer` for metrics, containing `new` and `builder` methods to get a `MetricsLayer` with the default configuration or a `MetricsLayerBuilder`, respectively. Because the `MetricsLayer` is specific to the struct provided in the type parameter, the `MetricsLayerBuilder` will be a product of the `#[smithy_metrics]` proc macro expansion, responsible for providing methods to customize things like the metrics initialization and setting custom request/response metrics. Contrarily, the `MetricsLayerConfig` along with its builder will be explicitly defined for general configuration not bound to any specific type parameter, such as enabling/disabling default metrics.

Contains a generic type parameter bound by a marker trait with a default of `DefaultMetrics`, which will be a type defined in the library that uses the `#[smithy_metrics]` expansion.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fleshed out this section in the latest commits


- `MetricsLayer::new()` for the default metrics and extensions

- `MetricsLayer::<CustomMetrics>::new()` for the default metrics with potential renaming or additional extensions from attribute proc macros
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is custom metrics here?


A proc macro that can be placed on a metrique metrics struct for purposes such as the addition of default request/response metrics fields, the implementation of a marker trait, and the expansion of a `MetricsLayerBuilder` with concrete type being the annotated struct.

This will also come with `#[smithy_metrics(rename(x = "y"))]` to rename default fields and `#[smithy_metrics(extension)]` to mark struct fields for insertion to the request extensions to be used in custom middleware or operation handlers.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When would you use this rename vs metrique rename?

Copy link
Contributor Author

@jasgin jasgin Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rename is for renaming of the out-of-the-box metrics that will get added to a metrics struct as part of the proc macro expansion (e.g. request_id, service_name, operation_name, etc). Since those fields won't be visible, they'd need to be applied at the outer level and then the expansion will apply the actual metrics rename.

.build();
}

#[smithy_metrics]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably nice to have something like #[smithy_metrics::root], #[smithy_metrics:: operation]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I currently have it like #[smithy_metrics] and #[smithy_metrics(extension)], I can create a bikeshedding thread at the end to flesh these out.


#[metrics]
struct OperationMetrics {
get_pokemon_species_metrics: Option<String>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I need to manually set this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is an example of a user-defined metrics struct for control of metrics in their operation handlers

@aajtodd
Copy link
Contributor

aajtodd commented Jan 5, 2026

This seems specific to metrique, was there not consideration given to our own runtime observability API: https://github.com/smithy-lang/smithy-rs/tree/main/rust-runtime/aws-smithy-observability

@jasgin jasgin force-pushed the rfc0046_server_request_metrics branch from 5ebaf8b to 860daae Compare January 9, 2026 15:27
@jasgin
Copy link
Contributor Author

jasgin commented Jan 9, 2026

Added some more content to the RFC explaining some of the open questions, and added a preliminary implementation of the metrics layer interface.

Yes the design only has metrique in mind. Maybe future scope can extend to aws-smithy-observability as well.

@github-actions
Copy link

github-actions bot commented Jan 9, 2026

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • Client Test (ignoring whitespace)
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@github-actions
Copy link

github-actions bot commented Jan 9, 2026

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • Client Test (ignoring whitespace)
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • Client Test (ignoring whitespace)
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • Client Test (ignoring whitespace)
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@jasgin jasgin force-pushed the rfc0046_server_request_metrics branch 3 times, most recently from 0dde16e to 0b97c30 Compare January 11, 2026 21:05
@jasgin jasgin force-pushed the rfc0046_server_request_metrics branch from 0b97c30 to 5654ba7 Compare January 11, 2026 21:10
@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@jasgin jasgin force-pushed the rfc0046_server_request_metrics branch from 3c5802d to c506136 Compare January 12, 2026 00:59
@github-actions
Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • Client Test (ignoring whitespace)
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • Client Test (ignoring whitespace)
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@jasgin jasgin force-pushed the rfc0046_server_request_metrics branch from ba8bcac to a6c26fb Compare January 12, 2026 04:24
@github-actions
Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • Client Test (ignoring whitespace)
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@jasgin jasgin force-pushed the rfc0046_server_request_metrics branch from b6a1b9b to 1fdb9fe Compare January 12, 2026 14:02
@github-actions
Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • Client Test (ignoring whitespace)
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

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