Skip to content

Commit 754454a

Browse files
committed
improve tracing doc for xray
1 parent 1fa11c1 commit 754454a

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

docs/core/tracing.md

+18-2
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,24 @@ under a subsegment, or you are doing multithreaded programming. Refer examples b
308308

309309
## Instrumenting SDK clients and HTTP calls
310310

311-
User should make sure to instrument the SDK clients explicitly based on the function dependency. Refer details on
312-
[how to instrument SDK client with Xray](https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-java-awssdkclients.html) and [outgoing http calls](https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-java-httpclients.html).
311+
Powertools for Lambda (Java) cannot intercept SDK clients instantiation to add X-Ray instrumentation. You should make sure to instrument the SDK clients explicitly. Refer details on
312+
[how to instrument SDK client with Xray](https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-java.html#xray-sdk-java-awssdkclients)
313+
and [outgoing http calls](https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-java.html#xray-sdk-java-httpclients). For example:
314+
315+
=== "LambdaHandler.java"
316+
317+
```java hl_lines="1 2 7"
318+
import com.amazonaws.xray.AWSXRay;
319+
import com.amazonaws.xray.handlers.TracingHandler;
320+
321+
public class LambdaHandler {
322+
private AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard()
323+
.withRegion(Regions.fromName(System.getenv("AWS_REGION")))
324+
.withRequestHandlers(new TracingHandler(AWSXRay.getGlobalRecorder()))
325+
.build();
326+
// ...
327+
}
328+
```
313329

314330
## Testing your code
315331

0 commit comments

Comments
 (0)