Documentation ¶
Overview ¶
Package client provides the instrumentation for an http client.
The detail that metrics and traces provides can be configured with the TransportOptions struct.
Metrics:
Tags for all metrics: - Host - URLPattern - Name (the name might be the combination of the endpoint + url pattern) Requests: - num cancelled requests: - per context timeout - per caller cancellation (for example when sending to multiple hosts) - content-lenght: the size of the payload to be sent Responses: Tags for all responses: - Status Code - content length: the server side provided content length - latency: the time since we send the request, until we have the response available (might or might not included the time for buffereing part or all the payload). - response bytes read: using the body tracker, account for the actual number of bytes read by the client. - response reading time: measures the time spent
Traces:
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InstrumentedHTTPClient ¶
InstrumentedHTTPClient creates a new instrumented http client with the options provided. If the provided options are nil, the default options (with everything enabled, except the detailed connection data: DNS, TLS, time to get a connection...) will be used. Check the TransportOptions struct for details..
func NewRoundTripper ¶
func NewRoundTripper(base http.RoundTripper, metricsOpts TransportMetricsOptions, tracesOpts TransportTracesOptions, clientName string, otelState state.OTEL, ) http.RoundTripper
NewRoundTripper creates an instrumented round tripper.
Types ¶
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport is an http.RoundTripper that instruments all outgoing requests with OpenTelemetry metrics and tracing.
The zero value is intended to be a useful default, but for now it's recommended that you explicitly set Propagation, since the default for this may change.
type TransportMetricsOptions ¶
type TransportMetricsOptions struct { RoundTrip bool // provide the round trip metrics ReadPayload bool // provide metrics for the reading the full body DetailedConnection bool // provide detailed metrics about the connection: dns lookup, tls ... FixedAttributes []attribute.KeyValue // "static" attributes set at config time. }
TransportMetricsOptions contains the options to enable / disable for reporting metrics, and a set of fixed attributes to add to all metrics.
func (*TransportMetricsOptions) Enabled ¶
func (o *TransportMetricsOptions) Enabled() bool
Enabled tells if metrics should be reported for the transport.
type TransportOptions ¶
type TransportOptions struct { MetricsOpts TransportMetricsOptions TracesOpts TransportTracesOptions OTELInstance state.OTEL }
TransportOptions defines the detail we want for the metrics and traces. See [TrasnportMetricsOptions] and TransportTracesOptions for more details. The OTELInstance member defines a function to obtain a State to use with this transport. The state getter is used at configuration time, not at runtime.
type TransportTracesOptions ¶
type TransportTracesOptions struct { RoundTrip bool // use a span for the round trip ReadPayload bool // use a span for the process of reading the full body DetailedConnection bool // add extra detail about the connection to the server: dns lookup, tls... FixedAttributes []attribute.KeyValue // "static" attributes set at config time. ReportHeaders bool }
TransportTracesOptions defines what information is enabled, and extra fixed attributes to add to the trace.
func (*TransportTracesOptions) Enabled ¶
func (o *TransportTracesOptions) Enabled() bool
Enabled returns if the transport should create a trace.