Constructs an AnalyticsBinding instance.
Optionalsettings: AnalyticsSettings
Resolved settings. Defaults to resolve('analytics'), so callers
normally construct this with no arguments at all.
The binding name this instance resolves.
The binding name as declared in wrangler.json.
Checks whether the binding is available on the given environment.
Use this to degrade gracefully when a binding is optional.
The Worker environment.
true when the binding is present.
Resolves the binding, failing fast when it is not configured.
The Worker environment.
The resolved binding.
MissingBindingError When the binding is absent from the environment.
Resolves the binding without throwing.
The Worker environment.
The resolved binding, or null when it is not configured.
Writes a data point to the dataset.
The Worker environment.
The data point — blobs, doubles, and indexes.
MissingBindingError When the Analytics Engine binding is absent.
Writes a data point, swallowing any failure.
Telemetry is never worth failing a request over, so a missing binding or a rejected write is logged and reported through the return value instead of propagating.
The Worker environment.
The data point — blobs, doubles, and indexes.
true when the write was accepted, false when it failed.
The two failures are not the same event, and conflating them is what made
the earlier version of this method unreadable in production. A Worker with
no TELEMETRY dataset bound is configured that way — it is the degraded
path this accessor documents — so an error line per request would be a
permanent, sampled, billed restatement of a deployment decision. A write
that was accepted and then rejected is a real fault, and rare enough to be
worth a line.
Both go through Logger rather than console.error directly, so the line
is one indexed JSON object like every other and analytics.error is a
filter rather than a substring search.
Accessor for the Analytics Engine dataset binding (
analytics_engine_datasetsinwrangler.json).The dataset carries telemetry — measurements to aggregate — and never log lines: Analytics Engine samples at volume, so an individual line written here may simply not be there when it is needed. Logging belongs to
Loggerin@bayudwiyansatria/core, which writes to the runtime's log stream instead.Example
Author
Bayu Dwiyan Satria
Version
1.0.0
Since
1.0.0