3
3
pub mod agent_response;
4
4
pub mod builder;
5
5
pub mod error;
6
+ pub mod metrics;
6
7
7
8
// Re-export the builder
8
9
pub use builder:: TraceExporterBuilder ;
9
10
10
11
use self :: agent_response:: AgentResponse ;
12
+ use self :: metrics:: MetricsEmitter ;
11
13
use crate :: agent_info:: { AgentInfoFetcher , ResponseObserver } ;
12
14
use crate :: pausable_worker:: PausableWorker ;
13
15
use crate :: stats_exporter:: StatsExporter ;
@@ -39,8 +41,7 @@ use ddcommon::tag::Tag;
39
41
use ddcommon:: MutexExt ;
40
42
use ddcommon:: { hyper_migration, Endpoint } ;
41
43
use ddtelemetry:: worker:: TelemetryWorker ;
42
- use dogstatsd_client:: { Client , DogStatsDAction } ;
43
- use either:: Either ;
44
+ use dogstatsd_client:: Client ;
44
45
use http_body_util:: BodyExt ;
45
46
use hyper:: http:: uri:: PathAndQuery ;
46
47
use hyper:: { header:: CONTENT_TYPE , Method , Uri } ;
@@ -50,7 +51,7 @@ use std::time::Duration;
50
51
use std:: { borrow:: Borrow , collections:: HashMap , str:: FromStr , time} ;
51
52
use tokio:: runtime:: Runtime ;
52
53
use tokio_util:: sync:: CancellationToken ;
53
- use tracing:: { debug , error, info, warn} ;
54
+ use tracing:: { error, info, warn} ;
54
55
55
56
const DEFAULT_STATS_ELIGIBLE_SPAN_KINDS : [ & str ; 4 ] = [ "client" , "server" , "producer" , "consumer" ] ;
56
57
const STATS_ENDPOINT : & str = "/v0.6/stats" ;
@@ -846,29 +847,8 @@ impl TraceExporter {
846
847
847
848
/// Emit a health metric to dogstatsd
848
849
fn emit_metric ( & self , metric : HealthMetric , custom_tags : Option < Vec < & Tag > > ) {
849
- let has_custom_tags = custom_tags. is_some ( ) ;
850
- if let Some ( flusher) = & self . dogstatsd {
851
- let tags = match custom_tags {
852
- None => Either :: Left ( & self . common_stats_tags ) ,
853
- Some ( custom) => Either :: Right ( self . common_stats_tags . iter ( ) . chain ( custom) ) ,
854
- } ;
855
- match metric {
856
- HealthMetric :: Count ( name, c) => {
857
- debug ! (
858
- metric_name = name,
859
- count = c,
860
- has_custom_tags = has_custom_tags,
861
- "Emitting health metric to dogstatsd"
862
- ) ;
863
- flusher. send ( vec ! [ DogStatsDAction :: Count ( name, c, tags. into_iter( ) ) ] )
864
- }
865
- }
866
- } else {
867
- debug ! (
868
- metric = ?metric,
869
- "Skipping metric emission - dogstatsd client not configured"
870
- ) ;
871
- }
850
+ let emitter = MetricsEmitter :: new ( self . dogstatsd . as_ref ( ) , & self . common_stats_tags ) ;
851
+ emitter. emit ( metric, custom_tags) ;
872
852
}
873
853
874
854
/// Add all spans from the given iterator into the stats concentrator
0 commit comments