Skip to content

Commit 29d24fa

Browse files
committed
wip
1 parent d444a77 commit 29d24fa

File tree

4 files changed

+39
-6
lines changed

4 files changed

+39
-6
lines changed

datadog-sidecar-ffi/src/lib.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,35 @@ pub unsafe extern "C" fn ddog_sidecar_telemetry_enqueueConfig(
410410
MaybeError::None
411411
}
412412

413+
/// Reports an endpoint to the telemetry.
414+
#[no_mangle]
415+
#[allow(clippy::missing_safety_doc)]
416+
pub unsafe extern "C" fn ddog_sidecar_telemetry_addEndpoint(
417+
transport: &mut Box<SidecarTransport>,
418+
instance_id: &InstanceId,
419+
queue_id: &QueueId,
420+
r#type: CharSlice,
421+
method: ddtelemetry::data::Method,
422+
path: CharSlice,
423+
operation_name: CharSlice,
424+
resource_name: CharSlice,
425+
) {
426+
let endpoint = TelemetryActions::AddEndpoint(ddtelemetry::data::Endpoint {
427+
r#type: Some(r#type.to_utf8_lossy().into_owned()),
428+
method: Some(method),
429+
path: Some(path.to_utf8_lossy().into_owned()),
430+
operation_name: operation_name.to_utf8_lossy().into_owned(),
431+
resource_name: resource_name.to_utf8_lossy().into_owned(),
432+
});
433+
434+
try_c!(blocking::enqueue_actions(
435+
transport,
436+
instance_id,
437+
queue_id,
438+
vec![SidecarAction::Telemetry(endpoint)],
439+
));
440+
}
441+
413442
/// Reports a dependency to the telemetry.
414443
#[no_mangle]
415444
#[allow(clippy::missing_safety_doc)]

datadog-sidecar/src/service/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,5 @@ pub enum SidecarAction {
7171
RegisterTelemetryMetric(MetricContext),
7272
AddTelemetryMetricPoint((String, f64, Vec<Tag>)),
7373
PhpComposerTelemetryFile(PathBuf),
74-
ClearQueueId,
75-
AddEndpoint(ddtelemetry::data::Endpoint),
74+
ClearQueueId
7675
}

datadog-sidecar/src/service/sidecar_server.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,13 @@ impl SidecarInterface for SidecarServer {
448448
}
449449
SidecarAction::ClearQueueId => {
450450
remove_entry = true;
451-
}
451+
},
452+
SidecarAction::Telemetry(TelemetryActions::AddEndpoint(ref endpoint)) => {
453+
if telemetry.buffered_endpoints.insert(endpoint.clone()) {
454+
buffered_info_changed = true;
455+
actions_to_process.push(action);
456+
}
457+
},
452458
SidecarAction::Telemetry(TelemetryActions::Lifecycle(
453459
LifecycleAction::Stop,
454460
)) => {

datadog-sidecar/src/service/telemetry.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ pub struct TelemetryCachedClient {
6262
pub config_sent: bool,
6363
pub buffered_integrations: HashSet<Integration>,
6464
pub buffered_composer_paths: HashSet<PathBuf>,
65+
pub buffered_endpoints: HashSet<ddtelemetry::data::Endpoint>,
6566
pub telemetry_metrics: Arc<Mutex<HashMap<String, ContextKey>>>,
6667
pub handle: Arc<Mutex<Option<JoinHandle<()>>>>,
6768
}
@@ -99,6 +100,7 @@ impl TelemetryCachedClient {
99100
config_sent: false,
100101
buffered_integrations: HashSet::new(),
101102
buffered_composer_paths: HashSet::new(),
103+
buffered_endpoints: HashSet::new(),
102104
telemetry_metrics: Default::default(),
103105
handle: Arc::new(Mutex::new(None)),
104106
}
@@ -153,9 +155,6 @@ impl TelemetryCachedClient {
153155
SidecarAction::AddTelemetryMetricPoint(point) => {
154156
actions.push(self.to_telemetry_point(point));
155157
}
156-
SidecarAction::AddEndpoint(endpoint) => {
157-
actions.push(TelemetryActions::AddEndpoint(endpoint));
158-
}
159158
SidecarAction::PhpComposerTelemetryFile(_) => {} // handled separately
160159
SidecarAction::ClearQueueId => {} // handled separately
161160
}

0 commit comments

Comments
 (0)