Documentation
¶
Index ¶
- Constants
- Variables
- func Init(cfg *config.AgentConfig) func()
- func InitAsAdditional(cfg *config.AgentConfig) (trace.SpanProcessor, func())
- func InitWithSpanProcessorWrapper(cfg *config.AgentConfig, wrapper SpanProcessorWrapper, ...) func()
- func InitWithSpanProcessorWrapperAndZap(cfg *config.AgentConfig, wrapper SpanProcessorWrapper, ...) func()
- func MakeRemoveGoAgentAttrs(attrsRemovalPrefixes []string) func(sp trace.SpanExporter) trace.SpanExporter
- func NewHttpOperationMetricsHandler(nameGetter func(*http.Request) string) sdk.HttpOperationMetricsHandler
- func RegisterService(key string, resourceAttributes map[string]string, opts ...ServiceOption) (sdk.StartSpan, trace.TracerProvider, error)
- func RegisterServiceWithSpanProcessorWrapper(key string, resourceAttributes map[string]string, wrapper SpanProcessorWrapper, ...) (sdk.StartSpan, trace.TracerProvider, error)
- func SpanFromContext(ctx context.Context) sdk.Span
- type AttributeList
- type HttpOperationMetricsHandler
- type ServiceOption
- type ServiceOptions
- type Span
- func (s *Span) AddEvent(name string, ts time.Time, attributes map[string]interface{})
- func (s *Span) GetAttributes() sdk.AttributeList
- func (s *Span) GetSpanId() string
- func (s *Span) IsNoop() bool
- func (s *Span) SetAttribute(key string, value interface{})
- func (s *Span) SetError(err error)
- func (s *Span) SetStatus(code sdk.Code, description string)
- type SpanProcessorWrapper
Examples ¶
Constants ¶
const TracerDomain = "org.hypertrace.goagent"
TracerDomain represents the tracer name for the Hypertrace instrumentation
Variables ¶
var NoopStartSpan = startSpan(trace.NewNoopTracerProvider)
var RemoveGoAgentAttrs = MakeRemoveGoAgentAttrs(attrsRemovalPrefixes)
var StartSpan = startSpan(otel.GetTracerProvider)
Functions ¶
func Init ¶
func Init(cfg *config.AgentConfig) func()
Init initializes opentelemetry tracing and returns a shutdown function to flush data immediately on a termination signal.
Example ¶
cfg := config.Load() cfg.ServiceName = config.String("my_example_svc") cfg.DataCapture.HttpHeaders.Request = config.Bool(true) cfg.Reporting.Endpoint = config.String("http://api.traceable.ai:9411/api/v2/spans") shutdown := Init(cfg) defer shutdown()
Output:
func InitAsAdditional ¶ added in v0.5.0
func InitAsAdditional(cfg *config.AgentConfig) (trace.SpanProcessor, func())
InitAsAdditional initializes opentelemetry tracing and returns a span processor and a shutdown function to flush data immediately on a termination signal. This is ideal for when we use goagent along with other opentelemetry setups.
func InitWithSpanProcessorWrapper ¶ added in v0.6.0
func InitWithSpanProcessorWrapper(cfg *config.AgentConfig, wrapper SpanProcessorWrapper, versionInfoAttrs []attribute.KeyValue) func()
InitWithSpanProcessorWrapper initializes opentelemetry tracing with a wrapper over span processor and returns a shutdown function to flush data immediately on a termination signal.
func InitWithSpanProcessorWrapperAndZap ¶ added in v0.18.0
func InitWithSpanProcessorWrapperAndZap(cfg *config.AgentConfig, wrapper SpanProcessorWrapper, versionInfoAttrs []attribute.KeyValue, logger *zap.Logger) func()
InitWithSpanProcessorWrapperAndZap initializes opentelemetry tracing with a wrapper over span processor and returns a shutdown function to flush data immediately on a termination signal. Also sets opentelemetry internal errorhandler to the provider zap errorhandler
func MakeRemoveGoAgentAttrs ¶ added in v0.5.0
func MakeRemoveGoAgentAttrs(attrsRemovalPrefixes []string) func(sp trace.SpanExporter) trace.SpanExporter
RemoveGoAgentAttrs removes custom goagent attributes from the spans so that other tracing servers don't receive them and don't have to handle the load.
func NewHttpOperationMetricsHandler ¶ added in v0.12.0
func NewHttpOperationMetricsHandler(nameGetter func(*http.Request) string) sdk.HttpOperationMetricsHandler
func RegisterService ¶
func RegisterService(key string, resourceAttributes map[string]string, opts ...ServiceOption) (sdk.StartSpan, trace.TracerProvider, error)
RegisterService creates tracerprovider for a new service (represented via a unique key) and returns a func which can be used to create spans and the TracerProvider
Example ¶
cfg := config.Load() cfg.ServiceName = config.String("my_example_svc") cfg.DataCapture.HttpHeaders.Request = config.Bool(true) cfg.Reporting.TraceReporterType = config.TraceReporterType_LOGGING shutdown := Init(cfg) defer shutdown() _, _, err := RegisterService("custom_service", map[string]string{"test1": "val1"}) if err != nil { log.Fatalf("Error while initializing service: %v", err) }
Output:
func RegisterServiceWithSpanProcessorWrapper ¶ added in v0.6.0
func RegisterServiceWithSpanProcessorWrapper(key string, resourceAttributes map[string]string, wrapper SpanProcessorWrapper, versionInfoAttrs []attribute.KeyValue, opts ...ServiceOption) (sdk.StartSpan, trace.TracerProvider, error)
RegisterServiceWithSpanProcessorWrapper creates a tracerprovider for a new service (represented via a unique key) with a wrapper over opentelemetry span processor and returns a func which can be used to create spans and the TracerProvider
Types ¶
type AttributeList ¶ added in v0.6.0
type AttributeList struct {
// contains filtered or unexported fields
}
func (*AttributeList) GetValue ¶ added in v0.6.0
func (l *AttributeList) GetValue(key string) interface{}
func (*AttributeList) Iterate ¶ added in v0.16.0
func (l *AttributeList) Iterate(yield func(key string, value interface{}) bool)
func (*AttributeList) Len ¶ added in v0.16.0
func (l *AttributeList) Len() int
type HttpOperationMetricsHandler ¶ added in v0.12.0
type HttpOperationMetricsHandler struct {
// contains filtered or unexported fields
}
func (*HttpOperationMetricsHandler) AddToRequestCount ¶ added in v0.12.0
func (mh *HttpOperationMetricsHandler) AddToRequestCount(n int64, r *http.Request)
type ServiceOption ¶ added in v0.19.0
type ServiceOption func(*ServiceOptions)
func WithHeaders ¶ added in v0.19.0
func WithHeaders(headers map[string]string) ServiceOption
type ServiceOptions ¶ added in v0.19.0
type ServiceOptions struct {
// contains filtered or unexported fields
}
type Span ¶
func (*Span) GetAttributes ¶ added in v0.6.0
func (s *Span) GetAttributes() sdk.AttributeList
func (*Span) SetAttribute ¶
type SpanProcessorWrapper ¶ added in v0.6.0
type SpanProcessorWrapper interface { OnStart(parent context.Context, s sdktrace.ReadWriteSpan, delegate sdktrace.SpanProcessor) OnEnd(s sdktrace.ReadOnlySpan, delegate sdktrace.SpanProcessor) }
SpanProcessorWrapper wraps otel span processor and is responsible to delegate calls to the wrapped processor
Directories
¶
Path | Synopsis |
---|---|
database
|
|
github.com
|
|
jackc/hyperpgx
Module
|
|
google.golang.org
|
|
internal
|
|
net
|
|