nv_ingest.framework.util.telemetry package#

Submodules#

nv_ingest.framework.util.telemetry.global_stats module#

class nv_ingest.framework.util.telemetry.global_stats.GlobalStats[source]#

Bases: object

Singleton class for maintaining global and job-specific statistics within a pipeline.

This class is designed to keep track of various statistics, including the number of submitted and completed jobs, as well as dynamic statistics (mean and median) for job-specific metrics over a sliding window.

Usage#

global_stats = GlobalStats.get_instance()

# Setting and incrementing global statistics global_stats.set_stat(“submitted_jobs”, 5) global_stats.increment_stat(“completed_jobs”)

# Appending job-specific statistics global_stats.append_job_stat(“job_1”, 100) global_stats.append_job_stat(“job_1”, 200)

# Retrieving statistics submitted_jobs = global_stats.get_stat(“submitted_jobs”) job_1_mean = global_stats.get_job_stat(“job_1”, “mean”)

get_instance():

Returns the singleton instance of the GlobalStats class.

reset_all_stats():

Resets all global and job-specific statistics.

set_stat(stat_name, value):

Sets a specific global statistic to the given value.

increment_stat(stat_name, value=1):

Increments a specific global statistic by the given value (default is 1).

append_job_stat(job_name, value):

Appends a value to the job-specific statistics and updates the mean and median for the job.

get_stat(stat_name):

Retrieves the value of a specific global statistic.

get_job_stat(job_name, stat_name):

Retrieves the value of a specific job-specific statistic (mean or median).

get_all_stats():

Returns a dictionary containing all global and job-specific statistics.

max_jobs#

The maximum number of jobs to retain in the statistics window (default is 100).

Type:

int

stats#

Dictionary to hold global statistics.

Type:

dict

job_stats#

Dictionary to hold job-specific statistics, with each job having its own deque for values, mean, and median.

Type:

defaultdict

Example

>>> global_stats = GlobalStats.get_instance()
>>> global_stats.increment_stat("submitted_jobs", 10)
>>> global_stats.append_job_stat("job_1", 50)
>>> global_stats.append_job_stat("job_1", 70)
>>> print(global_stats.get_stat("submitted_jobs"))
10
>>> print(global_stats.get_job_stat("job_1", "mean"))
60.0
>>> print(global_stats.get_job_stat("job_1", "median"))
60.0
append_job_stat(job_name, value)[source]#
get_all_stats()[source]#
static get_instance()[source]#
get_job_stat(job_name, stat_name)[source]#
get_stat(stat_name)[source]#
increment_stat(stat_name, value=1)[source]#
reset_all_stats()[source]#
set_stat(stat_name, value)[source]#

Module contents#