@@ -65,18 +65,18 @@ You can initialize Metrics anywhere in your code as many times as you need - It'
6565
6666You 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
6969public 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" )
115115public 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
122122This 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
131131If 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
141142You 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
149151If it's a cold start invocation, this feature will:
0 commit comments