Skip to content

Commit 7d633cf

Browse files
committed
Updated docs example
1 parent 630b56d commit 7d633cf

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

docs/core/tracer.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,13 @@ You can quickly start by importing the `Tracer` class, initialize it outside the
108108
// Add the error as metadata
109109
tracer.addErrorAsMetadata(err as Error);
110110
throw err;
111+
} finally {
112+
// Close subsegment (the AWS Lambda one is closed automatically)
113+
subsegment.close();
114+
// Set the facade segment as active again
115+
tracer.setSegment(segment);
111116
}
112117

113-
// Close subsegment (the AWS Lambda one is closed automatically)
114-
subsegment.close();
115-
// Set the facade segment as active again
116-
tracer.setSegment(segment);
117-
118118
return res;
119119
}
120120
```

packages/tracing/README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ export const handler = async (_event: any, context: any) => {
8585
// Add the error as metadata
8686
tracer.addErrorAsMetadata(err as Error);
8787
throw err;
88+
} finally {
89+
// Close subsegment (the AWS Lambda one is closed automatically)
90+
subsegment.close();
91+
// Set the facade segment as active again
92+
tracer.setSegment(segment);
8893
}
8994

90-
// Close subsegment (the AWS Lambda one is closed automatically)
91-
subsegment.close();
92-
// Set the facade segment as active again
93-
tracer.setSegment(segment);
94-
9595
return res;
9696
}
9797
```

packages/tracing/src/Tracer.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ import { Segment, Subsegment } from 'aws-xray-sdk-core';
9898
* // Add the error as metadata
9999
* tracer.addErrorAsMetadata(err as Error);
100100
* throw err;
101+
* } finally {
102+
* // Close the subsegment
103+
* subsegment.close();
104+
* // Set the facade segment as active again
105+
* tracer.setSegment(segment);
101106
* }
102107
*
103-
* // Close subsegment (the AWS Lambda one is closed automatically)
104-
* subsegment.close();
105-
* // Set the facade segment as active again
106-
* tracer.setSegment(segment);
107-
*
108108
* return res;
109109
* }
110110
* ```

0 commit comments

Comments
 (0)