app_agent_receiver

package
v0.30.2 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultRateLimitingRPS is the default value of Requests Per Second
	// for ratelimiting
	DefaultRateLimitingRPS = 100
	// DefaultRateLimitingBurstiness is the default burstiness factor of the
	// token bucket algorigthm
	DefaultRateLimitingBurstiness = 50
	// DefaultMaxPayloadSize is the max paylad size in bytes
	DefaultMaxPayloadSize = 5e6
)

Variables

View Source
var DefaultConfig = Config{

	Server: ServerConfig{
		Host: "127.0.0.1",
		Port: 12347,
		RateLimiting: RateLimitingConfig{
			Enabled:    true,
			RPS:        DefaultRateLimitingRPS,
			Burstiness: DefaultRateLimitingBurstiness,
		},
		MaxAllowedPayloadSize: DefaultMaxPayloadSize,
	},
	LogsLabels:      map[string]string{},
	LogsSendTimeout: time.Second * 2,
	SourceMaps: SourceMapConfig{
		DownloadFromOrigins: []string{"*"},
		DownloadTimeout:     time.Second,
	},
}

DefaultConfig holds the default configuration of the receiver

View Source
var IntegrationName = "app_agent_receiver"

IntegrationName is the name of this integration

Functions

func KeyValAdd

func KeyValAdd(kv *KeyVal, key string, value string)

KeyValAdd adds a key + value string pair to kv

func KeyValToInterfaceMap

func KeyValToInterfaceMap(kv *KeyVal) map[string]interface{}

KeyValToInterfaceMap converts KeyVal to map[string]interface

func KeyValToInterfaceSlice

func KeyValToInterfaceSlice(kv *KeyVal) []interface{}

KeyValToInterfaceSlice converts KeyVal to []interface{}, typically used for logging

func MergeKeyVal

func MergeKeyVal(target *KeyVal, source *KeyVal)

MergeKeyVal will merge source in target

func MergeKeyValWithPrefix

func MergeKeyValWithPrefix(target *KeyVal, source *KeyVal, prefix string)

MergeKeyValWithPrefix will merge source in target, adding a prefix to each key being merged in

func NewLogsExporter

func NewLogsExporter(logger kitlog.Logger, conf LogsExporterConfig, sourceMapStore SourceMapStore) appAgentReceiverExporter

NewLogsExporter creates a new logs exporter with the given configuration

func NewReceiverMetricsExporter

func NewReceiverMetricsExporter(reg prometheus.Registerer) appAgentReceiverExporter

NewReceiverMetricsExporter creates a new ReceiverMetricsExporter

func NewTracesExporter

func NewTracesExporter(getTracesConsumer tracesConsumerGetter) appAgentReceiverExporter

NewTracesExporter creates a trace exporter for the app agent receiver.

Types

type App

type App struct {
	Name        string `json:"name,omitempty"`
	Release     string `json:"release,omitempty"`
	Version     string `json:"version,omitempty"`
	Environment string `json:"environment,omitempty"`
}

App holds metadata about the application event originates from

func (App) KeyVal

func (a App) KeyVal() *KeyVal

KeyVal produces key-> value representation of App metadata

type AppAgentReceiverHandler

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

AppAgentReceiverHandler struct controls the data ingestion http handler of the receiver

func NewAppAgentReceiverHandler

func NewAppAgentReceiverHandler(conf *Config, exporters []appAgentReceiverExporter, reg prometheus.Registerer) AppAgentReceiverHandler

NewAppAgentReceiverHandler creates a new AppReceiver instance based on the given configuration

func (*AppAgentReceiverHandler) HTTPHandler

func (ar *AppAgentReceiverHandler) HTTPHandler(logger log.Logger) http.Handler

HTTPHandler is the http.Handler for the receiver. It will do the following 0. Enable CORS for the configured hosts 1. Check if the request should be rate limited 2. Verify that the payload size is within limits 3. Start two go routines for exporters processing and exporting data respectively 4. Respond with 202 once all the work is done

type Browser

type Browser struct {
	Name    string `json:"name,omitempty"`
	Version string `json:"version,omitempty"`
	OS      string `json:"os,omitempty"`
	Mobile  bool   `json:"mobile,omitempty"`
}

Browser holds metadata about a client's browser

func (Browser) KeyVal

func (b Browser) KeyVal() *KeyVal

