stats

package
v0.85.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const BlockstoreTypeKey = "blockstore_type"

Variables

View Source
var (
	ErrSendError        = errors.New("stats: send error")
	ErrNoInstallationID = fmt.Errorf("installation ID is missing: %w", ErrSendError)
)

Functions

func BuildMetadataProvider

func BuildMetadataProvider(logger logging.Logger, c *config.Config) cloud.MetadataProvider

func HashMetricValue added in v0.83.0

func HashMetricValue(s string) string

Types

type BufferedCollector

type BufferedCollector struct {
	// contains filtered or unexported fields
}

func NewBufferedCollector

func NewBufferedCollector(installationID string, c *config.Config, opts ...BufferedCollectorOpts) *BufferedCollector

func (*BufferedCollector) Close added in v0.62.0

func (s *BufferedCollector) Close()

func (*BufferedCollector) CollectEvent

func (s *BufferedCollector) CollectEvent(ev Event)

func (*BufferedCollector) CollectMetadata

func (s *BufferedCollector) CollectMetadata(accountMetadata *Metadata)

func (*BufferedCollector) Run

func (s *BufferedCollector) Run(ctx context.Context)

func (*BufferedCollector) SetInstallationID

func (s *BufferedCollector) SetInstallationID(installationID string)

func (*BufferedCollector) SetRuntimeCollector added in v0.48.0

func (s *BufferedCollector) SetRuntimeCollector(runtimeCollector func() map[string]string)

type BufferedCollectorOpts

type BufferedCollectorOpts func(s *BufferedCollector)

func WithExtended added in v0.83.0

func WithExtended(b bool) BufferedCollectorOpts

func WithFlushInterval

func WithFlushInterval(d time.Duration) BufferedCollectorOpts

func WithLogger added in v0.83.0

func WithLogger(l logging.Logger) BufferedCollectorOpts

func WithSendTimeout

func WithSendTimeout(d time.Duration) BufferedCollectorOpts

func WithSender

func WithSender(sender Sender) BufferedCollectorOpts

func WithWriteBufferSize

func WithWriteBufferSize(bufferSize int) BufferedCollectorOpts

type Collector

type Collector interface {
	CollectEvent(ev Event)
	CollectMetadata(accountMetadata *Metadata)
	SetInstallationID(installationID string)

	// Close must be called to ensure the delivery of pending stats
	Close()
}

type Event added in v0.83.0

type Event struct {
	Class      string `json:"class"`
	Name       string `json:"name"`
	Repository string `json:"repository,omitempty"`
	Ref        string `json:"ref,omitempty"`
	SourceRef  string `json:"source_ref,omitempty"`
	UserID     string `json:"user_id,omitempty"`
	Client     string `json:"client,omitempty"`
}

func (Event) ClearExtended added in v0.83.0

func (e Event) ClearExtended() Event

ClearExtended clear values of *all* extended fields

func (Event) HashExtended added in v0.83.0

func (e Event) HashExtended() Event

HashExtended hash the values of extended fields with sensitive information

type FlushTicker

type FlushTicker interface {
	Stop()
	Tick() <-chan time.Time
}

type HTTPSender

type HTTPSender struct {
	// contains filtered or unexported fields
}

func NewHTTPSender

func NewHTTPSender(addr string, timeout time.Duration, timeFunc TimeFn) *HTTPSender

func (*HTTPSender) SendEvent

func (s *HTTPSender) SendEvent(ctx context.Context, installationID, processID string, metrics []Metric) error

func (*HTTPSender) UpdateMetadata

func (s *HTTPSender) UpdateMetadata(ctx context.Context, m Metadata) error

type InputEvent

type InputEvent struct {
	InstallationID string   `json:"installation_id"`
	ProcessID      string   `json:"process_id"`
	Time           string   `json:"time"`
	Metrics        []Metric `json:"metrics"`
}

type Metadata

type Metadata struct {
	InstallationID string          `json:"installation_id"`
	Entries        []MetadataEntry `json:"entries"`
}

func NewMetadata

func NewMetadata(ctx context.Context, logger logging.Logger, blockstoreType string, authMetadataManager auth.MetadataManager, cloudMetadataProvider cloud.MetadataProvider) *Metadata

type MetadataEntry

type MetadataEntry struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type Metric

type Metric struct {
	Event
	Value uint64 `json:"value"`
}

type NullCollector added in v0.70.1

type NullCollector struct{}

func (*NullCollector) Close added in v0.70.1

func (m *NullCollector) Close()

func (*NullCollector) CollectEvent added in v0.70.1

func (m *NullCollector) CollectEvent(_ Event)

func (*NullCollector) CollectMetadata added in v0.70.1

func (m *NullCollector) CollectMetadata(_ *Metadata)

func (*NullCollector) SetInstallationID added in v0.70.1

func (m *NullCollector) SetInstallationID(_ string)

type Sender

type Sender interface {
	SendEvent(ctx context.Context, installationID, processID string, m []Metric) error
	UpdateMetadata(ctx context.Context, m Metadata) error
}

type TimeFn

type TimeFn func() time.Time

type TimeTicker

type TimeTicker struct {
	// contains filtered or unexported fields
}

func (*TimeTicker) Stop

func (t *TimeTicker) Stop()

func (*TimeTicker) Tick

func (t *TimeTicker) Tick() <-chan time.Time

Jump to

Keyboard shortcuts

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