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 HealthChecker
- type HealthHandler
- type Logger
- type Monitor
- 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 ( HealthEndpoint = "/health" PprofIndexEndpoint = "/debug/pprof" EchoShutdownTimeout = 5 * time.Second )
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 (
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 HealthChecker ¶
type HealthHandler ¶
type HealthHandler struct {
health.CompositeChecker
}
func NewHealthHandler ¶
func NewHealthHandler() *HealthHandler
NewHealthHandler returns a new Handler
func (*HealthHandler) ServeHTTP ¶
func (h *HealthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP returns a json encoded health set the status to http.StatusServiceUnavailable if the check is down
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 Monitor ¶
type Monitor interface {
AddHealthChecker(ctx context.Context, handlers ...HealthChecker)
}
type MonitorConfig ¶ added in v2.0.3
type OtelConfig ¶
type Telemetry ¶
func (Telemetry) Meter ¶ added in v2.0.4
Meter create new metric instance which should be treated as new
func (Telemetry) MetricProvider ¶ added in v2.0.7
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 ¶ added in v2.0.7
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 ¶ added in v2.0.7
func (t Telemetry) TracerProvider() trace.TracerProvider
TracerProvider used in constructor creation
func (Telemetry) WithContext ¶
WithContext put new copy of telemetry into context
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
example
|
|
checker
Package checker OTLP GRPC protocol endpoint is it alive
|
Package checker OTLP GRPC protocol endpoint is it alive |
middleware
|
|
mq
Package mq common package for any MQ system Based on Kafka Stream but everything what you need is -
|
Package mq common package for any MQ system Based on Kafka Stream but everything what you need is - |
monitoring
|
|
pkg
|
|