distro

package module
v0.0.0-...-4d63041 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: Apache-2.0 Imports: 26 Imported by: 1

README

Package github.com/signalfx/splunk-otel-go/distro

Go Reference

Run is the main entry point for this package. Use it to create an SDK ready to be used with OpenTelemetry and forward all telemetry to Splunk Observabilty Cloud.

See our example applications.

Read the official documentation for this distribution in the Splunk Docs site.

Documentation

Overview

Package distro provides functionality to quickly setup the OpenTelemetry Go SDK with useful Splunk defaults.

The default configuration sets the default OpenTelemetry SDK to propagate traces using a W3C tracecontext and W3C baggage propagator and export all spans and metrics to a locally running Splunk OpenTelemetry Collector.

Example
package main

import (
	"context"

	"github.com/unionai/splunk-otel-go/distro"
)

func main() {
	// By default, the Run function creates a OTLP gRPC exporter and
	// configures the W3C tracecontext and W3C baggage propagation format to
	// be used in extracting and injecting trace context.
	sdk, err := distro.Run()
	if err != nil {
		panic(err)
	}
	// To ensure all spans are flushed before the application exits, make sure
	// to shutdown.
	defer func() {
		if err := sdk.Shutdown(context.Background()); err != nil {
			panic(err)
		}
	}()
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Version

func Version() string

Version returns the version of distro.

Types

type Option

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

Option sets a config setting value.

func WithIDGenerator

func WithIDGenerator(g trace.IDGenerator) Option

WithIDGenerator configures the generator used to generate span and trace IDs. If this option is not provided, the SDK's default ID generator will be used.

func WithLogger

func WithLogger(l logr.Logger) Option

WithLogger configures the logger used by this distro.

The logr.Logger provided should be configured with a verbosity enabled to emit Info logs of the desired level. The following log level to verbosity value are used.

  • warning: 0
  • info: 1
  • debug: 2+

By default, a zapr.Logger configured for info logging will be used if this is not provided.

func WithTLSConfig

func WithTLSConfig(conf *tls.Config) Option

WithTLSConfig configures the TLS configuration used by the exporter.

If this option is not provided, the exporter connection will use the default TLS config.

type SDK

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

SDK is the Splunk distribution of the OpenTelemetry SDK.

func Run

func Run(opts ...Option) (SDK, error)

Run configures the default OpenTelemetry SDK and installs it globally.

It is the callers responsibility to shut down the returned SDK when complete. This ensures all resources are released and all telemetry flushed.

func (SDK) Shutdown

func (s SDK) Shutdown(ctx context.Context) error

Shutdown stops the SDK and releases any used resources.

Jump to

Keyboard shortcuts

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