1import type * as xray from "@distilled.cloud/aws/xray";
2import type * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4
5export interface PutTraceSegmentsRequest extends xray.PutTraceSegmentsRequest {}
6
7/**
8 * Upload segment documents to X-Ray — custom instrumentation for work
9 * the X-Ray SDK does not capture (background jobs, fan-out steps,
10 * external calls).
11 *
12 * Bind the operation in the function's init phase to get a runtime callable;
13 * provide the implementation with `Effect.provide(XRay.PutTraceSegmentsHttp)`.
14 * The action is account-scoped: X-Ray does not support resource-level
15 * permissions for `xray:PutTraceSegments`, so the binding grants it on `*`.
16 * ### Writing Traces
17 * **Example:** Upload a custom segment
18 * ```typescript
19 * import * as XRay from "alchemy/AWS/XRay";
20 *
21 * // init — grants xray:PutTraceSegments
22 * const putTraceSegments = yield* XRay.PutTraceSegments();
23 *
24 * // runtime — record a completed unit of work as its own segment
25 * const result = yield* putTraceSegments({
26 * TraceSegmentDocuments: [
27 * JSON.stringify({
28 * name: "nightly-import",
29 * id: "70de5b6f19ff9a0a",
30 * trace_id: "1-63a2090f-3f4da4bcd9b1a3e07531423b",
31 * start_time: 1672000000.0,
32 * end_time: 1672000000.5,
33 * }),
34 * ],
35 * });
36 * const failed = result.UnprocessedTraceSegments ?? [];
37 * ```
38 *
39 * @binding
40 */
41export interface PutTraceSegments extends Binding.Service<
42 PutTraceSegments,
43 "AWS.XRay.PutTraceSegments",
44 () => Effect.Effect<
45 (
46 request: PutTraceSegmentsRequest,
47 ) => Effect.Effect<xray.PutTraceSegmentsResult, xray.PutTraceSegmentsError>
48 >
49> {}
50export const PutTraceSegments = Binding.Service<PutTraceSegments>(
51 "AWS.XRay.PutTraceSegments",
52);