Skip to content

Feature request: support high resolution metrics #1041

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dreamorosi opened this issue Feb 8, 2023 · 1 comment
Closed

Feature request: support high resolution metrics #1041

dreamorosi opened this issue Feb 8, 2023 · 1 comment
Assignees
Labels
feature-request New feature or request status/staged-major-release This change will go with the next major release v2 Version 2

Comments

@dreamorosi
Copy link
Contributor

Is your feature request related to a problem? Please describe.

Amazon CloudWatch announced support for high resolution metric extraction from structured logs (EMF). Customers can now provide an optional StorageResolution parameter within the EMF specification with a value of 1 or 60 (default) to indicate the desired resolution (in seconds) of the metric.

We should consider adding support for this new optional parameter to Metrics.

The EMF log should have this format:

{
  "_aws": {
    "CloudWatchMetrics": [
      {
        "Metrics": [
          {
            "Name": "Time",
            "Unit": "Milliseconds",
            "StorageResolution": 60 // <- new key
          }
        ],
        ...
      }
    ]
  },
  "Time": 1
}

As part of this issue we should also update the API docs, documentation, and unit/integration tests.

Describe the solution you'd like

import software.amazon.lambda.powertools.metrics.Metrics;
import software.amazon.cloudwatchlogs.emf.logger.MetricsLogger;

public class MetricsEnabledHandler implements RequestHandler<Object, Object> {

    MetricsLogger metricsLogger = MetricsUtils.metricsLogger();

    @Override
    @Metrics(namespace = "ExampleApplication", service = "booking")
    public Object handleRequest(Object input, Context context) {
        // Publish a metric with standard resolution i.e. StorageResolution = 60
        metricsLogger.putMetric("SuccessfulBooking", 1, Unit.COUNT, Resolution.STANDARD);
        // Publish a metric with high resolution i.e. StorageResolution = 1
        metricsLogger.putMetric("SuccessfulBooking", 1, Unit.COUNT, Resolution.HIGH);
        // The last parameter (storage resolution) is optional
        metricsLogger.putMetric("SuccessfulBooking", 1, Unit.COUNT);
    }
}

Describe alternatives you've considered

Additional context

@msailes
Copy link
Contributor

msailes commented Feb 18, 2023

This feature depends on a major version upgrade of aws-embedded-metrics-java v4.1.0.

The upgrade involves a breaking change, described in #944.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request status/staged-major-release This change will go with the next major release v2 Version 2
Projects
Status: Coming soon
Development

Successfully merging a pull request may close this issue.

7 participants