Cloudflare - v1.3.0
    Preparing search index...

    Class AnalyticsService<E>

    Telemetry capability, backed by Analytics Engine.

    Records measurements — durations, counts, statuses — as data points to aggregate with SQL: request rate, latency percentiles, error rate, and whatever the domain wants counted.

    Deliberately separate from Logger. Analytics Engine samples at volume, which is right for aggregates and wrong for individual lines, so logs go to the observability logstream and only metrics come here.

    Writes are best-effort and never throw: telemetry must not be able to fail the request it is describing.

    Bayu Dwiyan Satria

    1.0.0

    1.0.0

    Type Parameters

    Implements

    • TelemetrySink<E>
    Index
    • Records a domain metric.

      Parameters

      • env: E

        The Worker environment.

      • name: string

        The metric name — the sampling key it is grouped by.

      • dimensions: string[] = []

        String dimensions to filter and group by.

      • measures: number[] = ...

        Numeric measurements to aggregate.

      Returns boolean

      true when the data point was accepted.

      analytics.event(env, 'article.create', [String(id)], [body.length])
      
    • Reports whether telemetry will actually be recorded.

      false when the dataset is unbound or analytics.enabled is off.

      Parameters

      • env: E

        The Worker environment.

      Returns boolean

      true when data points are being written.

    • Records one request: its duration and a unit count, grouped by route with method, status, colo, and country as filter dimensions.

      Parameters

      • env: E

        The Worker environment.

      • metric: RequestMetric

        The request measurement.

      Returns boolean

      true when the data point was accepted.

      Returns false without writing when the status is below analytics.minRequestStatus, which is 500 unless a deployment widens it.

    • Writes one data point, swallowing anything that goes wrong.

      Parameters

      • env: E

        The Worker environment.

      • index: string

        The sampling key. Analytics Engine caps this at 96 bytes.

      • blobs: string[]

        String dimensions.

      • doubles: number[]

        Numeric measurements.

      Returns boolean

      true when the data point was accepted.