DISCLAIMER: THIS LIBRARY IS STILL IN ACTIVE DEVELOPMENT
CMetrics is a standalone C library to
create, mutate, aggregate, encode, and decode metrics contexts.
Supported Metric Types
Counter
Gauge
Untyped
Histogram
Exponential Histogram
Summary
All metric points store a sample timestamp in nanoseconds.
Datapoint Start Timestamp (OTLP)
CMetrics also supports an optional native start_timestamp per datapoint.
This is primarily relevant for OTLP cumulative streams.
API (cmt_metric.h):
cmt_metric_set_start_timestamp(...)
cmt_metric_unset_start_timestamp(...)
cmt_metric_has_start_timestamp(...)
cmt_metric_get_start_timestamp(...)
Backward compatibility: existing code that only uses timestamp is unchanged.
Supported Encoders
OpenTelemetry Metrics (OTLP protobuf)
Prometheus text exposition
Prometheus Remote Write
Influx line protocol
Splunk HEC
CloudWatch EMF
CMetrics msgpack (internal format)
Text (human-readable)
Supported Decoders
OpenTelemetry Metrics (OTLP protobuf)
Prometheus text exposition
Prometheus Remote Write
StatsD
CMetrics msgpack (internal format)
OTLP and start_timestamp
OTLP decoder populates native start_timestamp from
start_time_unix_nano.
OTLP encoder prefers native start_timestamp and falls back to OTLP metadata
when needed.
Internal CMetrics msgpack supports optional start_ts to preserve this value
across internal encode/decode flows.
Non-OTLP formats (for example Prometheus text, Influx, Splunk HEC, and
CloudWatch EMF) do not define an OTLP-style start timestamp field, so they
serialize sample timestamps only.
CMetrics
CMetrics is a standalone C library to create, mutate, aggregate, encode, and decode metrics contexts.
Supported Metric Types
All metric points store a sample
timestampin nanoseconds.Datapoint Start Timestamp (OTLP)
CMetrics also supports an optional native
start_timestampper datapoint. This is primarily relevant for OTLP cumulative streams.API (
cmt_metric.h):cmt_metric_set_start_timestamp(...)cmt_metric_unset_start_timestamp(...)cmt_metric_has_start_timestamp(...)cmt_metric_get_start_timestamp(...)Backward compatibility: existing code that only uses
timestampis unchanged.Supported Encoders
Supported Decoders
OTLP and
start_timestampstart_timestampfromstart_time_unix_nano.start_timestampand falls back to OTLP metadata when needed.start_tsto preserve this value across internal encode/decode flows.Non-OTLP formats (for example Prometheus text, Influx, Splunk HEC, and CloudWatch EMF) do not define an OTLP-style start timestamp field, so they serialize sample timestamps only.
C Usage Example
Design Reference
CMetrics is heavily inspired by the Go Prometheus Client API design:
License
This program is under the terms of the Apache License v2.0.
Authors
Calyptia Team