| 1 | import type * as Credentials from "@distilled.cloud/aws/Credentials"; |
| 2 | import type * as SigV4 from "@distilled.cloud/aws/SigV4"; |
| 3 | import type * as Effect from "effect/Effect"; |
| 4 | import * as Binding from "../../Binding.ts"; |
| 5 | import type { |
| 6 | PrometheusApiError, |
| 7 | PrometheusMetricMetadata, |
| 8 | } from "./PrometheusTypes.ts"; |
| 9 | import type { Workspace } from "./Workspace.ts"; |
| 10 | |
| 11 | export interface GetMetricMetadataRequest { |
| 12 | /** Restrict metadata to one metric name. */ |
| 13 | metric?: string; |
| 14 | /** Maximum number of metrics to return. */ |
| 15 | limit?: number; |
| 16 | } |
| 17 | |
| 18 | /** |
| 19 | * Runtime binding for `aps:GetMetricMetadata` — read metric metadata (type, |
| 20 | * help, unit) from an AMP {@link Workspace}'s Prometheus-compatible |
| 21 | * `api/v1/metadata` endpoint, SigV4-signed with the host Function's |
| 22 | * credentials. |
| 23 | * |
| 24 | * ### Reading Metric Metadata |
| 25 | * **Example:** All Metric Metadata |
| 26 | * ```typescript |
| 27 | * const getMetricMetadata = yield* AMP.GetMetricMetadata(workspace); |
| 28 | * const metadata = yield* getMetricMetadata({}); |
| 29 | * // { http_requests_total: [{ type: "counter", help: "...", unit: "" }], ... } |
| 30 | * ``` |
| 31 | * |
| 32 | * @binding |
| 33 | */ |
| 34 | export interface GetMetricMetadata extends Binding.Service< |
| 35 | GetMetricMetadata, |
| 36 | "AWS.AMP.GetMetricMetadata", |
| 37 | ( |
| 38 | workspace: Workspace, |
| 39 | ) => Effect.Effect< |
| 40 | ( |
| 41 | request: GetMetricMetadataRequest, |
| 42 | ) => Effect.Effect< |
| 43 | Record<string, PrometheusMetricMetadata[]>, |
| 44 | PrometheusApiError | Credentials.CredentialsError | SigV4.SigningError |
| 45 | > |
| 46 | > |
| 47 | > {} |
| 48 | export const GetMetricMetadata = Binding.Service<GetMetricMetadata>( |
| 49 | "AWS.AMP.GetMetricMetadata", |
| 50 | ); |