telemetry

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

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

Go to latest
Published: Jan 10, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Copied from pluginapi/experimental/bot/logger to avoid upgrading min_server_version remove this file once pluginapi can be updated to 0.1.3+ ( min_server_version is

safe to point at 7.x)

Index

Constants

View Source
const (
	// LogLevelDebug denotes debug messages
	LogLevelDebug = "debug"
	// LogLevelInfo denotes info messages
	LogLevelInfo = "info"
	// LogLevelWarn denotes warn messages
	LogLevelWarn = "warn"
	// LogLevelError denotes error messages
	LogLevelError = "error"
)
View Source
const (
	ErrorKey = "error"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// Enqueue adds a tracker event (Track) to be registered
	Enqueue(t Track) error
	// Close closes the client connection, flushing any event left on the queue
	Close() error
}

Client defines a telemetry client

func NewRudderClient

func NewRudderClient() (Client, error)

NewRudderClient creates a new telemetry client with Rudder using the default configuration.

func NewRudderClientWithCredentials

func NewRudderClientWithCredentials(writeKey, dataPlaneURL string) (Client, error)

NewRudderClientWithCredentials lets you create a Rudder client with your own credentials.

type LogAPI

type LogAPI interface {
	LogError(message string, keyValuePairs ...interface{})
	LogWarn(message string, keyValuePairs ...interface{})
	LogInfo(message string, keyValuePairs ...interface{})
	LogDebug(message string, keyValuePairs ...interface{})
}

type LogContext

type LogContext map[string]interface{}

LogContext defines the context for the logs.

type LogLevel

type LogLevel string

LogLevel defines the level of log messages

type Logger

type Logger interface {
	// With adds a logContext to the logger.
	With(LogContext) Logger
	// WithError adds an Error to the logger.
	WithError(error) Logger
	// Context returns the current context
	Context() LogContext
	// Timed add a timed log context.
	Timed() Logger
	// Debugf logs a formatted string as a debug message.
	Debugf(format string, args ...interface{})
	// Errorf logs a formatted string as an error message.
	Errorf(format string, args ...interface{})
	// Infof logs a formatted string as an info message.
	Infof(format string, args ...interface{})
	// Warnf logs a formatted string as an warning message.
	Warnf(format string, args ...interface{})
}

Logger defines an object able to log messages.

func NewLogger

func NewLogger(api LogAPI) Logger

New creates a new logger.

- api: LogAPI implementation

type Track

type Track struct {
	UserID         string
	Event          string
	Properties     map[string]interface{}
	InstallationID string
}

Track defines an event ready for the client to process

type Tracker

type Tracker interface {
	// TrackEvent registers an event through the configured telemetry client
	TrackEvent(event string, properties map[string]interface{}) error
	// TrackUserEvent registers an event through the configured telemetry client associated to a user
	TrackUserEvent(event string, userID string, properties map[string]interface{}) error
	// Reload Config re-evaluates tracker config to determine if tracking behavior should change
	ReloadConfig(config TrackerConfig)
}

Tracker defines a telemetry tracker

func NewTracker

func NewTracker(
	c Client,
	diagnosticID,
	serverVersion,
	pluginID,
	pluginVersion,
	telemetryShortName string,
	config TrackerConfig,
	l Logger,
) Tracker

NewTracker creates a default Tracker - c Client: A telemetry client. If nil, the tracker will not track any event. - diagnosticID: Server unique ID used for telemetry. - severVersion: Mattermost server version. - pluginID: The plugin ID. - pluginVersion: The plugin version. - telemetryShortName: Short name for the plugin to use in telemetry. Used to avoid dot separated names like `com.company.pluginName`. If a empty string is provided, it will use the pluginID. - config: Whether the system has enabled sending telemetry data. If false, the tracker will not track any event. - l Logger: A logger to debug event tracking and some important changes (it won't log if nil is passed as logger).

type TrackerConfig

type TrackerConfig struct {
	EnabledTracking bool
	EnabledLogging  bool
}

func NewTrackerConfig

func NewTrackerConfig(config *model.Config) TrackerConfig

NewTrackerConfig returns a new trackerConfig from the current values of the model.Config.

Jump to

Keyboard shortcuts

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