xtel

package module
v0.0.0-...-d298684 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: MIT Imports: 12 Imported by: 1

Documentation

Overview

Package xtel provides a set of tools for OpenTelemetry.

Index

Examples

Constants

This section is empty.

Variables

View Source
var DisableClientAutoTracing = &disableClientTracing{}

DisableClientAutoTracing controls automatic tracing of downstream client connection. This is ENABLED by default.

Functions

This section is empty.

Types

type MeterProvider

type MeterProvider = metric.MeterProvider

MeterProvider handles the creation and coordination of Meters. All Meters created by a MeterProvider will be associated with the same Resource, have the same Views applied to them, and have their produced metric telemetry passed to the configured Readers.

type MetricReaderFunc

type MetricReaderFunc func(context.Context) (metric.Reader, error)

MetricReaderFunc is used to create a new metric.Reader.

type Provider

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

Provider helps manage the lifecycle and configuration of different Exporter(s) and other service level configurations for tracing and metrics.

func NewProvider

func NewProvider(serviceName string, opts ...ProviderOption) (*Provider, error)

NewProvider creates a new Provider for the given ProviderOption.

Example
package main

import (
	"github.com/gojekfarm/xtools/xtel"
)

func main() {
	tp, err := xtel.NewProvider(
		"service-a",
		xtel.DisableClientAutoTracing,
		xtel.SamplingFraction(0.1),
	)
	if err != nil {
		panic(err)
	}

	if err := tp.Start(); err != nil {
		panic(err)
	}

	if err := tp.Stop(); err != nil {
		panic(err)
	}
}
Output:

func (*Provider) MeterProvider

func (p *Provider) MeterProvider() *MeterProvider

MeterProvider provides an OpenTelemetry MeterProvider over a given Provider which will be used to provide meters to instrumentation.

func (*Provider) Run

func (p *Provider) Run(ctx context.Context) error

Run will start running the Provider and associated processes. This method blocks until the passed context has been cancelled and then calls Stop. This makes Provider compatible with https://pkg.go.dev/github.com/gojekfarm/xrun package.

func (*Provider) Start

func (p *Provider) Start() error

Start starts Provider and initialises any related processes used for tracing.

func (*Provider) Stop

func (p *Provider) Stop() error

Stop stops the Provider and closes any resources being used for tracing.

func (*Provider) TracerProvider

func (p *Provider) TracerProvider() *TracerProvider

TracerProvider provides an OpenTelemetry TracerProvider over a given Provider which will be used to provide tracers to instrumentation.

type ProviderOption

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

ProviderOption changes the behaviour of Provider.

type SamplingFraction

type SamplingFraction float64

SamplingFraction configures sampling decision of traces. It makes a sampling decision based on the TraceID ratio. SamplingFraction >= 1 will always sample. SamplingFraction < 0 are treated as zero.

type TraceExporterFunc

type TraceExporterFunc func(context.Context) (trace.SpanExporter, error)

TraceExporterFunc is used to create a new trace.SpanExporter.

type TracerProvider

type TracerProvider = trace.TracerProvider

TracerProvider is an OpenTelemetry TracerProvider. It provides Tracers to instrumentation, so it can trace operational flow through a system.

Directories

Path Synopsis
exporter module

Jump to

Keyboard shortcuts

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