Module Import alias Import alias Import alias Import alias ImportFrom alias alias alias alias ImportFrom alias Assign NameStore Call AttributeLoad NameLoad attr NameLoad ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad NameLoad NameLoad body Expr Str Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr BoolOpOr NameLoad Call NameLoad Assign AttributeStore NameLoad attr Dict Assign AttributeStore NameLoad attr Dict Assign AttributeStore NameLoad attr Dict Assign AttributeStore NameLoad attr BoolOpOr NameLoad ListLoad For NameStore AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr ListLoad If NameLoad body FunctionDef arguments args defaults body While NameLoad body Expr Call AttributeLoad NameLoad attr Num Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad decorator_list Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad Assign AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Str Str Str Call NameLoad Lambda arguments args NameParam NameParam defaults Call NameLoad AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Return AttributeLoad NameLoad attr decorator_list NameLoad FunctionDef arguments args NameParam defaults body Expr Str Return AttributeLoad NameLoad attr decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults Str NameLoad body Expr Str Assign NameStore Call NameLoad AttributeLoad AttributeLoad NameLoad attr attr Expr Call AttributeLoad NameLoad attr BoolOpOr NameLoad Dict Return Call NameLoad NameLoad NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str If UnaryOpNot NameLoad body Raise Call NameLoad Str Return Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults NameLoad AttributeLoad NameLoad attr NameLoad body Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad If NameLoad body Return NameLoad With AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad NameLoad attr NameLoad If UnaryOpNot NameLoad body Assign NameStore Call NameLoad NameLoad NameLoad NameLoad BoolOpOr NameLoad AttributeLoad NameLoad attr NameLoad Assign SubscriptStore AttributeLoad NameLoad attr Index NameLoad NameLoad If NameLoad body For NameStore NameLoad body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad If UnaryOpNot NameLoad body Assign NameStore ListLoad Assign SubscriptStore AttributeLoad NameLoad attr Index NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Str NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad If NameLoad body Assign NameStore NameLoad With AttributeLoad NameLoad attr body With AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad If BoolOpAnd NameLoad CompareEq NameLoad NameLoad body For NameStore AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Str NameLoad Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad If NameLoad body For NameStore NameLoad body Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad body Expr Str Assign NameStore Call NameLoad NameLoad NameLoad BoolOpOr NameLoad AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str With AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad If NameLoad body For NameStore AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str With AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr Call NameLoad Call AttributeLoad AttributeLoad NameLoad attr attr Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body With AttributeLoad NameLoad attr body If CompareIn AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Raise Call NameLoad BinOpMod Str AttributeLoad NameLoad attr Assign SubscriptStore AttributeLoad NameLoad attr Index AttributeLoad NameLoad attr NameLoad For NameStore AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr NameLoad decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam defaults body Assign NameStore Call NameLoad Call AttributeLoad AttributeLoad NameLoad attr attr For TupleStore NameStore NameStore NameLoad body With AttributeLoad NameLoad attr body If Call AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr Str NameLoad Expr Call AttributeLoad NameLoad attr NameLoad decorator_list NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str For NameStore AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr decorator_list decorator_list
N/A N/A logging N/A sys N/A time N/A threading kafka.metrics AnonMeasurable KafkaMetric MetricConfig MetricName kafka.metrics.stats Sensor N/A logger N/A N/A logging getLogger __name__ Metrics N/A object N/A N/A 
    A registry of sensors and metrics.

    A metric is a named, numerical measurement. A sensor is a handle to
    record numerical measurements as they occur. Each Sensor has zero or
    more associated metrics. For example a Sensor might represent message
    sizes and we might associate with this sensor a metric for the average,
    maximum, or other statistics computed off the sequence of message sizes
    that are recorded by the sensor.

    Usage looks something like this:
        # set up metrics:
        metrics = Metrics() # the global repository of metrics and sensors
        sensor = metrics.sensor('message-sizes')
        metric_name = MetricName('message-size-avg', 'producer-metrics')
        sensor.add(metric_name, Avg())
        metric_name = MetricName('message-size-max', 'producer-metrics')
        sensor.add(metric_name, Max())

        # as messages are sent we record the sizes
        sensor.record(message_size);
     __init__ N/A N/A self default_config reporters enable_expiration N/A None None False N/A N/A 
        Create a metrics repository with a default config, given metric
        reporters and the ability to expire eligible sensors

        Arguments:
            default_config (MetricConfig, optional): The default config
            reporters (list of AbstractMetricsReporter, optional):
                The metrics reporters
            enable_expiration (bool, optional): true if the metrics instance
                can garbage collect inactive sensors, false otherwise
         N/A N/A self _lock N/A N/A threading RLock N/A N/A self _config N/A default_config N/A MetricConfig N/A N/A self _sensors N/A N/A N/A self _metrics N/A N/A N/A self _children_sensors N/A N/A N/A self _reporters N/A reporters N/A N/A reporter N/A self _reporters N/A N/A N/A N/A reporter init N/A N/A enable_expiration N/A expire_loop N/A N/A N/A N/A N/A True N/A N/A N/A N/A time sleep 30 N/A N/A N/A N/A self ExpireSensorTask run self N/A N/A metrics_scheduler N/A N/A threading Thread target expire_loop N/A N/A metrics_scheduler daemon True N/A N/A N/A metrics_scheduler start N/A N/A N/A self add_metric N/A N/A self metric_name count kafka-metrics-count total number of registered metrics N/A AnonMeasurable N/A N/A N/A config now N/A N/A len N/A self _metrics N/A config N/A N/A self N/A N/A N/A N/A self _config N/A property metrics N/A N/A self N/A N/A N/A 
        Get all the metrics currently maintained and indexed by metricName
         N/A N/A self _metrics N/A property metric_name N/A N/A self name group description tags N/A None N/A N/A 
        Create a MetricName with the given name, group, description and tags,
        plus default tags specified in the metric configuration.
        Tag in tags takes precedence if the same tag key is specified in
        the default metric configuration.

        Arguments:
            name (str): The name of the metric
            group (str): logical group name of the metrics to which this
                metric belongs
            description (str, optional): A human-readable description to
                include in the metric
            tags (dict, optionals): additional key/value attributes of
                the metric
         N/A combined_tags N/A dict N/A N/A self config tags N/A N/A N/A combined_tags update N/A tags N/A N/A N/A MetricName name group description combined_tags N/A get_sensor N/A N/A self name N/A N/A N/A 
        Get the sensor with the given name if it exists

        Arguments:
            name (str): The name of the sensor

        Returns:
            Sensor: The sensor or None if no such sensor exists
         N/A N/A name N/A N/A N/A ValueError name must be non-empty N/A N/A N/A N/A self _sensors get name None N/A sensor N/A N/A self name config inactive_sensor_expiration_time_seconds parents N/A None N/A sys maxsize None N/A N/A 
        Get or create a sensor with the given unique name and zero or
        more parent sensors. All parent sensors will receive every value
        recorded with this sensor.

        Arguments:
            name (str): The name of the sensor
            config (MetricConfig, optional): A default configuration to use
                for this sensor for metrics that don't have their own config
            inactive_sensor_expiration_time_seconds (int, optional):
                If no value if recorded on the Sensor for this duration of
                time, it is eligible for removal
            parents (list of Sensor): The parent sensors

        Returns:
            Sensor: The sensor that is created
         N/A sensor N/A N/A self get_sensor name N/A sensor N/A N/A sensor N/A N/A self _lock N/A N/A sensor N/A N/A self get_sensor name N/A N/A sensor N/A N/A sensor N/A Sensor self name parents N/A config N/A self config inactive_sensor_expiration_time_seconds N/A N/A N/A self _sensors N/A name sensor N/A parents N/A N/A parent parents N/A N/A children N/A N/A N/A self _children_sensors get parent N/A N/A children N/A N/A children N/A N/A N/A N/A self _children_sensors N/A parent children N/A N/A N/A children append sensor N/A N/A N/A logger debug Added sensor with name %s name N/A sensor N/A remove_sensor N/A N/A self name N/A N/A N/A 
        Remove a sensor (if it exists), associated metrics and its children.

        Arguments:
            name (str): The name of the sensor to be removed
         N/A sensor N/A N/A N/A self _sensors get name N/A sensor N/A N/A child_sensors None N/A N/A sensor _lock N/A N/A N/A self _lock N/A N/A val N/A N/A N/A self _sensors pop name None N/A N/A val N/A val sensor N/A N/A metric N/A sensor metrics N/A N/A N/A N/A self remove_metric N/A metric metric_name N/A N/A N/A logger debug Removed sensor with name %s name N/A child_sensors N/A N/A N/A self _children_sensors pop sensor None N/A child_sensors N/A N/A child_sensor child_sensors N/A N/A N/A N/A self remove_sensor N/A child_sensor name N/A add_metric N/A N/A self metric_name measurable config N/A None N/A N/A 
        Add a metric to monitor an object that implements measurable.
        This metric won't be associated with any sensor.
        This is a way to expose existing values as metrics.

        Arguments:
            metricName (MetricName): The name of the metric
            measurable (AbstractMeasurable): The measurable that will be
                measured by this metric
            config (MetricConfig, optional): The configuration to use when
                measuring this measurable
         N/A metric N/A KafkaMetric metric_name measurable N/A config N/A self config N/A N/A N/A self register_metric metric N/A remove_metric N/A N/A self metric_name N/A N/A N/A 
        Remove a metric if it exists and return it. Return None otherwise.
        If a metric is removed, `metric_removal` will be invoked
        for each reporter.

        Arguments:
            metric_name (MetricName): The name of the metric

        Returns:
            KafkaMetric: the removed `KafkaMetric` or None if no such
                metric exists
         N/A N/A self _lock N/A N/A metric N/A N/A N/A self _metrics pop metric_name None N/A metric N/A N/A reporter N/A self _reporters N/A N/A N/A N/A reporter metric_removal metric N/A metric N/A add_reporter N/A N/A self reporter N/A N/A N/A Add a MetricReporter N/A N/A self _lock N/A N/A N/A N/A reporter init N/A list N/A N/A N/A self metrics values N/A N/A N/A N/A self _reporters append reporter N/A register_metric N/A N/A self metric N/A N/A N/A N/A self _lock N/A N/A N/A N/A metric metric_name N/A self metrics N/A N/A N/A ValueError N/A A metric named "%s" already exists, cannot register another one. N/A metric metric_name N/A N/A N/A self metrics N/A N/A metric metric_name metric N/A reporter N/A self _reporters N/A N/A N/A N/A reporter metric_change metric N/A ExpireSensorTask N/A object N/A N/A 
        This iterates over every Sensor and triggers a remove_sensor
        if it has expired. Package private for testing
         run N/A N/A metrics N/A N/A N/A items N/A list N/A N/A N/A metrics _sensors items N/A N/A name sensor items N/A N/A N/A sensor _lock N/A N/A N/A N/A sensor has_expired N/A N/A N/A N/A logger debug Removing expired sensor %s name N/A N/A N/A metrics remove_sensor name N/A staticmethod N/A close N/A N/A self N/A N/A N/A Close this metrics repository. N/A reporter N/A self _reporters N/A N/A N/A N/A reporter close N/A N/A