You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat(metrics): introduce Metrics.flushMetrics
- introduce `Metrics.flushMetrics` as a more powerful version of `flushSingleMetrics` to allow
- using defaults by inheriting state e.g. namespace, dimensions and metadata
- emitting multiple metrics in one metrics context
- refactor `flushSingleMetrics` to use `flushMetrics`
- move namespace/service setting from `MetricsFactory` to `EmfMetricsLogger`
* feat(metrics): introduce Metrics.flushMetrics
- introduce `Metrics.flushMetrics` as a more powerful version of `flushSingleMetrics` to allow
- using defaults by inheriting state e.g. namespace, dimensions and metadata
- emitting multiple metrics in one metrics context
- refactor `flushSingleMetrics` to use `flushMetrics`
- move namespace/service setting from `MetricsFactory` to `EmfMetricsLogger`
* address metrics context issue
* fix addDimension wrongly adding to defaultDimensions
* introduce Metrics.addProperty and use it instead of addMetadata
* use flushMetrics in captureColdStartMetric
* use putProperty for addMetadata and consolidate duplicate logic
* update docs and javadoc
* Update docs/core/metrics.md
Co-authored-by: Philipp Page <philipp.page@yahoo.de>
---------
Co-authored-by: Philipp Page <philipp.page@yahoo.de>
Copy file name to clipboardExpand all lines: docs/core/metrics.md
+17-13Lines changed: 17 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -462,9 +462,9 @@ If you wish to set custom default dimensions, it can be done via `#!java metrics
462
462
Overwriting the default dimensions will also overwrite the default `Service` dimension. If you wish to keep `Service` in your default dimensions, you need to add it manually.
463
463
<!-- prettier-ignore-end -->
464
464
465
-
### Creating a single metric with different configuration
465
+
### Creating metrics with different configuration
466
466
467
-
You can create a single metric with its own namespace and dimensions using `flushSingleMetric`:
467
+
You can create metrics with different configurations e.g. different namespace and/or dimensions using `flushMetrics()`:
468
468
469
469
=== "App.java"
470
470
@@ -480,13 +480,17 @@ You can create a single metric with its own namespace and dimensions using `flus
480
480
@Override
481
481
@FlushMetrics(namespace = "ServerlessAirline", service = "payment")
482
482
public Object handleRequest(Object input, Context context) {
483
-
metrics.flushSingleMetric(
484
-
"CustomMetric",
485
-
1,
486
-
MetricUnit.COUNT,
487
-
"CustomNamespace",
488
-
DimensionSet.of("CustomDimension", "value") // Dimensions are optional
* Flush a single metric with custom dimensions. This creates a separate metrics context
166
+
* Flush a separate metrics context that inherits the namespace, default dimensions, and metadata. This creates a separate metrics context
167
+
* that doesn't affect the default metrics context.
168
+
*
169
+
* @param metricsConsumer the consumer to use to edit the metrics instance (e.g. add metrics, override namespace, set or add custom dimensions) before flushing
Copy file name to clipboardExpand all lines: powertools-metrics/src/main/java/software/amazon/lambda/powertools/metrics/internal/LambdaMetricsAspect.java
0 commit comments