# Tracing

X-Ray Tracing Modes (https://docs.aws.amazon.com/lambda/latest/dg/API_TracingConfig.html).

- Source: [`aws-lambda/lib/function.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-lambda/lib/function.ts#L56)

## Example

```ts
const fn = new lambda.Function(this, 'MyFunction', {
  runtime: lambda.Runtime.NODEJS_LATEST,
  handler: 'index.handler',
  code: lambda.Code.fromInline('exports.handler = function(event, ctx, cb) { return cb(null, "hi"); }'),
  tracing: lambda.Tracing.ACTIVE,
});
```

## Members

| Member | Description |
| --- | --- |
| `ACTIVE` | Lambda will respect any tracing header it receives from an upstream service. |
| `PASS_THROUGH` | Lambda will only trace the request from an upstream service if it contains a tracing header with "sampled=1". |
| `DISABLED` | Lambda will not trace any request. |

## Referenced by

- [`FunctionOptions`](/v2/docs/aws-cdk-lib.aws_lambda.FunctionOptions).tracing
