instana

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: MIT Imports: 12 Imported by: 1

README

Instana Go OpenTelemetry Exporter

An OpenTelemetry exporter that converts and sends Instana spans to the backend.

Installation

$ go get github.com/instana/go-otel-exporter

Usage

Once you have your application properly configured to be monitored by the OpenTelemetry SDK, the tracer provider expects an exporter. Import and instantiate the exporter to be used by the tracer provider.

The code sample below demonstrates how the tracing module could look like with the Instana exporter:

package main

import (
	"context"
	"time"

	instana "github.com/instana/go-otel-exporter"
	"go.opentelemetry.io/otel"
	sdktrace "go.opentelemetry.io/otel/sdk/trace"
	"go.opentelemetry.io/otel/trace"
)

// This example application demonstrates how to use the Instana OTel Exporter.
// Make sure to provide the required environment variables before run the application:
// * INSTANA_ENDPOINT_URL
// * INSTANA_AGENT_KEY
func main() {
	ch := make(chan bool)
	// Acquire an instance of the Instana OTel Exporter
	exporter := instana.New()

	// Setup and bootstrap the tracer provider
	tracerProvider := sdktrace.NewTracerProvider(
		sdktrace.WithBatcher(exporter),
	)

	otel.SetTracerProvider(tracerProvider)

	ctx := context.Background()

	// Instrument something with OTel
	tracer := otel.Tracer("my-traced-tech")
	_, span := tracer.Start(ctx, "my_span", trace.WithSpanKind(trace.SpanKindServer))
	time.Sleep(time.Millisecond * 400)
	span.End()

	<-ch
}

That's all you have to do. Your spans will be properly exported from your OpenTelemetry tracer to the Instana backend.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Exporter

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

The Exporter implements the OTel `sdktrace.SpanExporter` interface and it's responsible for converting otlp spans into Instana spans and upload them to the Instana backend.

func New

func New() *Exporter

New returns an instance of instana.Exporter

func (*Exporter) ExportSpans

func (e *Exporter) ExportSpans(ctx context.Context, spans []sdktrace.ReadOnlySpan) error

ExportSpans exports a batch of spans.

This function is called synchronously, so there is no concurrency safety requirement. However, due to the synchronous calling pattern, it is critical that all timeouts and cancellations contained in the passed context must be honored.

Any retry logic must be contained in this function. The SDK that calls this function will not implement any retry logic. All errors returned by this function are considered unrecoverable and will be reported to a configured error Handler.

func (*Exporter) Shutdown

func (e *Exporter) Shutdown(ctx context.Context) error

Shutdown notifies the exporter of a pending halt to operations. The exporter is expected to preform any cleanup or synchronization it requires while honoring all timeouts and cancellations contained in the passed context.

Directories

Path Synopsis
example module

Jump to

Keyboard shortcuts

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