telemetry

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvPodName = "POD_NAME"
)
View Source
const (
	// PropertyApiVersion is the property name of the telemetry item that contains the APIServer endpoint.
	// apiserver is used to distinguish the telemetry items from different Kubernetes clusters and should be uniformed
	// across all the telemetry items from the same cluster with the format http(s)://<host>:<port>.
	// For example "https://retina-test-c4528d-zn0ugsna.hcp.southeastasia.azmk8s.io:443
	PropertyApiserver = "apiserver"
)

Variables

This section is empty.

Functions

func GetEnvironmentProperties

func GetEnvironmentProperties() map[string]string

func GetK8SApiserverURLFromKubeConfig

func GetK8SApiserverURLFromKubeConfig() (string, error)

GetK8SApiserverURLFromKubeConfig returns apiserver URL from kubeconfig. The apiserver URL is expected to be publicly unique identifier of the Kubernetes cluster. In case the kubeconfig does not exists, this identifier can be obtained for pods from kube-system namespace. Kubelet will populate env KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT for Pods deployed in kube-system namespace, which can be used to generate apiserver URL from `GetConfig()`.

func InitAppInsights

func InitAppInsights(appinsightsId, appVersion string)

func KernelVersion

func KernelVersion(ctx context.Context) (string, error)

func ShutdownAppInsights

func ShutdownAppInsights()

func TrackPanic

func TrackPanic()

TrackPanic function sends the stacktrace and flushes logs only in a goroutine where its call is deferred. Panics in other goroutines will not be caught by this recover function.

Types

type NoopTelemetry

type NoopTelemetry struct{}

func NewNoopTelemetry

func NewNoopTelemetry() *NoopTelemetry

func (NoopTelemetry) Heartbeat

func (m NoopTelemetry) Heartbeat(ctx context.Context, heartbeatInterval time.Duration)

func (NoopTelemetry) StartPerf

func (m NoopTelemetry) StartPerf(functionName string) *PerformanceCounter

func (NoopTelemetry) StopPerf

func (m NoopTelemetry) StopPerf(counter *PerformanceCounter)

func (NoopTelemetry) TrackEvent

func (m NoopTelemetry) TrackEvent(name string, properties map[string]string)

func (NoopTelemetry) TrackMetric

func (m NoopTelemetry) TrackMetric(name string, value float64, properties map[string]string)

func (NoopTelemetry) TrackTrace

func (m NoopTelemetry) TrackTrace(name string, severity contracts.SeverityLevel, properties map[string]string)

type PerformanceCounter

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

type Telemetry

type Telemetry interface {
	StartPerf(name string) *PerformanceCounter
	StopPerf(counter *PerformanceCounter)
	Heartbeat(ctx context.Context, heartbeatInterval time.Duration)
	TrackEvent(name string, properties map[string]string)
	TrackMetric(name string, value float64, properties map[string]string)
	TrackTrace(name string, severity contracts.SeverityLevel, properties map[string]string)
}

type TelemetryClient

type TelemetryClient struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewAppInsightsTelemetryClient

func NewAppInsightsTelemetryClient(processName string, additionalproperties map[string]string) *TelemetryClient

func (*TelemetryClient) Heartbeat

func (t *TelemetryClient) Heartbeat(ctx context.Context, heartbeatInterval time.Duration)

func (*TelemetryClient) StartPerf

func (t *TelemetryClient) StartPerf(functionName string) *PerformanceCounter

Used with start to measure the execution time of a function usage defer telemetry.StopPerf(telemetry.StartPerf("functionName")) start perf will be evaluated on defer line, and then stop perf will be evaluated on return

func (*TelemetryClient) StopPerf

func (t *TelemetryClient) StopPerf(counter *PerformanceCounter)

func (*TelemetryClient) TrackEvent

func (t *TelemetryClient) TrackEvent(name string, properties map[string]string)

func (*TelemetryClient) TrackException

func (t *TelemetryClient) TrackException(exception *appinsights.ExceptionTelemetry)

func (*TelemetryClient) TrackMetric

func (t *TelemetryClient) TrackMetric(metricname string, value float64, properties map[string]string)

func (*TelemetryClient) TrackTrace

func (t *TelemetryClient) TrackTrace(name string, severity contracts.SeverityLevel, properties map[string]string)

Jump to

Keyboard shortcuts

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