metric

package
v1.1.105 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 41 Imported by: 6

Documentation

Index

Constants

View Source
const (
	Success   statusText = "Success"
	Failure   statusText = "Failure"
	Exception statusText = "Exception"
)
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, counters map[string]metrics.Counter) 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,omitempty"`
	App           models.AppDetails         `json:"application,omitempty"`
	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,omitempty"`
	Status        string                    `json:"status,omitempty"`
	Count         int64                     `json:"count"`
	Response      ResponseMetrics           `json:"response,omitempty"`
	Observation   models.ObservationDetails `json:"observation"`
	EventID       string                    `json:"-"`
	StartTime     time.Time                 `json:"-"`
	Unit          *models.Unit              `json:"unit,omitempty"`
}

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) GetLogFields added in v1.1.80

func (a *APIMetric) GetLogFields() logrus.Fields

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 {
	InitializeBatch()
	AddMetric(apiDetails models.APIDetails, statusCode string, duration, bytes int64, appName string)
	AddCustomMetricDetail(metric models.CustomMetricDetail)
	AddMetricDetail(metricDetail Detail)
	AddAPIMetricDetail(metric MetricDetail)
	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
	AppDetails models.AppDetails
	StatusCode string
	UnitName   string
	Duration   int64
	Bytes      int64
}

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 acknowledgeded, cleanup the counters

func (*EventBatch) AddEvent

func (b *EventBatch) AddEvent(event beatPub.Event, histogram metrics.Histogram, counters map[string]metrics.Counter)

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 MetricDetail added in v1.1.86

type MetricDetail struct {
	APIDetails  models.APIDetails
	AppDetails  models.AppDetails
	StatusCode  string
	Count       int64
	Response    ResponseMetrics
	Observation models.ObservationDetails
}

type Reporter added in v1.1.105

type Reporter struct {
	AgentVersion     string `json:"agentVersion,omitempty"`
	AgentType        string `json:"agentType,omitempty"`
	AgentSDKVersion  string `json:"agentSDKVersion,omitempty"`
	AgentName        string `json:"agentName,omitempty"`
	ObservationDelta int64  `json:"observationDelta,omitempty"`
}

type ResponseMetrics

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

ResponseMetrics - Holds metrics API response

type Transactions added in v1.1.105

type Transactions struct {
	UnitCount
	Response *ResponseMetrics `json:"response,omitempty"`
	Status   string           `json:"status,omitempty"`
}

type UnitCount added in v1.1.105

type UnitCount struct {
	Count int64                     `json:"count"`
	Quota *models.ResourceReference `json:"quota,omitempty"`
}

type Units added in v1.1.105

type Units struct {
	Transactions *Transactions         `json:"transactions,omitempty"`
	CustomUnits  map[string]*UnitCount `json:"-"`
}

func (Units) MarshalJSON added in v1.1.105

func (u Units) MarshalJSON() ([]byte, error)

type UsageEvent added in v1.1.80

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

UsageEvent -Lighthouse Usage Event

type UsageReport added in v1.1.80

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

UsageReport -Lighthouse Usage report

type UsageResponse added in v1.1.80

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

type V4Data

type V4Data interface {
	GetStartTime() time.Time
	GetType() string
	GetEventID() string
	GetLogFields() logrus.Fields
}

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