Skip to content

Commit 2539fbb

Browse files
committed
docs: switched to serviceName according to #401
1 parent ac7587a commit 2539fbb

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

Diff for: docs/core/metrics.md

+17-17
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ For a **complete list** of supported environment variables, refer to [this secti
7474
// You can also pass the parameters in the constructor
7575
// const metrics = new Metrics({
7676
// namespace: 'serverlessAirline',
77-
// service: 'orders'
77+
// serviceName: 'orders'
7878
// });
7979
```
8080

@@ -103,7 +103,7 @@ You can create metrics using the `addMetric` method, and you can create dimensio
103103
```typescript hl_lines="6"
104104
import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
105105

106-
const metrics = new Metrics({ namespace: 'serverlessAirline', service: 'orders' });
106+
const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
107107

108108
export const handler = async (_event: any, _context: any) => {
109109
metrics.addMetric('successfulBooking', MetricUnits.Count, 1);
@@ -116,7 +116,7 @@ You can create metrics using the `addMetric` method, and you can create dimensio
116116
```typescript hl_lines="6-7"
117117
import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
118118

119-
const metrics = new Metrics({ namespace: 'serverlessAirline', service: 'orders' });
119+
const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
120120

121121
export const handler = async (_event: any, _context: any) => {
122122
metrics.addDimension('environment', 'prod');
@@ -144,7 +144,7 @@ You can call `addMetric()` with the same name multiple times. The values will be
144144
import { Context } from 'aws-lambda';
145145

146146

147-
const metrics = new Metrics({namespace:"serverlessAirline", service:"orders"});
147+
const metrics = new Metrics({namespace:"serverlessAirline", serviceName:"orders"});
148148

149149
export const handler = async (event: any, context: Context) => {
150150
metrics.addMetric('performedActionA', MetricUnits.Count, 2);
@@ -198,7 +198,7 @@ You can add default dimensions to your metrics by passing them as parameters in
198198

199199
const metrics = new Metrics({
200200
namespace: 'serverlessAirline',
201-
service: 'orders',
201+
serviceName: 'orders',
202202
defaultDimensions: { 'environment': 'prod', 'foo': 'bar' }
203203
});
204204

@@ -219,7 +219,7 @@ You can add default dimensions to your metrics by passing them as parameters in
219219
import { Metrics, MetricUnits, logMetrics } from '@aws-lambda-powertools/metrics';
220220
import middy from '@middy/core';
221221

222-
const metrics = new Metrics({ namespace: 'serverlessAirline', service: 'orders' });
222+
const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
223223

224224
const lambdaHandler = async (_event: any, _context: any) => {
225225
metrics.addMetric('successfulBooking', MetricUnits.Count, 1);
@@ -236,7 +236,7 @@ You can add default dimensions to your metrics by passing them as parameters in
236236
```typescript hl_lines="4"
237237
import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
238238

239-
const metrics = new Metrics({ namespace: 'serverlessAirline', service: 'orders' });
239+
const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
240240
metrics.setDefaultDimensions({ 'environment': 'prod', 'foo': 'bar' });
241241

242242
export const handler = async (event: any, _context: any) => {
@@ -250,7 +250,7 @@ You can add default dimensions to your metrics by passing them as parameters in
250250
import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
251251
import { LambdaInterface } from '@aws-lambda-powertools/commons';
252252

253-
const metrics = new Metrics({ namespace: 'serverlessAirline', service: 'orders' });
253+
const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
254254
const DEFAULT_DIMENSIONS = { 'environment': 'prod', 'foo': 'bar' };
255255

256256
export class MyFunction implements LambdaInterface {
@@ -297,7 +297,7 @@ You can manually flush the metrics with `publishStoredMetrics` as follows:
297297
```typescript hl_lines="7"
298298
import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
299299

300-
const metrics = new Metrics({ namespace: 'serverlessAirline', service: 'orders' });
300+
const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
301301

302302
export const handler = async (_event: any, _context: any) => {
303303
metrics.addMetric('successfulBooking', MetricUnits.Count, 10);
@@ -343,7 +343,7 @@ See below an example of how to automatically flush metrics with the Middy-compat
343343
import { Metrics, MetricUnits, logMetrics } from '@aws-lambda-powertools/metrics';
344344
import middy from '@middy/core';
345345

346-
const metrics = new Metrics({ namespace: 'serverlessAirline', service: 'orders' });
346+
const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
347347

348348
const lambdaHandler = async (_event: any, _context: any) => {
349349
metrics.addMetric('successfulBooking', MetricUnits.Count, 1);
@@ -394,7 +394,7 @@ The `logMetrics` decorator of the metrics utility can be used when your Lambda h
394394
import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
395395
import { LambdaInterface } from '@aws-lambda-powertools/commons';
396396

397-
const metrics = new Metrics({ namespace: 'serverlessAirline', service: 'orders' });
397+
const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
398398

399399
export class MyFunction implements LambdaInterface {
400400

@@ -439,7 +439,7 @@ If you want to ensure that at least one metric is emitted before you flush them,
439439
import { Metrics, MetricUnits, logMetrics } from '@aws-lambda-powertools/metrics';
440440
import middy from '@middy/core';
441441

442-
const metrics = new Metrics({ namespace: 'serverlessAirline', service: 'orders' });
442+
const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
443443

444444
const lambdaHandler = async (_event: any, _context: any) => {
445445
metrics.addMetric('successfulBooking', MetricUnits.Count, 1);
@@ -459,7 +459,7 @@ You can optionally capture cold start metrics with the `logMetrics` middleware o
459459
import { Metrics, MetricUnits, logMetrics } from '@aws-lambda-powertools/metrics';
460460
import middy from '@middy/core';
461461

462-
const metrics = new Metrics({ namespace: 'serverlessAirline', service: 'orders' });
462+
const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
463463

464464
const lambdaHandler = async (_event: any, _context: any) => {
465465
metrics.addMetric('successfulBooking', MetricUnits.Count, 1);
@@ -475,7 +475,7 @@ You can optionally capture cold start metrics with the `logMetrics` middleware o
475475
import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
476476
import { LambdaInterface } from '@aws-lambda-powertools/commons';
477477

478-
const metrics = new Metrics({namespace: 'serverlessAirline', service: 'orders' });
478+
const metrics = new Metrics({namespace: 'serverlessAirline', serviceName: 'orders' });
479479

480480
export class MyFunction implements LambdaInterface {
481481

@@ -510,7 +510,7 @@ You can add high-cardinality data as part of your Metrics log with the `addMetad
510510
import { Metrics, MetricUnits, logMetrics } from '@aws-lambda-powertools/metrics';
511511
import middy from '@middy/core';
512512

513-
const metrics = new Metrics({ namespace: 'serverlessAirline', service: 'orders' });
513+
const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
514514

515515
const lambdaHandler = async (_event: any, _context: any) => {
516516
metrics.addMetric('successfulBooking', MetricUnits.Count, 1);
@@ -574,7 +574,7 @@ CloudWatch EMF uses the same dimensions across all your metrics. Use `singleMetr
574574
import { Metrics, MetricUnits, logMetrics } from '@aws-lambda-powertools/metrics';
575575
import middy from '@middy/core';
576576

577-
const metrics = new Metrics({ namespace: 'serverlessAirline', service: 'orders' });
577+
const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
578578

579579
const lambdaHandler = async (_event: any, _context: any) => {
580580
metrics.addDimension('metricUnit', 'milliseconds');
@@ -597,7 +597,7 @@ CloudWatch EMF uses the same dimensions across all your metrics. Use `singleMetr
597597
import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
598598
import { LambdaInterface } from '@aws-lambda-powertools/commons';
599599

600-
const metrics = new Metrics({ namespace: 'serverlessAirline', service: 'orders' });
600+
const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
601601

602602
class Lambda implements LambdaInterface {
603603

0 commit comments

Comments
 (0)