1import * as cloudwatch from "@distilled.cloud/aws/cloudwatch";
2import * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4
5export interface PutMetricDataRequest extends cloudwatch.PutMetricDataInput {}
6
7/**
8 * Runtime binding for `cloudwatch:PutMetricData` — publish custom metric
9 * datums from inside a function runtime.
10 *
11 * Provide `CloudWatch.PutMetricDataHttp` on the hosting Lambda Function to
12 * satisfy the requirement. For high-volume publishing prefer the batching
13 * {@link MetricSink}, which packs datums into 1000-datum `PutMetricData`
14 * calls.
15 * ### Publishing Metrics
16 * **Example:** Publish a Custom Metric from a Lambda Function
17 * ```typescript
18 * export default MyFunction.make(
19 * { main: import.meta.url, functionUrl: true },
20 * Effect.gen(function* () {
21 * // init — grants cloudwatch:PutMetricData to the function
22 * const putMetricData = yield* AWS.CloudWatch.PutMetricData();
23 *
24 * return {
25 * fetch: Effect.gen(function* () {
26 * // runtime — publish a datum on every request
27 * yield* putMetricData({
28 * Namespace: "MyApp/Payments",
29 * MetricData: [
30 * { MetricName: "PaymentProcessed", Value: 1, Unit: "Count" },
31 * ],
32 * });
33 * return HttpServerResponse.text("ok");
34 * }).pipe(Effect.orDie),
35 * };
36 * }).pipe(Effect.provide(AWS.CloudWatch.PutMetricDataHttp)),
37 * );
38 * ```
39 *
40 * @binding
41 */
42export interface PutMetricData extends Binding.Service<
43 PutMetricData,
44 "AWS.CloudWatch.PutMetricData",
45 () => Effect.Effect<
46 (
47 request: PutMetricDataRequest,
48 ) => Effect.Effect<
49 cloudwatch.PutMetricDataResponse,
50 cloudwatch.PutMetricDataError
51 >
52 >
53> {}
54
55export const PutMetricData = Binding.Service<PutMetricData>(
56 "AWS.CloudWatch.PutMetricData",
57);