KeyVal produces key->value representation of the Browser metadata

type Config

type Config struct {
	Common          common.MetricsConfig `yaml:",inline"`
	Server          ServerConfig         `yaml:"server,omitempty"`
	TracesInstance  string               `yaml:"traces_instance,omitempty"`
	LogsInstance    string               `yaml:"logs_instance,omitempty"`
	LogsLabels      map[string]string    `yaml:"logs_labels,omitempty"`
	LogsSendTimeout time.Duration        `yaml:"logs_send_timeout,omitempty"`
	SourceMaps      SourceMapConfig      `yaml:"sourcemaps,omitempty"`
}

Config is the configuration struct of the integration

func (*Config) ApplyDefaults

func (c *Config) ApplyDefaults(globals integrations.Globals) error

ApplyDefaults applies runtime-specific defaults to c.

func (*Config) Identifier

func (c *Config) Identifier(globals integrations.Globals) (string, error)

Identifier uniquely identifies the app agent receiver integration

func (*Config) Name

func (c *Config) Name() string

Name returns the name of the integration that this config represents

func (*Config) NewIntegration

func (c *Config) NewIntegration(l log.Logger, globals integrations.Globals) (integrations.Integration, error)

NewIntegration converts this config into an instance of an integration

func (*Config) UnmarshalYAML

func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the Unmarshaler interface

type Event added in v0.27.0

type Event struct {
	Name       string            `json:"name"`
	Domain     string            `json:"domain,omitempty"`
	Attributes map[string]string `json:"attributes,omitempty"`
	Timestamp  time.Time         `json:"timestamp,omitempty"`
	Trace      TraceContext      `json:"trace,omitempty"`
}

Event holds RUM event data

func (Event) KeyVal added in v0.27.0

func (e Event) KeyVal() *KeyVal

KeyVal produces key -> value representation of Event metadata

type Exception

type Exception struct {
	Type       string       `json:"type,omitempty"`
	Value      string       `json:"value,omitempty"`
	Stacktrace *Stacktrace  `json:"stacktrace,omitempty"`
	Timestamp  time.Time    `json:"timestamp"`
	Trace      TraceContext `json:"trace,omitempty"`
}

Exception struct controls all the data regarding an exception

func TransformException

func TransformException(store SourceMapStore, log log.Logger, ex *Exception, release string) *Exception

TransformException will attempt to resolved all monified source locations in the stacktrace with original source locations

func (Exception) KeyVal

func (e Exception) KeyVal() *KeyVal

KeyVal representation of the exception object

func (Exception) Message

func (e Exception) Message() string

Message string is concatenating of the Exception.Type and Exception.Value

func (Exception) String

func (e Exception) String() string

String is the string representation of an Exception

type Frame

type Frame struct {
	Function string `json:"function,omitempty"`
	Module   string `json:"module,omitempty"`
	Filename string `json:"filename,omitempty"`
	Lineno   int    `json:"lineno,omitempty"`
	Colno    int    `json:"colno,omitempty"`
}

Frame struct represents a single stacktrace frame

func ResolveSourceLocation

func ResolveSourceLocation(store SourceMapStore, frame *Frame, release string) (*Frame, error)

ResolveSourceLocation resolves minified source location to original source location

func (Frame) String

func (frame Frame) String() string

String function converts a Frame into a human readable string

type KeyVal

type KeyVal = om.OrderedMap

KeyVal is an ordered map of string to interface

func KeyValFromMap

func KeyValFromMap(m map[string]string) *KeyVal

KeyValFromMap will instantiate KeyVal from a map[string]string

func NewKeyVal

func NewKeyVal() *KeyVal

NewKeyVal creates new empty KeyVal

func SpanToKeyVal

func SpanToKeyVal(s ptrace.Span) *KeyVal

SpanToKeyVal returns KeyVal representation of a Span.

type Log

type Log struct {
	Message   string       `json:"message,omitempty"`
	LogLevel  LogLevel     `json:"level,omitempty"`
	Context   LogContext   `json:"context,omitempty"`
	Timestamp time.Time    `json:"timestamp"`
	Trace     TraceContext `json:"trace,omitempty"`
}

Log struct controls the data that come into a Log message

func (Log) KeyVal

func (l Log) KeyVal() *KeyVal

KeyVal representation of a Log object

type LogContext

