apm

package
v0.0.0-...-d9ff298 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: Apache-2.0 Imports: 19 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTags

func GetTags(ctx context.Context) []string

func NewMonitor

func NewMonitor(opts ...Option) *event.CommandMonitor

NewMonitor creates a new mongodb event CommandMonitor.

func SetTags

func SetTags(ctx context.Context, tags ...string) context.Context

Types

type CommandTransformer

type CommandTransformer func(command bson.Raw) string

CommandTransformer defines a function that transforms a MongoDB command attribute. If the function returns an empty string, the attribute will not be added to the Span.

type Event

type Event interface {
	Message() message.Composer
	Document() *birch.Document
}

Event describes a single "event" produced by rotating the Client's cached storage. These events aren't single events from the perspective of the driver, but rather a window of events.

type Monitor

type Monitor interface {
	DriverAPM() *event.CommandMonitor
	Rotate() Event
}

Monitor provides a high level command monitoring total.

func NewBasicMonitor

func NewBasicMonitor(config *MonitorConfig) Monitor

NewBasicMonitor returns a simple monitor implementation that does not automatically rotate data. The MonitorConfig makes it possible to filter events. If this value is nil, no events will be filtered.

func NewLoggingMonitor

func NewLoggingMonitor(ctx context.Context, dur time.Duration, m Monitor) Monitor

NewLoggingMonitor wraps an existing logging monitor that automatically logs the output the default grip logger on the specified interval.

type MonitorConfig

type MonitorConfig struct {
	// PopulateEvents, when true, forces the collector to
	// preallocate the output structures, for all filtered
	// combinations of databases, collections, and commands as
	// well as namespaces and commands. This is primarily useful
	// when the output requires a predetermined schema or
	// structure and you want to maintain the shape of the data
	// even if no events for a particular command or namespace
	// occurred.
	//
	// When pre-populating events, you should specify commands to
	// filter and either a list of collections and databases or a
	// list of namespaces.
	PopulateEvents bool

	// Commands, Databases, and Collections give you the ability
	// to whitelist a number of operations to filter and exclude
	// other non-matching operations.
	Commands    []string
	Databases   []string
	Collections []string

	// Tags are added to operations via contexts and permit
	// more granular annotations. You must specify a tag in Tags
	// to tracked counters. If AllTags is set, all tags are
	// tracked and reported.
	Tags    []string
	AllTags bool

	// Namespaces allow you to declare a specific database and
	// collection name as a pair. When specified, only events that
	// match the namespace will be collected. Namespace filtering
	// occurs after the other filtering, including by command.
	Namespaces []Namespace
}

MonitorConfig makes it possible to configure the behavior of the Monitor. In most cases you can pass a nil value.

type Namespace

type Namespace struct {
	DB         string
	Collection string
}

Namespace defines a MongoDB collection and database.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option specifies instrumentation configuration options.

func WithCommandAttributeDisabled

func WithCommandAttributeDisabled(disabled bool) Option

WithCommandAttributeDisabled specifies if the MongoDB command is added as an attribute to Spans or not. This is disabled by default and the MongoDB command will not be added as an attribute to Spans if this option is not provided.

func WithCommandAttributeTransformer

func WithCommandAttributeTransformer(transformer CommandTransformer) Option

WithCommandAttributeTransformer specifies a function to transform the MongoDB command attribute.

func WithTracerProvider

func WithTracerProvider(provider trace.TracerProvider) Option

WithTracerProvider specifies a tracer provider to use for creating a tracer. If none is specified, the global provider is used.

Jump to

Keyboard shortcuts

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