scope

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package scope groups OpenTelemetry instruments under one instrumentation scope name.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChildOnly added in v1.1.4

func ChildOnly(provider trace.TracerProvider) trace.TracerProvider

ChildOnly wraps provider so its tracers start a span only under a parent: a context carrying a valid span context, local or remote. Without one they start nothing and return the context unchanged with its non-recording span. Given to an instrumented client (a database, a cache), it adds spans to the operations that use the client and never turns the client's own background work (polling, pings, sweeps) into root traces.

Types

type Option

type Option func(*options)

Option configures a Scope.

func WithMeterProvider

func WithMeterProvider(provider metric.MeterProvider) Option

WithMeterProvider uses provider to construct the scope meter.

func WithTracerProvider

func WithTracerProvider(provider trace.TracerProvider) Option

WithTracerProvider uses provider to construct the scope tracer.

type Scope

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

Scope owns commonly used OpenTelemetry instruments for a component.

func New

func New(name string, opts ...Option) *Scope

New constructs a Scope for name.

func (*Scope) Meter

func (s *Scope) Meter() metric.Meter

Meter returns the scope meter.

func (*Scope) Name

func (s *Scope) Name() string

Name returns the instrumentation scope name.

func (*Scope) Run

func (s *Scope) Run(ctx context.Context, name string, f span.Func, opts ...span.Option) error

Run starts a span on the scope tracer and executes f.

func (*Scope) Tracer

func (s *Scope) Tracer() trace.Tracer

Tracer returns the scope tracer.

Jump to

Keyboard shortcuts

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