telemetry

package
v0.0.0-...-c407d37 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestTelemetryName    = "github.com/transcom/mymove/request"
	RequestTelemetryVersion = "0.1"
)

Variables

This section is empty.

Functions

func ContextWithRoutePattern

func ContextWithRoutePattern(ctx context.Context, routePattern *string) context.Context

ContextWithRoutePattern adds the route pattern to the context. See NewOtelHTTPMiddleware for usage

func ContextWithStatusCode

func ContextWithStatusCode(ctx context.Context, statusCode *int) context.Context

ContextWithStatusCode adds the status code to the context. See NewOtelHTTPMiddleware for usage

func Init

func Init(logger *zap.Logger, config *Config) (func(), sdktrace.SpanExporter, sdkmetric.Exporter)

Init sets up open telemetry as specified by config. It returns a shutdown function, and also the span and metric exporters. The latter two are useful in testing, but would almost certainly be ignored in production

func NewOtelHTTPMiddleware

func NewOtelHTTPMiddleware(config *Config, name string, globalLogger *zap.Logger) func(http.Handler) http.Handler

func RegisterDBStatsObserver

func RegisterDBStatsObserver(appCtx appcontext.AppContext, config *Config) error

RegisterDBStatsObserver creates a custom metric that is updated automatically using an observer

func RegisterMilmoveDataObserver

func RegisterMilmoveDataObserver(appCtx appcontext.AppContext, config *Config) error

func RegisterRuntimeObserver

func RegisterRuntimeObserver(_ appcontext.AppContext, config *Config) error

RegisterRuntimeObserver creates a custom metric that is updated automatically using an observer

func RoutePatternFromContext

func RoutePatternFromContext(ctx context.Context) *string

RoutePatternFromContext returns the route pattern if found, or the empty string

func StatusCodeFromContext

func StatusCodeFromContext(ctx context.Context) *int

StatusCodeFromContext returns the route pattern if found, or the empty string

Types

type Config

type Config struct {
	Enabled          bool
	Endpoint         string
	UseXrayID        bool
	SamplingFraction float64
	CollectSeconds   int
	ReadEvents       bool
	WriteEvents      bool
	EnvironmentName  string
}

Config defines the config necessary to enable telemetry gathering

type RequestTelemetry

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

func NewRequestTelemetry

func NewRequestTelemetry(logger *zap.Logger) *RequestTelemetry

NewRequestTelemetry provides a way for the request logger to provide stats. If we want accurate request counts with dimensions, this seems to be the best way to do it

According to the cloudwatch concepts documentation

https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html

CloudWatch treats each unique combination of dimensions as a
separate metric, even if the metrics have the same metric name.

This means if we try to use the "Sample count" statistic in cloud watch, it will count across all dimensions. It doesn't seem possible to get the count without dimensions.

Increment a request count with the same dimensions

func (*RequestTelemetry) IncrementRequestCount

func (rt *RequestTelemetry) IncrementRequestCount(r *http.Request, routePattern string, statusCode int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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