Skip to content

Commit f0dcb8f

Browse files
docs(navigation): standardize link targets to enhance customer experience (aws-powertools#2420)
Co-authored-by: erikayao93 <[email protected]>
1 parent 824912b commit f0dcb8f

18 files changed

+146
-145
lines changed

docs/core/event_handler/api_gateway.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ When using Amazon Application Load Balancer (ALB) to front your Lambda functions
102102

103103
#### Lambda Function URL
104104

105-
When using [AWS Lambda Function URL](https://docs.aws.amazon.com/lambda/latest/dg/urls-configuration.html), you can use `LambdaFunctionUrlResolver`.
105+
When using [AWS Lambda Function URL](https://docs.aws.amazon.com/lambda/latest/dg/urls-configuration.html){target="_blank"}, you can use `LambdaFunctionUrlResolver`.
106106

107107
=== "getting_started_lambda_function_url_resolver.py"
108108

@@ -253,7 +253,7 @@ When using [Custom Domain API Mappings feature](https://docs.aws.amazon.com/apig
253253

254254
**Scenario**: You have a custom domain `api.mydomain.dev`. Then you set `/payment` API Mapping to forward any payment requests to your Payments API.
255255

256-
**Challenge**: This means your `path` value for any API requests will always contain `/payment/<actual_request>`, leading to HTTP 404 as Event Handler is trying to match what's after `payment/`. This gets further complicated with an [arbitrary level of nesting](https://github.com/awslabs/aws-lambda-powertools-roadmap/issues/34).
256+
**Challenge**: This means your `path` value for any API requests will always contain `/payment/<actual_request>`, leading to HTTP 404 as Event Handler is trying to match what's after `payment/`. This gets further complicated with an [arbitrary level of nesting](https://github.com/awslabs/aws-lambda-powertools-roadmap/issues/34){target="_blank"}.
257257

258258
To address this API Gateway behavior, we use `strip_prefixes` parameter to account for these prefixes that are now injected into the path regardless of which type of API Gateway you're using.
259259

@@ -344,7 +344,7 @@ You can use the `Response` class to have full control over the response. For exa
344344
Some event sources require headers and cookies to be encoded as `multiValueHeaders`.
345345

346346
???+ warning "Using multiple values for HTTP headers in ALB?"
347-
Make sure you [enable the multi value headers feature](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html#multi-value-headers) to serialize response headers correctly.
347+
Make sure you [enable the multi value headers feature](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html#multi-value-headers){target="_blank"} to serialize response headers correctly.
348348

349349
=== "fine_grained_responses.py"
350350

@@ -420,7 +420,7 @@ Like `compress` feature, the client must send the `Accept` header with the corre
420420

421421
### Debug mode
422422

423-
You can enable debug mode via `debug` param, or via `POWERTOOLS_DEV` [environment variable](../../index.md#environment-variables).
423+
You can enable debug mode via `debug` param, or via `POWERTOOLS_DEV` [environment variable](../../index.md#environment-variables){target="_blank"}.
424424

425425
This will enable full tracebacks errors in the response, print request and responses, and set CORS in development mode.
426426

docs/core/logger.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ You can set a Correlation ID using `correlation_id_path` param by passing a [JME
108108

109109
#### set_correlation_id method
110110

111-
You can also use `set_correlation_id` method to inject it anywhere else in your code. Example below uses [Event Source Data Classes utility](../utilities/data_classes.md) to easily access events properties.
111+
You can also use `set_correlation_id` method to inject it anywhere else in your code. Example below uses [Event Source Data Classes utility](../utilities/data_classes.md){target="_blank"} to easily access events properties.
112112

113113
=== "set_correlation_id_method.py"
114114

@@ -242,7 +242,7 @@ You can remove any additional key from Logger state using `remove_keys`.
242242

243243
#### Clearing all state
244244

245-
Logger is commonly initialized in the global scope. Due to [Lambda Execution Context reuse](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-context.html), this means that custom keys can be persisted across invocations. If you want all custom keys to be deleted, you can use `clear_state=True` param in `inject_lambda_context` decorator.
245+
Logger is commonly initialized in the global scope. Due to [Lambda Execution Context reuse](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-context.html){target="_blank"}, this means that custom keys can be persisted across invocations. If you want all custom keys to be deleted, you can use `clear_state=True` param in `inject_lambda_context` decorator.
246246

247247
???+ tip "Tip: When is this useful?"
248248
It is useful when you add multiple custom keys conditionally, instead of setting a default `None` value if not present. Any key with `None` value is automatically removed by Logger.
@@ -360,7 +360,7 @@ You can use any of the following built-in JMESPath expressions as part of [injec
360360

361361
### Reusing Logger across your code
362362

363-
Similar to [Tracer](./tracer.md#reusing-tracer-across-your-code), a new instance that uses the same `service` name - env var or explicit parameter - will reuse a previous Logger instance. Just like `logging.getLogger("logger_name")` would in the standard library if called with the same logger name.
363+
Similar to [Tracer](./tracer.md#reusing-tracer-across-your-code){target="_blank"}, a new instance that uses the same `service` name - env var or explicit parameter - will reuse a previous Logger instance. Just like `logging.getLogger("logger_name")` would in the standard library if called with the same logger name.
364364

365365
Notice in the CloudWatch Logs output how `payment_id` appeared as expected when logging in `collect.py`.
366366

@@ -407,7 +407,7 @@ You can use values ranging from `0.0` to `1` (100%) when setting `POWERTOOLS_LOG
407407
Sampling decision happens at the Logger initialization. This means sampling may happen significantly more or less than depending on your traffic patterns, for example a steady low number of invocations and thus few cold starts.
408408

409409
???+ note
410-
Open a [feature request](https://github.com/awslabs/aws-lambda-powertools-python/issues/new?assignees=&labels=feature-request%2C+triage&template=feature_request.md&title=) if you want Logger to calculate sampling for every invocation
410+
Open a [feature request](https://github.com/awslabs/aws-lambda-powertools-python/issues/new?assignees=&labels=feature-request%2C+triage&template=feature_request.md&title=){target="_blank"} if you want Logger to calculate sampling for every invocation
411411

412412
=== "sampling_debug_logs.py"
413413

@@ -744,4 +744,4 @@ Here's an example where we persist `payment_id` not `request_id`. Note that `pay
744744
<!-- markdownlint-disable MD013 -->
745745
### How do I aggregate and search Powertools for AWS Lambda (Python) logs across accounts?
746746

747-
As of now, ElasticSearch (ELK) or 3rd party solutions are best suited to this task. Please refer to this [discussion for more details](https://github.com/awslabs/aws-lambda-powertools-python/issues/460)
747+
As of now, ElasticSearch (ELK) or 3rd party solutions are best suited to this task. Please refer to this [discussion for more details](https://github.com/awslabs/aws-lambda-powertools-python/issues/460){target="_blank"}

docs/core/metrics.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ title: Metrics
33
description: Core utility
44
---
55

6-
Metrics creates custom metrics asynchronously by logging metrics to standard output following [Amazon CloudWatch Embedded Metric Format (EMF)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Embedded_Metric_Format.html).
6+
Metrics creates custom metrics asynchronously by logging metrics to standard output following [Amazon CloudWatch Embedded Metric Format (EMF)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Embedded_Metric_Format.html){target="_blank"}.
77

8-
These metrics can be visualized through [Amazon CloudWatch Console](https://console.aws.amazon.com/cloudwatch/).
8+
These metrics can be visualized through [Amazon CloudWatch Console](https://console.aws.amazon.com/cloudwatch/){target="_blank"}.
99

1010
## Key features
1111

@@ -22,7 +22,7 @@ If you're new to Amazon CloudWatch, there are two terminologies you must be awar
2222
* **Dimensions**. Metrics metadata in key-value format. They help you slice and dice metrics visualization, for example `ColdStart` metric by Payment `service`.
2323
* **Metric**. It's the name of the metric, for example: `SuccessfulBooking` or `UpdatedBooking`.
2424
* **Unit**. It's a value representing the unit of measure for the corresponding metric, for example: `Count` or `Seconds`.
25-
* **Resolution**. It's a value representing the storage resolution for the corresponding metric. Metrics can be either Standard or High resolution. Read more [here](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/publishingMetrics.html#high-resolution-metrics).
25+
* **Resolution**. It's a value representing the storage resolution for the corresponding metric. Metrics can be either Standard or High resolution. Read more [here](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/publishingMetrics.html#high-resolution-metrics){target="_blank"}.
2626

2727
<figure>
2828
<img src="../../media/metrics_terminology.png" />
@@ -83,7 +83,7 @@ You can create metrics using `add_metric`, and you can create dimensions for all
8383

8484
### Adding high-resolution metrics
8585

86-
You can create [high-resolution metrics](https://aws.amazon.com/about-aws/whats-new/2023/02/amazon-cloudwatch-high-resolution-metric-extraction-structured-logs/) passing `resolution` parameter to `add_metric`.
86+
You can create [high-resolution metrics](https://aws.amazon.com/about-aws/whats-new/2023/02/amazon-cloudwatch-high-resolution-metric-extraction-structured-logs/){target="_blank"} passing `resolution` parameter to `add_metric`.
8787

8888
???+ tip "When is it useful?"
8989
High-resolution metrics are data with a granularity of one second and are very useful in several situations such as telemetry, time series, real-time incident management, and others.
@@ -154,7 +154,7 @@ This decorator also **validates**, **serializes**, and **flushes** all your metr
154154

155155
* Maximum of 29 user-defined dimensions
156156
* Namespace is set, and no more than one
157-
* Metric units must be [supported by CloudWatch](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDatum.html)
157+
* Metric units must be [supported by CloudWatch](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDatum.html){target="_blank"}
158158

159159
#### Raising SchemaValidationError on empty metrics
160160

@@ -191,7 +191,7 @@ If it's a cold start invocation, this feature will:
191191
This has the advantage of keeping cold start metric separate from your application metrics, where you might have unrelated dimensions.
192192

193193
???+ info
194-
We do not emit 0 as a value for ColdStart metric for cost reasons. [Let us know](https://github.com/awslabs/aws-lambda-powertools-python/issues/new?assignees=&labels=feature-request%2C+triage&template=feature_request.md&title=) if you'd prefer a flag to override it.
194+
We do not emit 0 as a value for ColdStart metric for cost reasons. [Let us know](https://github.com/awslabs/aws-lambda-powertools-python/issues/new?assignees=&labels=feature-request%2C+triage&template=feature_request.md&title=){target="_blank"} if you'd prefer a flag to override it.
195195

196196
## Advanced
197197

@@ -219,7 +219,7 @@ You can add high-cardinality data as part of your Metrics log with `add_metadata
219219
CloudWatch EMF uses the same dimensions across all your metrics. Use `single_metric` if you have a metric that should have different dimensions.
220220

221221
???+ info
222-
Generally, this would be an edge case since you [pay for unique metric](https://aws.amazon.com/cloudwatch/pricing). Keep the following formula in mind:
222+
Generally, this would be an edge case since you [pay for unique metric](https://aws.amazon.com/cloudwatch/pricing){target="_blank"}. Keep the following formula in mind:
223223

224224
**unique metric = (metric_name + dimension_name + dimension_value)**
225225

@@ -292,7 +292,7 @@ The former creates metrics asynchronously via CloudWatch Logs, and the latter us
292292
!!! important "Key concept"
293293
CloudWatch [considers a metric unique](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Metric){target="_blank"} by a combination of metric **name**, metric **namespace**, and zero or more metric **dimensions**.
294294

295-
With EMF, metric dimensions are shared with any metrics you define. With `PutMetricData` API, you can set a [list](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDatum.html) defining one or more metrics with distinct dimensions.
295+
With EMF, metric dimensions are shared with any metrics you define. With `PutMetricData` API, you can set a [list](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDatum.html){target="_blank"} defining one or more metrics with distinct dimensions.
296296

297297
This is a subtle yet important distinction. Imagine you had the following metrics to emit:
298298

@@ -329,7 +329,7 @@ That is why `Metrics` shares data across instances by default, as that covers 80
329329

330330
For example, `Metrics(namespace="ServerlessAirline", service="booking")`
331331

332-
Make sure to set `POWERTOOLS_METRICS_NAMESPACE` and `POWERTOOLS_SERVICE_NAME` before running your tests to prevent failing on `SchemaValidation` exception. You can set it before you run tests or via pytest plugins like [dotenv](https://pypi.org/project/pytest-dotenv/).
332+
Make sure to set `POWERTOOLS_METRICS_NAMESPACE` and `POWERTOOLS_SERVICE_NAME` before running your tests to prevent failing on `SchemaValidation` exception. You can set it before you run tests or via pytest plugins like [dotenv](https://pypi.org/project/pytest-dotenv/){target="_blank"}.
333333

334334
```bash title="Injecting dummy Metric Namespace before running tests"
335335
--8<-- "examples/metrics/src/run_tests_env_var.sh"
@@ -374,4 +374,4 @@ You can read standard output and assert whether metrics have been flushed. Here'
374374
```
375375

376376
???+ tip
377-
For more elaborate assertions and comparisons, check out [our functional testing for Metrics utility.](https://github.com/awslabs/aws-lambda-powertools-python/blob/develop/tests/functional/test_metrics.py)
377+
For more elaborate assertions and comparisons, check out [our functional testing for Metrics utility.](https://github.com/awslabs/aws-lambda-powertools-python/blob/develop/tests/functional/test_metrics.py){target="_blank"}

docs/core/tracer.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Tracer
33
description: Core utility
44
---
55

6-
Tracer is an opinionated thin wrapper for [AWS X-Ray Python SDK](https://github.com/aws/aws-xray-sdk-python/).
6+
Tracer is an opinionated thin wrapper for [AWS X-Ray Python SDK](https://github.com/aws/aws-xray-sdk-python/){target="_blank"}.
77

88
![Tracer showcase](../media/tracer_utility_showcase.png)
99

@@ -29,7 +29,7 @@ Add `aws-lambda-powertools[tracer]` as a dependency in your preferred tool: _e.g
2929

3030
### Permissions
3131

32-
Before your use this utility, your AWS Lambda function [must have permissions](https://docs.aws.amazon.com/lambda/latest/dg/services-xray.html#services-xray-permissions) to send traces to AWS X-Ray.
32+
Before your use this utility, your AWS Lambda function [must have permissions](https://docs.aws.amazon.com/lambda/latest/dg/services-xray.html#services-xray-permissions){target="_blank"} to send traces to AWS X-Ray.
3333

3434
```yaml hl_lines="9 12" title="AWS Serverless Application Model (SAM) example"
3535
--8<-- "examples/tracer/sam/template.yaml"
@@ -51,7 +51,7 @@ You can quickly start by initializing `Tracer` and use `capture_lambda_handler`
5151

5252
### Annotations & Metadata
5353

54-
**Annotations** are key-values associated with traces and indexed by AWS X-Ray. You can use them to filter traces and to create [Trace Groups](https://aws.amazon.com/about-aws/whats-new/2018/11/aws-xray-adds-the-ability-to-group-traces/) to slice and dice your transactions.
54+
**Annotations** are key-values associated with traces and indexed by AWS X-Ray. You can use them to filter traces and to create [Trace Groups](https://aws.amazon.com/about-aws/whats-new/2018/11/aws-xray-adds-the-ability-to-group-traces/){target="_blank"} to slice and dice your transactions.
5555

5656
```python hl_lines="8" title="Adding annotations with put_annotation method"
5757
--8<-- "examples/tracer/src/put_trace_annotations.py"
@@ -107,7 +107,7 @@ You can trace asynchronous functions and generator functions (including context
107107

108108
### Patching modules
109109

110-
Tracer automatically patches all [supported libraries by X-Ray](https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-python-patching.html) during initialization, by default. Underneath, AWS X-Ray SDK checks whether a supported library has been imported before patching.
110+
Tracer automatically patches all [supported libraries by X-Ray](https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-python-patching.html){target="_blank"} during initialization, by default. Underneath, AWS X-Ray SDK checks whether a supported library has been imported before patching.
111111

112112
If you're looking to shave a few microseconds, or milliseconds depending on your function memory configuration, you can patch specific modules using `patch_modules` param:
113113

@@ -172,7 +172,7 @@ You can use `aiohttp_trace_config` function to create a valid [aiohttp trace_con
172172

173173
You can use `tracer.provider` attribute to access all methods provided by AWS X-Ray `xray_recorder` object.
174174

175-
This is useful when you need a feature available in X-Ray that is not available in the Tracer utility, for example [thread-safe](https://github.com/aws/aws-xray-sdk-python/#user-content-trace-threadpoolexecutor), or [context managers](https://github.com/aws/aws-xray-sdk-python/#user-content-start-a-custom-segmentsubsegment).
175+
This is useful when you need a feature available in X-Ray that is not available in the Tracer utility, for example [thread-safe](https://github.com/aws/aws-xray-sdk-python/#user-content-trace-threadpoolexecutor){target="_blank"}, or [context managers](https://github.com/aws/aws-xray-sdk-python/#user-content-start-a-custom-segmentsubsegment){target="_blank"}.
176176

177177
```python hl_lines="14" title="Tracing a code block with in_subsegment escape hatch"
178178
--8<-- "examples/tracer/src/sdk_escape_hatch.py"
@@ -181,7 +181,7 @@ This is useful when you need a feature available in X-Ray that is not available
181181
### Concurrent asynchronous functions
182182

183183
???+ warning
184-
[X-Ray SDK will raise an exception](https://github.com/aws/aws-xray-sdk-python/issues/164) when async functions are run and traced concurrently
184+
[X-Ray SDK will raise an exception](https://github.com/aws/aws-xray-sdk-python/issues/164){target="_blank"} when async functions are run and traced concurrently
185185

186186
A safe workaround mechanism is to use `in_subsegment_async` available via Tracer escape hatch (`tracer.provider`).
187187

@@ -221,4 +221,4 @@ Tracer is disabled by default when not running in the AWS Lambda environment - T
221221

222222
* Use annotations on key operations to slice and dice traces, create unique views, and create metrics from it via Trace Groups
223223
* Use a namespace when adding metadata to group data more easily
224-
* Annotations and metadata are added to the current subsegment opened. If you want them in a specific subsegment, use a [context manager](https://github.com/aws/aws-xray-sdk-python/#start-a-custom-segmentsubsegment) via the escape hatch mechanism
224+
* Annotations and metadata are added to the current subsegment opened. If you want them in a specific subsegment, use a [context manager](https://github.com/aws/aws-xray-sdk-python/#start-a-custom-segmentsubsegment){target="_blank"} via the escape hatch mechanism

0 commit comments

Comments
 (0)