package module
Version: v2.4.2 Latest Latest

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

Go to latest
Published: May 22, 2023 License: Apache-2.0 Imports: 12 Imported by: 5



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




This section is empty.


This section is empty.


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.

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

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


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