Skip to content

Commit 45ffa9d

Browse files
committed
docs: update documentation to use code snippets consistently
1 parent 78c8c3c commit 45ffa9d

File tree

2 files changed

+3
-36
lines changed

2 files changed

+3
-36
lines changed

docs/features/metrics.md

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -509,38 +509,8 @@ You can create multiple dimension sets for your metrics using the `addDimensions
509509

510510
=== "Creating multiple dimension sets"
511511

512-
```typescript
513-
import { Metrics, MetricUnit } from '@aws-lambda-powertools/metrics';
514-
515-
const metrics = new Metrics({
516-
namespace: 'serverlessAirline',
517-
serviceName: 'orders',
518-
defaultDimensions: { environment: 'prod' }
519-
});
520-
521-
export const handler = async () => {
522-
// Add a single dimension to the default dimension set
523-
metrics.addDimension('region', 'us-west-2');
524-
525-
// Add a new dimension set
526-
metrics.addDimensions({
527-
dimension1: "1",
528-
dimension2: "2"
529-
});
530-
531-
// Add another dimension set (addDimensionSet is an alias for addDimensions)
532-
metrics.addDimensionSet({
533-
feature: "booking",
534-
version: "v1"
535-
});
536-
537-
// This will create three dimension sets in the EMF output:
538-
// [["service", "environment", "region"]],
539-
// [["service", "dimension1", "dimension2"]], and
540-
// [["service", "feature", "version"]]
541-
metrics.addMetric('successfulBooking', MetricUnit.Count, 1);
542-
metrics.publishStoredMetrics();
543-
};
512+
```typescript hl_lines="10-25"
513+
--8<-- "examples/snippets/metrics/multiDimensionSets.ts"
544514
```
545515

546516
=== "Example CloudWatch Logs excerpt"

examples/snippets/metrics/multiDimensionSets.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ export const handler = async () => {
2222
version: 'v1',
2323
});
2424

25-
// This will create three dimension sets in the EMF output:
26-
// [["service", "environment", "region"]],
27-
// [["service", "dimension1", "dimension2"]], and
28-
// [["service", "feature", "version"]]
25+
// This will create three dimension sets in the EMF output
2926
metrics.addMetric('successfulBooking', MetricUnit.Count, 1);
3027
metrics.publishStoredMetrics();
3128
};

0 commit comments

Comments
 (0)