mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 13:02:25 -05:00
[feature] Initial Prometheus metrics implementation (#2334)
* feat: Initial OTEL metrics * docs: add metrics documentation * fix: metrics endpoint conditional check * feat: metrics endpoint basic auth * fix: make metrics-auth-enabled default false * fix: go fmt helpers.gen.go * fix: add metric-related env vars to envparsing.sh * fix: metrics docs * fix: metrics related stuff in envparsing.sh * fix: metrics docs * chore: metrics docs wording * fix: metrics stuff in envparsing? * bump otel versions --------- Co-authored-by: Tsuribori <user@acertaindebian> Co-authored-by: Tsuribori <none@example.org> Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
This commit is contained in:
parent
16275853eb
commit
1ba3e14b36
251 changed files with 48389 additions and 22 deletions
74
vendor/github.com/technologize/otel-go-contrib/otelginmetrics/option.go
generated
vendored
Normal file
74
vendor/github.com/technologize/otel-go-contrib/otelginmetrics/option.go
generated
vendored
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
package otelginmetrics
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
)
|
||||
|
||||
// Option applies a configuration to the given config
|
||||
type Option interface {
|
||||
apply(cfg *config)
|
||||
}
|
||||
|
||||
type optionFunc func(cfg *config)
|
||||
|
||||
func (fn optionFunc) apply(cfg *config) {
|
||||
fn(cfg)
|
||||
}
|
||||
|
||||
// WithAttributes sets a func using which what attributes to be recorded can be specified.
|
||||
// By default the DefaultAttributes is used
|
||||
func WithAttributes(attributes func(serverName, route string, request *http.Request) []attribute.KeyValue) Option {
|
||||
return optionFunc(func(cfg *config) {
|
||||
cfg.attributes = attributes
|
||||
})
|
||||
}
|
||||
|
||||
// WithRecordInFlight determines whether to record In Flight Requests or not
|
||||
// By default the recordInFlight is true
|
||||
func WithRecordInFlightDisabled() Option {
|
||||
return optionFunc(func(cfg *config) {
|
||||
cfg.recordInFlight = false
|
||||
})
|
||||
}
|
||||
|
||||
// WithRecordDuration determines whether to record Duration of Requests or not
|
||||
// By default the recordDuration is true
|
||||
func WithRecordDurationDisabled() Option {
|
||||
return optionFunc(func(cfg *config) {
|
||||
cfg.recordDuration = false
|
||||
})
|
||||
}
|
||||
|
||||
// WithRecordSize determines whether to record Size of Requests and Responses or not
|
||||
// By default the recordSize is true
|
||||
func WithRecordSizeDisabled() Option {
|
||||
return optionFunc(func(cfg *config) {
|
||||
cfg.recordSize = false
|
||||
})
|
||||
}
|
||||
|
||||
// WithGroupedStatus determines whether to group the response status codes or not. If true 2xx, 3xx will be stored
|
||||
// By default the groupedStatus is true
|
||||
func WithGroupedStatusDisabled() Option {
|
||||
return optionFunc(func(cfg *config) {
|
||||
cfg.groupedStatus = false
|
||||
})
|
||||
}
|
||||
|
||||
// WithRecorder sets a recorder for recording requests
|
||||
// By default the open telemetry recorder is used
|
||||
func WithRecorder(recorder Recorder) Option {
|
||||
return optionFunc(func(cfg *config) {
|
||||
cfg.recorder = recorder
|
||||
})
|
||||
}
|
||||
|
||||
// WithShouldRecordFunc sets a func using which whether a record should be recorded
|
||||
// By default the all api calls are recorded
|
||||
func WithShouldRecordFunc(shouldRecord func(serverName, route string, request *http.Request) bool) Option {
|
||||
return optionFunc(func(cfg *config) {
|
||||
cfg.shouldRecord = shouldRecord
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue