client

package
v2.15.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2024 License: Apache-2.0 Imports: 17 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractDistributedTracingExtension

func ExtractDistributedTracingExtension(ctx context.Context, event cloudevents.Event) context.Context

ExtractDistributedTracingExtension extracts the tracecontext from the cloud event into the context.

Calling this method will always replace the tracecontext in the context with the one extracted from the event. In case this is undesired, check first if the context has a recording span with: `trace.SpanFromContext(ctx)`

func GetDefaultSpanAttributes

func GetDefaultSpanAttributes(e *cloudevents.Event, method string) []attribute.KeyValue

GetDefaultSpanAttributes returns the attributes that are always added to the spans created by the OTelObservabilityService.

func InjectDistributedTracingExtension

func InjectDistributedTracingExtension(ctx context.Context, event cloudevents.Event)

InjectDistributedTracingExtension injects the tracecontext from the context into the event as a DistributedTracingExtension

If a DistributedTracingExtension is present in the provided event, its current value is replaced with the tracecontext obtained from the context.

func NewClientHTTP

func NewClientHTTP(topt []cehttp.Option, copt []client.Option, obsOpts ...OTelObservabilityServiceOption) (client.Client, error)

NewClientHTTP produces a new client instrumented with OpenTelemetry.

Types

type CloudEventCarrier

type CloudEventCarrier struct {
	Extension *extensions.DistributedTracingExtension
}

CloudEventCarrier wraps the distributed trace extension to satisfy the TextMapCarrier interface. https://github.com/open-telemetry/opentelemetry-go/blob/v1.0.0-RC3/propagation/propagation.go#L23

func NewCloudEventCarrier

func NewCloudEventCarrier() CloudEventCarrier

NewCloudEventCarrier creates a new CloudEventCarrier with an empty distributed tracing extension.

func NewCloudEventCarrierWithEvent

func NewCloudEventCarrierWithEvent(ctx context.Context, event cloudevents.Event) CloudEventCarrier

NewCloudEventCarrierWithEvent creates a new CloudEventCarrier with a distributed tracing extension populated with the trace data from the event.

func (CloudEventCarrier) Get

func (cec CloudEventCarrier) Get(key string) string

Get returns the value associated with the passed key.

func (CloudEventCarrier) Keys

func (cec CloudEventCarrier) Keys() []string

Keys lists the keys stored in this carrier.

func (CloudEventCarrier) Set

func (cec CloudEventCarrier) Set(key string, value string)

Set stores the key-value pair.

type OTelObservabilityService

type OTelObservabilityService struct {
	// contains filtered or unexported fields
}

OTelObservabilityService implements the ObservabilityService interface from cloudevents

func NewOTelObservabilityService

func NewOTelObservabilityService(opts ...OTelObservabilityServiceOption) *OTelObservabilityService

NewOTelObservabilityService returns an OpenTelemetry-enabled observability service

func (OTelObservabilityService) InboundContextDecorators

func (o OTelObservabilityService) InboundContextDecorators() []func(context.Context, binding.Message) context.Context

InboundContextDecorators returns a decorator function that allows enriching the context with the incoming parent trace. This method gets invoked automatically by passing the option 'WithObservabilityService' when creating the cloudevents HTTP client.

func (OTelObservabilityService) RecordCallingInvoker

func (o OTelObservabilityService) RecordCallingInvoker(ctx context.Context, event *cloudevents.Event) (context.Context, func(errOrResult error))

RecordCallingInvoker starts a new span before calling the invoker upon a received event. In case the operation fails, the error is recorded and the span is marked as failed.

func (OTelObservabilityService) RecordReceivedMalformedEvent

func (o OTelObservabilityService) RecordReceivedMalformedEvent(ctx context.Context, err error)

RecordReceivedMalformedEvent records the error from a malformed event in the span.

func (OTelObservabilityService) RecordRequestEvent

func (o OTelObservabilityService) RecordRequestEvent(ctx context.Context, event cloudevents.Event) (context.Context, func(errOrResult error, event *cloudevents.Event))

RecordRequestEvent starts a new span before transmitting the given request. In case the operation fails, the error is recorded and the span is marked as failed.

func (OTelObservabilityService) RecordSendingEvent

func (o OTelObservabilityService) RecordSendingEvent(ctx context.Context, event cloudevents.Event) (context.Context, func(errOrResult error))

RecordSendingEvent starts a new span before sending the event. In case the operation fails, the error is recorded and the span is marked as failed.

type OTelObservabilityServiceOption

type OTelObservabilityServiceOption func(*OTelObservabilityService)

func WithSpanAttributesGetter

func WithSpanAttributesGetter(attrGetter func(cloudevents.Event) []attribute.KeyValue) OTelObservabilityServiceOption

WithSpanAttributesGetter appends the returned attributes from the function to the span.

func WithSpanNameFormatter

func WithSpanNameFormatter(nameFormatter func(cloudevents.Event) string) OTelObservabilityServiceOption

WithSpanNameFormatter replaces the default span name with the string returned from the function

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL