33
44//! Exporter used to measure the performance of the OTAP data pipeline.
55//!
6- //! ToDo – Future developments / improvements:
6+ //! ToDo - Future developments / improvements:
77//! - Replace this exporter with a processor that could be combined with a Noop exporter to achieve
88//! the same functionality. The advantage would be to allow performance measurements anywhere in
99//! the pipeline.
1010//! - Measure the number of memory allocations for the current thread. This would allow measuring
1111//! the memory used by the pipeline. This is possible using `mimalloc-sys`.
12- //! - Measure per-thread CPU usage. This would allow measuring the pipeline’ s CPU load. This is
13- //! possible using the "libc" crate function `getrusage(RUSAGE\_THREAD )`.
12+ //! - Measure per-thread CPU usage. This would allow measuring the pipeline' s CPU load. This is
13+ //! possible using the "libc" crate function `getrusage(RUSAGE_THREAD )`.
1414//! - Measure network usage either via a cgroup or via eBPF.
15- //! - Measure per-thread perf counters (see crates perfcnt, perfcnt2, or direct perf\_event\_open
15+ //! - Measure per-thread perf counters (see crates perfcnt, perfcnt2, or direct perf_event_open
1616//! via nix/libc). We could measure task-clock, context switches, page faults, ...
1717//! - Measure the latency of signals traversing the pipeline. This would require adding a timestamp
1818//! in the headers of pdata messages.
1919//! - Support live reconfiguration via control message.
2020
21- use crate :: OTAP_EXPORTER_FACTORIES ;
22- use crate :: metrics:: ExporterPDataMetrics ;
23- use crate :: pdata :: OtapPdata ;
24- use crate :: perf_exporter:: config:: Config ;
25- use crate :: perf_exporter:: metrics:: PerfExporterPdataMetrics ;
21+ pub mod config ;
22+ pub mod metrics;
23+
24+ use crate :: exporters :: perf_exporter:: config:: Config ;
25+ use crate :: exporters :: perf_exporter:: metrics:: PerfExporterPdataMetrics ;
2626use async_trait:: async_trait;
27+ use linkme:: distributed_slice;
2728use otap_df_config:: SignalType ;
2829use otap_df_config:: node:: NodeUserConfig ;
2930use otap_df_engine:: ConsumerEffectHandlerExtension ;
31+ use otap_df_engine:: ExporterFactory ;
3032use otap_df_engine:: config:: ExporterConfig ;
3133use otap_df_engine:: context:: PipelineContext ;
3234use otap_df_engine:: control:: { AckMsg , NodeControlMsg } ;
@@ -36,7 +38,9 @@ use otap_df_engine::local::exporter as local;
3638use otap_df_engine:: message:: { Message , MessageChannel } ;
3739use otap_df_engine:: node:: NodeId ;
3840use otap_df_engine:: terminal_state:: TerminalState ;
39- use otap_df_engine:: { ExporterFactory , distributed_slice} ;
41+ use otap_df_otap:: OTAP_EXPORTER_FACTORIES ;
42+ use otap_df_otap:: metrics:: ExporterPDataMetrics ;
43+ use otap_df_otap:: pdata:: OtapPdata ;
4044use otap_df_pdata:: otap:: OtapArrowRecords ;
4145use otap_df_telemetry:: metrics:: { MetricSet , MetricSetHandler } ;
4246use otap_df_telemetry:: otel_info;
@@ -267,22 +271,17 @@ impl local::Exporter<OtapPdata> for PerfExporter {
267271
268272#[ cfg( test) ]
269273mod tests {
270- use crate :: fixtures:: {
271- SimpleDataGenOptions , create_simple_logs_arrow_record_batches,
272- create_simple_metrics_arrow_record_batches, create_simple_trace_arrow_record_batches,
273- } ;
274- use crate :: pdata:: OtapPdata ;
275- use crate :: perf_exporter:: config:: Config ;
276- use crate :: perf_exporter:: exporter:: { OTAP_PERF_EXPORTER_URN , PerfExporter } ;
274+ use super :: { OTAP_PERF_EXPORTER_URN , PerfExporter } ;
275+ use crate :: exporters:: perf_exporter:: config:: Config ;
277276 use otap_df_config:: node:: NodeUserConfig ;
278277 use otap_df_engine:: context:: ControllerContext ;
279278 use otap_df_engine:: error:: Error ;
280279 use otap_df_engine:: exporter:: ExporterWrapper ;
281280 use otap_df_engine:: testing:: exporter:: TestContext ;
282281 use otap_df_engine:: testing:: exporter:: TestRuntime ;
283282 use otap_df_engine:: testing:: test_node;
284- use otap_df_pdata :: Consumer ;
285- use otap_df_pdata :: otap :: { OtapArrowRecords , from_record_messages } ;
283+ use otap_df_otap :: pdata :: OtapPdata ;
284+ use otap_df_otap :: testing :: create_test_pdata ;
286285 use otap_df_telemetry:: registry:: TelemetryRegistryHandle ;
287286 use std:: future:: Future ;
288287 use std:: ops:: Add ;
@@ -297,59 +296,10 @@ mod tests {
297296 -> impl FnOnce ( TestContext < OtapPdata > ) -> std:: pin:: Pin < Box < dyn Future < Output = ( ) > > > {
298297 |ctx| {
299298 Box :: pin ( async move {
300- // send some messages to the exporter to calculate pipeline statistics
301- for i in 0 ..3 {
302- let mut traces_batch_data =
303- create_simple_trace_arrow_record_batches ( SimpleDataGenOptions {
304- id_offset : 3 * i,
305- num_rows : 5 ,
306- ..Default :: default ( )
307- } ) ;
308- let mut logs_batch_data =
309- create_simple_logs_arrow_record_batches ( SimpleDataGenOptions {
310- id_offset : 3 * i + 1 ,
311- num_rows : 5 ,
312- ..Default :: default ( )
313- } ) ;
314- let mut metrics_batch_data =
315- create_simple_metrics_arrow_record_batches ( SimpleDataGenOptions {
316- id_offset : 3 * i + 2 ,
317- num_rows : 5 ,
318- ..Default :: default ( )
319- } ) ;
320-
321- let trace_batch_data = from_record_messages (
322- Consumer :: default ( )
323- . consume_bar ( & mut traces_batch_data)
324- . unwrap ( ) ,
325- ) ;
326- let logs_batch_data = from_record_messages (
327- Consumer :: default ( )
328- . consume_bar ( & mut logs_batch_data)
329- . unwrap ( ) ,
330- ) ;
331- let metrics_batch_data = from_record_messages (
332- Consumer :: default ( )
333- . consume_bar ( & mut metrics_batch_data)
334- . unwrap ( ) ,
335- ) ;
336-
337- // Send a data message
338- ctx. send_pdata ( OtapPdata :: new_default (
339- OtapArrowRecords :: Traces ( trace_batch_data) . into ( ) ,
340- ) )
341- . await
342- . expect ( "Failed to send data message" ) ;
343- ctx. send_pdata ( OtapPdata :: new_default (
344- OtapArrowRecords :: Logs ( logs_batch_data) . into ( ) ,
345- ) )
346- . await
347- . expect ( "Failed to send data message" ) ;
348- ctx. send_pdata ( OtapPdata :: new_default (
349- OtapArrowRecords :: Metrics ( metrics_batch_data) . into ( ) ,
350- ) )
351- . await
352- . expect ( "Failed to send data message" ) ;
299+ for _ in 0 ..3 {
300+ ctx. send_pdata ( create_test_pdata ( ) )
301+ . await
302+ . expect ( "Failed to send data message" ) ;
353303 }
354304
355305 // TODO ADD DELAY BETWEEN HERE
0 commit comments