Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(tracer): clarify escape hatch mechanism #3056

Merged
merged 5 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/core/tracer.md
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ Tracer exposes a `getRootXrayTraceId()` method that allows you to retrieve the [

### Escape hatch mechanism

You can use `tracer.provider` attribute to access all methods provided by the [AWS X-Ray SDK](https://docs.aws.amazon.com/xray-sdk-for-nodejs/latest/reference/AWSXRay.html).
You can use `tracer.provider` attribute to access [a subset of the methods provided](https://docs.powertools.aws.dev/lambda/typescript/latest/api/classes/_aws_lambda_powertools_tracer.provider_ProviderService.ProviderService.html) by the [AWS X-Ray SDK](https://docs.aws.amazon.com/xray-sdk-for-nodejs/latest/reference/AWSXRay.html).

This is useful when you need a feature available in X-Ray that is not available in the Tracer utility, for example [SQL queries tracing](https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-nodejs-sqlclients.html), or [a custom logger](https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-nodejs-configuration.html#xray-sdk-nodejs-configuration-logging).

Expand All @@ -388,6 +388,8 @@ This is useful when you need a feature available in X-Ray that is not available
--8<-- "examples/snippets/tracer/escapeHatch.ts"
```

If you need to access a method that is not available you can import it directly from the AWS X-Ray SDK for Node.js. Compatibility with the Tracer utility is not guaranteed.
dreamorosi marked this conversation as resolved.
Show resolved Hide resolved

## Testing your code

Tracer is disabled by default when not running in the AWS Lambda environment - This means no code changes or environment variables to be set.
Expand Down
11 changes: 11 additions & 0 deletions packages/tracer/src/provider/ProviderService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ import {
isHttpSubsegment,
} from './utilities.js';

/**
* The ProviderService class is a wrapper around the AWS X-Ray SDK for Node.js.
*
* The service provides exposes a selection of methods to interact with the SDK directly,
* these methods were chosen to be the most useful in the context of a Lambda function and
* have been tested to work with Powertools for AWS Lambda.
*
* If you want to use one of the other methods that are not exposed by this class,
* you can import the methods directly from the `aws-xray-sdk-core` package, and for most cases,
* they should work as expected. However, support for these methods is not guaranteed.
*/
class ProviderService implements ProviderServiceInterface {
/**
* @deprecated
Expand Down
9 changes: 6 additions & 3 deletions packages/tracer/typedoc.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"extends": ["../../typedoc.base.json"],
"extends": [
"../../typedoc.base.json"
],
"entryPoints": [
"./src/index.ts",
"./src/types/index.ts",
"./src/middleware/middy.ts"
"./src/middleware/middy.ts",
"./src/provider/ProviderService.ts",
],
"readme": "README.md"
}
}