metrics

package
v0.0.0-...-2cc3bea Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package metrics defines metrics for various build events, and utility functions to be used in other modules for the metric updates.

Index

Constants

This section is empty.

Variables

View Source
var (

	// V1 is a collection of metric objects for V1 metrics.
	V1 = struct {
		BuildCount              metric.Int
		BuildCountCreated       metric.Counter
		BuildCountStarted       metric.Counter
		BuildCountCompleted     metric.Counter
		BuildDurationCycle      metric.CumulativeDistribution
		BuildDurationRun        metric.CumulativeDistribution
		BuildDurationScheduling metric.CumulativeDistribution
		ExpiredLeaseReset       metric.Counter
		MaxAgeScheduled         metric.Float
	}{
		BuildCount: metric.NewInt(
			"buildbucket/builds/count",
			"Number of pending/running prod builds", nil,
			bFields("status")...,
		),
		BuildCountCreated: metric.NewCounter(
			"buildbucket/builds/created",
			"Build creation", nil,
			bFields("user_agent")...,
		),
		BuildCountStarted: metric.NewCounter(
			"buildbucket/builds/started",
			"Build start", nil,
			bFields("canary")...,
		),
		BuildCountCompleted: metric.NewCounter(
			"buildbucket/builds/completed",
			"Build completion, including success, failure and cancellation", nil,
			bFields("result", "failure_reason", "cancelation_reason", "canary")...,
		),
		BuildDurationCycle: newbuildDurationMetric(
			"buildbucket/builds/cycle_durations",
			"Duration between build creation and completion",
		),
		BuildDurationRun: newbuildDurationMetric(
			"buildbucket/builds/run_durations",
			"Duration between build start and completion",
		),
		BuildDurationScheduling: newbuildDurationMetric(
			"buildbucket/builds/scheduling_durations",
			"Duration between build creation and start",
		),
		ExpiredLeaseReset: metric.NewCounter(
			"buildbucket/builds/lease_expired",
			"Build lease expirations", nil,
			bFields("status")...,
		),
		MaxAgeScheduled: metric.NewFloat(
			"buildbucket/builds/max_age_scheduled",
			"Age of the oldest SCHEDULED build",
			&types.MetricMetadata{Units: types.Seconds},
			bFields("must_be_never_leased")...,
		),
	}
)
View Source
var (
	// V2 is a collection of metric objects for V2 metrics.
	V2 = struct {
		BuildCount              metric.Int
		BuildCountCreated       metric.Counter
		BuildCountStarted       metric.Counter
		BuildCountCompleted     metric.Counter
		BuildDurationCycle      metric.CumulativeDistribution
		BuildDurationRun        metric.CumulativeDistribution
		BuildDurationScheduling metric.CumulativeDistribution
		BuilderPresence         metric.Bool
		ConsecutiveFailureCount metric.Int
		MaxAgeScheduled         metric.Float
	}{
		BuildCount: metric.NewIntWithTargetType(
			"buildbucket/v2/builds/count",
			(&bbmetrics.BuilderTarget{}).Type(),
			"Number of pending/running prod builds",
			nil,
			field.String("status"),
		),
		BuildCountCreated: metric.NewCounterWithTargetType(
			"buildbucket/v2/builds/created",
			(&bbmetrics.BuilderTarget{}).Type(),
			"Build creation",
			nil,
			field.String("experiments"),
		),
		BuildCountStarted: metric.NewCounterWithTargetType(
			"buildbucket/v2/builds/started",
			(&bbmetrics.BuilderTarget{}).Type(),
			"Build start",
			nil,
			field.String("experiments"),
		),
		BuildCountCompleted: metric.NewCounterWithTargetType(
			"buildbucket/v2/builds/completed",
			(&bbmetrics.BuilderTarget{}).Type(),
			"Build completion, including success, failure and cancellation",
			nil,
			field.String("status"),
			field.String("experiments"),
		),
		BuildDurationCycle: metric.NewCumulativeDistributionWithTargetType(
			"buildbucket/v2/builds/cycle_durations",
			(&bbmetrics.BuilderTarget{}).Type(),
			"Duration between build creation and completion",
			&types.MetricMetadata{Units: types.Seconds},

			distribution.GeometricBucketer(math.Pow(10, 0.053), 100),
			field.String("status"),
			field.String("experiments"),
		),
		BuildDurationRun: metric.NewCumulativeDistributionWithTargetType(
			"buildbucket/v2/builds/run_durations",
			(&bbmetrics.BuilderTarget{}).Type(),
			"Duration between build start and completion",
			&types.MetricMetadata{Units: types.Seconds},

			distribution.GeometricBucketer(math.Pow(10, 0.053), 100),
			field.String("status"),
			field.String("experiments"),
		),
		BuildDurationScheduling: metric.NewCumulativeDistributionWithTargetType(
			"buildbucket/v2/builds/scheduling_durations",
			(&bbmetrics.BuilderTarget{}).Type(),
			"Duration between build creation and start",
			&types.MetricMetadata{Units: types.Seconds},

			distribution.GeometricBucketer(math.Pow(10, 0.053), 100),
			field.String("experiments"),
		),
		BuilderPresence: metric.NewBoolWithTargetType(
			"buildbucket/v2/builder/presence",
			(&bbmetrics.BuilderTarget{}).Type(),
			"A constant, always-true metric that indicates the presence of LUCI Builder",
			nil,
		),
		ConsecutiveFailureCount: metric.NewIntWithTargetType(
			"buildbucket/v2/builds/consecutive_failure_count",
			(&bbmetrics.BuilderTarget{}).Type(),
			"Number of consecutive non-successful build terminations since the last successful build.",
			nil,
			field.String("status"),
		),
		MaxAgeScheduled: metric.NewFloatWithTargetType(
			"buildbucket/v2/builds/max_age_scheduled",
			(&bbmetrics.BuilderTarget{}).Type(),
			"Age of the oldest SCHEDULED build",
			&types.MetricMetadata{Units: types.Seconds},
		),
	}
)

Functions

func BuildCompleted

func BuildCompleted(ctx context.Context, b *model.Build)

BuildCompleted updates metrics for a build completion event.

func BuildCreated

func BuildCreated(ctx context.Context, b *model.Build)

BuildCreated updates metrics for a build creation event.

func BuildStarted

func BuildStarted(ctx context.Context, b *model.Build)

BuildStarted updates metrics for a build start event.

func ExpiredLeaseReset

func ExpiredLeaseReset(ctx context.Context, b *model.Build)

ExpiredLeaseReset updates metrics for an expired lease reset.

func ReportBuilderMetrics

func ReportBuilderMetrics(ctx context.Context) error

ReportBuilderMetrics computes and reports Builder metrics.

func WithBuilder

func WithBuilder(ctx context.Context, project, bucket, builder string) context.Context

WithBuilder returns a context for a Builder target with the given info.

WithServiceInfo must be called once before this function. Otherwise, this panics.

func WithServiceInfo

func WithServiceInfo(ctx context.Context, service, job, instance string) context.Context

WithServiceInfo sets the service info to be set in the Builder target.

Call this in the initialization of a server process.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL