Skip to content

Commit aeabcb6

Browse files
committed
improv: address Nicolas feedback; improve docs
1 parent cfc38df commit aeabcb6

File tree

3 files changed

+34
-8
lines changed

3 files changed

+34
-8
lines changed

docs/content/core/tracer.mdx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,16 @@ def handler(event, context):
6565
...
6666
```
6767

68+
### disabling response auto-capture
69+
70+
> New in 1.9.0
71+
6872
<Note type="warning">
6973
<strong>Returning sensitive information from your Lambda handler or functions, where Tracer is used?</strong>
7074
<br/><br/>
71-
You can disable Tracer from capturing their responses as tracing metadata with <strong><code>capture_response=False</code></strong> parameter in both capture_lambda_handler and capture_method decorators.
7275
</Note><br/>
7376

77+
You can disable Tracer from capturing their responses as tracing metadata with <strong><code>capture_response=False</code></strong> parameter in both capture_lambda_handler and capture_method decorators.
7478

7579
```python:title=do_not_capture_response_as_metadata.py
7680
# Disables Tracer from capturing response and adding as metadata
@@ -80,6 +84,25 @@ def handler(event, context):
8084
return "sensitive_information"
8185
```
8286

87+
### disabling exception auto-capture
88+
89+
> New in 1.10.0
90+
91+
<Note type="warning">
92+
<strong>Can exceptions contain sensitive information from your Lambda handler or functions, where Tracer is used?</strong>
93+
<br/><br/>
94+
</Note><br/>
95+
96+
You can disable Tracer from capturing their exceptions as tracing metadata with <strong><code>capture_error=False</code></strong> parameter in both capture_lambda_handler and capture_method decorators.
97+
98+
```python:title=do_not_capture_response_as_metadata.py
99+
# Disables Tracer from capturing response and adding as metadata
100+
# Useful when dealing with sensitive data
101+
@tracer.capture_lambda_handler(capture_error=False) # highlight-line
102+
def handler(event, context):
103+
raise ValueError("some sensitive info in the stack trace...")
104+
```
105+
83106
### Annotations
84107

85108
Annotations are key-values indexed by AWS X-Ray on a per trace basis. You can use them to filter traces as well as to create [Trace Groups](https://aws.amazon.com/about-aws/whats-new/2018/11/aws-xray-adds-the-ability-to-group-traces/).

docs/content/index.mdx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,19 @@ Utility | Description
116116

117117
## Environment variables
118118

119+
<Note type="info">
120+
<strong>Explicit parameters take precedence over environment variables.</strong><br/><br/>
121+
</Note>
122+
119123
**Environment variables** used across suite of utilities.
120124

121125
Environment variable | Description | Utility | Default
122126
------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | ------------------------------------------------- | -------------------------------------------------
123127
**POWERTOOLS_SERVICE_NAME** | Sets service name used for tracing namespace, metrics dimension and structured logging | All | `"service_undefined"`
124128
**POWERTOOLS_METRICS_NAMESPACE** | Sets namespace used for metrics | [Metrics](./core/metrics) | `None`
125129
**POWERTOOLS_TRACE_DISABLED** | Disables tracing | [Tracing](./core/tracer) | `false`
126-
**POWERTOOLS_TRACER_CAPTURE_RESPONSE** | Overrides tracer from auto-capturing response as metadata | [Tracing](./core/tracer) | `true`
130+
**POWERTOOLS_TRACER_CAPTURE_RESPONSE** | Captures Lambda or method return as metadata. | [Tracing](./core/tracer) | `true`
131+
**POWERTOOLS_TRACER_CAPTURE_ERROR** | Captures Lambda or method exception as metadata. | [Tracing](./core/tracer) | `true`
127132
**POWERTOOLS_TRACE_MIDDLEWARES** | Creates sub-segment for each custom middleware | [Middleware factory](./utilities/middleware_factory) | `false`
128133
**POWERTOOLS_LOGGER_LOG_EVENT** | Logs incoming event | [Logging](./core/logger) | `false`
129134
**POWERTOOLS_LOGGER_SAMPLE_RATE** | Debug log sampling | [Logging](./core/logger) | `0`
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import os
2-
31
from aws_lambda_powertools.shared.functions import resolve_env_var_choice
42

53

6-
def test_explicit_wins_over_env_var():
7-
choice_env = os.getenv("CHOICE", True)
4+
def test_resolve_env_var_choice_explicit_wins_over_env_var():
5+
assert resolve_env_var_choice(env="true", choice=False) is False
86

9-
choice = resolve_env_var_choice(env=choice_env, choice=False)
107

11-
assert choice is False
8+
def test_resolve_env_var_choice_env_wins_over_absent_explicit():
9+
assert resolve_env_var_choice(env="true") == 1

0 commit comments

Comments
 (0)