metric

package
v1.1.78 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 38 Imported by: 6

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

func ExitMetricInit added in v1.1.58

func ExitMetricInit()

Types

type APIMetric

type APIMetric struct {
	Subscription  models.Subscription  `json:"subscription"`
	App           models.AppDetails    `json:"application"`
	Product       models.Product       `json:"product,omitempty"`
	API           models.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"`
	EventID       string               `json:"eventID"`
	StartTime     time.Time            `json:"-"`
}

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

func (*APIMetric) GetEventID added in v1.1.73

func (a *APIMetric) GetEventID() string

GetType - Returns APIMetric

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 AppUsage

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

AppUsage - struct to hold metric specific for app usage

type Collector

type Collector interface {
	AddMetric(apiDetails models.APIDetails, statusCode string, duration, bytes int64, appName string)
	AddMetricDetail(metricDetail Detail)
	AddAPIMetric(apiMetric *APIMetric)
	Publish()
	ShutdownPublish()
}

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 models.APIDetails
	StatusCode string
	Duration   int64
	UsageBytes int64
	AppDetails models.AppDetails
	TeamName   string
}

Data - struct for data to report as API Metrics

type Detail

type Detail struct {
	APIDetails models.APIDetails
	StatusCode string
	Duration   int64
	Bytes      int64
	AppDetails models.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) AddEventWithoutHistogram added in v1.1.64

func (b *EventBatch) AddEventWithoutHistogram(event beatPub.Event)

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 LighthouseUsageResponse added in v1.1.73

type LighthouseUsageResponse struct {
	Success     bool   `json:"success"`
	Description string `json:"description"`
	StatusCode  int    `json:"code"`
}

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 V4Data

type V4Data interface {
	GetStartTime() time.Time
	GetType() string
	GetEventID() 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,omitempty"` // ORG GUID
	Version      string               `json:"version"`
	Distribution *V4EventDistribution `json:"distribution"`
	Data         V4Data               `json:"data"`
	Session      *V4Session           `json:"session,omitempty"`
}

V4Event - represents V7 event

type V4EventDistribution

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

V4EventDistribution - represents V4 distribution

type V4Session added in v1.1.58

type V4Session struct {
	ID string `json:"id"`
}

V4Session - represents V4 session

Jump to

Keyboard shortcuts

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