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 ¶
- func ExporterOTLP(endpoint string, insecure bool, headers map[string]string, protocol string) (sdkTrace.SpanExporter, sdkMetric.Exporter, error)
- func ExporterStdout(pretty bool) (sdkTrace.SpanExporter, sdkMetric.Exporter, error)
- type Instrumentation
- type Option
- func WithBaseLogger(ll log.Logger) Option
- func WithExemplars() Option
- func WithExporterOTLP(endpoint string, insecure bool, headers map[string]string, protocol string) []Option
- func WithExporterStdout(pretty bool) []Option
- func WithHostMetrics() Option
- func WithMetricExporter(exp sdkMetric.Exporter) Option
- func WithPropagator(mp propagation.TextMapPropagator) Option
- func WithResourceAttributes(fields otel.Attributes) Option
- func WithRuntimeMetrics(interval time.Duration) Option
- func WithSampler(ss sdkTrace.Sampler) Option
- func WithServiceName(name string) Option
- func WithServiceVersion(version string) Option
- func WithSpanExporter(exp sdkTrace.SpanExporter) Option
- func WithSpanLimits(sl sdkTrace.SpanLimits) Option
- func WithSpanProcessor(sp sdkTrace.SpanProcessor) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExporterOTLP ¶
func ExporterOTLP(endpoint string, insecure bool, headers map[string]string, protocol string) (sdkTrace.SpanExporter, sdkMetric.Exporter, error)
ExporterOTLP returns an initialized OTLP exporter instance utilizing the requested protocol.
func ExporterStdout ¶
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 ¶
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 WithExporterOTLP ¶
func WithExporterOTLP(endpoint string, insecure bool, headers map[string]string, protocol 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 ¶
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 WithMetricExporter ¶
WithMetricExporter configures the application's meter provider to export the caputered metrics data using a "push" mechanism.
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:
- W3C Trace Context (https://www.w3.org/TR/trace-context/)
- W3C Baggage (https://www.w3.org/TR/baggage/)
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 ¶
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 ¶
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 ¶
WithServiceName adjust the `service.name` attribute.
func WithServiceVersion ¶
WithServiceVersion adjust the `service.version` attribute.
func WithSpanExporter ¶
func WithSpanExporter(exp sdkTrace.SpanExporter) Option
WithSpanExporter 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 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.