validation

package
v0.0.0-...-feb402c Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccessMetricDescriptor

func AccessMetricDescriptor(uploadedMetricDescriptors map[string]*metric.MetricDescriptor, metricType string) (*metric.MetricDescriptor, error)

AccessMetricDescriptor attempts to retrieve the given metric descriptor. If it does / exist, an error is returned.

func AccessSpan

func AccessSpan(index int, uploadedSpans []*cloudtrace.Span) *cloudtrace.Span

AccessSpan returns the span at the given index if it is in range. If it is not in range, nil is returned.

func AddMetricDescriptor

func AddMetricDescriptor(uploadedMetricDescriptors map[string]*metric.MetricDescriptor, metricType string, metricDescriptor *metric.MetricDescriptor) error

AddMetricDescriptor adds a new MetricDescriptor to the map if a duplicate type does not already exist. If a duplicate is detected, an error is returned.

func AddPoint

func AddPoint(timeSeries []*monitoring.TimeSeries, uploadedPoints map[string]*PreviousPoint)

AddPoint sets the latest point to be the current point for a given time series.

func AddSpans

func AddSpans(spanData *SpanData, spans ...*cloudtrace.Span)

AddSpans adds the given spans to the list of uploaded spans.

func CheckForRequiredFields

func CheckForRequiredFields(requiredFields []string, reqReflect reflect.Value, requestName string) error

CheckForRequiredFields verifies that the required fields for the given request are present.

func Delay

func Delay(ctx context.Context, delay time.Duration) error

Delay will block for the specified amount of time. Used to delay writing spans to memory.

func RemoveMetricDescriptor

func RemoveMetricDescriptor(uploadedMetricDescriptors map[string]*metric.MetricDescriptor, metricType string) error

RemoveMetricDescriptor attempts to delete the given metric descriptor. If it does not exist, an error is returned.

func ValidateCreateMetricDescriptor

func ValidateCreateMetricDescriptor(metricDescriptor *metric.MetricDescriptor) error

func ValidateCreateTimeSeries

func ValidateCreateTimeSeries(timeSeries []*monitoring.TimeSeries, timeSeriesData *TimeSeriesData, descriptors map[string]*metric.MetricDescriptor) error

ValidateCreateTimeSeries checks that the given TimeSeries conform to the API requirements.

func ValidateDuplicateErrDetails

func ValidateDuplicateErrDetails(err error, duplicateName string) bool

ValidateDuplicateErrDetails is used in tests to verify that the error returned contains the correct duplicated value.

func ValidateMissingFieldsErrDetails

func ValidateMissingFieldsErrDetails(err error, missingFields map[string]struct{}) bool

ValidateMissingFieldsErrDetails is used to test that the error details contain the correct missing fields.

func ValidateProjectName

func ValidateProjectName(projectName string) error

ValidateProjectName verifies that the project name from the BatchWriteSpans request is of the form projects/[PROJECT_ID]

func ValidateRateLimit

func ValidateRateLimit(timeSeries []*monitoring.TimeSeries, uploadedPoints map[string]*PreviousPoint) error

ValidateRateLimit validates that the rate at which points are written does not exceed the limit. The limit is one point every 10 seconds.

func ValidateRequiredFields

func ValidateRequiredFields(req interface{}) error

ValidateRequiredFields verifies that the given request contains the required fields.

func ValidateSpans

func ValidateSpans(requestName string, spanData *SpanData, spans ...*cloudtrace.Span) error

ValidateSpans checks that the spans conform to the API requirements. That is, required fields are present, and optional fields are of the correct form. If any violations are detected, the errors will be added to the result table.

Types

type DescriptorStatus

type DescriptorStatus struct {
	MetricDescriptor *metric.MetricDescriptor
	Status           string
}

MetricDescriptorStatus wraps a MetricDescriptor with the status of its creation. Used in the MetricDescriptor summary table.

type MetricDescriptorData

type MetricDescriptorData struct {
	UploadedMetricDescriptors map[string]*metric.MetricDescriptor
	MetricDescriptorSummary   []*DescriptorStatus
	MetricDescriptorsLock     sync.Mutex
}

MetricDescriptorData is a wrapper struct for all the data that the server keeps with respect to metric descriptors.

type PreviousPoint

type PreviousPoint struct {
	Point *monitoring.Point
	Time  time.Time
}

PreviousPoint contains information about the most recently uploaded point for a time series.

type SpanData

type SpanData struct {
	// If a batch has a bad span, we don't write batch to memory, but still want
	// info on them for summary, so need SpansSummary
	SpansSummary      []*cloudtrace.Span
	UploadedSpanNames map[string]struct{}
	UploadedSpans     []*cloudtrace.Span
	Mutex             sync.RWMutex
}

SpanData wraps all the span data on the server into a struct.

type TimeSeriesData

type TimeSeriesData struct {
	UploadedPoints    map[string]*PreviousPoint
	TimeSeriesSummary []*TimeSeriesStatus
	TimeSeriesLock    sync.Mutex
}

TimeSeriesData is a wrapper struct for all the data that the server keeps with respect to time series.

type TimeSeriesStatus

type TimeSeriesStatus struct {
	TimeSeries *monitoring.TimeSeries
	Status     string
}

TimeSeriesStruct wraps a TimeSeries with the status of its creation. Used in the TimeSeries summary table.

Jump to

Keyboard shortcuts

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