File tree 1 file changed +29
-0
lines changed
1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -183,6 +183,35 @@ You can use `putMetadata` for advanced use cases, where you want to metadata as
183
183
184
184
This will be available in CloudWatch Logs to ease operations on high cardinal data.
185
185
186
+ ## Overriding default dimension set
187
+
188
+ By default, all metrics emitted via module captures ` Service ` as one of the default dimension. This is either specified via
189
+ ` POWERTOOLS_SERVICE_NAME ` environment variable or via ` service ` attribute on ` Metrics ` annotation. If you wish to override the default
190
+ Dimension, it can be done via ` #!java MetricsUtils.defaultDimensionSet() ` .
191
+
192
+ === "App.java"
193
+
194
+ ```java hl_lines="8 9 10"
195
+ import software.amazon.lambda.powertools.metrics.Metrics;
196
+ import static software.amazon.lambda.powertools.metrics.MetricsUtils
197
+
198
+ public class App implements RequestHandler<Object, Object> {
199
+
200
+ MetricsLogger metricsLogger = MetricsUtils.metricsLogger();
201
+
202
+ static {
203
+ MetricsUtils.defaultDimensionSet(DimensionSet.of("CustomDimension", "booking"));
204
+ }
205
+
206
+ @Override
207
+ @Metrics(namespace = "ExampleApplication", service = "booking")
208
+ public Object handleRequest(Object input, Context context) {
209
+ ...
210
+ MetricsUtils.withSingleMetric("Metric2", 1, Unit.COUNT, log -> {});
211
+ }
212
+ }
213
+ ```
214
+
186
215
## Creating a metric with a different dimension
187
216
188
217
CloudWatch EMF uses the same dimensions across all your metrics. Use ` withSingleMetric ` if you have a metric that should have different dimensions.
You can’t perform that action at this time.
0 commit comments