Documentation
¶
Index ¶
- Constants
- func MetricAttributes(r *http.Request, statusCode int, additionalAttributes []attribute.KeyValue) []attribute.KeyValue
- func Middleware(opts ...Option) func(next http.Handler) http.Handler
- func NewServerTotalRequests(meter metric.Meter) (metric.Int64Counter, error)
- func RequestTraceAttrs(req *http.Request) []attribute.KeyValue
- func ResponseTraceAttrs(resp ResponseTelemetry) []attribute.KeyValue
- func Version() string
- type BodyWrapper
- type Filter
- type HTTPMeter
- type MetricData
- type Option
- func WithMeterProvider(provider metric.MeterProvider) Option
- func WithMetricAttributesFn(fn func(*http.Request) []attribute.KeyValue) Option
- func WithPropagators(propagators propagation.TextMapPropagator) Option
- func WithPublicEndpoint() Option
- func WithPublicEndpointFn(fn func(*http.Request) bool) Option
- func WithSpanNameFormatter(formatter func(routeName string, r *http.Request) string) Option
- func WithTracerProvider(provider trace.TracerProvider) Option
- type ResponseTelemetry
Constants ¶
const (
// ScopeName is the instrumentation scope name.
ScopeName = "github.com/rakunlabs/ada/middleware/telemetry"
)
Variables ¶
This section is empty.
Functions ¶
func MetricAttributes ¶
func Middleware ¶
Middleware is an echo middleware to add metrics to rec for each HTTP request. If recorder config is nil, the middleware will use a recorder with default configuration.
func NewServerTotalRequests ¶
func NewServerTotalRequests(meter metric.Meter) (metric.Int64Counter, error)
func ResponseTraceAttrs ¶
func ResponseTraceAttrs(resp ResponseTelemetry) []attribute.KeyValue
Types ¶
type BodyWrapper ¶
type BodyWrapper struct { io.ReadCloser // contains filtered or unexported fields }
BodyWrapper wraps a http.Request.Body (an io.ReadCloser) to track the number of bytes read and the last error.
func NewBodyWrapper ¶
func NewBodyWrapper(body io.ReadCloser) *BodyWrapper
NewBodyWrapper creates a new BodyWrapper.
The onRead attribute is a callback that will be called every time the data is read, with the number of bytes being read.
func (*BodyWrapper) BytesRead ¶
func (w *BodyWrapper) BytesRead() int64
BytesRead returns the number of bytes read up to this point.
type Filter ¶
Filter is a predicate used to determine whether a given http.request should be traced. A Filter must return true if the request should be traced.
type HTTPMeter ¶
type HTTPMeter struct {
// contains filtered or unexported fields
}
HTTPMeter is a recorder of HTTP metrics for prometheus. Use NewHTTPMeter to initialize it.
func NewHTTPMeter ¶
type MetricData ¶
type Option ¶
type Option func(*config)
func WithMeterProvider ¶
func WithMeterProvider(provider metric.MeterProvider) Option
WithMeterProvider specifies a meter provider to use for creating a metric. If none is specified, the global provider is used.
func WithMetricAttributesFn ¶
WithMetricAttributesFn allows customizing the attributes added to metrics.
func WithPropagators ¶
func WithPropagators(propagators propagation.TextMapPropagator) Option
WithPropagators specifies propagators to use for extracting information from the HTTP requests. If none are specified, global ones will be used.
func WithPublicEndpoint ¶
func WithPublicEndpoint() Option
WithPublicEndpoint configures the Handler to link the span with an incoming span context. If this option is not provided, then the association is a child association instead of a link.
func WithPublicEndpointFn ¶
WithPublicEndpointFn runs with every request, and allows conditionally configuring the Handler to link the span with an incoming span context. If this option is not provided or returns false, then the association is a child association instead of a link. Note: WithPublicEndpoint takes precedence over WithPublicEndpointFn.
func WithSpanNameFormatter ¶
WithSpanNameFormatter specifies a span name formatter to use for creating span names.
func WithTracerProvider ¶
func WithTracerProvider(provider trace.TracerProvider) Option
WithTracerProvider specifies a tracer provider to use for creating spans. If none is specified, the global provider is used.