trace

package
v0.26.4 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Copyright 2023 The Radius Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2023 The Radius Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	// FrontendTracerName represents the name of frontend tracer name.
	FrontendTracerName string = "radius-frontend-tracer"
	// BackendTracerName represents the name of backend tracer name.
	BackendTracerName string = "radius-backend-tracer"
)

Variables

This section is empty.

Functions

func ExtractTraceparent

func ExtractTraceparent(ctx context.Context) string

ExtractTraceparent extracts the traceparent header from the context. Retrieve the current span context from context and serialize it to its w3c string representation using propagator. ref: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/messaging.md

func InitTracer

func InitTracer(opts Options) (func(context.Context) error, error)

InitTracer sets up a tracer provider with a sampler and resource attributes, and optionally registers a Zipkin exporter and batcher. It returns a shutdown function and an error if one occurs.

func SetAsyncResultStatus

func SetAsyncResultStatus(result ctrl.Result, span trace.Span)

SetAsyncResultStatus sets the status of the span based on the result and adds an exception event if the result contains an error.

func StartConsumerSpan

func StartConsumerSpan(ctx context.Context, spanName string, tracerName string) (context.Context, trace.Span)

StartConsumerSpan creates a new span with SpanKindConsumer for dequeing async operations. It creates the span with the given spanName and tracerName, and adds the given attributes.

func StartCustomSpan

func StartCustomSpan(ctx context.Context, spanName string, tracerName string, attrs []attribute.KeyValue, opts ...trace.SpanStartOption) (context.Context, trace.Span)

StartCustomSpan creates a new span with the given name, tracer name and attributes and returns a context and the span.

func StartProducerSpan

func StartProducerSpan(ctx context.Context, spanName string, tracerName string) (context.Context, trace.Span)

StartProducerSpan creates a new span with SpanKindProducer for enqueuing async operations. It creates the span with the given spanName and tracerName, and adds the given attributes.

func WithTraceparent

func WithTraceparent(ctx context.Context, traceparent string) context.Context

WithTraceparent creates a new context with the given traceparent string.

Types

type Options

type Options struct {
	// ServiceName represents the name of service.
	ServiceName string `yaml:"serviceName,omitempty"`
	// Zipkin represents zipkin options.
	Zipkin *ZipkinOptions `yaml:"zipkin,omitempty"`
}

Options represents the trace options.

type Service added in v0.26.0

type Service struct {
	Options Options
}

Service implements the hosting.Service interface for the tracer.

func (*Service) Name added in v0.26.0

func (s *Service) Name() string

Name gets the service name.

func (*Service) Run added in v0.26.0

func (s *Service) Run(ctx context.Context) error

Run runs the tracer service.

type ZipkinOptions

type ZipkinOptions struct {
	// URL represents the url of zipkin endpoint.
	URL string `yaml:"url"`
}

ZipkinOptions represents zipkin trace provider options.

Jump to

Keyboard shortcuts

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