metrics

package
v0.0.0-...-8aeb8a1 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TokenSourceType = "token"
	EmptySourceTap  = ""
)
View Source
const Unknown = "unknown"

Variables

View Source
var Auth bool
View Source
var DefaultRelayURL = "https://cplane.jitsu.com/api/prometheus/relay/submit"

DefaultRelayURL is the URL which is used by default for relaying metrics.

View Source
var Endpoint string
View Source
var Exported bool
View Source
var SensitiveLabels = map[string]bool{
	"source_id":      true,
	"destination_id": true,
}

SensitiveLabels are label names which values should be hashed in order to respect users' privacy.

Functions

func CloneMetricData

func CloneMetricData(src []*dto.MetricFamily) ([]*dto.MetricFamily, error)

func CoordinationRedisErrors

func CoordinationRedisErrors(errorType string)

func DequeuedEvent

func DequeuedEvent(destinationType, destinationName string)

func DequeuedRecognitionEvent

func DequeuedRecognitionEvent(identifier string)

func Enabled

func Enabled() bool

func EnqueuedEvent

func EnqueuedEvent(destinationType, destinationName string)

func EnqueuedRecognitionEvent

func EnqueuedRecognitionEvent(identifier string)

func ErrorObjects

func ErrorObjects(sourceType, sourceTap, sourceName string, value int)

func ErrorSourceEvents

func ErrorSourceEvents(sourceType, sourceTap, sourceName, destinationType, destinationName string, value int)

func ErrorTokenEvent

func ErrorTokenEvent(tokenID, destinationType, destinationName string)

func ErrorTokenEvents

func ErrorTokenEvents(tokenID, destinationType, destinationName string, value int)

func ErrorTokenObjects

func ErrorTokenObjects(tokenID string, value int)

func EventsRedisErrors

func EventsRedisErrors(errorType string)

func FreeSourcesGoroutines

func FreeSourcesGoroutines(value int)

func Handler

func Handler() http.Handler

func Init

func Init(exported bool, auth bool, endpoint string)

func InitialUsersRecognitionQueueSize

func InitialUsersRecognitionQueueSize(identifier string, value int)

func MetaRedisErrors

func MetaRedisErrors(errorType string)

func NewCounterVec

func NewCounterVec(opts prometheus.CounterOpts, labels []string) *prometheus.CounterVec

func NewGaugeVec

func NewGaugeVec(opts prometheus.GaugeOpts, labels []string) *prometheus.GaugeVec

func NewHistogramVec

func NewHistogramVec(opts prometheus.HistogramOpts, labels []string) *prometheus.HistogramVec

func RecognitionEvent

func RecognitionEvent(metricType RecognitionMetric, tokenID string, value int)

func RunningSourcesGoroutines

func RunningSourcesGoroutines(value int)

func SetStreamEventsBufferSize

func SetStreamEventsBufferSize(destinationType, destinationName string, value int)

func SetStreamEventsQueueSize

func SetStreamEventsQueueSize(destinationType, destinationName string, value int)

func SkipTokenEvent

func SkipTokenEvent(tokenID, destinationType, destinationName string)

func SkipTokenEvents

func SkipTokenEvents(tokenID, destinationType, destinationName string, value int)

func SuccessObjects

func SuccessObjects(sourceType, sourceTap, sourceName string, value int)

func SuccessSourceEvents

func SuccessSourceEvents(sourceType, sourceTap, sourceName, destinationType, destinationName string, value int)

func SuccessTokenEvent

func SuccessTokenEvent(tokenID, destinationType, destinationName string)

func SuccessTokenEvents

func SuccessTokenEvents(tokenID, destinationType, destinationName string, value int)

func SuccessTokenObjects

func SuccessTokenObjects(tokenID string, value int)

func TransformErrors

func TransformErrors(destinationId string)

func TransformKeyValueDel

func TransformKeyValueDel(destinationId string)

func TransformKeyValueGet

func TransformKeyValueGet(destinationId string)

func TransformKeyValueRedisErrors

func TransformKeyValueRedisErrors(errorType string)

func TransformKeyValueSet

func TransformKeyValueSet(destinationId string, size int)

func UserRecognitionRedisErrors

func UserRecognitionRedisErrors(errorType string)

Types

type RecognitionMetric

type RecognitionMetric int
const (
	TotalEvents RecognitionMetric = iota
	AnonymousEvents
	IdentifiedEvents
	IdentifiedCacheHits
	IdentifiedAggregatedEvents
	RecognizedEvents
	BotEvents

	Dummy //to allocate proper array
)

type Relay

type Relay struct {
	URL          string
	HostID       string
	DeploymentID string
	Timeout      time.Duration
	// contains filtered or unexported fields
}

func InitRelay

func InitRelay(clusterID string, viper *viper.Viper) *Relay

func (*Relay) Relay

func (r *Relay) Relay(ctx context.Context, gatherer prometheus.Gatherer) error

Relay is responsible for relaying all metrics data from Registry to some HTTP endpoint via POST request with JSON body (see RelayData) while also hashing sensitive label values.

func (*Relay) Run

func (r *Relay) Run(rootCtx context.Context, trigger RelayTrigger, gatherer prometheus.Gatherer)

func (*Relay) Stop

func (r *Relay) Stop()

type RelayData

type RelayData struct {
	Timestamp    int64               `json:"timestamp"`
	HostID       string              `json:"hostId"`
	DeploymentID string              `json:"deploymentId"`
	Data         []*dto.MetricFamily `json:"data"`
}

type RelayTrigger

type RelayTrigger interface {

	// Channel returns the channel which events are emitted to.
	// The returned channel values are ignored.
	Channel() <-chan time.Time

	// Stop stops this trigger from emitting events.
	Stop()
}

RelayTrigger is basically an interface of time.Ticker. Triggers are responsible for emitting events on the channel returned by Channel when some conditions for relay execution are met.

type TickerTrigger

type TickerTrigger struct {
	*time.Ticker
}

TickerTrigger wraps the stdlib time.Ticker into RelayTrigger interface.

func (TickerTrigger) Channel

func (t TickerTrigger) Channel() <-chan time.Time

Jump to

Keyboard shortcuts

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