Documentation
¶
Index ¶
- Constants
- func ContextWithRoutePattern(ctx context.Context, routePattern *string) context.Context
- func ContextWithStatusCode(ctx context.Context, statusCode *int) context.Context
- func Init(logger *zap.Logger, config *Config) (func(), sdktrace.SpanExporter, sdkmetric.Exporter)
- func NewOtelHTTPMiddleware(config *Config, name string, globalLogger *zap.Logger) func(http.Handler) http.Handler
- func RegisterDBStatsObserver(appCtx appcontext.AppContext, config *Config) error
- func RegisterMilmoveDataObserver(appCtx appcontext.AppContext, config *Config) error
- func RegisterRuntimeObserver(_ appcontext.AppContext, config *Config) error
- func RoutePatternFromContext(ctx context.Context) *string
- func StatusCodeFromContext(ctx context.Context) *int
- type Config
- type RequestTelemetry
Constants ¶
const ( RequestTelemetryName = "github.com/transcom/mymove/request" RequestTelemetryVersion = "0.1" )
Variables ¶
This section is empty.
Functions ¶
func ContextWithRoutePattern ¶
ContextWithRoutePattern adds the route pattern to the context. See NewOtelHTTPMiddleware for usage
func ContextWithStatusCode ¶
ContextWithStatusCode adds the status code to the context. See NewOtelHTTPMiddleware for usage
func Init ¶
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 nolint:staticcheck
func NewOtelHTTPMiddleware ¶
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 ¶
RoutePatternFromContext returns the route pattern if found, or the empty string
func StatusCodeFromContext ¶
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)