| 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 PutTelemetryRecordsRequest |
| 6 | extends xray.PutTelemetryRecordsRequest {} |
| 7 | |
| 8 | /** |
| 9 | * Upload telemetry about segment transmission (received/sent/rejected |
| 10 | * counts and backend connection errors) — the companion action to |
| 11 | * `PutTraceSegments` used by X-Ray daemons and custom emitters. |
| 12 | * |
| 13 | * Bind the operation in the function's init phase to get a runtime callable; |
| 14 | * provide the implementation with `Effect.provide(XRay.PutTelemetryRecordsHttp)`. |
| 15 | * The action is account-scoped: X-Ray does not support resource-level |
| 16 | * permissions for `xray:PutTelemetryRecords`, so the binding grants it on `*`. |
| 17 | * ### Writing Traces |
| 18 | * **Example:** Report segment transmission telemetry |
| 19 | * ```typescript |
| 20 | * import * as XRay from "alchemy/AWS/XRay"; |
| 21 | * |
| 22 | * // init — grants xray:PutTelemetryRecords |
| 23 | * const putTelemetryRecords = yield* XRay.PutTelemetryRecords(); |
| 24 | * |
| 25 | * // runtime |
| 26 | * yield* putTelemetryRecords({ |
| 27 | * TelemetryRecords: [ |
| 28 | * { |
| 29 | * Timestamp: new Date(), |
| 30 | * SegmentsReceivedCount: 10, |
| 31 | * SegmentsSentCount: 10, |
| 32 | * }, |
| 33 | * ], |
| 34 | * }); |
| 35 | * ``` |
| 36 | * |
| 37 | * @binding |
| 38 | */ |
| 39 | export interface PutTelemetryRecords extends Binding.Service< |
| 40 | PutTelemetryRecords, |
| 41 | "AWS.XRay.PutTelemetryRecords", |
| 42 | () => Effect.Effect< |
| 43 | ( |
| 44 | request: PutTelemetryRecordsRequest, |
| 45 | ) => Effect.Effect< |
| 46 | xray.PutTelemetryRecordsResult, |
| 47 | xray.PutTelemetryRecordsError |
| 48 | > |
| 49 | > |
| 50 | > {} |
| 51 | export const PutTelemetryRecords = Binding.Service<PutTelemetryRecords>( |
| 52 | "AWS.XRay.PutTelemetryRecords", |
| 53 | ); |