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)
    Example (WithDifferentSignalCollectors)
    Example (WithTLS)




    View Source
    const (
    	// DefaultServiceConfig is the gRPC service config used if none is
    	// provided by the user.
    	// For more info on gRPC service configs:
    	// For more info on the RetryableStatusCodes we allow here:
    	// Note: MaxAttempts > 5 are treated as 5. See
    	// for more details.
    	DefaultServiceConfig = `` /* 478-byte string literal not displayed */


    This section is empty.


    func NewDriver

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

      NewDriver creates a new gRPC protocol driver.


      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 This can be done by encoding.RegisterCompressor. Some compressors auto-register on import, such as gzip, which can be registered by calling `import _ ""`

          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() 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.