@@ -7,7 +7,7 @@ pub mod store;
7
7
8
8
use crate :: {
9
9
config:: Config ,
10
- data:: { self , Application , Dependency , Host , Integration , Log , Payload , Telemetry } ,
10
+ data:: { self , Application , Dependency , Endpoint , Host , Integration , Log , Payload , Telemetry } ,
11
11
metrics:: { ContextKey , MetricBuckets , MetricContexts } ,
12
12
} ;
13
13
use ddcommon:: Endpoint ;
@@ -79,6 +79,7 @@ pub enum TelemetryActions {
79
79
AddDependency ( Dependency ) ,
80
80
AddIntegration ( Integration ) ,
81
81
AddLog ( ( LogIdentifier , Log ) ) ,
82
+ AddEndpoint ( Endpoint ) ,
82
83
Lifecycle ( LifecycleAction ) ,
83
84
#[ serde( skip) ]
84
85
CollectStats ( oneshot:: Sender < TelemetryWorkerStats > ) ,
@@ -110,6 +111,7 @@ struct TelemetryWorkerData {
110
111
dependencies : store:: Store < Dependency > ,
111
112
configurations : store:: Store < data:: Configuration > ,
112
113
integrations : store:: Store < data:: Integration > ,
114
+ endpoints : store:: Store < data:: Endpoint > ,
113
115
logs : store:: QueueHashMap < LogIdentifier , Log > ,
114
116
metric_contexts : MetricContexts ,
115
117
metric_buckets : MetricBuckets ,
@@ -181,6 +183,8 @@ pub struct TelemetryWorkerStats {
181
183
pub configurations_unflushed : u32 ,
182
184
pub integrations_stored : u32 ,
183
185
pub integrations_unflushed : u32 ,
186
+ pub endpoints_stored : u32 ,
187
+ pub endpoints_unflushed : u32 ,
184
188
pub logs : u32 ,
185
189
pub metric_contexts : u32 ,
186
190
pub metric_buckets : MetricBucketStats ,
@@ -197,6 +201,8 @@ impl Add for TelemetryWorkerStats {
197
201
configurations_unflushed : self . configurations_unflushed + rhs. configurations_unflushed ,
198
202
integrations_stored : self . integrations_stored + rhs. integrations_stored ,
199
203
integrations_unflushed : self . integrations_unflushed + rhs. integrations_unflushed ,
204
+ endpoints_stored : self . endpoints_stored + rhs. endpoints_stored ,
205
+ endpoints_unflushed : self . endpoints_unflushed + rhs. endpoints_unflushed ,
200
206
logs : self . logs + rhs. logs ,
201
207
metric_contexts : self . metric_contexts + rhs. metric_contexts ,
202
208
metric_buckets : MetricBucketStats {
@@ -315,7 +321,7 @@ impl TelemetryWorker {
315
321
}
316
322
}
317
323
}
318
- AddConfig ( _) | AddDependency ( _) | AddIntegration ( _) | Lifecycle ( ExtendedHeartbeat ) => { }
324
+ AddConfig ( _) | AddDependency ( _) | AddIntegration ( _) | AddEndpoint ( _ ) | Lifecycle ( ExtendedHeartbeat ) => { }
319
325
Lifecycle ( Stop ) => {
320
326
if !self . data . started {
321
327
return BREAK ;
@@ -372,6 +378,7 @@ impl TelemetryWorker {
372
378
AddDependency ( dep) => self . data . dependencies . insert ( dep) ,
373
379
AddIntegration ( integration) => self . data . integrations . insert ( integration) ,
374
380
AddConfig ( cfg) => self . data . configurations . insert ( cfg) ,
381
+ AddEndpoint ( endpoint) => self . data . endpoints . insert ( endpoint) ,
375
382
AddLog ( ( identifier, log) ) => {
376
383
let ( l, new) = self . data . logs . get_mut_or_insert ( identifier, log) ;
377
384
if !new {
@@ -424,6 +431,7 @@ impl TelemetryWorker {
424
431
self . data . dependencies . unflush_stored ( ) ;
425
432
self . data . integrations . unflush_stored ( ) ;
426
433
self . data . configurations . unflush_stored ( ) ;
434
+ self . data . endpoints . unflush_stored ( ) ;
427
435
428
436
let app_started = data:: Payload :: AppStarted ( self . build_app_started ( ) ) ;
429
437
match self . send_payload ( & app_started) . await {
@@ -516,6 +524,13 @@ impl TelemetryWorker {
516
524
} ,
517
525
) )
518
526
}
527
+ if self . data . endpoints . flush_not_empty ( ) {
528
+ payloads. push ( data:: Payload :: AppEndpointsChange (
529
+ data:: AppEndpointsChange {
530
+ endpoints : self . data . endpoints . unflushed ( ) . cloned ( ) . collect ( ) ,
531
+ } ,
532
+ ) )
533
+ }
519
534
payloads
520
535
}
521
536
@@ -618,6 +633,9 @@ impl TelemetryWorker {
618
633
. data
619
634
. configurations
620
635
. removed_flushed ( p. configuration . len ( ) ) ,
636
+ AppEndpointsChange ( p) => {
637
+ self . data . endpoints . removed_flushed ( p. endpoints . len ( ) )
638
+ }
621
639
MessageBatch ( batch) => {
622
640
for p in batch {
623
641
self . payload_sent_success ( p) ;
@@ -722,6 +740,8 @@ impl TelemetryWorker {
722
740
configurations_unflushed : self . data . configurations . len_unflushed ( ) as u32 ,
723
741
integrations_stored : self . data . integrations . len_stored ( ) as u32 ,
724
742
integrations_unflushed : self . data . integrations . len_unflushed ( ) as u32 ,
743
+ endpoints_stored : self . data . endpoints . len_stored ( ) as u32 ,
744
+ endpoints_unflushed : self . data . endpoints . len_unflushed ( ) as u32 ,
725
745
logs : self . data . logs . len ( ) as u32 ,
726
746
metric_contexts : self . data . metric_contexts . lock ( ) . len ( ) as u32 ,
727
747
metric_buckets : self . data . metric_buckets . stats ( ) ,
@@ -910,7 +930,7 @@ impl TelemetryWorkerHandle {
910
930
}
911
931
}
912
932
913
- /// How many dependencies/integrations/configs we keep in memory at most
933
+ /// How many dependencies/integrations/configs/endpoints we keep in memory at most
914
934
pub const MAX_ITEMS : usize = 5000 ;
915
935
916
936
#[ derive( Debug , Default , Clone , Copy ) ]
@@ -930,6 +950,7 @@ pub struct TelemetryWorkerBuilder {
930
950
pub dependencies : store:: Store < data:: Dependency > ,
931
951
pub integrations : store:: Store < data:: Integration > ,
932
952
pub configurations : store:: Store < data:: Configuration > ,
953
+ pub endpoints : store:: Store < data:: Endpoint > ,
933
954
pub native_deps : bool ,
934
955
pub rust_shared_lib_deps : bool ,
935
956
pub config : Config ,
@@ -980,6 +1001,7 @@ impl TelemetryWorkerBuilder {
980
1001
dependencies : store:: Store :: new ( MAX_ITEMS ) ,
981
1002
integrations : store:: Store :: new ( MAX_ITEMS ) ,
982
1003
configurations : store:: Store :: new ( MAX_ITEMS ) ,
1004
+ endpoints : store:: Store :: new ( MAX_ITEMS ) ,
983
1005
native_deps : true ,
984
1006
rust_shared_lib_deps : false ,
985
1007
config : Config :: default ( ) ,
@@ -1010,6 +1032,7 @@ impl TelemetryWorkerBuilder {
1010
1032
dependencies : self . dependencies ,
1011
1033
integrations : self . integrations ,
1012
1034
configurations : self . configurations ,
1035
+ endpoints : self . endpoints ,
1013
1036
logs : store:: QueueHashMap :: default ( ) ,
1014
1037
metric_contexts : contexts. clone ( ) ,
1015
1038
metric_buckets : MetricBuckets :: default ( ) ,
0 commit comments