Documentation ¶
Overview ¶
Package tracer is a library wrapped in go.opentelemetry.io/otel.
Index ¶
- func Close(ctx context.Context) error
- func GetProvider() *trace.TracerProvider
- func Init(exporter trace.SpanExporter, res *resource.Resource, fractions ...float64)
- func InitWithConfig(appName string, appEnv string, appVersion string, jaegerAgentHost string, ...)
- func NewConsoleExporter() (sdkTrace.SpanExporter, error)
- func NewFileExporter(filename string) (sdkTrace.SpanExporter, *os.File, error)
- func NewJaegerAgentExporter(host string, port string) (sdkTrace.SpanExporter, error)
- func NewJaegerExporter(url string, opts ...JaegerOption) (sdkTrace.SpanExporter, error)
- func NewResource(opts ...ResourceOption) *resource.Resource
- func NewSpan(ctx context.Context, spanName string, tags map[string]interface{}) (context.Context, trace.Span)
- func SetTraceName(name string)
- type JaegerOption
- type ResourceOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetProvider ¶ added in v1.0.9
func GetProvider() *trace.TracerProvider
GetProvider get tracer provider
func Init ¶
func Init(exporter trace.SpanExporter, res *resource.Resource, fractions ...float64)
Init Initialize tracer, parameter fraction is fraction, default is 1.0, value >= 1.0 means all links are sampled, value <= 0 means all are not sampled, 0 < value < 1 only samples percentage
func InitWithConfig ¶
func InitWithConfig(appName string, appEnv string, appVersion string, jaegerAgentHost string, jaegerAgentPort string, jaegerSamplingRate float64)
InitWithConfig Initialize tracer according to configuration, fraction is fraction, default is 1.0, value >= 1.0 means all links are sampled, value <= 0 means all are not sampled, 0 < value < 1 only samples percentage
func NewConsoleExporter ¶
func NewConsoleExporter() (sdkTrace.SpanExporter, error)
NewConsoleExporter output to console
func NewFileExporter ¶
NewFileExporter output to file, note: close the file before ending
func NewJaegerAgentExporter ¶
func NewJaegerAgentExporter(host string, port string) (sdkTrace.SpanExporter, error)
NewJaegerAgentExporter use jaeger agent as exporter, e.g. host=localhost port=6831
func NewJaegerExporter ¶
func NewJaegerExporter(url string, opts ...JaegerOption) (sdkTrace.SpanExporter, error)
NewJaegerExporter use jaeger collector as exporter, e.g. default url=http://localhost:14268/api/traces
func NewResource ¶
func NewResource(opts ...ResourceOption) *resource.Resource
NewResource returns a resource describing this application.
func NewSpan ¶
func NewSpan(ctx context.Context, spanName string, tags map[string]interface{}) (context.Context, trace.Span)
NewSpan create a span, to end a span you must call span.End()
func SetTraceName ¶
func SetTraceName(name string)
SetTraceName each service corresponds to a traceName
Types ¶
type ResourceOption ¶
type ResourceOption interface {
// contains filtered or unexported methods
}
ResourceOption modifying struct field values by means of an interface
func WithAttributes ¶
func WithAttributes(attributes map[string]string) ResourceOption
WithAttributes set service attributes
func WithEnvironment ¶
func WithEnvironment(environment string) ResourceOption
WithEnvironment set service environment
func WithServiceName ¶
func WithServiceName(name string) ResourceOption
WithServiceName set service name
func WithServiceVersion ¶
func WithServiceVersion(version string) ResourceOption
WithServiceVersion set service version