MCPcopy Create free account
hub / github.com/AgentOps-AI/agentops / initialize_from_config

Method initialize_from_config

agentops/sdk/core.py:334–379  ·  view source on GitHub ↗

Initialize the tracing core from a configuration object. Args: config: Configuration object (dict or object with dict method) jwt_provider: Function that returns the current JWT token **kwargs: Additional keyword arguments to pass to initialize

(
        cls, config_obj: Any, jwt_provider: Optional[Callable[[], Optional[str]]] = None, **kwargs: Any
    )

Source from the content-addressed store, hash-verified

332
333 @classmethod
334 def initialize_from_config(
335 cls, config_obj: Any, jwt_provider: Optional[Callable[[], Optional[str]]] = None, **kwargs: Any
336 ) -> None:
337 """
338 Initialize the tracing core from a configuration object.
339
340 Args:
341 config: Configuration object (dict or object with dict method)
342 jwt_provider: Function that returns the current JWT token
343 **kwargs: Additional keyword arguments to pass to initialize
344 """
345 # Use the global tracer instance instead of getting singleton
346 instance = tracer
347
348 # Extract tracing-specific configuration
349 # For TracingConfig, we can directly pass it to initialize
350 if isinstance(config_obj, dict):
351 # If it's already a dict (TracingConfig), use it directly
352 tracing_kwargs = config_obj.copy()
353 else:
354 # For backward compatibility with old Config object
355 # Extract tracing-specific configuration from the Config object
356 # Use getattr with default values to ensure we don't pass None for required fields
357 tracing_kwargs = {
358 k: v
359 for k, v in {
360 "exporter": getattr(config_obj, "exporter", None),
361 "processor": getattr(config_obj, "processor", None),
362 "exporter_endpoint": getattr(config_obj, "exporter_endpoint", None),
363 "max_queue_size": getattr(config_obj, "max_queue_size", 512),
364 "max_wait_time": getattr(config_obj, "max_wait_time", 5000),
365 "export_flush_interval": getattr(config_obj, "export_flush_interval", 1000),
366 "api_key": getattr(config_obj, "api_key", None),
367 "project_id": getattr(config_obj, "project_id", None),
368 "endpoint": getattr(config_obj, "endpoint", None),
369 }.items()
370 if v is not None
371 }
372 # Update with any additional kwargs
373 tracing_kwargs.update(kwargs)
374
375 # Initialize with the extracted configuration
376 instance.initialize(jwt_provider=jwt_provider, **tracing_kwargs)
377
378 # Span types are registered in the constructor
379 # No need to register them here anymore
380
381 def start_trace(
382 self, trace_name: str = "session", tags: Optional[dict | list] = None, is_init_trace: bool = False

Callers 1

initMethod · 0.80

Calls 1

initializeMethod · 0.80

Tested by

no test coverage detected