MCPcopy Create free account
hub / github.com/CodSpeedHQ/codspeed / any_value_string

Function any_value_string

src/instruments/otel/rows.rs:200–215  ·  view source on GitHub ↗

Strings as is, and other scalars as text. Bytes are base64-encoded, and arrays and maps are JSON.

(value: AnyValue)

Source from the content-addressed store, hash-verified

198/// Strings as is, and other scalars as text. Bytes are base64-encoded, and arrays and maps are
199/// JSON.
200fn any_value_string(value: AnyValue) -> String {
201 match value.value {
202 // An index into a string table that OTLP traces and logs don't carry.
203 None | Some(any_value::Value::StringValueStrindex(_)) => String::new(),
204 Some(any_value::Value::StringValue(value)) => value,
205 Some(any_value::Value::BoolValue(value)) => value.to_string(),
206 Some(any_value::Value::IntValue(value)) => value.to_string(),
207 Some(any_value::Value::DoubleValue(value)) => value.to_string(),
208 Some(any_value::Value::BytesValue(value)) => {
209 base64::engine::general_purpose::STANDARD.encode(value)
210 }
211 Some(value @ (any_value::Value::ArrayValue(_) | any_value::Value::KvlistValue(_))) => {
212 any_value_json(Some(value)).to_string()
213 }
214 }
215}
216
217fn any_value_json(value: Option<any_value::Value>) -> serde_json::Value {
218 use serde_json::Value as Json;

Callers

nothing calls this directly

Calls 1

any_value_jsonFunction · 0.85

Tested by

no test coverage detected