Class OTelMetricNameBuilder
Converts Typhon resource paths and metric kinds to OpenTelemetry metric names.
public static class OTelMetricNameBuilder
- Inheritance
-
OTelMetricNameBuilder
- Inherited Members
Remarks
OTel metric naming conventions:
- Use dots (.) for hierarchy
- Use lowercase with underscores for multi-word names
- Pattern:
{prefix}.{path}.{kind}.{sub_metric}
Prometheus auto-converts dots to underscores, so the same names work for both systems.
var name = OTelMetricNameBuilder.Build("typhon.resource", "Storage/PageCache", "memory", "allocated_bytes");
// Result: "typhon.resource.storage.page_cache.memory.allocated_bytes"
Methods
Build(string, string, string, string)
Build an OTel metric name from components.
public static string Build(string prefix, string nodePath, string metricKind, string subMetric)
Parameters
prefixstringMetric namespace prefix (e.g., "typhon.resource").
nodePathstringResource path (e.g., "Storage/PageCache" or "Root/Storage/PageCache").
metricKindstringMetric category (e.g., "memory", "capacity", "contention").
subMetricstringSpecific metric within the category (e.g., "allocated_bytes", "utilization").
Returns
- string
Fully qualified OTel metric name.
BuildNamed(string, string, string, string, string)
Build an OTel metric name for throughput and duration metrics that have named instances.
public static string BuildNamed(string prefix, string nodePath, string metricKind, string metricName, string subMetric)
Parameters
prefixstringMetric namespace prefix (e.g., "typhon.resource").
nodePathstringResource path (e.g., "Storage/PageCache").
metricKindstringMetric category (e.g., "throughput", "duration").
metricNamestringNamed metric instance (e.g., "CacheHits", "Checkpoint").
subMetricstringSpecific metric within the instance (e.g., "count", "last_us").
Returns
- string
Fully qualified OTel metric name.
NormalizePath(string)
Normalize a resource path to OTel-compatible format.
public static string NormalizePath(string nodePath)
Parameters
nodePathstringResource path (e.g., "Root/Storage/PageCache" or "Storage/PageCache").
Returns
- string
Normalized path in lowercase with underscores and dots (e.g., "storage.page_cache").
Remarks
Transformations applied:
- Remove "Root/" prefix if present
- Convert "/" to "."
- Convert PascalCase to snake_case
- Convert to lowercase
ToSnakeCase(string)
Convert a PascalCase or camelCase string to snake_case.
public static string ToSnakeCase(string input)
Parameters
inputstringInput string in PascalCase or camelCase.
Returns
- string
Output string in snake_case.