Exemple #1
0
def SecondsDistribution(name):
    """Returns a metric handle for a cumulative distribution named |name|.

  The distribution handle returned by this method is better suited than the
  default one for recording handling times, in seconds.

  This metric handle has bucketing that is optimized for time intervals
  (in seconds) in the range of 1 second to 32 days.
  """
    b = ts_mon.GeometricBucketer(growth_factor=_SECONDS_BUCKET_FACTOR)
    return ts_mon.CumulativeDistributionMetric(name, bucketer=b)
Exemple #2
0
    def _report_job_time_distribution(self, jobs):
        """Report distribution of job durations to monarch."""
        jobs_time_distribution = metrics.Distribution(_METRICS_PREFIX +
                                                      'known_jobs_durations')
        now = datetime.datetime.now()

        # The type expected by the .set(...) of a distribution is a
        # distribution.
        dist = ts_mon.Distribution(ts_mon.GeometricBucketer())
        for job in jobs:
            duration = int(max(0, (now - job.created_on).total_seconds()))
            dist.add(duration)
        jobs_time_distribution.set(dist)
def CumulativeSecondsDistribution(name, scale=1, reset_after=False,
                                  description=None, field_spec=_MISSING):
  """Returns a metric handle for a cumulative distribution named |name|.

  The distribution handle returned by this method is better suited than the
  default one for recording handling times, in seconds.

  This metric handle has bucketing that is optimized for time intervals
  (in seconds) in the range of 1 second to 32 days. Use |scale| to adjust this
  (e.g. scale=0.1 covers a range from .1 seconds to 3.2 days).

  Args:
    name: string name of metric
    scale: scaling factor of buckets, and size of the first bucket. default: 1
    reset_after: Should the metric be reset after reporting.
    description: A string description of the metric.
    field_spec: A sequence of ts_mon.Field objects to specify the field schema.
  """
  b = ts_mon.GeometricBucketer(growth_factor=_SECONDS_BUCKET_FACTOR,
                               scale=scale)
  return ts_mon.CumulativeDistributionMetric(
      name, bucketer=b, units=ts_mon.MetricsDataUnits.SECONDS,
      description=description, field_spec=field_spec)
field_spec = [
    ts_mon.StringField('builder'),
    ts_mon.StringField('master'),
    ts_mon.StringField('project_id'),
    ts_mon.StringField('result'),
    ts_mon.StringField('slave'),
    ts_mon.StringField('subproject_id'),
]

result_count = ts_mon.CounterMetric('buildbot/master/builders/results/count',
    'Number of items consumed from ts_mon.log by mastermon',
    field_spec)
# A custom bucketer with 12% resolution in the range of 1..10**5,
# better suited for build cycle times.
bucketer = ts_mon.GeometricBucketer(
    growth_factor=10**0.05, num_finite_buckets=100)
cycle_times = ts_mon.CumulativeDistributionMetric(
    'buildbot/master/builders/builds/durations',
    'Durations (in seconds) that slaves spent actively doing work towards '
    'builds for each builder',
    field_spec,
    bucketer=bucketer)
pending_times = ts_mon.CumulativeDistributionMetric(
    'buildbot/master/builders/builds/pending_durations',
    'Durations (in seconds) that the master spent waiting for slaves to become '
    'available for each builder',
    field_spec,
    bucketer=bucketer)
total_times = ts_mon.CumulativeDistributionMetric(
    'buildbot/master/builders/builds/total_durations',
    'Total duration (in seconds) that builds took to complete for each builder',