client

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2023 License: Apache-2.0 Imports: 23 Imported by: 2

Documentation

Index

Constants

View Source
const (
	OCOK                 = 0
	OCCancelled          = 1
	OCUnknown            = 2
	OCInvalidArgument    = 3
	OCDeadlineExceeded   = 4
	OCNotFound           = 5
	OCAlreadyExists      = 6
	OCPermissionDenied   = 7
	OCResourceExhausted  = 8
	OCFailedPrecondition = 9
	OCAborted            = 10
	OCOutOfRange         = 11
	OCUnimplemented      = 12
	OCInternal           = 13
	OCUnavailable        = 14
	OCDataLoss           = 15
	OCUnauthenticated    = 16
)

https://github.com/googleapis/googleapis/blob/bee79fbe03254a35db125dc6d2f1e9b752b390fe/google/rpc/code.proto#L33-L186

Variables

This section is empty.

Functions

func OCStatusCodeFromHTTP added in v0.4.0

func OCStatusCodeFromHTTP(code int32) int32

OCStatusCodeFromHTTP takes an HTTP status code and return the appropriate OpenTelemetry status code See: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/data-http.md

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client implements an HTTP sender for the SAPM protocol

func New

func New(opts ...Option) (*Client, error)

New creates a new SAPM Client

func (*Client) Export

func (sa *Client) Export(ctx context.Context, batches []*jaegerpb.Batch) error

Export takes a Jaeger batches and uses one of the available workers to export it synchronously. It returns an error in case a request cannot be processed. It's up to the caller to retry.

func (*Client) ExportWithAccessToken added in v0.5.3

func (sa *Client) ExportWithAccessToken(ctx context.Context, batches []*jaegerpb.Batch, accessToken string) error

ExportWithAccessToken takes a Jaeger batches and an SFx access token and uses one of the available workers to export it synchronously, preferentially using the provided token and defaulting to the worker's token if empty. It returns an error in case a request cannot be processed. It's up to the caller to retry.

func (*Client) ExportWithAccessTokenAndGetResponse added in v0.10.0

func (sa *Client) ExportWithAccessTokenAndGetResponse(ctx context.Context, batches []*jaegerpb.Batch, accessToken string) (*IngestResponse, error)

ExportWithAccessTokenAndGetResponse does everything ExportWithAccessToken does and in addition will return a ResponseBody indicating the response returned from trace ingest. This can be used by consumers to get insights into partial drops of spans/traces from within a batch.

func (*Client) Stop

func (sa *Client) Stop()

Stop waits for all inflight requests to finish and then drains the worker pool so no more work can be done. It returns once all workers are drained from the pool. Note that the client can accept new requests while Stop() waits for other requests to finish.

type CompressionMethod added in v0.13.0

type CompressionMethod string

CompressionMethod strings MUST match the Content-Encoding http header values.

const CompressionMethodGzip CompressionMethod = "gzip"
const CompressionMethodZstd CompressionMethod = "zstd"

type ErrSend added in v0.3.0

type ErrSend struct {
	Err               error
	StatusCode        int
	Permanent         bool
	RetryDelaySeconds int
}

ErrSend is returned by the HTTP sender when it fails to complete a request for any reason.

func (*ErrSend) Error added in v0.3.0

func (e *ErrSend) Error() string

type IngestResponse added in v0.10.0

type IngestResponse struct {
	Body []byte
	Err  error
}

IngestResponse encapsulates the body of response returned by trace ingest and any error encountered by the worker while reading the body.

type Option

type Option func(*Client) error

Option takes a reference to a Client and sets relevant config fields on it.

func WithAccessToken

func WithAccessToken(t string) Option

WithAccessToken allows to pass an authentication token to the client. The auth token is set to X-SF-TOKEN HTTP header.

func WithCompressionMethod added in v0.13.0

func WithCompressionMethod(compressionMethod CompressionMethod) Option

WithCompressionMethod chooses the compression method for the outgoing requests. The default compression method is CompressionMethodGzip. This option is ignored if WithDisabledCompression() is used.

func WithDisabledCompression added in v0.5.1

func WithDisabledCompression() Option

WithDisabledCompression configures the client to not apply compression on the outgoing requests.

func WithEndpoint

func WithEndpoint(endpoint string) Option

WithEndpoint takes an HTTP endpoint as a string in the format scheme://address:port/path and configures the client to export all requests to this endpoint.

func WithHTTPClient

func WithHTTPClient(c *http.Client) Option

WithHTTPClient allows to pass a custom HTTP Client instance to SAPM Client

func WithMaxConnections

func WithMaxConnections(n uint) Option

WithMaxConnections allows to specify the max number of open HTTP connections the client should keep at any time.

func WithTracerProvider added in v0.9.0

func WithTracerProvider(tracerProvider trace.TracerProvider) Option

WithTracerProvider returns an Option to use the TracerProvider when creating a Tracer.

func WithWorkers

func WithWorkers(n uint) Option

WithWorkers configures the client to use N number of workers.

Jump to

Keyboard shortcuts

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