Flow Studio
Emitting Custom Metrics
Executors emit custom business metrics via ctx.Observability.Metrics. Use IncrementCounter for event counts and RecordHistogram for measured values. All custom metrics are shipped to Prometheus with the node's standard tags pre-applied.
INodeMetrics Interface
public interface INodeMetrics
{
void IncrementCounter(string name, long value = 1,
IDictionary<string, string>? tags = null);
void RecordHistogram(string name, double value,
IDictionary<string, string>? tags = null);
void SetGauge(string name, double value,
IDictionary<string, string>? tags = null);
}
Counter — Counting Events
// Count business events that happen within this node execution
var metrics = ctx.Observability.Metrics;
// Payment processed
metrics.IncrementCounter("payments.processed");
// Email sent
metrics.IncrementCounter("emails.sent", tags: new Dictionary<string, string>
{
["template"] = "invoice",
["channel"] = "sendgrid"
});
// Multiple items processed
metrics.IncrementCounter("items.processed", value: itemCount);
Histogram — Measuring Values
// Measure a business value — payment amount, file size, response time
metrics.RecordHistogram("payment.amount_cents", amount * 100);
metrics.RecordHistogram("api.response_time_ms", externalCallDuration.TotalMilliseconds,
tags: new Dictionary<string, string> { ["provider"] = "stripe" });
Metric Naming Conventions
| Convention | Example |
|---|---|
| Use dot-separated lowercase | payments.processed |
| Include unit suffix for histograms | api.response_time_ms |
| Node-specific prefix not required | Standard tags already carry nodeId/nodeType |
| Avoid high cardinality tags | Do not tag with executionId (each run = new label set) |
Standard Tags Pre-applied
All custom metrics automatically include the standard node tags — no need to add them manually:
// Custom metric: payments.processed
// Prometheus labels it receives automatically:
payments_processed{
nodeId = "node-payment",
nodeType = "PaymentNode",
processId= "proc-xyz",
tenantId = "tenant-001"
} += 1
Avoid raw IMetricsProvider. Do not inject and use
IMetricsProvider directly in an executor. It will not have the standard node tags pre-applied. Always use ctx.Observability.Metrics.