MetricBuilder
Declares a Metric projected from the Events added to it.
Remarks
Section titled “Remarks”Every selected Event adds one entry to the Metric’s time series, valued by its calculation handler and tagged with the values its Dimension handlers resolve. Projection runs after the publishing Mutation or Listener completes, so a Metric can lag the Events it counts.
Example
Section titled “Example”A deliveries Metric with two Dimensions
const deliveries = app.addMetric('deliveries');deliveries.addEvent(sendgrid.templates.delivery.events.delivered);deliveries.addEvent(slack.templates.delivery.events.delivered);deliveries.addDimension(deliveryDimension, 1, deliveryDimensionHandler);deliveries.addDimension(automationDimension, 2, automationDimensionHandler);Extends
Section titled “Extends”Properties
Section titled “Properties”dimensions
Section titled “dimensions”
readonlydimensions:Record<string, {dimension:MetricDimensionBuilder;handler:MetricDimensionHandler; }>
Attached Dimensions and their handlers, keyed by Dimension key.
readonlyprn:string
Platform Resource Name of the declared resource, derived from the App key and resource key.
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”addDimension()
Section titled “addDimension()”addDimension(
dimension,position,handler):this
Attaches a Dimension to this Metric at one of four positions.
Parameters
Section titled “Parameters”dimension
Section titled “dimension”Dimension declared with AppBuilder.addMetricDimension.
position
Section titled “position”1 | 2 | 3 | 4
Column position, 1 to 4.
handler
Section titled “handler”Resolver of the Dimension value for each Event.
Returns
Section titled “Returns”this
This builder for chaining.
Remarks
Section titled “Remarks”The position selects the projection column that stores the value, so each position holds one Dimension. Attaching a Dimension with the same key again replaces the earlier handler and position.
addEvent()
Section titled “addEvent()”addEvent(
event,handler?):this
Selects an Event whose occurrences the Metric counts.
Parameters
Section titled “Parameters”Event to count.
handler?
Section titled “handler?”Computes the value each Event contributes.
Returns
Section titled “Returns”this
This builder for chaining.
Remarks
Section titled “Remarks”Events from any App in the composition can be selected. Without a handler each Event contributes 1.
addGrant()
Section titled “addGrant()”addGrant(
role):MetricGrant
Grants an App Role permission to query this Metric.
Parameters
Section titled “Parameters”App Role receiving access.
Returns
Section titled “Returns”The Grant builder.
setDescription()
Section titled “setDescription()”setDescription(
description):this
Sets the description emitted into the definition and rendered in generated reference and application assets.
Parameters
Section titled “Parameters”description
Section titled “description”string
Human-readable description of the resource.
Returns
Section titled “Returns”this
This builder for chaining.

