telemetry

package
v0.0.0-...-5b8cc2b Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package telemetry provides functionality for emitting telemetry in azd.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FirstNotice

func FirstNotice() string

func IsTelemetryEnabled

func IsTelemetryEnabled() bool

func SetupFirstRun

func SetupFirstRun() error

Types

type Exporter

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

Exporter is an implementation of trace.SpanExporter that writes spans into a storage queue in ApplicationInsights format.

func NewExporter

func NewExporter(queue simpleQueue, instrumentationKey string) *Exporter

func (*Exporter) ExportSpans

func (e *Exporter) ExportSpans(ctx context.Context, spans []trace.ReadOnlySpan) error

ExportSpans writes spans to the storage queue in AppInsights format.

func (*Exporter) ExportedAny

func (e *Exporter) ExportedAny() bool

func (*Exporter) MarshalLog

func (e *Exporter) MarshalLog() interface{}

MarshalLog is the marshaling function used by the logging system to represent this exporter.

func (*Exporter) Shutdown

func (e *Exporter) Shutdown(ctx context.Context) error

Shutdown is called to stop the exporter, it performs no action.

type Queue

type Queue interface {
	Enqueue(message []byte) error
	EnqueueWithDelay(message []byte, delayDuration time.Duration, retryCount int) error
	Peek() (*StoredItem, error)
	Remove(item *StoredItem) error
}

type StorageQueue

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

StorageQueue is a FIFO-based queue backed by disk storage, with items stored as individual files. The current implementation allows for multiple producers, single consumer.

Items can be queued by Enqueue or EnqueueWithDelay. QueueWithDelay allows for producers to queue items that should not be picked up by consumers until after the specified duration has passed. This is useful for retry delay scheduling.

Items can be read by Peek, which will read the next available item. Once the item is processed, consumers are responsible for calling Remove to remove the item from the queue.

func NewStorageQueue

func NewStorageQueue(
	folder string, itemFileExtension string, itemFileMaxTimeKept time.Duration) (*StorageQueue, error)

Creates the storage-based queue.

func (*StorageQueue) Cleanup

func (stg *StorageQueue) Cleanup(ctx context.Context, done chan (struct{}))

Scans the storage directory for any obsoleted items or temp files.

func (*StorageQueue) Enqueue

func (stg *StorageQueue) Enqueue(message []byte) error

Queues a message.

func (*StorageQueue) EnqueueWithDelay

func (stg *StorageQueue) EnqueueWithDelay(message []byte, delayDuration time.Duration, retryCount int) error

Queues a message with delay.

func (*StorageQueue) Peek

func (stg *StorageQueue) Peek() (*StoredItem, error)

Gets the next available item for processing. Returns nil if no items exist. Returns error if an error occurs while reading storage.

func (*StorageQueue) Remove

func (stg *StorageQueue) Remove(item *StoredItem) error

Removes the stored item from queue. Does not return an error if the item is already removed.

type StoredItem

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

func (*StoredItem) Message

func (itm *StoredItem) Message() []byte

func (*StoredItem) RetryCount

func (itm *StoredItem) RetryCount() int

type TelemetrySystem

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

func GetTelemetrySystem

func GetTelemetrySystem() *TelemetrySystem

Returns the singleton TelemetrySystem instance. Returns nil if telemetry failed to initialize, or user has disabled telemetry.

func (*TelemetrySystem) EmittedAnyTelemetry

func (ts *TelemetrySystem) EmittedAnyTelemetry() bool

Returns true if any telemetry was emitted.

func (*TelemetrySystem) GetTelemetryQueue

func (ts *TelemetrySystem) GetTelemetryQueue() Queue

Returns the telemetry queue instance.

func (*TelemetrySystem) NewUploader

func (ts *TelemetrySystem) NewUploader(enableDebugLogging bool) Uploader

func (*TelemetrySystem) RunBackgroundUpload

func (ts *TelemetrySystem) RunBackgroundUpload(ctx context.Context, enableDebugLogging bool) error

func (*TelemetrySystem) Shutdown

func (ts *TelemetrySystem) Shutdown(ctx context.Context) error

Flushes all ongoing telemetry and shuts down telemetry

type TelemetryUploader

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

func NewUploader

func NewUploader(
	telemetryQueue Queue,
	transmitter appinsightsexporter.Transmitter,
	clock clock.Clock,
	isDebugMode bool,
) *TelemetryUploader

func (*TelemetryUploader) Upload

func (u *TelemetryUploader) Upload(ctx context.Context, result chan (error))

Uploads all items that are currently in the telemetry queue. This function returns when no items remain in the queue. An error is only returned if there is a fatal, persistent error with reading the queue.

type Uploader

type Uploader interface {
	Upload(ctx context.Context, result chan (error))
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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