Skip to content

Commit d749599

Browse files
committed
Remove non used fields
1 parent 961844a commit d749599

File tree

2 files changed

+4
-84
lines changed

2 files changed

+4
-84
lines changed

datadog-sidecar-ffi/src/lib.rs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -409,58 +409,24 @@ pub unsafe extern "C" fn ddog_sidecar_telemetry_enqueueConfig(
409409
MaybeError::None
410410
}
411411

412-
unsafe fn box_from_raw_opt<T: Default>(ptr: *mut T) -> Option<Box<T>> {
413-
if ptr.is_null() {
414-
Some(Box::new(T::default()))
415-
} else {
416-
Some(Box::from_raw(ptr))
417-
}
418-
}
419-
420-
fn slice_of_char_slice_to_vec_of_string<'a, T>(ffi_vec: T) -> Vec<String>
421-
where
422-
T: AsRef<[CharSlice<'a>]>,
423-
{
424-
ffi_vec
425-
.as_ref()
426-
.iter()
427-
.map(|s| s.to_utf8_lossy().into_owned())
428-
.collect()
429-
}
430-
431412
/// Reports an endpoint to the telemetry.
432413
#[no_mangle]
433414
#[allow(clippy::missing_safety_doc)]
434415
pub unsafe extern "C" fn ddog_sidecar_telemetry_addEndpoint(
435416
transport: &mut Box<SidecarTransport>,
436417
instance_id: &InstanceId,
437418
queue_id: &QueueId,
438-
r#type: CharSlice,
439419
method: ddtelemetry::data::Method,
440420
path: CharSlice,
441421
operation_name: CharSlice,
442422
resource_name: CharSlice,
443-
request_body_type: *mut ffi::Vec<CharSlice>,
444-
response_body_type: *mut ffi::Vec<CharSlice>,
445-
authentication: *mut ffi::Vec<ddtelemetry::data::Authentication>,
446-
metadata: CharSlice,
447423
) -> MaybeError {
448-
let request_body_type = box_from_raw_opt(request_body_type);
449-
let response_body_type = box_from_raw_opt(response_body_type);
450-
let authentication = box_from_raw_opt(authentication);
451-
452424
#[allow(clippy::unwrap_used)]
453425
let endpoint = TelemetryActions::AddEndpoint(ddtelemetry::data::Endpoint {
454-
r#type: Some(r#type.to_utf8_lossy().into_owned()),
455426
method: Some(method),
456427
path: Some(path.to_utf8_lossy().into_owned()),
457428
operation_name: operation_name.to_utf8_lossy().into_owned(),
458429
resource_name: resource_name.to_utf8_lossy().into_owned(),
459-
request_body_type: request_body_type.map(|v| slice_of_char_slice_to_vec_of_string(&**v)),
460-
response_body_type: response_body_type.map(|v| slice_of_char_slice_to_vec_of_string(&**v)),
461-
// into_iter() is not implemented correctly for ffi::Vec, so we need to copy the elements
462-
authentication: authentication.map(|v| v.iter().map(|auth| auth.to_owned()).collect()),
463-
metadata: metadata.assume_utf8().to_string(),
464430
});
465431

466432
try_c!(blocking::enqueue_actions(

ddtelemetry/src/data/payloads.rs

Lines changed: 4 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
use crate::data::metrics;
55

66
use serde::{Deserialize, Serialize};
7-
use tracing::warn;
87

98
#[derive(Serialize, Deserialize, Debug, Hash, PartialEq, Eq, Clone, Default)]
109
pub struct Dependency {
@@ -119,67 +118,22 @@ pub enum Method {
119118
Other = 9, //This is specified as "*" in the OpenAPI spec
120119
}
121120

122-
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Hash, Clone)]
123-
#[serde(rename_all = "UPPERCASE")]
124-
#[repr(C)]
125-
pub enum Authentication {
126-
Jwt = 0,
127-
Basic = 1,
128-
Oauth = 2,
129-
Oidc = 3,
130-
ApiKey = 4,
131-
Session = 5,
132-
Mtls = 6,
133-
Saml = 7,
134-
Ldap = 8,
135-
Form = 9,
136-
Other = 10,
137-
}
138-
139121
#[derive(Serialize, Deserialize, Debug, Hash, PartialEq, Eq, Clone, Default)]
140122
pub struct Endpoint {
141-
#[serde(default)]
142-
pub r#type: Option<String>,
143123
#[serde(default)]
144124
pub method: Option<Method>,
145125
#[serde(default)]
146126
pub path: Option<String>,
147-
pub operation_name: String,
148-
pub resource_name: String,
149-
#[serde(default)]
150-
pub request_body_type: Option<Vec<String>>,
151-
#[serde(default)]
152-
pub response_body_type: Option<Vec<String>>,
153-
#[serde(default)]
154-
pub authentication: Option<Vec<Authentication>>,
155-
#[serde(default)]
156-
pub metadata: String,
127+
pub operation_name: String,
128+
pub resource_name: String
157129
}
158130

159131
impl Endpoint {
160132
pub fn to_json_value(&self) -> serde_json::Result<serde_json::Value> {
161133
let result = serde_json::to_value(self);
162134
match result {
163-
Ok(mut value) => {
164-
// replace the metadata string with parsed JSON
165-
if let Some(obj) = value.as_object_mut() {
166-
let metadata_json = if self.metadata.is_empty() {
167-
serde_json::json!({})
168-
} else {
169-
serde_json::from_str(&self.metadata)?
170-
};
171-
obj.insert("metadata".to_string(), metadata_json);
172-
}
173-
174-
Ok(value)
175-
}
176-
Err(err) => {
177-
warn!(
178-
"Failed to convert Endpoint to JSON: {}: {}",
179-
self.metadata, err
180-
);
181-
Err(err)
182-
}
135+
Ok(value) => Ok(value),
136+
Err(err) => Err(err),
183137
}
184138
}
185139
}

0 commit comments

Comments
 (0)