package trace
import "go.opentelemetry.io/contrib/internal/trace"
Index ¶
- func EndUserAttributesFromHTTPRequest(request *http.Request) []otelkv.KeyValue
- func HTTPAttributesFromHTTPStatusCode(code int) []otelkv.KeyValue
- func HTTPServerAttributesFromHTTPRequest(serverName, route string, request *http.Request) []otelkv.KeyValue
- func NetAttributesFromHTTPRequest(network string, request *http.Request) []otelkv.KeyValue
- func SpanStatusFromHTTPStatusCode(code int) (codes.Code, string)
- type Provider
- type Span
- func (ms *Span) AddEvent(ctx context.Context, name string, attrs ...otelkv.KeyValue)
- func (ms *Span) AddEventWithTimestamp(ctx context.Context, timestamp time.Time, name string, attrs ...otelkv.KeyValue)
- func (ms *Span) End(options ...oteltrace.EndOption)
- func (ms *Span) IsRecording() bool
- func (ms *Span) RecordError(ctx context.Context, err error, opts ...oteltrace.ErrorOption)
- func (ms *Span) SetAttribute(key string, value interface{})
- func (ms *Span) SetAttributes(attributes ...otelkv.KeyValue)
- func (ms *Span) SetName(name string)
- func (ms *Span) SetStatus(status codes.Code, msg string)
- func (ms *Span) SpanContext() oteltrace.SpanContext
- func (ms *Span) Tracer() oteltrace.Tracer
- type Tracer
- func NewTracer(name string) *Tracer
- func (mt *Tracer) EndedSpans() []*Span
- func (mt *Tracer) Start(ctx context.Context, name string, o ...oteltrace.StartOption) (context.Context, oteltrace.Span)
- func (mt *Tracer) WithSpan(ctx context.Context, name string, body func(context.Context) error, opts ...oteltrace.StartOption) error
Functions ¶
func EndUserAttributesFromHTTPRequest ¶
EndUserAttributesFromHTTPRequest generates attributes of the enduser namespace as specified by the OpenTelemetry specification for a span.
func HTTPAttributesFromHTTPStatusCode ¶
HTTPAttributesFromHTTPStatusCode generates attributes of the http namespace as specified by the OpenTelemetry specification for a span.
func HTTPServerAttributesFromHTTPRequest ¶
func HTTPServerAttributesFromHTTPRequest(serverName, route string, request *http.Request) []otelkv.KeyValue
HTTPServerAttributesFromHTTPRequest generates attributes of the http namespace as specified by the OpenTelemetry specification for a span on the server side. Currently, only basic authentication is supported.
func NetAttributesFromHTTPRequest ¶
NetAttributesFromHTTPRequest generates attributes of the net namespace as specified by the OpenTelemetry specification for a span. The network parameter is a string that net.Dial function from standard library can understand.
func SpanStatusFromHTTPStatusCode ¶
SpanStatusFromHTTPStatusCode generates a status code and a message as specified by the OpenTelemetry specification for a span.
Types ¶
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
func (*Provider) Tracer ¶
type Span ¶
type Span struct { Name string Attributes map[otelkv.Key]otelvalue.Value Kind oteltrace.SpanKind Status codes.Code ParentSpanID oteltrace.SpanID // contains filtered or unexported fields }
Span is a mock span used in association with Tracer for testing purpose only.
func (*Span) AddEvent ¶
AddEvent does nothing.
func (*Span) AddEventWithTimestamp ¶
func (ms *Span) AddEventWithTimestamp(ctx context.Context, timestamp time.Time, name string, attrs ...otelkv.KeyValue)
AddEvent does nothing.
func (*Span) End ¶
End puts the span into tracers ended spans.
func (*Span) IsRecording ¶
IsRecording always returns false for Span.
func (*Span) RecordError ¶
RecordError does nothing.
func (*Span) SetAttribute ¶
SetAttribute adds a single inferred attribute.
func (*Span) SetAttributes ¶
SetAttributes adds an attribute to Attributes member.
func (*Span) SetName ¶
SetName sets the span name.
func (*Span) SetStatus ¶
SetStatus sets the Status member.
func (*Span) SpanContext ¶
func (ms *Span) SpanContext() oteltrace.SpanContext
SpanContext returns associated oteltrace.SpanContext.
If the receiver is nil it returns an empty oteltrace.SpanContext.
func (*Span) Tracer ¶
Tracer returns the mock tracer implementation of Tracer.
type Tracer ¶
type Tracer struct { // StartSpanID is used to initialize span ID. It is incremented // by one every time a new span is created. // // StartSpanID has to be aligned for 64-bit atomic operations. StartSpanID uint64 // Name of the tracer, received from the provider. Name string // Sampled specifies if the new span should be sampled or not. Sampled bool // OnSpanStarted is called every time a new span is started. OnSpanStarted func(span *Span) // contains filtered or unexported fields }
Tracer is a simple tracer used for testing purpose only. SpanID is atomically increased every time a new span is created.
func NewTracer ¶
func (*Tracer) EndedSpans ¶
func (*Tracer) Start ¶
func (mt *Tracer) Start(ctx context.Context, name string, o ...oteltrace.StartOption) (context.Context, oteltrace.Span)
Start starts a new Span and puts it into the context.
The function generates a new random TraceID if either there is no parent SpanContext in context or the WithNewRoot option is passed to the function. Otherwise the function will take the TraceID from parent SpanContext.
Currently no other StartOption has any effect here.
func (*Tracer) WithSpan ¶
func (mt *Tracer) WithSpan(ctx context.Context, name string, body func(context.Context) error, opts ...oteltrace.StartOption) error
WithSpan does nothing except creating a new span and executing the body.
Source Files ¶
http.go mock_span.go mock_tracer.go
- Version
- v0.6.0
- Published
- Jun 8, 2020
- Platform
- linux/amd64
- Imports
- 15 packages
- Last checked
- 5 hours ago –
Tools for package owners.