Skip to main content

SplunkAOLoggerSingleton

A singleton class that manages a collection of SplunkAOLogger instances. This class ensures that only one instance exists across the application and provides a thread-safe way to retrieve or create SplunkAOLogger clients based on the given ‘project’ and ‘agent_stream’ parameters. If the parameters are not provided, the class attempts to read the values from the environment variables SPLUNK_AO_PROJECT and SPLUNK_AO_AGENT_STREAM. The loggers are stored in a dictionary using a tuple (project, agent_stream) as the key.

flush

Flush (upload and clear) a SplunkAOLogger instance. If both project and agent_stream are None, then all cached loggers are flushed and cleared. Otherwise, only the specific logger corresponding to the provided key (project, agent_stream) is flushed and removed. Arguments
  • project (Optional[str], optional): The project name. Defaults to None.
  • project_id (Optional[str], optional): The project ID. Defaults to None.
  • agent_stream (Optional[str], optional): The agent stream name. Defaults to None.
  • agent_stream_id (Optional[str], optional): The agent stream ID. Defaults to None.
  • experiment_id (Optional[str], optional): The experiment ID. Defaults to None.
  • mode (Optional[str], optional): The logger mode. Defaults to SPLUNK_AO_MODE env var, or “batch” if not set.

flush_all

Flush (upload and clear) all SplunkAOLogger instances.

get

Retrieve an existing SplunkAOLogger or create a new one if it does not exist. This method first computes the key from the project and agent_stream parameters, checks if a logger exists in the cache, and if not, creates a new SplunkAOLogger. The creation and caching are done in a thread-safe manner. Arguments
  • project (Optional[str], optional): The project name. Defaults to None.
  • agent_stream (Optional[str], optional): The agent stream name. Defaults to None.
  • experiment_id (Optional[str], optional): The experiment ID. Defaults to None.
  • local_metrics (Optional[list[LocalScorerConfig]], optional): Local scorers to run on traces/spans. Only used if initializing a new logger, ignored otherwise. Defaults to None.
Returns
  • SplunkAOLogger: An instance of SplunkAOLogger corresponding to the key.

get_all_loggers

Retrieve a copy of the dictionary containing all active loggers. Returns
  • A dictionary mapping keys to their corresponding SplunkAOLogger instances.

reset

Reset (terminate and remove) one or all SplunkAOLogger instances. Arguments
  • project (Optional[str], optional): The project name. Defaults to None.
  • project_id (Optional[str], optional): The project ID. Defaults to None.
  • agent_stream (Optional[str], optional): The agent stream name. Defaults to None.
  • agent_stream_id (Optional[str], optional): The agent stream ID. Defaults to None.
  • experiment_id (Optional[str], optional): The experiment ID. Defaults to None.
  • mode (Optional[str], optional): The logger mode. Defaults to SPLUNK_AO_MODE env var, or “batch” if not set.

reset_all

Reset (terminate and remove) all SplunkAOLogger instances.