Documentation ¶
Index ¶
- Constants
- Variables
- func NewClient(cfg Config) (otlptrace.Client, error)
- func NewExporter(ctx context.Context, cfg Config) (sdktrace.SpanExporter, error)
- func NewNoopClient() otlptrace.Client
- func NewStartedClient(ctx context.Context, cfg Config) (otlptrace.Client, error)
- func NoopTracer(instrumentationName string) oteltrace.Tracer
- type Collector
- func (c *Collector) ClientTLSConfig() *tls.Config
- func (c *Collector) Export(ctx context.Context, req *coltracepb.ExportTraceServiceRequest) (*coltracepb.ExportTraceServiceResponse, error)
- func (c *Collector) GRPCAddr() string
- func (c *Collector) HTTPAddr() string
- func (c *Collector) HTTPSAddr() string
- func (c *Collector) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (c *Collector) Shutdown(ctx context.Context) error
- func (c *Collector) Spans() []*otlp.ScopeSpans
- func (c *Collector) Start() error
- type CollectorConfig
- type Config
- type Provider
- type RotatingFileClient
Constants ¶
const ( // DefaultExporterDialTimeout is the default timeout for dialing the exporter. DefaultExporterDialTimeout = 5 * time.Second // VersionKey is the attribute key for the teleport version. VersionKey = "teleport.version" // ProcessIDKey is attribute key for the process ID. ProcessIDKey = "teleport.process.id" // HostnameKey is the attribute key for the hostname. HostnameKey = "teleport.host.name" // HostIDKey is the attribute key for the host UUID. HostIDKey = "teleport.host.uuid" )
const DefaultFileLimit uint64 = 1048576 * 100 // 100MB
DefaultFileLimit is the default file size limit used before rotating to a new traces file
Variables ¶
var ErrShutdown = errors.New("the client is shutdown")
Functions ¶
func NewClient ¶
NewClient either returns the provided Config.Client or constructs a new client that is connected to the Config.ExporterURL with the appropriate TLS credentials. The returned client is not started, it will be started by the provider if passed to one.
func NewExporter ¶
NewExporter returns a new exporter that is configured per the provided Config.
func NewNoopClient ¶
NewNoopClient returns an oltptrace.Client that does nothing
func NewStartedClient ¶
NewStartedClient either returns the provided Config.Client or constructs a new client that is connected to the Config.ExporterURL with the appropriate TLS credentials. The client is started prior to returning to the caller.
func NoopTracer ¶
NoopTracer creates a new Tracer that never samples any spans.
Types ¶
type Collector ¶
type Collector struct { coltracepb.TraceServiceServer // contains filtered or unexported fields }
Collector is a simple in memory implementation of an OpenTelemetry Collector that is used for testing purposes.
func NewCollector ¶
func NewCollector(cfg CollectorConfig) (*Collector, error)
NewCollector creates a new Collector based on the provided config.
func (*Collector) ClientTLSConfig ¶
ClientTLSConfig returns the tls.Config that clients should use to connect to the collector.
func (*Collector) Export ¶
func (c *Collector) Export(ctx context.Context, req *coltracepb.ExportTraceServiceRequest) (*coltracepb.ExportTraceServiceResponse, error)
Export is the grpc handler for the Collector.
func (*Collector) ServeHTTP ¶
func (c *Collector) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP is the HTTP handler for the Collector.
func (*Collector) Spans ¶
func (c *Collector) Spans() []*otlp.ScopeSpans
type CollectorConfig ¶
CollectorConfig configures how a Collector should be created.
type Config ¶
type Config struct { // Service is the name of the service that will be reported to the tracing system. Service string // Attributes is a set of key value pairs that will be added to all spans. Attributes []attribute.KeyValue // ExporterURL is the URL of the exporter. ExporterURL string // SamplingRate determines how many spans are recorded and exported SamplingRate float64 // TLSCert is the TLS configuration to use for the exporter. TLSConfig *tls.Config // DialTimeout is the timeout for dialing the exporter. DialTimeout time.Duration // Logger is the logger to use. Logger logrus.FieldLogger // Client is the client to use to export traces. This takes precedence over creating a // new client with the ExporterURL. Ownership of the client is transferred to the // tracing provider. It should **NOT** be closed by the caller. Client *tracing.Client // contains filtered or unexported fields }
Config used to set up the tracing exporter and provider
func (*Config) CheckAndSetDefaults ¶
CheckAndSetDefaults checks the config and sets default values.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider wraps the OpenTelemetry tracing provider to provide common tags for all tracers.
func NewTraceProvider ¶
NewTraceProvider creates a new Provider that is configured per the provided Config.
func NoopProvider ¶
func NoopProvider() *Provider
NoopProvider creates a new Provider that never samples any spans.
func (*Provider) Shutdown ¶
Shutdown shuts down the span processors in the order they were registered.
func (*Provider) Tracer ¶
func (p *Provider) Tracer(instrumentationName string, opts ...oteltrace.TracerOption) oteltrace.Tracer
Tracer returns a Tracer with the given name and options. If a Tracer for the given name and options does not exist it is created, otherwise the existing Tracer is returned.
If name is empty, DefaultTracerName is used instead.
This method is safe to be called concurrently.
type RotatingFileClient ¶
type RotatingFileClient struct {
// contains filtered or unexported fields
}
RotatingFileClient is an otlptrace.Client that writes traces to a file. It will automatically rotate files when they reach the configured limit. Each line in the file is a JSON-encoded otlp.Span.
func NewRotatingFileClient ¶
func NewRotatingFileClient(dir string, limit uint64) (*RotatingFileClient, error)
NewRotatingFileClient returns a new RotatingFileClient that will store files in the provided directory. The files will be rotated when they reach the provided limit.
func (*RotatingFileClient) Start ¶
func (f *RotatingFileClient) Start(ctx context.Context) error
Start is a noop needed to satisfy the otlptrace.Client interface.
func (*RotatingFileClient) Stop ¶
func (f *RotatingFileClient) Stop(ctx context.Context) error
Stop closes the active file and sets it to nil to indicate to UploadTraces that no more traces should be written.
func (*RotatingFileClient) UploadTraces ¶
func (f *RotatingFileClient) UploadTraces(ctx context.Context, protoSpans []*otlp.ResourceSpans) error
UploadTraces writes the provided spans to a file in the configured directory. If writing another span to the file would cause it to exceed the limit, then the file is first rotated before the write is attempted. In the event that Stop has already been called this will always return ErrShutdown.