Skip to content

Commit bce1498

Browse files
make fn compute_series_hash public for rw use (#1801)
1 parent 39fd526 commit bce1498

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎src/otel/metrics.rs‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,16 +160,19 @@ fn target_info_record(
160160
target
161161
}
162162

163-
/// Compute a stable u64 identifier for the physical series a sample
164-
/// belongs to. Hashes `metric_name` plus every attribute key/value pair
163+
/// Compute a stable u64 identifier for an already-flattened physical series.
164+
/// Protocol adapters can call this directly without constructing an
165+
/// intermediate OTLP `MetricsData` tree.
166+
///
167+
/// Hashes `metric_name` plus every attribute key/value pair
165168
/// that survived OTel flattening — everything in the flattened data
166169
/// point that isn't a known sample-level field is treated as a label.
167170
///
168171
/// Hash output must be stable across process restarts and matching at
169172
/// query time. Uses rustc-hash's FxHasher (fast, deterministic,
170173
/// non-cryptographic) and feeds keys in sorted order so the hash
171174
/// doesn't depend on JSON Map iteration order.
172-
fn compute_series_hash(dp: &Map<String, Value>) -> u64 {
175+
pub fn compute_series_hash(dp: &Map<String, Value>) -> u64 {
173176
let mut label_pairs: Vec<(&str, Cow<'_, str>)> = Vec::with_capacity(dp.len());
174177
for (key, value) in dp {
175178
if OTEL_METRICS_KNOWN_FIELDS.contains(key.as_str()) {

0 commit comments

Comments
 (0)