UNPKG

@squidcloud/client

Version:

A typescript implementation of the Squid client

35 lines (34 loc) 1.72 kB
import { Metric, QueryMetricsRequest, QueryMetricsResponse } from '../../internal-common/src/public-types/metric.public-types'; /** * A client for reporting user metrics and querying both application-related Squid and user metrics. * @category Platform */ export declare class ObservabilityClient { private readonly rpcManager; private pendingPromises; private isReporting; /** * Reports metrics to the metric submission queue. * The metric can be sent immediately or with some (several seconds) delay * due to optimizations applied by Squid client. * If no tags are provided tags are set to an empty record ({}). * If no timestamp is provided the timestamp is set to now(). */ reportMetric<MetricNameType = string>(metric: MetricReport<MetricNameType>): void; /** * Flushes all pending (unsent) metrics. * Note: Even after flushing, it may take some time for these metrics to become visible via 'queryMetrics' due to the * eventual consistency of the metrics storage. */ flush(): Promise<void>; /** Queries a batch of metric values. */ queryMetrics<MetricName extends string = string>(metricRequest: QueryMetricsRequest<MetricName>): Promise<QueryMetricsResponse<MetricName>>; } /** A single metric event. */ export { Metric } from '../../internal-common/src/public-types/metric.public-types'; /** * MetricReport represents a single metric event with some optional fields. * These optional fields are automatically populated by Squid with default values. * @category Platform */ export type MetricReport<MetricNameType = string> = Omit<Metric<MetricNameType>, 'tags' | 'timestamp'> & Partial<Pick<Metric, 'tags' | 'timestamp'>>;