From d162f7d0d12e401fbff97f313b12ae2c2117e210 Mon Sep 17 00:00:00 2001 From: msailes Date: Wed, 23 Sep 2020 10:29:04 +0100 Subject: [PATCH] docs: fixes to the documentation --- README.md | 9 +++++++++ docs/content/core/metrics.mdx | 26 ++++++++++++++------------ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index a82a03d10..71d5ca616 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,11 @@ Powertools is available in Maven Central. You can use your favourite dependency powertools-logging 0.3.0-beta + + software.amazon.lambda + powertools-metrics + 0.3.0-beta + ... ``` @@ -51,6 +56,10 @@ And configure the aspectj-maven-plugin to compile-time weave (CTW) the aws-lambd software.amazon.lambda powertools-tracing + + software.amazon.lambda + powertools-metrics + diff --git a/docs/content/core/metrics.mdx b/docs/content/core/metrics.mdx index f5df760ee..f9f33078a 100644 --- a/docs/content/core/metrics.mdx +++ b/docs/content/core/metrics.mdx @@ -65,7 +65,7 @@ You can initialize Metrics anywhere in your code as many times as you need - It' You can create metrics using `putMetric`, and manually create dimensions for all your aggregate metrics using `add_dimension`. -```java:title=app.py +```java:title=Handler.java public class PowertoolsMetricsEnabledHandler implements RequestHandler { MetricsLogger metricsLogger = PowertoolsMetricsLogger.metricsLogger(); @@ -73,10 +73,10 @@ public class PowertoolsMetricsEnabledHandler implements RequestHandlerThis will not be available during metrics visualization - Use dimensions for this purpose
-```javv:title=Handler.java +```java:title=Handler.java @PowertoolsMetrics(namespace = "ServerlessAirline", service = "payment") public APIGatewayProxyResponseEvent handleRequest(Object input, Context context) { metricsLogger().putMetric("CustomMetric1", 1, Unit.COUNT); - metricsLogger().putMetadata("booking_id", "1234567890"); # highlight-line - + metricsLogger().putMetadata("booking_id", "1234567890"); // highlight-line ... +} ``` This will be available in CloudWatch Logs to ease operations on high cardinal data. @@ -131,9 +131,10 @@ If metrics are provided, and any of the following criteria are not met, `Validat If you want to ensure that at least one metric is emitted, you can pass `raiseOnEmptyMetrics = true` to the **@PowertoolsMetrics** annotation: ```java:title=Handler.java - @PowertoolsMetrics(raiseOnEmptyMetrics = true) - public Object handleRequest(Object input, Context context) { - ... +@PowertoolsMetrics(raiseOnEmptyMetrics = true) +public Object handleRequest(Object input, Context context) { +... +} ``` ## Capturing cold start metric @@ -141,9 +142,10 @@ If you want to ensure that at least one metric is emitted, you can pass `raiseOn You can capture cold start metrics automatically with `@PowertoolsMetrics` via the `captureColdStart` variable. ```java:title=Handler.java - @PowertoolsMetrics(captureColdStart = true) - public Object handleRequest(Object input, Context context) { - ... +@PowertoolsMetrics(captureColdStart = true) +public Object handleRequest(Object input, Context context) { +... +} ``` If it's a cold start invocation, this feature will: