Documentation ¶
Overview ¶
Package tel represent Telemetry service we support context as source of Telemetry for gracefully support middleware we not pass ref to Telemetry for better handling different log instances
Index ¶
- Constants
- Variables
- func CreateRes(ctx context.Context, l Config) *resource.Resource
- func SetGlobal(t Telemetry)
- func SetInstanceIDGenerator(fn func(string) string)
- func SetLogOutput(log *Telemetry) *bytes.Buffer
- func StartSpanFromContext(ctx context.Context, name string, opts ...trace.SpanStartOption) (trace.Span, context.Context)
- func UpdateTraceFields(ctx context.Context)
- func WithContext(ctx context.Context, l Telemetry) context.Context
- func WrapContext(ctx context.Context, l *Telemetry) context.Context
- type Config
- type Logger
- type MonitorConfig
- type Option
- type OtelConfig
- type Telemetry
- func (t Telemetry) Copy() Telemetry
- func (t Telemetry) Ctx() context.Context
- func (t Telemetry) IsDebug() bool
- func (t Telemetry) LogLevel() zapcore.Level
- func (t Telemetry) Meter(ins string, opts ...metric.MeterOption) metric.Meter
- func (t Telemetry) MetricProvider() metric.MeterProvider
- func (t *Telemetry) Printf(msg string, items ...interface{})
- func (t *Telemetry) PutAttr(attr ...attribute.KeyValue) *Telemetry
- func (t *Telemetry) PutFields(fields ...zap.Field) *Telemetry
- func (t *Telemetry) StartSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (trace.Span, context.Context)
- func (t Telemetry) T() trace.Tracer
- func (t Telemetry) Tracer(name string, opts ...trace.TracerOption) Telemetry
- func (t Telemetry) TracerProvider() trace.TracerProvider
- func (t Telemetry) WithContext(ctx context.Context) context.Context
- func (t Telemetry) WithSpan(s trace.Span) *Telemetry
Constants ¶
const DisableLog = "none"
Variables ¶
var ( Any = zap.Any Binary = zap.Binary ByteString = zap.ByteString Bool = zap.Bool Duration = zap.Duration Float32 = zap.Float32 Float64 = zap.Float64 Int = zap.Int Int64 = zap.Int64 Int32 = zap.Int32 Int16 = zap.Int16 Int8 = zap.Int8 String = zap.String Time = zap.Time Uint = zap.Uint Uint64 = zap.Uint64 Uint32 = zap.Uint32 Uint16 = zap.Uint16 Uint8 = zap.Uint8 Uintptr = zap.Uintptr Error = zap.Error )
var ( Strings = zap.Strings Ints = zap.Ints )
var DefaultHistogramBoundaries = []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10}
DefaultHistogramBoundaries have been copied from prometheus.DefBuckets.
Note we anticipate the use of a high-precision histogram sketch as the standard histogram aggregator for OTLP export. (https://github.com/open-telemetry/opentelemetry-specification/issues/982).
var (
GenServiceName = defaultServiceFmt
)
Functions ¶
func SetInstanceIDGenerator ¶
SetInstanceIDGenerator set generator for instance name
func SetLogOutput ¶
SetLogOutput debug function for duplicate input log into bytes.Buffer
func StartSpanFromContext ¶
func StartSpanFromContext(ctx context.Context, name string, opts ...trace.SpanStartOption) ( trace.Span, context.Context)
StartSpanFromContext start telemetry span witch create or continue existent trace for gracefully continue trace ctx should contain both span and tele
func UpdateTraceFields ¶
UpdateTraceFields during session start good way to update tracing fields @prefix - for split different inter-service calls: kafka, grpc, db and etc
Types ¶
type Config ¶
type Config struct { Service string `env:"OTEL_SERVICE_NAME"` Namespace string `env:"NAMESPACE"` Environment string `env:"DEPLOY_ENVIRONMENT"` Version string `env:"VERSION"` LogLevel string `env:"LOG_LEVEL" envDefault:"info"` // Valid values are "json", "console" or "none" LogEncode string `env:"LOG_ENCODE" envDefault:"json"` Debug bool `env:"DEBUG" envDefault:"false"` MonitorConfig OtelConfig }
func DefaultConfig ¶
func DefaultConfig() Config
func DefaultDebugConfig ¶
func DefaultDebugConfig() Config
func GetConfigFromEnv ¶
func GetConfigFromEnv() Config
GetConfigFromEnv uses DefaultConfig and overwrite only variables present in env
type Logger ¶
type Logger interface { Check(lvl zapcore.Level, msg string) *zapcore.CheckedEntry Debug(msg string, fields ...zap.Field) Info(msg string, fields ...zap.Field) Warn(msg string, fields ...zap.Field) Error(msg string, fields ...zap.Field) Panic(msg string, fields ...zap.Field) Fatal(msg string, fields ...zap.Field) Sync() error Core() zapcore.Core }
type MonitorConfig ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option interface used for setting optional config properties.
func WithHealthCheckers ¶
WithHealthCheckers provide checkers to monitoring system for check health status of service
func WithMonitorEnable ¶
WithMonitorEnable enable monitoring
func WithMonitoringAddr ¶
WithMonitoringAddr overwrite monitoring addr
type OtelConfig ¶
type Telemetry ¶
func (Telemetry) MetricProvider ¶
func (t Telemetry) MetricProvider() metric.MeterProvider
MetricProvider used in constructor creation
func (*Telemetry) PutFields ¶
PutFields update current logger instance with new fields, which would affect only on nest write log call for current tele instance Because reference it also affect context and this approach is covered in Test_telemetry_With
func (*Telemetry) StartSpan ¶
func (t *Telemetry) StartSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (trace.Span, context.Context)
StartSpan start new trace telemetry span in case if ctx contains embed trace it will continue chain keep in mind than that function don't continue any trace, only create new for continue span use StartSpanFromContext
return context where embed telemetry with span writer
func (Telemetry) Tracer ¶
func (t Telemetry) Tracer(name string, opts ...trace.TracerOption) Telemetry
Tracer instantiate with specific name and tel option @return new Telemetry pointed to this one
func (Telemetry) TracerProvider ¶
func (t Telemetry) TracerProvider() trace.TracerProvider
TracerProvider used in constructor creation
func (Telemetry) WithContext ¶
WithContext put new copy of telemetry into context