opentelemetry

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

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

Go to latest
Published: Oct 25, 2022 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Attribute

func Attribute(key string, value interface{}) attribute.KeyValue

Attribute returns an attribute.KeyValue from a key and any value.

func GetTextMapPropagator

func GetTextMapPropagator() propagation.TextMapPropagator

func GlobalMeter

func GlobalMeter() metric.Meter

func GlobalTracer

func GlobalTracer() trace.Tracer

func NewMetricInOption

func NewMetricInOption(c *Config) (mp metric.MeterProvider, shutdown func(ctx context.Context) error, err error)

NewMetricInOption return meter which export has been set in `metric.Option`

func NewOtlpMetric

func NewOtlpMetric(c *Config) (mp metric.MeterProvider, shutdown func(ctx context.Context) error, err error)

func NewOtlpTracer

func NewOtlpTracer(c *Config) (tp trace.TracerProvider, shutdown func(ctx context.Context) error, err error)

func NewStdMetric

func NewStdMetric(c *Config) (mp metric.MeterProvider, shutdown func(ctx context.Context) error, err error)

NewStdMetric return a stdout metric provider and an error if any

func NewStdTracer

func NewStdTracer(c *Config, opts ...stdouttrace.Option) (
	tp *sdktrace.TracerProvider, shutdown func(ctx context.Context) error, err error)

NewStdTracer return a stdout tracer provider and an error if any

func NewTraceInOption

func NewTraceInOption(c *Config) (tp trace.TracerProvider, shutdown func(ctx context.Context) error, err error)

NewTraceInOption return trace provider which export has been set in `trace.TracerProviderOption`

func SemVersion

func SemVersion() string

SemVersion is the semantic version to be supplied to tracer/meter creation.

func SetGlobalConfig

func SetGlobalConfig(cfg *Config)

func Version

func Version() string

Version is the current release version of the woocoo instrumentation.

Types

type Config

type Config struct {
	ServiceName                    string `json:"serviceName,omitempty" yaml:"serviceName"`
	ServiceNamespace               string `json:"serviceNamespace,omitempty" yaml:"serviceNamespace"`
	ServiceVersion                 string `json:"serviceVersion,omitempty" yaml:"serviceVersion"`
	AttributesEnvKeys              string `json:"attributesEnvKeys,omitempty" yaml:"attributesEnvKeys"`
	TraceExporterEndpoint          string `json:"traceExporterEndpoint" yaml:"traceExporterEndpoint"`
	TraceExporterEndpointInsecure  bool   `json:"traceExporterEndpointInsecure" yaml:"traceExporterEndpointInsecure"`
	MetricExporterEndpoint         string `json:"metricExporterEndpoint" yaml:"metricExporterEndpoint"`
	MetricExporterEndpointInsecure bool   `json:"metricExporterEndpointInsecure" yaml:"metricExporterEndpointInsecure"`
	// the intervening time between exports for a PeriodicReader.
	MetricPeriodicReaderInterval time.Duration `json:"metricReportingPeriod" yaml:"metricReportingPeriod"`

	Resource       *resource.Resource            `json:"-" yaml:"-"`
	TracerProvider trace.TracerProvider          `json:"-" yaml:"-"`
	Tracer         trace.Tracer                  `json:"-" yaml:"-"`
	MeterProvider  metric.MeterProvider          `json:"-" yaml:"-"`
	Meter          metric.Meter                  `json:"-" yaml:"-"`
	Propagator     propagation.TextMapPropagator `json:"-" yaml:"-"`
	// contains filtered or unexported fields
}

Config is the configuration for the opentelemetry instrumentation,Through it to set global tracer and meter provider.

func GlobalConfig

func GlobalConfig() *Config

func NewConfig

func NewConfig(cnf *conf.Configuration, opts ...Option) *Config

func (*Config) Apply

func (c *Config) Apply(cnf *conf.Configuration)

Apply implement conf.Configurable interface

if ServiceName and ServiceVersion and ServiceNameSpace is set in cfg, they will override before

func (*Config) Shutdown

func (c *Config) Shutdown()

type Option

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

Option specifies instrumentation configuration options.

func WithMeterProvider

func WithMeterProvider(provider metric.MeterProvider, shutdown func(ctx context.Context) error) Option

WithMeterProvider specifies a meter provider to use for creating a meter.

If none is specified, the metric.NewNoopMeterProvider is used.

func WithMeterProviderOptions

func WithMeterProviderOptions(opts ...sdkmetric.Option) Option

WithMeterProviderOptions specifies sdk tracer provider options to use for creating a tracer.

func WithPropagator

func WithPropagator(propagator propagation.TextMapPropagator) Option

WithPropagator specifies propagators to use for extracting information from the HTTP requests. If none are specified, global ones will be used.

func WithResource

func WithResource(resource *resource.Resource) Option

WithResource configures attributes on the resource

func WithResourceAttributes

func WithResourceAttributes(attributes map[string]string) Option

WithResourceAttributes configures attributes on the resource

example: zone=shanghai|app=app1|app_version=1.0.0

func WithTracerProvider

func WithTracerProvider(provider trace.TracerProvider, shutdown func(ctx context.Context) error) Option

WithTracerProvider specifies a tracer provider to use for creating a tracer.

If none is specified, the global provider is used.

func WithTracerProviderOptions

func WithTracerProviderOptions(opts ...sdktrace.TracerProviderOption) Option

WithTracerProviderOptions specifies sdk tracer provider options to use for creating a tracer.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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