Documentation

Overview

    Package otlpgrpc provides an implementation of otlp.ProtocolDriver that connects to the collector and sends traces and metrics using gRPC.

    This package is currently in a pre-GA phase. Backwards incompatible changes may be introduced in subsequent minor version releases as we work to track the evolving OpenTelemetry specification and user feedback.

    Example (Insecure)
    Output:
    
    
    Example (WithDifferentSignalCollectors)
    Output:
    
    
    Example (WithTLS)
    Output:
    
    

    Index

    Examples

    Constants

    View Source
    const (
    	// DefaultServiceConfig is the gRPC service config used if none is
    	// provided by the user.
    	//
    	// For more info on gRPC service configs:
    	// https://github.com/grpc/proposal/blob/master/A6-client-retries.md
    	//
    	// For more info on the RetryableStatusCodes we allow here:
    	// https://github.com/open-telemetry/oteps/blob/be2a3fcbaa417ebbf5845cd485d34fdf0ab4a2a4/text/0035-opentelemetry-protocol.md#export-response
    	//
    	// Note: MaxAttempts > 5 are treated as 5. See
    	// https://github.com/grpc/proposal/blob/master/A6-client-retries.md#validation-of-retrypolicy
    	// for more details.
    	DefaultServiceConfig = `` /* 478-byte string literal not displayed */
    
    )

    Variables

    This section is empty.

    Functions

    func NewDriver

    func NewDriver(opts ...Option) otlp.ProtocolDriver

      NewDriver creates a new gRPC protocol driver.

      Types

      type Option

      type Option func(cfg *config)

        Option applies an option to the gRPC driver.

        func WithCompressor

        func WithCompressor(compressor string) Option

          WithCompressor will set the compressor for the gRPC client to use when sending requests. It is the responsibility of the caller to ensure that the compressor set has been registered with google.golang.org/grpc/encoding. This can be done by encoding.RegisterCompressor. Some compressors auto-register on import, such as gzip, which can be registered by calling `import _ "google.golang.org/grpc/encoding/gzip"`

          func WithDialOption

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

            WithDialOption opens support to any grpc.DialOption to be used. If it conflicts with some other configuration the GRPC specified via the collector the ones here will take preference since they are set last.

            func WithEndpoint

            func WithEndpoint(endpoint string) Option

              WithEndpoint allows one to set the endpoint that the exporter will connect to the collector on. If unset, it will instead try to use connect to DefaultCollectorHost:DefaultCollectorPort.

              func WithHeaders

              func WithHeaders(headers map[string]string) Option

                WithHeaders will send the provided headers with 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.

                  func WithReconnectionPeriod

                  func WithReconnectionPeriod(rp time.Duration) Option

                    WithReconnectionPeriod allows one to set the delay between next connection attempt after failing to connect with the collector.

                    func WithServiceConfig

                    func WithServiceConfig(serviceConfig string) Option

                      WithServiceConfig defines the default gRPC service config 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 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.