sdk

package
v0.0.0-...-1aa08c1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: BSD-3-Clause Imports: 26 Imported by: 1

Documentation

Overview

Package sdk provides the utilities necessary to setup a monitoring implementation at runtime.

Setting up a specific monitoring pipeline/stack is independent of instrumenting an application or library. For instrumentation utilities use the `api` package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExporterOTLP

func ExporterOTLP(endpoint string, insecure bool, headers map[string]string) (*otlptrace.Exporter, sdkMetric.Exporter, error)

ExporterOTLP returns an initialized OTLP exporter instance.

func ExporterStdout

func ExporterStdout(pretty bool) (*stdouttrace.Exporter, sdkMetric.Exporter, error)

ExporterStdout returns a new trace exporter to send telemetry data to standard output.

Types

type Instrumentation

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

Instrumentation represents an OpenTelemetry instrumented application.

func Setup

func Setup(options ...Option) (*Instrumentation, error)

Setup a new OpenTelemetry instrumented application.

func (*Instrumentation) Flush

func (app *Instrumentation) Flush(ctx context.Context)

Flush immediately exports all spans that have not yet been exported for all the registered span processors and shut down them down. No further data will be captured or processed after this call.

func (*Instrumentation) Logger

func (app *Instrumentation) Logger() log.Logger

Logger returns the application's logger instance.

type Option

type Option func(*Instrumentation)

Option provide a functional style configuration mechanism to instrument an application.

func WithBaseLogger

func WithBaseLogger(ll log.Logger) Option

WithBaseLogger set the output handler. If not provided, all output is discarded by default. The application will create an extended logger using all the attributes discovered/provided during the setup process.

func WithExemplars

func WithExemplars() Option

WithExemplars enable experimental support for exemplars by settings the adequate ENV variables

https://github.com/open-telemetry/opentelemetry-go/blob/main/sdk/metric/internal/x/README.md

func WithExporter

func WithExporter(exp sdkTrace.SpanExporter) Option

WithExporter enables a trace (i.e. span) exporter as data sink for the application. If no exporter is set, all traces are discarded by default.

func WithExporterOTLP

func WithExporterOTLP(endpoint string, insecure bool, headers map[string]string) []Option

WithExporterOTLP is a utility method to automatically setup and attach trace and metric exporters to send the generated telemetry data to an OTLP exporter instance. https://opentelemetry.io/docs/collector/

func WithExporterStdout

func WithExporterStdout(pretty bool) []Option

WithExporterStdout is a utility method to automatically setup and attach trace and metric exporters to send the generated telemetry data to standard output.

func WithHostMetrics

func WithHostMetrics() Option

WithHostMetrics enables the application to capture the conventional host metric instruments specified by OpenTelemetry. Host metric events are sometimes collected through the OpenTelemetry Collector `host metrics` receiver running as an agent; this instrumentation option provides an alternative for processes that want to record the same information without an agent.

func WithMetricReader

func WithMetricReader(exp sdkMetric.Reader) Option

WithMetricReader configures the application's meter provider to export the measured data. Readers take two forms: ones that push to an endpoint (NewPeriodicReader), and ones that an endpoint pulls from. See the `go.opentelemetry.io/otel/exporters` package for exporters that can be used as or with these Readers.

func WithPropagator

func WithPropagator(mp propagation.TextMapPropagator) Option

WithPropagator add a new propagator to the application. OpenTelemetry propagators are used to extract and inject context data from and into messages exchanged by applications. The application supports the following propagation mechanisms by default:

func WithResourceAttributes

func WithResourceAttributes(fields otel.Attributes) Option

WithResourceAttributes allows extending (or overriding) the core attributes used globally by the application. The core attributes must provide information at the resource level. These attributes are used to configure the application's tracer and logger instances.

func WithRuntimeMetrics

func WithRuntimeMetrics(interval time.Duration) Option

WithRuntimeMetrics enables the application to capture the conventional runtime metrics specified by OpenTelemetry. The provided interval value sets the minimum interval between calls to runtime.ReadMemStats(), which is a relatively expensive call to make frequently. The default interval value is 10 seconds, passing a value <= 0 uses the default.

func WithSampler

func WithSampler(ss sdkTrace.Sampler) Option

WithSampler adjust the sampling strategy used by the application. All traces are sampled by default.

https://opentelemetry.io/docs/instrumentation/go/exporting_data/#sampling

func WithServiceName

func WithServiceName(name string) Option

WithServiceName adjust the `service.name` attribute.

func WithServiceVersion

func WithServiceVersion(version string) Option

WithServiceVersion adjust the `service.version` attribute.

func WithSpanLimits

func WithSpanLimits(sl sdkTrace.SpanLimits) Option

WithSpanLimits allows to adjust the limits bound any Span created by the tracer. https://pkg.go.dev/go.opentelemetry.io/otel/sdk/trace#SpanLimits

func WithSpanProcessor

func WithSpanProcessor(sp sdkTrace.SpanProcessor) Option

WithSpanProcessor registers a new span processor in the trace provider processing chain.

Jump to

Keyboard shortcuts

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