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 MakeRemoveGoAgentAttrs(attrsRemovalPrefixes []string) func(sp trace.SpanExporter) trace.SpanExporter
- func NewHttpOperationMetricsHandler(nameGetter func(*http.Request) string) sdk.HttpOperationMetricsHandler
- func RegisterService(serviceName string, resourceAttributes map[string]string) (sdk.StartSpan, trace.TracerProvider, error)
- func RegisterServiceWithSpanProcessorWrapper(serviceName string, resourceAttributes map[string]string, ...) (sdk.StartSpan, trace.TracerProvider, error)
- func SpanFromContext(ctx context.Context) sdk.Span
- type AttributeList
- type HttpOperationMetricsHandler
- type Span
- func (s *Span) AddEvent(name string, ts time.Time, attributes map[string]interface{})
- func (s *Span) GetAttributes() sdk.AttributeList
- 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 ( // Pseudo of go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp#RequestCount since a metric is not // created for that one for some reason.(annotated with hypertrace to avoid a duplicate if otel go ever implement // their own) RequestCount = "hypertrace.http.server.request_count" // Incoming request count total )
Server HTTP metrics.
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) 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 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(serviceName string, resourceAttributes map[string]string) (sdk.StartSpan, trace.TracerProvider, error)
RegisterService creates tracerprovider for a new service 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(serviceName string, resourceAttributes map[string]string, wrapper SpanProcessorWrapper) (sdk.StartSpan, trace.TracerProvider, error)
RegisterServiceWithSpanProcessorWrapper creates a tracerprovider for a new service 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{}
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)
func (*HttpOperationMetricsHandler) CreateRequestCount ¶ added in v0.12.0
func (mh *HttpOperationMetricsHandler) CreateRequestCount()
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
|
|