Skip to content

docs: fixes to the documentation #102

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

Merged
merged 1 commit into from
Sep 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ Powertools is available in Maven Central. You can use your favourite dependency
<artifactId>powertools-logging</artifactId>
<version>0.3.0-beta</version>
</dependency>
<dependency>
<groupId>software.amazon.lambda</groupId>
<artifactId>powertools-metrics</artifactId>
<version>0.3.0-beta</version>
</dependency>
...
</dependencies>
```
Expand Down Expand Up @@ -51,6 +56,10 @@ And configure the aspectj-maven-plugin to compile-time weave (CTW) the aws-lambd
<groupId>software.amazon.lambda</groupId>
<artifactId>powertools-tracing</artifactId>
</aspectLibrary>
<aspectLibrary>
<groupId>software.amazon.lambda</groupId>
<artifactId>powertools-metrics</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<executions>
Expand Down
26 changes: 14 additions & 12 deletions docs/content/core/metrics.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,18 @@ 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<Object, Object> {

MetricsLogger metricsLogger = PowertoolsMetricsLogger.metricsLogger();

@Override
@PowertoolsMetrics(namespace = "ExampleApplication", service = "booking")
public Object handleRequest(Object input, Context context) {
# highlight-start
// highlight-start
metricsLogger.putDimensions(DimensionSet.of("environment", "prod"));
metricsLogger.putMetric("SuccessfulBooking", 1, Unit.COUNT);
# highlight-end
// highlight-end
...
}
}
Expand Down Expand Up @@ -110,13 +110,13 @@ You can use `putMetadata` for advanced use cases, where you want to metadata as
<strong>This will not be available during metrics visualization</strong> - Use <strong>dimensions</strong> for this purpose
</Note><br/>

```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.
Expand All @@ -131,19 +131,21 @@ 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

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:
Expand Down