otlp

package
v2.22.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: MIT Imports: 23 Imported by: 0

README

Otlp Configuration

This package provides a configuration for the OpenTelemetry Protocol (OTLP) exporter.

Usage Example

package main

import (
	"context"

	"go.opentelemetry.io/otel/attribute"

	"github.com/go-kratos-ecosystem/components/v2/otel/otlp"
)

func main() {
	ctx := context.TODO()

	// transport
	transport := otlp.NewGRPCTransport("localhost:4317", otlp.WithGRPCTransportInsecure(true))

	// client
	client := otlp.NewClient(
		otlp.WithServiceName("service-name"),
		otlp.WithDeploymentEnvironment("development"),
		otlp.WithAttributes(
			attribute.String("key", "value"),
			// ...
		),
		otlp.WithTransport(transport),
	)

	if err := client.Configure(ctx); err != nil {
		panic(err)
	}

	defer client.Shutdown(ctx)

	// do something
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(opts ...Option) *Client

func (*Client) Configure

func (c *Client) Configure(ctx context.Context) error

func (*Client) RegisterResource

func (c *Client) RegisterResource(resource *sdkresource.Resource)

func (*Client) Shutdown

func (c *Client) Shutdown(ctx context.Context) (err error)

type GRPCTransport

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

func NewGRPCTransport

func NewGRPCTransport(endpoint string, opts ...GRPCTransportOption) *GRPCTransport

func (*GRPCTransport) GetLogExporter

func (t *GRPCTransport) GetLogExporter(ctx context.Context) (log.Exporter, error)

func (*GRPCTransport) GetMetricExporter

func (t *GRPCTransport) GetMetricExporter(ctx context.Context) (metric.Exporter, error)

func (*GRPCTransport) GetTraceSpanExporter

func (t *GRPCTransport) GetTraceSpanExporter(ctx context.Context) (trace.SpanExporter, error)

type GRPCTransportOption

type GRPCTransportOption func(*GRPCTransport)

func WithGRPCTransportInsecure

func WithGRPCTransportInsecure(insecure bool) GRPCTransportOption

func WithGRPCTransportTraceSampler

func WithGRPCTransportTraceSampler(sampler sdktrace.Sampler) GRPCTransportOption

type Option

type Option func(*Client)

func WithAttributes

func WithAttributes(attributes ...attribute.KeyValue) Option

func WithDeploymentEnvironment

func WithDeploymentEnvironment(deploymentEnvironment string) Option

func WithEnableRuntimeMetrics

func WithEnableRuntimeMetrics(enable bool) Option

func WithLoggerProvider

func WithLoggerProvider(provider log.LoggerProvider) Option

func WithMeterProvider

func WithMeterProvider(provider metric.MeterProvider) Option

func WithPropagator

func WithPropagator(propagator propagation.TextMapPropagator) Option

func WithResource

func WithResource(resource *sdkresource.Resource) Option

func WithServiceName

func WithServiceName(serviceName string) Option

func WithTraceSampler

func WithTraceSampler(sampler sdktrace.Sampler) Option

func WithTracerProvider

func WithTracerProvider(provider trace.TracerProvider) Option

func WithTransport

func WithTransport(transport Transport) Option

type Provider

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

func NewProvider

func NewProvider(client *Client) *Provider

func (*Provider) Bootstrap

func (p *Provider) Bootstrap(ctx context.Context) (context.Context, error)

func (*Provider) Terminate

func (p *Provider) Terminate(ctx context.Context) (context.Context, error)

type Transport

type Transport interface {
	GetTraceSpanExporter(ctx context.Context) (trace.SpanExporter, error)
	GetMetricExporter(ctx context.Context) (metric.Exporter, error)
	GetLogExporter(ctx context.Context) (log.Exporter, error)
}

Jump to

Keyboard shortcuts

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