Skip to content

Commit 799aa3c

Browse files
authored
docs: fixes to the documentation (#102)
1 parent f99db35 commit 799aa3c

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ Powertools is available in Maven Central. You can use your favourite dependency
2424
<artifactId>powertools-logging</artifactId>
2525
<version>0.3.0-beta</version>
2626
</dependency>
27+
<dependency>
28+
<groupId>software.amazon.lambda</groupId>
29+
<artifactId>powertools-metrics</artifactId>
30+
<version>0.3.0-beta</version>
31+
</dependency>
2732
...
2833
</dependencies>
2934
```
@@ -51,6 +56,10 @@ And configure the aspectj-maven-plugin to compile-time weave (CTW) the aws-lambd
5156
<groupId>software.amazon.lambda</groupId>
5257
<artifactId>powertools-tracing</artifactId>
5358
</aspectLibrary>
59+
<aspectLibrary>
60+
<groupId>software.amazon.lambda</groupId>
61+
<artifactId>powertools-metrics</artifactId>
62+
</aspectLibrary>
5463
</aspectLibraries>
5564
</configuration>
5665
<executions>

docs/content/core/metrics.mdx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,18 @@ You can initialize Metrics anywhere in your code as many times as you need - It'
6565

6666
You can create metrics using `putMetric`, and manually create dimensions for all your aggregate metrics using `add_dimension`.
6767

68-
```java:title=app.py
68+
```java:title=Handler.java
6969
public class PowertoolsMetricsEnabledHandler implements RequestHandler<Object, Object> {
7070

7171
MetricsLogger metricsLogger = PowertoolsMetricsLogger.metricsLogger();
7272

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

113-
```javv:title=Handler.java
113+
```java:title=Handler.java
114114
@PowertoolsMetrics(namespace = "ServerlessAirline", service = "payment")
115115
public APIGatewayProxyResponseEvent handleRequest(Object input, Context context) {
116116
metricsLogger().putMetric("CustomMetric1", 1, Unit.COUNT);
117-
metricsLogger().putMetadata("booking_id", "1234567890"); # highlight-line
118-
117+
metricsLogger().putMetadata("booking_id", "1234567890"); // highlight-line
119118
...
119+
}
120120
```
121121

122122
This will be available in CloudWatch Logs to ease operations on high cardinal data.
@@ -131,19 +131,21 @@ If metrics are provided, and any of the following criteria are not met, `Validat
131131
If you want to ensure that at least one metric is emitted, you can pass `raiseOnEmptyMetrics = true` to the **@PowertoolsMetrics** annotation:
132132

133133
```java:title=Handler.java
134-
@PowertoolsMetrics(raiseOnEmptyMetrics = true)
135-
public Object handleRequest(Object input, Context context) {
136-
...
134+
@PowertoolsMetrics(raiseOnEmptyMetrics = true)
135+
public Object handleRequest(Object input, Context context) {
136+
...
137+
}
137138
```
138139

139140
## Capturing cold start metric
140141

141142
You can capture cold start metrics automatically with `@PowertoolsMetrics` via the `captureColdStart` variable.
142143

143144
```java:title=Handler.java
144-
@PowertoolsMetrics(captureColdStart = true)
145-
public Object handleRequest(Object input, Context context) {
146-
...
145+
@PowertoolsMetrics(captureColdStart = true)
146+
public Object handleRequest(Object input, Context context) {
147+
...
148+
}
147149
```
148150

149151
If it's a cold start invocation, this feature will:

0 commit comments

Comments
 (0)