Skip to content

Commit 35e6466

Browse files
author
Pankaj Agrawal
committed
docs: support for env variable in tracing capture modes
1 parent 65bec4c commit 35e6466

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

docs/content/core/tracing.mdx

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,52 @@ public class App implements RequestHandler<APIGatewayProxyRequestEvent, APIGatew
6161
}
6262
```
6363

64-
By default this annotation will automatically record method responses and exceptions.
6564
If you want to customize segment name that appears in traces, use:
66-
`@Tracing(segmentName="yourCustomName")`
65+
66+
```java:title=CustomSegmentName.java
67+
public class App implements RequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> {
68+
69+
@Tracing(segmentName="yourCustomName")
70+
public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent input, Context context) {
71+
...
72+
}
73+
```
74+
75+
By default, this annotation will automatically record method responses and exceptions. You can change the default behavior by setting
76+
the environment variables `TRACING_CAPTURE_RESPONSE` and `TRACING_CAPTURE_ERROR` as needed. Optionally, you can override behavior by
77+
different supported `captureMode` to record response, exception or both.
6778

6879
<Note type="warning">
6980
<strong>Returning sensitive information from your Lambda handler or functions, where Tracer is used?</strong>
7081
<br/><br/>
71-
You can disable Tracer from capturing their responses and exception as tracing metadata with <strong><code>captureResponse=false</code></strong> and <strong><code>captureError=false</code></strong>
82+
You can disable Tracer from capturing their responses and exception as tracing metadata with <strong><code>captureMode=DISABLED</code></strong>
83+
or globally by setting environment variables <strong><code><strong><code>captureMode=DISABLED</code></strong></code></strong> and <strong><code>TRACING_CAPTURE_ERROR</code></strong> to `false`.
7284
</Note><br/>
7385

7486
```java:title=HandlerWithoutCapturingResponseOrError.java
7587
public class App implements RequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> {
7688

77-
@Tracing(captureError = false, captureResponse = false)
89+
@Tracing(captureMode=CaptureMode.DISABLED)
7890
public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent input, Context context) {
7991
...
8092
}
8193
```
94+
Globally:
95+
96+
```yaml:title=template.yaml
97+
Resources:
98+
HelloWorldFunction:
99+
Type: AWS::Serverless::Function
100+
Properties:
101+
...
102+
Runtime: java8
103+
104+
Tracing: Active
105+
Environment:
106+
Variables:
107+
TRACING_CAPTURE_RESPONSE: false # highlight-line
108+
TRACING_CAPTURE_ERROR: false # highlight-line
109+
```
82110

83111
### Annotations
84112

docs/content/index.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ Environment variable | Description | Utility
123123
**POWERTOOLS_SERVICE_NAME** | Sets service name used for tracing namespace, metrics dimension and structured logging | All
124124
**POWERTOOLS_METRICS_NAMESPACE** | Sets namespace used for metrics | [Metrics](./core/metrics)
125125
**POWERTOOLS_LOGGER_SAMPLE_RATE** | Debug log sampling | [Logging](./core/logging)
126-
**LOG_LEVEL** | Sets logging level | [Logging](./core/logger)
126+
**LOG_LEVEL** | Sets logging level | [Logging](./core/logging)
127+
**TRACING_CAPTURE_RESPONSE** | Enables/Disables tracing mode to capture method response | [Tracing](./core/tracing)
128+
**TRACING_CAPTURE_ERROR** | Enables/Disables tracing mode to capture method error | [Tracing](./core/tracing)
127129

128130
## Tenets
129131

0 commit comments

Comments
 (0)