Documentation
¶
Overview ¶
Package otelresty instruments the go-resty/resty package (https://github.com/go-resty/resty).
Index ¶
- func SemVersion() string
- func TraceClient(client *resty.Client, options ...Option)
- func Version() string
- type Option
- func WithHideURL(hide bool) Option
- func WithPropagators(propagators propagation.TextMapPropagator) Option
- func WithSkipper(skipper func(r *resty.Request) bool) Option
- func WithSpanNameFormatter(f func(operation string, r *resty.Request) string) Option
- func WithSpanOptions(opts ...trace.SpanStartOption) Option
- func WithTracerName(name string) Option
- func WithTracerProvider(provider oteltrace.TracerProvider) Option
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SemVersion ¶
func SemVersion() string
SemVersion is the semantic version to be supplied to tracer/meter creation.
func TraceClient ¶
func TraceClient(client *resty.Client, options ...Option)
TraceClient instruments the resty client by adding OnBeforeRequest, OnAfterResponse and OnError hooks.
Example ¶
cli := resty.New() opts := []Option{ WithTracerName("my-tracer"), WithHideURL(true), } server := httptest.NewServer(testHandler()) // this hook is executed before the hook added by `TraceClient` cli.OnBeforeRequest(func(c *resty.Client, r *resty.Request) error { r.Header.Add("x-custom-header", "value") return nil }) TraceClient(cli, opts...) cli.R().Get(server.URL)
Output:
Types ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option applies a configuration value.
func WithHideURL ¶ added in v1.4.0
WithHideURL if set to true, the http.url will be replaced with "<redacted>". The default value is false.
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 WithSkipper ¶
WithSkipper specifies a skipper function to determine if the middleware should not create a span for a determined request. If not specified, a span will always be created.
func WithSpanNameFormatter ¶
WithSpanNameFormatter takes a function that will be called on every request and the returned string will become the Span Name.
func WithSpanOptions ¶
func WithSpanOptions(opts ...trace.SpanStartOption) Option
WithSpanOptions configures an additional set of trace.SpanOptions, which are applied to each new span.
func WithTracerName ¶
WithTracerName sets the name of the tracer used to create spans. The default value is "github.com/dubonzi/otelresty".
func WithTracerProvider ¶
func WithTracerProvider(provider oteltrace.TracerProvider) Option
WithTracerProvider specifies a tracer provider to use for creating a tracer. If none is specified, the global provider is used.