type LogContext map[string]string

LogContext is a string to string map structure that represents the context of a log message

type LogLevel

type LogLevel string

LogLevel is log level enum for incoming app logs

const (
	// LogLevelTrace is "trace"
	LogLevelTrace LogLevel = "trace"
	// LogLevelDebug is "debug"
	LogLevelDebug LogLevel = "debug"
	// LogLevelInfo is "info"
	LogLevelInfo LogLevel = "info"
	// LogLevelWarning is "warning"
	LogLevelWarning LogLevel = "warning"
	// LogLevelError is "error"
	LogLevelError LogLevel = "error"
)

type LogsExporter

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

LogsExporter will send logs & errors to loki

func (*LogsExporter) Export

func (le *LogsExporter) Export(ctx context.Context, payload Payload) error

Export implements the AppDataExporter interface

func (*LogsExporter) Name

func (le *LogsExporter) Name() string

Name of the exporter, for logging purposes

type LogsExporterConfig

type LogsExporterConfig struct {
	SendEntryTimeout time.Duration
	GetLogsInstance  logsInstanceGetter
	Labels           map[string]string
}

LogsExporterConfig holds the configuration of the logs exporter

type Measurement

type Measurement struct {
	Values    map[string]float64 `json:"values,omitempty"`
	Timestamp time.Time          `json:"timestamp,omitempty"`
	Trace     TraceContext       `json:"trace,omitempty"`
}

Measurement holds the data for user provided measurements

func (Measurement) KeyVal

func (m Measurement) KeyVal() *KeyVal

KeyVal representation of the exception object

type Meta

type Meta struct {
	SDK     SDK     `json:"sdk,omitempty"`
	App     App     `json:"app,omitempty"`
	User    User    `json:"user,omitempty"`
	Session Session `json:"session,omitempty"`
	Page    Page    `json:"page,omitempty"`
	Browser Browser `json:"browser,omitempty"`
}

Meta holds metadata about an app event

func (Meta) KeyVal

func (m Meta) KeyVal() *KeyVal

KeyVal produces key->value representation of the app event metadatga

type Page

type Page struct {
	ID         string            `json:"id,omitempty"`
	URL        string            `json:"url,omitempty"`
	Attributes map[string]string `json:"attributes,omitempty"`
}

Page holds metadata about the web page event originates from

func (Page) KeyVal

func (p Page) KeyVal() *KeyVal

KeyVal produces key->val representation of Page metadata

type Payload

type Payload struct {
	Exceptions   []Exception   `json:"exceptions,omitempty"`
	Logs         []Log         `json:"logs,omitempty"`
	Measurements []Measurement `json:"measurements,omitempty"`
	Events       []Event       `json:"events,omitempty"`
	Meta         Meta          `json:"meta,omitempty"`
	Traces       *Traces       `json:"traces,omitempty"`
}

Payload is the body of the receiver request

type RateLimitingConfig

type RateLimitingConfig struct {
	Enabled    bool    `yaml:"enabled,omitempty"`
	RPS        float64 `yaml:"rps,omitempty"`
	Burstiness int     `yaml:"burstiness,omitempty"`
}

RateLimitingConfig holds the configuration of the rate limiter

type RealSourceMapStore

type RealSourceMapStore struct {
	sync.Mutex
	// contains filtered or unexported fields
}

RealSourceMapStore is an implementation of SourceMapStore that can download source maps or read them from file system

func (*RealSourceMapStore) GetSourceMap

func (store *RealSourceMapStore) GetSourceMap(sourceURL string, release string) (*SourceMap, error)

GetSourceMap returns sourcemap for a given source url

type ReceiverMetricsExporter

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

ReceiverMetricsExporter is a app agent receiver exporter that will capture metrics about counts of logs, exceptions, measurements, traces being ingested

func (*ReceiverMetricsExporter) Export

func (re *ReceiverMetricsExporter) Export(ctx context.Context, payload Payload) error

Export implements the AppDataExporter interface

func (*ReceiverMetricsExporter) Name

func (re *ReceiverMetricsExporter) Name() string

Name of the exporter, for logging purposes

type SDK

type SDK struct {
	Name         string           `json:"name,omitempty"`
	Version      string           `json:"version,omitempty"`
	Integrations []SDKIntegration `json:"integrations,omitempty"`
}

SDK holds metadata about the app agent that produced the event

