Documentation
¶
Index ¶
- Constants
- Variables
- func GetTraceId(ctx context.Context) string
- func GrpcStreamTraceInterceptor() grpc.StreamServerInterceptor
- func GrpcUnaryTraceInterceptor() grpc.UnaryServerInterceptor
- func InitHttpHandler(handler http.Handler) http.Handler
- func SetLog(l logger.Logger)
- func Setup(opts ...Option)
- func SpanStart(ctx context.Context, spanName string, opts ...oteltrace.SpanStartOption) (context.Context, oteltrace.Span)
- func Stop()
- func TracerIsEnable() bool
- type Config
- type Exporter
- type Option
- func WithAttributes(attributes map[string]string) Option
- func WithErrorHandler(errorHandler otel.ErrorHandler) Option
- func WithHeaders(headers map[string]string) Option
- func WithIDGenerator(idGenerator sdktrace.IDGenerator) Option
- func WithMetricExporter(metricExporter *Exporter) Option
- func WithMetricReportPeriod(period string) Option
- func WithResource(resource *resource.Resource) Option
- func WithSampleRatio(sampleRatio float64) Option
- func WithServiceInfo(serviceInfo *ServiceInfo) Option
- func WithTraceBatchOptions(options []sdktrace.BatchSpanProcessorOption) Option
- func WithTraceExporter(traceExporter *Exporter) Option
- type ServiceInfo
Constants ¶
const (
DefaultStdout = "stdout"
)
Variables ¶
var (
DefaultCred = credentials.NewClientTLSFromCert(nil, "")
)
Functions ¶
func GrpcStreamTraceInterceptor ¶
func GrpcStreamTraceInterceptor() grpc.StreamServerInterceptor
func GrpcUnaryTraceInterceptor ¶
func GrpcUnaryTraceInterceptor() grpc.UnaryServerInterceptor
GrpcUnaryTraceInterceptor wrap grpc server with opentelemetry trace and filter health check request
func InitHttpHandler ¶
InitHttpHandler wrap handler with opentelemetry handler and filter health check request
func SpanStart ¶
func SpanStart(ctx context.Context, spanName string, opts ...oteltrace.SpanStartOption) (context.Context, oteltrace.Span)
SpanStart creates a span and a context.Context containing the newly-created span.
If the context.Context provided in `ctx` contains a Span then the newly-created Span will be a child of that span, otherwise it will be a root span. This behavior can be overridden by providing `WithNewRoot()` as a SpanOption, causing the newly-created Span to be a root span even if `ctx` contains a Span.
When creating a Span it is recommended to provide all known span attributes using the `WithAttributes()` SpanOption as samplers will only have access to the attributes provided when a Span is created.
Any Span that is created MUST also be ended. This is the responsibility of the user. Implementations of this API may leak memory or other resources if Spans are not ended.
func TracerIsEnable ¶
func TracerIsEnable() bool
Types ¶
type Exporter ¶
type Exporter struct { ExporterEndpoint string Insecure bool Creds credentials.TransportCredentials }
type Option ¶
type Option func(*Config)
func WithAttributes ¶
WithAttributes set attributes which span send with
func WithErrorHandler ¶
func WithErrorHandler(errorHandler otel.ErrorHandler) Option
WithErrorHandler set error handler when span send failed
func WithHeaders ¶
WithHeaders set headers which span send with
func WithIDGenerator ¶
func WithIDGenerator(idGenerator sdktrace.IDGenerator) Option
WithIDGenerator set id generator for trace id and span id
func WithMetricExporter ¶
WithMetricExporter sets export that metric will send to
func WithMetricReportPeriod ¶
WithMetricReportPeriod set period
func WithResource ¶
WithResource set resource which span send with
func WithSampleRatio ¶
WithSampleRatio set ratio of traces samples
func WithServiceInfo ¶
func WithServiceInfo(serviceInfo *ServiceInfo) Option
WithServiceInfo set service info
func WithTraceBatchOptions ¶
func WithTraceBatchOptions(options []sdktrace.BatchSpanProcessorOption) Option
WithTraceBatchOptions set configuration settings for BatchSpanProcessor
func WithTraceExporter ¶
WithTraceExporter sets export that spans will send to