Movatterモバイル変換


[0]ホーム

URL:


Warning Deprecated: Use exporters/otlp/otlptrace or exporters/otlp/otlpmetric instead.

otlp

packagemodule
v0.20.1Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License:Apache-2.0Imports:11Imported by:65

Details

Repository

github.com/open-telemetry/opentelemetry-go

Links

README

OpenTelemetry Collector Go Exporter

PkgGoDev

This exporter exports OpenTelemetry spans and metrics to the OpenTelemetry Collector.

Installation and Setup

The exporter can be installed using standardgo functionality.

$ go get -u go.opentelemetry.io/otel/exporters/otlp

A new exporter can be created using theNewExporter function.

Retries

The exporter will not, by default, retry failed requests to the collector.However, it is configured in a way that it can be easily enabled.

To enable retries, theGRPC_GO_RETRY environment variable needs to be set toon. For example,

GRPC_GO_RETRY=on go run .

Thedefault service config used by default is defined to retry failed requests with exponential backoff (0.3seconds * (2)^retry) witha max of5 retries).

These retries are only attempted for reponses that aredeemed "retry-able" by the collector.

Documentation

Overview

Deprecated: This package was moved to exporters/otlp/otlptrace and exporters/otlp/otlpmetric.

Index

Examples

Constants

View Source
const (// DefaultCollectorPort is the port the Exporter will attempt connect to// if no collector port is provided.DefaultCollectorPortuint16 = 4317// DefaultCollectorHost is the host address the Exporter will attempt// connect to if no collector address is provided.DefaultCollectorHoststring = "localhost")

Variables

This section is empty.

Functions

This section is empty.

Types

typeCompressionadded inv0.20.0

type Compressionint

Compression describes the compression used for payloads sent to thecollector.

const (// NoCompression tells the driver to send payloads without// compression.NoCompressionCompression =iota// GzipCompression tells the driver to send payloads after// compressing them with gzip.GzipCompression)

typeExporter

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

Exporter is an OpenTelemetry exporter. It exports both traces and metricsfrom OpenTelemetry instrumented to code using OpenTelemetry protocolbuffers to a configurable receiver.

funcInstallNewPipelineadded inv0.20.0

func InstallNewPipeline(ctxcontext.Context, driverProtocolDriver, exporterOpts ...ExporterOption) (*Exporter,*sdktrace.TracerProvider, *basic.Controller,error)

InstallNewPipeline instantiates a NewExportPipeline with therecommended configuration and registers it globally.

funcNewExportPipelineadded inv0.20.0

func NewExportPipeline(ctxcontext.Context, driverProtocolDriver, exporterOpts ...ExporterOption) (*Exporter,*sdktrace.TracerProvider, *basic.Controller,error)

NewExportPipeline sets up a complete export pipelinewith the recommended TracerProvider setup.

funcNewExporter

func NewExporter(ctxcontext.Context, driverProtocolDriver, opts ...ExporterOption) (*Exporter,error)

NewExporter constructs a new Exporter and starts it.

Example
package mainimport ("context""log""go.opentelemetry.io/otel/exporters/otlp""go.opentelemetry.io/otel""go.opentelemetry.io/otel/exporters/otlp/otlpgrpc"sdktrace "go.opentelemetry.io/otel/sdk/trace")func main() {ctx := context.Background()// Set different endpoints for the metrics and traces collectorsmetricsDriver := otlpgrpc.NewDriver(// Configure metrics driver here)tracesDriver := otlpgrpc.NewDriver(// Configure traces driver here)config := otlp.SplitConfig{ForMetrics: metricsDriver,ForTraces:  tracesDriver,}driver := otlp.NewSplitDriver(config)exporter, err := otlp.NewExporter(ctx, driver) // Configure as needed.if err != nil {log.Fatalf("failed to create exporter: %v", err)}defer func() {err := exporter.Shutdown(ctx)if err != nil {log.Fatalf("failed to stop exporter: %v", err)}}()tracerProvider := sdktrace.NewTracerProvider(sdktrace.WithBatcher(exporter))otel.SetTracerProvider(tracerProvider)}

funcNewUnstartedExporter

func NewUnstartedExporter(driverProtocolDriver, opts ...ExporterOption) *Exporter

NewUnstartedExporter constructs a new Exporter and does not start it.

func (*Exporter)Export

Export transforms and batches metric Records into OTLP Metrics andtransmits them to the configured collector.

func (*Exporter)ExportKindForadded inv0.7.0

func (e *Exporter) ExportKindFor(desc *metric.Descriptor, kindaggregation.Kind)metricsdk.ExportKind

ExportKindFor reports back to the OpenTelemetry SDK sending this Exportermetric telemetry that it needs to be provided in a configured format.

func (*Exporter)ExportSpans

func (e *Exporter) ExportSpans(ctxcontext.Context, ss []*tracesdk.SpanSnapshot)error

ExportSpans transforms and batches trace SpanSnapshots into OTLP Trace andtransmits them to the configured collector.

func (*Exporter)Shutdownadded inv0.12.0

func (e *Exporter) Shutdown(ctxcontext.Context)error

Shutdown closes all connections and releases resources currently being usedby the exporter. If the exporter is not started this does nothing. A shutdown exporter can't be started again. Shutting down an already shut downexporter does nothing.

func (*Exporter)Start

func (e *Exporter) Start(ctxcontext.Context)error

Start establishes connections to the OpenTelemetry collector. Starting analready started exporter returns an error.

typeExporterOption

type ExporterOption func(*config)

ExporterOption are setting options passed to an Exporter on creation.

funcWithMetricExportKindSelectoradded inv0.14.0

func WithMetricExportKindSelector(selectormetricsdk.ExportKindSelector)ExporterOption

WithMetricExportKindSelector defines the ExportKindSelector usedfor selecting AggregationTemporality (i.e., Cumulative vs. Deltaaggregation). If not specified otherwise, exporter will use acumulative export kind selector.

typeMarshaleradded inv0.20.0

type Marshalerint

Marshaler describes the kind of message format sent to the collector

const (// MarshalProto tells the driver to send using the protobuf binary format.MarshalProtoMarshaler =iota// MarshalJSON tells the driver to send using json format.MarshalJSON)

typeProtocolDriveradded inv0.16.0

type ProtocolDriver interface {// Start should establish connection(s) to endpoint(s). It is// called just once by the exporter, so the implementation// does not need to worry about idempotence and locking.Start(ctxcontext.Context)error// Stop should close the connections. The function is called// only once by the exporter, so the implementation does not// need to worry about idempotence, but it may be called// concurrently with ExportMetrics or ExportTraces, so proper// locking is required. The function serves as a// synchronization point - after the function returns, the// process of closing connections is assumed to be finished.Stop(ctxcontext.Context)error// ExportMetrics should transform the passed metrics to the// wire format and send it to the collector. May be called// concurrently with ExportTraces, so the manager needs to// take this into account by doing proper locking.ExportMetrics(ctxcontext.Context, cpsmetricsdk.CheckpointSet, selectormetricsdk.ExportKindSelector)error// ExportTraces should transform the passed traces to the wire// format and send it to the collector. May be called// concurrently with ExportMetrics, so the manager needs to// take this into account by doing proper locking.ExportTraces(ctxcontext.Context, ss []*tracesdk.SpanSnapshot)error}

ProtocolDriver is an interface used by OTLP exporter. It'sresponsible for connecting to and disconnecting from the collector,and for transforming traces and metrics into wire format andtransmitting them to the collector.

funcNewSplitDriveradded inv0.16.0

func NewSplitDriver(cfgSplitConfig)ProtocolDriver

NewSplitDriver creates a protocol driver which contains two otherprotocol drivers and will forward traces to one of them and metricsto another.

typeSplitConfigadded inv0.16.0

type SplitConfig struct {// ForMetrics driver will be used for sending metrics to the// collector.ForMetricsProtocolDriver// ForTraces driver will be used for sending spans to the// collector.ForTracesProtocolDriver}

SplitConfig is used to configure a split driver.

Source Files

View all Source files

Directories

PathSynopsis
internal
transform
Package transform provides translations for opentelemetry-go concepts and structures to otlp structures.
Package transform provides translations for opentelemetry-go concepts and structures to otlp structures.
retrymodule
Package otlpgrpc provides an implementation of otlp.ProtocolDriver that connects to the collector and sends traces and metrics using gRPC.
Package otlpgrpc provides an implementation of otlp.ProtocolDriver that connects to the collector and sends traces and metrics using gRPC.
Package otlphttp implements a protocol driver that sends traces and metrics to the collector using HTTP with binary protobuf payloads.
Package otlphttp implements a protocol driver that sends traces and metrics to the collector using HTTP with binary protobuf payloads.
otlplog
otlptracemodule

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp