metric

package
v1.1.37 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2022 License: Apache-2.0 Imports: 39 Imported by: 5

Documentation

Index

Constants

View Source
const (
	ISO8601 = "2006-01-02T15:04:00Z07:00"
)

ISO8601 - time format

Variables

This section is empty.

Functions

func AddCondorMetricEventToBatch

func AddCondorMetricEventToBatch(metricEvent V4Event, batch *EventBatch, histogram metrics.Histogram) error

AddCondorMetricEventToBatch - creates the condor metric event and adds to the batch

Types

type APIDetails

type APIDetails struct {
	ID                 string `json:"id"`
	Name               string `json:"name"`
	Revision           int    `json:"revision,omitempty"`
	TeamID             string `json:"teamId,omitempty"`
	APIServiceInstance string `json:"apiServiceInstance,omitempty"`
	Stage              string `json:"-"`
}

APIDetails - Holds the api details

type APIMetric

type APIMetric struct {
	Subscription  SubscriptionDetails  `json:"subscription"`
	App           AppDetails           `json:"application"`
	Product       models.Product       `json:"product,omitempty"`
	API           APIDetails           `json:"api"`
	AssetResource models.AssetResource `json:"assetResource,omitempty"`
	ProductPlan   models.ProductPlan   `json:"productPlan,omitempty"`
	Quota         models.Quota         `json:"quota,omitempty"`
	StatusCode    string               `json:"statusCode"`
	Status        string               `json:"status"`
	Count         int64                `json:"count"`
	Response      ResponseMetrics      `json:"response"`
	Observation   ObservationDetails   `json:"observation"`
	StartTime     time.Time            `json:"-"`
}

APIMetric - struct to hold metric aggregated for subscription,application,api,statuscode

func (*APIMetric) GetStartTime

func (a *APIMetric) GetStartTime() time.Time

GetStartTime - Returns the start time for subscription metric

func (*APIMetric) GetType

func (a *APIMetric) GetType() string

GetType - Returns APIMetric

type AppDetails

type AppDetails struct {
	ID            string `json:"id"`
	Name          string `json:"name"`
	ConsumerOrgID string `json:"consumerOrgId,omitempty"`
}

AppDetails - struct for app details to report

type AppUsage

type AppUsage struct {
	App   AppDetails `json:"app"`
	Count int64      `json:"count"`
}

AppUsage - struct to hold metric specific for app usage

type Collector

type Collector interface {
	AddMetric(apiDetails APIDetails, statusCode string, duration, bytes int64, appName string)
	AddMetricDetail(metricDetail Detail)
}

Collector - interface for collecting metrics

func GetMetricCollector

func GetMetricCollector() Collector

GetMetricCollector - Create metric collector

type CondorMetricEvent

type CondorMetricEvent struct {
	Message   string                 `json:"message"`
	Fields    map[string]interface{} `json:"fields"`
	Timestamp time.Time              `json:"-"`
	ID        string                 `json:"-"`
}

CondorMetricEvent - the condor event format to send metric data

func (*CondorMetricEvent) CreateEvent

func (c *CondorMetricEvent) CreateEvent() (beatPub.Event, error)

CreateEvent - creates the beat event to add to the batch

type Data

type Data struct {
	APIDetails APIDetails
	StatusCode string
	Duration   int64
	UsageBytes int64
	AppDetails AppDetails
	TeamName   string
}

Data - struct for data to report as API Metrics

type Detail

type Detail struct {
	APIDetails APIDetails
	StatusCode string
	Duration   int64
	Bytes      int64
	AppDetails AppDetails
}

Detail - holds the details for computing metrics for API and consumer subscriptions

type EventBatch

type EventBatch struct {
	beatPub.Batch
	// contains filtered or unexported fields
}

EventBatch - creates a batch of MetricEvents to send to Condor

func NewEventBatch

func NewEventBatch(c *collector) *EventBatch

NewEventBatch - creates a new batch

func (*EventBatch) ACK

func (b *EventBatch) ACK()

ACK - all events have been acked, cleanup the counters

func (*EventBatch) AddEvent

func (b *EventBatch) AddEvent(event beatPub.Event, histogram metrics.Histogram)

AddEvent - adds an event to the batch

func (*EventBatch) Cancelled

func (b *EventBatch) Cancelled()

Cancelled - batch has been cancelled

func (*EventBatch) CancelledEvents

func (b *EventBatch) CancelledEvents(events []beatPub.Event)

CancelledEvents - events have been cancelled

func (*EventBatch) Drop

func (b *EventBatch) Drop()

Drop - drop the entire batch

func (*EventBatch) Events

func (b *EventBatch) Events() []beatPub.Event

Events - return the events in the batch

func (*EventBatch) Publish

func (b *EventBatch) Publish() error

Publish - connects to the traceability clients and sends this batch of events

func (*EventBatch) Retry

func (b *EventBatch) Retry()

Retry - batch sent for retry, publish again

func (*EventBatch) RetryEvents

func (b *EventBatch) RetryEvents(events []beatPub.Event)

RetryEvents - certain events sent to retry

type ISO8601Time

type ISO8601Time time.Time

ISO8601Time - time

func (ISO8601Time) MarshalJSON

func (t ISO8601Time) MarshalJSON() ([]byte, error)

MarshalJSON -

func (*ISO8601Time) UnmarshalJSON

func (t *ISO8601Time) UnmarshalJSON(bytes []byte) error

UnmarshalJSON - unmarshal json for time

type LighthouseUsageEvent

type LighthouseUsageEvent struct {
	OrgGUID     string                           `json:"-"`
	EnvID       string                           `json:"envId"`
	Timestamp   ISO8601Time                      `json:"timestamp"`
	Granularity int                              `json:"granularity"`
	SchemaID    string                           `json:"schemaId"`
	Report      map[string]LighthouseUsageReport `json:"report"`
	Meta        map[string]interface{}           `json:"meta"`
}

LighthouseUsageEvent -Lighthouse Usage Event

type LighthouseUsageReport

type LighthouseUsageReport struct {
	Product string                 `json:"product"`
	Usage   map[string]int64       `json:"usage"`
	Meta    map[string]interface{} `json:"meta"`
}

LighthouseUsageReport -Lighthouse Usage report

type ObservationDetails

type ObservationDetails struct {
	Start int64 `json:"start,omitempty"`
	End   int64 `json:"end,omitempty"`
}

ObservationDetails - Holds start and end timestamp for interval

type ResponseMetrics

type ResponseMetrics struct {
	Max int64   `json:"max"`
	Min int64   `json:"min"`
	Avg float64 `json:"avg"`
}

ResponseMetrics - Holds metrics API response

type SubscriptionDetails

type SubscriptionDetails struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

SubscriptionDetails - struct for subscription metric detail

type V4Data

type V4Data interface {
	GetStartTime() time.Time
	GetType() string
}

V4Data - Interface for representing the metric data

type V4Event

type V4Event struct {
	ID           string               `json:"id"`
	Timestamp    int64                `json:"timestamp"`
	Event        string               `json:"event"`
	App          string               `json:"app"` // ORG GUID
	Version      string               `json:"version"`
	Distribution *V4EventDistribution `json:"distribution"`
	Data         V4Data               `json:"data"`
}

V4Event - represents V7 event

type V4EventDistribution

type V4EventDistribution struct {
	Environment string `json:"environment"`
	Version     string `json:"version"`
}

V4EventDistribution - represents V7 distribution

Jump to

Keyboard shortcuts

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