func (SDK) KeyVal

func (sdk SDK) KeyVal() *KeyVal

KeyVal produces key->value representation of Sdk metadata

type SDKIntegration

type SDKIntegration struct {
	Name    string `json:"name,omitempty"`
	Version string `json:"version,omitempty"`
}

SDKIntegration holds metadata about a plugin/integration on the app agent that collected and sent the event

func (SDKIntegration) String

func (i SDKIntegration) String() string

type ServerConfig

type ServerConfig struct {
	Host                  string             `yaml:"host,omitempty"`
	Port                  int                `yaml:"port,omitempty"`
	CORSAllowedOrigins    []string           `yaml:"cors_allowed_origins,omitempty"`
	RateLimiting          RateLimitingConfig `yaml:"rate_limiting,omitempty"`
	APIKey                string             `yaml:"api_key,omitempty"`
	MaxAllowedPayloadSize int64              `yaml:"max_allowed_payload_size,omitempty"`
}

ServerConfig holds the receiver http server configuration

type Session

type Session struct {
	ID         string            `json:"id,omitempty"`
	Attributes map[string]string `json:"attributes,omitempty"`
}

Session holds metadata about the browser session the event originates from

func (Session) KeyVal

func (s Session) KeyVal() *KeyVal

KeyVal produces key->value representation of the Session metadata

type SourceMap

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

SourceMap is a wrapper for go-sourcemap consumer

type SourceMapConfig

type SourceMapConfig struct {
	Download            bool                    `yaml:"download"`
	DownloadFromOrigins []string                `yaml:"download_origins,omitempty"`
	DownloadTimeout     time.Duration           `yaml:"download_timeout,omitempty"`
	FileSystem          []SourceMapFileLocation `yaml:"filesystem,omitempty"`
}

SourceMapConfig configure source map locations

type SourceMapFileLocation

type SourceMapFileLocation struct {
	Path               string `yaml:"path"`
	MinifiedPathPrefix string `yaml:"minified_path_prefix,omitempty"`
}

SourceMapFileLocation holds sourcemap location on file system

type SourceMapStore

type SourceMapStore interface {
	GetSourceMap(sourceURL string, release string) (*SourceMap, error)
}

SourceMapStore is interface for a sourcemap service capable of transforming minified source locations to original source location

func NewSourceMapStore

func NewSourceMapStore(l log.Logger, config SourceMapConfig, reg prometheus.Registerer, httpClient httpClient, fileService fileService) SourceMapStore

NewSourceMapStore creates an instance of SourceMapStore. httpClient and fileService will be instantiated to defaults if nil is provided

type Stacktrace

type Stacktrace struct {
	Frames []Frame `json:"frames,omitempty"`
}

Stacktrace is a collection of Frames

type TraceContext

type TraceContext struct {
	TraceID string `json:"trace_id"`
	SpanID  string `json:"span_id"`
}

TraceContext holds trace id and span id associated to an entity (log, exception, measurement...).

func (TraceContext) KeyVal

func (tc TraceContext) KeyVal() *KeyVal

KeyVal representation of the trace context object.

type Traces

type Traces struct {
	ptrace.Traces
}

Traces wraps the otel traces model.

func (Traces) MarshalJSON

func (t Traces) MarshalJSON() ([]byte, error)

MarshalJSON marshals Traces model to json.

func (Traces) SpanSlice

func (t Traces) SpanSlice() []ptrace.Span

SpanSlice unpacks Traces entity into a slice of Spans.

func (*Traces) UnmarshalJSON

func (t *Traces) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals Traces model.

type TracesExporter

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

TracesExporter will send traces to a traces instance

func (*TracesExporter) Export

func (te *TracesExporter) Export(ctx context.Context, payload Payload) error

Export implements the AppDataExporter interface

func (*TracesExporter) Name

func (te *TracesExporter) Name() string

Name of the exporter, for logging purposes

type User

type User struct {
	Email      string            `json:"email,omitempty"`
	ID         string            `json:"id,omitempty"`
	Username   string            `json:"username,omitempty"`
	Attributes map[string]string `json:"attributes,omitempty"`
}

User holds metadata about the user related to an app event

func (User) KeyVal

func (u User) KeyVal() *KeyVal

KeyVal produces a key->value representation User metadata

Jump to

Keyboard shortcuts

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