Skip to content

Commit

Permalink
Remove custom AttributeValue
Browse files Browse the repository at this point in the history
  • Loading branch information
hatchan committed Aug 26, 2024
1 parent 20747f2 commit 1ec69bf
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions fpx-lib/src/api/models/otel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ impl From<StatusCode> for SpanStatusCode {
}

#[derive(Clone, Debug, Serialize, Deserialize, Default, PartialEq)]
pub struct AttributeMap(BTreeMap<String, Option<AttributeValue>>);
pub struct AttributeMap(BTreeMap<String, Option<any_value::Value>>);

impl From<KeyValueList> for AttributeMap {
fn from(value: KeyValueList) -> Self {
Expand All @@ -241,7 +241,7 @@ impl From<KeyValueList> for AttributeMap {

impl From<Vec<KeyValue>> for AttributeMap {
fn from(attributes: Vec<KeyValue>) -> Self {
let result: BTreeMap<String, Option<AttributeValue>> = attributes
let result: BTreeMap<String, Option<any_value::Value>> = attributes
.into_iter()
.map(|kv| {
(
Expand All @@ -255,37 +255,37 @@ impl From<Vec<KeyValue>> for AttributeMap {
}
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub enum AttributeValue {
String(String),
Bool(bool),
Int(i64),
Double(f64),
Array(Vec<AttributeValue>),
KeyValueList(AttributeMap),
Bytes(Vec<u8>),
}

impl From<any_value::Value> for AttributeValue {
fn from(value: any_value::Value) -> Self {
match value {
any_value::Value::StringValue(val) => AttributeValue::String(val),
any_value::Value::BoolValue(val) => AttributeValue::Bool(val),
any_value::Value::IntValue(val) => AttributeValue::Int(val),
any_value::Value::DoubleValue(val) => AttributeValue::Double(val),
any_value::Value::BytesValue(val) => AttributeValue::Bytes(val),
any_value::Value::ArrayValue(val) => {
let val: Vec<_> = val
.values
.into_iter()
.flat_map(|value| value.value.map(|value| value.into()))
.collect();
AttributeValue::Array(val)
}
any_value::Value::KvlistValue(val) => AttributeValue::KeyValueList(val.values.into()),
}
}
}
// #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
// pub enum AttributeValue {
// String(String),
// Bool(bool),
// Int(i64),
// Double(f64),
// Array(Vec<AttributeValue>),
// KeyValueList(AttributeMap),
// Bytes(Vec<u8>),
// }

// impl From<any_value::Value> for AttributeValue {
// fn from(value: any_value::Value) -> Self {
// match value {
// any_value::Value::StringValue(val) => AttributeValue::String(val),
// any_value::Value::BoolValue(val) => AttributeValue::Bool(val),
// any_value::Value::IntValue(val) => AttributeValue::Int(val),
// any_value::Value::DoubleValue(val) => AttributeValue::Double(val),
// any_value::Value::BytesValue(val) => AttributeValue::Bytes(val),
// any_value::Value::ArrayValue(val) => {
// let val: Vec<_> = val
// .values
// .into_iter()
// .flat_map(|value| value.value.map(|value| value.into()))
// .collect();
// AttributeValue::Array(val)
// }
// any_value::Value::KvlistValue(val) => AttributeValue::KeyValueList(val.values.into()),
// }
// }
// }

/// A trace contains a summary of its traces.
#[derive(Clone, Debug, Deserialize, Serialize)]
Expand Down

0 comments on commit 1ec69bf

Please sign in to comment.