The reason I ask is that there are metric logging scenarios where there is no single method available to apply the @metric_scope annotation to.
An example, and the problem I am specifically looking at, is emitting per request metrics from a Flask application. Unless I'm missing something, there is no singular method you can apply the @metric_scope annotation to in Flask.
Instead, you need to create a metric logger in a before_request hook, and then emit metrics in a teardown_request hook, with the metric logger then available to you in the request itself to add additional metrics if desired.
There's some discussion of this in https://github.com/awslabs/aws-embedded-metrics-python/issues/71, but I wanted to ask the question more directly.
The reason I ask is that there are metric logging scenarios where there is no single method available to apply the
@metric_scope
annotation to.An example, and the problem I am specifically looking at, is emitting per request metrics from a Flask application. Unless I'm missing something, there is no singular method you can apply the
@metric_scope
annotation to in Flask.Instead, you need to create a metric logger in a
before_request
hook, and then emit metrics in ateardown_request
hook, with the metric logger then available to you in the request itself to add additional metrics if desired.Is this a supported way to use the package, or am I setting my self up for future pain by depending on the internals of the package?