apmelasticsearch

package module
v2.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 12 Imported by: 8

Documentation

Overview

Package apmelasticsearch provides support for tracing the HTTP transport layer of Elasticsearch clients.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func WrapRoundTripper

func WrapRoundTripper(r http.RoundTripper, o ...ClientOption) http.RoundTripper

WrapRoundTripper returns an http.RoundTripper wrapping r, reporting each request as a span to Elastic APM, if the request's context contains a sampled transaction.

If r is nil, then http.DefaultTransport is wrapped.

Example
httpClient := &http.Client{
	Transport: WrapRoundTripper(http.DefaultTransport),
}
_ = httpClient

// client, err := elastic.NewClient(elastic.SetHttpClient(httpClient))
// ...
Output:

Types

type ClientOption

type ClientOption func(*roundTripper)

ClientOption sets options for tracing client requests.

func WithClusterName added in v2.2.0

func WithClusterName(f ClusterNameFunc) ClientOption

WithClusterName returns a ClientOption which sets f as the function to use to obtain the Elasticsearch cluster name for recording on spans.

type ClusterNameFunc added in v2.2.0

type ClusterNameFunc func(*http.Response) string

ClusterNameFunc is a function for fetching the Elasticsearch cluster name for an HTTP request.

func DefaultClusterName added in v2.2.0

func DefaultClusterName(rt http.RoundTripper) ClusterNameFunc

DefaultClusterName returns the default ClusterNameFunc implementation used by WrapRoundTripper, if WithClusterName is not specified.

DefaultClusterName looks for the X-Found-Handling-Cluster response header, using that if received; this is set by Elastic Cloud to the target cluster name. with its own cached host-to-cluster-name mappings.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL