| 1 | import type * as xray from "@distilled.cloud/aws/xray"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | |
| 5 | export interface BatchGetTracesRequest extends xray.BatchGetTracesRequest {} |
| 6 | |
| 7 | /** |
| 8 | * Retrieve full traces (all segment documents) for a list of trace IDs |
| 9 | * returned by `GetTraceSummaries`. |
| 10 | * |
| 11 | * Bind the operation in the function's init phase to get a runtime callable; |
| 12 | * provide the implementation with `Effect.provide(XRay.BatchGetTracesHttp)`. |
| 13 | * |
| 14 | * X-Ray trace reads are account-scoped: IAM does not support resource-level |
| 15 | * permissions for `xray:BatchGetTraces`, so the binding grants the action on |
| 16 | * `*`. |
| 17 | * ### Reading Traces |
| 18 | * **Example:** Fetch full traces from a Handler |
| 19 | * ```typescript |
| 20 | * import * as XRay from "alchemy/AWS/XRay"; |
| 21 | * |
| 22 | * export default MyFunction.make( |
| 23 | * { main: import.meta.url, functionUrl: true, tracing: "Active" }, |
| 24 | * Effect.gen(function* () { |
| 25 | * // init — bind the operation (grants xray:BatchGetTraces) |
| 26 | * const batchGetTraces = yield* XRay.BatchGetTraces(); |
| 27 | * |
| 28 | * return { |
| 29 | * fetch: Effect.gen(function* () { |
| 30 | * // runtime — fetch full segment documents by trace ID |
| 31 | * const result = yield* batchGetTraces({ |
| 32 | * TraceIds: ["1-63a2090f-3f4da4bcd9b1a3e07531423b"], |
| 33 | * }); |
| 34 | * return yield* HttpServerResponse.json({ |
| 35 | * segments: result.Traces?.[0]?.Segments?.length ?? 0, |
| 36 | * }); |
| 37 | * }).pipe(Effect.orDie), |
| 38 | * }; |
| 39 | * }).pipe(Effect.provide(XRay.BatchGetTracesHttp)), |
| 40 | * ); |
| 41 | * ``` |
| 42 | * |
| 43 | * @binding |
| 44 | */ |
| 45 | export interface BatchGetTraces extends Binding.Service< |
| 46 | BatchGetTraces, |
| 47 | "AWS.XRay.BatchGetTraces", |
| 48 | () => Effect.Effect< |
| 49 | ( |
| 50 | request: BatchGetTracesRequest, |
| 51 | ) => Effect.Effect<xray.BatchGetTracesResult, xray.BatchGetTracesError> |
| 52 | > |
| 53 | > {} |
| 54 | export const BatchGetTraces = Binding.Service<BatchGetTraces>( |
| 55 | "AWS.XRay.BatchGetTraces", |
| 56 | ); |