otlploggrpc

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(opts ...Option) *Client

NewClient creates a new gRPC log export client.

func (*Client) ExportLogs

func (c *Client) ExportLogs(ctx context.Context, logDatas []*sdklog.LogData) error

UploadTraces sends a batch of spans.

Retryable errors from the server will be handled according to any RetryConfig the client was created with.

func (*Client) MarshalLog

func (c *Client) MarshalLog() interface{}

MarshalLog is the marshaling function used by the logging system to represent this Client.

func (*Client) Shutdown

func (c *Client) Shutdown(ctx context.Context) error

Shutdown is an alias for Stop.

func (*Client) Start

func (c *Client) Start(ctx context.Context) error

Start establishes a gRPC connection to the collector.

func (*Client) Stop

func (c *Client) Stop(ctx context.Context) error

Stop shuts down the client.

Any active connections to a remote endpoint are closed if they were created by the client. Any gRPC connection passed during creation using WithGRPCConn will not be closed. It is the caller's responsibility to handle cleanup of that resource.

This method synchronizes with the UploadTraces method of the client. It will wait for any active calls to that method to complete unimpeded, or it will cancel any active calls if ctx expires. If ctx expires, the context error will be forwarded as the returned error. All client held resources will still be released in this situation.

If the client has already stopped, an error will be returned describing this.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option applies an option to the gRPC driver.

func WithCompressor

func WithCompressor(compressor string) Option

WithCompressor sets the compressor for the gRPC client to use when sending requests. Supported compressor values: "gzip".

func WithDialOption

func WithDialOption(opts ...grpc.DialOption) Option

WithDialOption sets explicit grpc.DialOptions to use when making a connection. The options here are appended to the internal grpc.DialOptions used so they will take precedence over any other internal grpc.DialOptions they might conflict with.

This option has no effect if WithGRPCConn is used.

func WithEndpoint

func WithEndpoint(endpoint string) Option

WithEndpoint sets the target endpoint the Exporter will connect to.

If the OTEL_EXPORTER_OTLP_ENDPOINT or OTEL_EXPORTER_OTLP_METRICS_ENDPOINT environment variable is set, and this option is not passed, that variable value will be used. If both are set, OTEL_EXPORTER_OTLP_TRACES_ENDPOINT will take precedence.

If both this option and WithEndpointURL are used, the last used option will take precedence.

By default, if an environment variable is not set, and this option is not passed, "localhost:4317" will be used.

This option has no effect if WithGRPCConn is used.

func WithEndpointURL

func WithEndpointURL(u string) Option

WithEndpointURL sets the target endpoint URL the Exporter will connect to.

If the OTEL_EXPORTER_OTLP_ENDPOINT or OTEL_EXPORTER_OTLP_METRICS_ENDPOINT environment variable is set, and this option is not passed, that variable value will be used. If both are set, OTEL_EXPORTER_OTLP_TRACES_ENDPOINT will take precedence.

If both this option and WithEndpoint are used, the last used option will take precedence.

If an invalid URL is provided, the default value will be kept.

By default, if an environment variable is not set, and this option is not passed, "localhost:4317" will be used.

This option has no effect if WithGRPCConn is used.

func WithGRPCConn

func WithGRPCConn(conn *grpc.ClientConn) Option

WithGRPCConn sets conn as the gRPC ClientConn used for all communication.

This option takes precedence over any other option that relates to establishing or persisting a gRPC connection to a target endpoint. Any other option of those types passed will be ignored.

It is the callers responsibility to close the passed conn. The client Shutdown method will not close this connection.

func WithHeaders

func WithHeaders(headers map[string]string) Option

WithHeaders will send the provided headers with each gRPC requests.

func WithInsecure

func WithInsecure() Option

WithInsecure disables client transport security for the exporter's gRPC connection just like grpc.WithInsecure() (https://pkg.go.dev/google.golang.org/grpc#WithInsecure) does. Note, by default, client security is required unless WithInsecure is used.

This option has no effect if WithGRPCConn is used.

func WithReconnectionPeriod

func WithReconnectionPeriod(rp time.Duration) Option

WithReconnectionPeriod set the minimum amount of time between connection attempts to the target endpoint.

This option has no effect if WithGRPCConn is used.

func WithRetry

func WithRetry(settings RetryConfig) Option

WithRetry sets the retry policy for transient retryable errors that may be returned by the target endpoint when exporting a batch of spans.

If the target endpoint responds with not only a retryable error, but explicitly returns a backoff time in the response. That time will take precedence over these settings.

These settings do not define any network retry strategy. That is entirely handled by the gRPC ClientConn.

If unset, the default retry policy will be used. It will retry the export 5 seconds after receiving a retryable error and increase exponentially after each error for no more than a total time of 1 minute.

func WithServiceConfig

func WithServiceConfig(serviceConfig string) Option

WithServiceConfig defines the default gRPC service config used.

This option has no effect if WithGRPCConn is used.

func WithTLSCredentials

func WithTLSCredentials(creds credentials.TransportCredentials) Option

WithTLSCredentials allows the connection to use TLS credentials when talking to the server. It takes in grpc.TransportCredentials instead of say a Certificate file or a tls.Certificate, because the retrieving of these credentials can be done in many ways e.g. plain file, in code tls.Config or by certificate rotation, so it is up to the caller to decide what to use.

This option has no effect if WithGRPCConn is used.

func WithTimeout

func WithTimeout(duration time.Duration) Option

WithTimeout sets the max amount of time a client will attempt to export a batch of spans. This takes precedence over any retry settings defined with WithRetry, once this time limit has been reached the export is abandoned and the batch of spans is dropped.

If unset, the default timeout will be set to 10 seconds.

type RetryConfig

type RetryConfig retry.Config

RetryConfig defines configuration for retrying export of span batches that failed to be received by the target endpoint.

This configuration does not define any network retry strategy. That is entirely handled by the gRPC ClientConn.

Directories

Path Synopsis
retry
Package retry provides request retry functionality that can perform configurable exponential backoff for transient errors and honor any explicit throttle responses received.
Package retry provides request retry functionality that can perform configurable exponential backoff for transient errors and honor any explicit throttle responses received.

Jump to

Keyboard shortcuts

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