Skip to content

Commit eb3534f

Browse files
committed
docs(metrics): improve word placement on env vars
1 parent 3cdc27a commit eb3534f

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

docs/core/metrics.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,14 @@ Setting | Description | Environment variable | Constructor parameter
6565
metrics = Metrics(namespace="ServerlessAirline", service="orders") # Sets metric namespace, and service as a metric dimension
6666
```
6767

68-
You can initialize Metrics anywhere in your code - It'll keep track of your aggregate metrics in memory.
6968

7069
### Creating metrics
7170

7271
You can create metrics using `add_metric`, and you can create dimensions for all your aggregate metrics using `add_dimension` method.
7372

73+
!!! tip
74+
You can initialize Metrics in any other module too. It'll keep track of your aggregate metrics in memory to optimize costs (one blob instead of multiples).
75+
7476
=== "Metrics"
7577

7678
```python hl_lines="8"
@@ -334,8 +336,7 @@ CloudWatch EMF uses the same dimensions across all your metrics. Use `single_met
334336

335337
If you prefer not to use `log_metrics` because you might want to encapsulate additional logic when doing so, you can manually flush and clear metrics as follows:
336338

337-
???+ warning
338-
Metrics, dimensions and namespace validation still applies.
339+
!!! warning "Warning: Metrics, dimensions and namespace validation still applies"
339340

340341
=== "manual_metric_serialization.py"
341342

@@ -357,9 +358,14 @@ If you prefer not to use `log_metrics` because you might want to encapsulate add
357358

358359
### Environment variables
359360

361+
!!! tip
362+
Ignore this section, if you are explicitly setting namespace/default dimension via `namespace` and `service` parameters.
363+
364+
For example, `Metrics(namespace=ApplicationName, service=ServiceName)`
365+
360366
Use `POWERTOOLS_METRICS_NAMESPACE` and `POWERTOOLS_SERVICE_NAME` env vars when unit testing your code to ensure metric namespace and dimension objects are created, and your code doesn't fail validation.
361367

362-
=== "shell"
368+
=== "test runner"
363369

364370
```bash
365371
POWERTOOLS_SERVICE_NAME="Example" POWERTOOLS_METRICS_NAMESPACE="Application" python -m pytest
@@ -378,10 +384,6 @@ If you prefer setting environment variable for specific tests, and are using Pyt
378384
...
379385
```
380386

381-
#### TODO - below statement is related to Clearing metrics section ?
382-
383-
> Ignore this, if you are explicitly setting namespace/default dimension via `namespace` and `service` parameters: `metrics = Metrics(namespace=ApplicationName, service=ServiceName)`
384-
385387
### Clearing metrics
386388

387389
`Metrics` keep metrics in memory across multiple instances. If you need to test this behaviour, you can use the following Pytest fixture to ensure metrics are reset incl. cold start:

0 commit comments

Comments
 (0)