@@ -31,6 +31,7 @@ def setup_telemetry(
3131 metrics_endpoint : str = "https://otlp.agentops.ai/v1/metrics" ,
3232 max_queue_size : int = 512 ,
3333 max_wait_time : int = 5000 ,
34+ export_flush_interval : int = 1000 ,
3435 jwt : Optional [str ] = None ,
3536) -> tuple [TracerProvider , MeterProvider ]:
3637 """
@@ -43,6 +44,7 @@ def setup_telemetry(
4344 metrics_endpoint: Endpoint for the metrics exporter
4445 max_queue_size: Maximum number of spans to queue before forcing a flush
4546 max_wait_time: Maximum time in milliseconds to wait before flushing
47+ export_flush_interval: Time interval in milliseconds between automatic exports of telemetry data
4648 jwt: JWT token for authentication
4749
4850 Returns:
@@ -73,7 +75,7 @@ def setup_telemetry(
7375 processor = BatchSpanProcessor (
7476 exporter ,
7577 max_export_batch_size = max_queue_size ,
76- schedule_delay_millis = max_wait_time ,
78+ schedule_delay_millis = export_flush_interval ,
7779 )
7880 provider .add_span_processor (processor )
7981 provider .add_span_processor (InternalSpanProcessor ()) # Catches spans for AgentOps on-terminal printing
@@ -151,6 +153,7 @@ def initialize(self, jwt: Optional[str] = None, **kwargs) -> None:
151153 kwargs .setdefault ("metrics_endpoint" , "https://otlp.agentops.ai/v1/metrics" )
152154 kwargs .setdefault ("max_queue_size" , 512 )
153155 kwargs .setdefault ("max_wait_time" , 5000 )
156+ kwargs .setdefault ("export_flush_interval" , 1000 )
154157
155158 # Create a TracingConfig from kwargs with proper defaults
156159 config : TracingConfig = {
@@ -159,6 +162,7 @@ def initialize(self, jwt: Optional[str] = None, **kwargs) -> None:
159162 "metrics_endpoint" : kwargs ["metrics_endpoint" ],
160163 "max_queue_size" : kwargs ["max_queue_size" ],
161164 "max_wait_time" : kwargs ["max_wait_time" ],
165+ "export_flush_interval" : kwargs ["export_flush_interval" ],
162166 "api_key" : kwargs .get ("api_key" ),
163167 "project_id" : kwargs .get ("project_id" ),
164168 }
@@ -173,6 +177,7 @@ def initialize(self, jwt: Optional[str] = None, **kwargs) -> None:
173177 metrics_endpoint = config ["metrics_endpoint" ] or "" ,
174178 max_queue_size = config ["max_queue_size" ],
175179 max_wait_time = config ["max_wait_time" ],
180+ export_flush_interval = config ["export_flush_interval" ],
176181 jwt = jwt ,
177182 )
178183
@@ -250,6 +255,7 @@ def initialize_from_config(cls, config, **kwargs):
250255 "exporter_endpoint" : getattr (config , "exporter_endpoint" , None ),
251256 "max_queue_size" : getattr (config , "max_queue_size" , 512 ),
252257 "max_wait_time" : getattr (config , "max_wait_time" , 5000 ),
258+ "export_flush_interval" : getattr (config , "export_flush_interval" , 1000 ),
253259 "api_key" : getattr (config , "api_key" , None ),
254260 "project_id" : getattr (config , "project_id" , None ),
255261 "endpoint" : getattr (config , "endpoint" , None ),
0 commit comments