telemetry

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 68 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// The base64-encoded, protobuf-marshalled callpbv1.Call that this span
	// represents.
	DagCallAttr = "dagger.io/dag.call"

	// The digest of the protobuf-marshalled Call that this span represents.
	//
	// This value acts as a node ID in the conceptual DAG.
	DagDigestAttr = "dagger.io/dag.digest"

	// The list of DAG digests that the span depends on.
	//
	// This is not currently used by the UI, but it could be used to drive higher
	// level DAG walking processes without having to unmarshal the full call.
	DagInputsAttr = "dagger.io/dag.inputs"

	// The DAG call digest that the call returned, if the call returned an
	// Object.
	//
	// This information is used to simplify values in the UI by showing their
	// highest-level creator. For example, if foo().bar() returns a().b().c(), we
	// will show foo().bar() instead of a().b().c() as it will be a more
	// recognizable value to the user.
	DagOutputAttr = "dagger.io/dag.output"

	// Indicates that this span is "internal" and can be hidden by default.
	//
	// Internal spans may typically be revealed with a toggle.
	UIInternalAttr = "dagger.io/ui.internal"

	// Hide child spans by default.
	UIEncapsulateAttr = "dagger.io/ui.encapsulate"

	// Substitute the span for its children and move its logs to its parent.
	UIPassthroughAttr = "dagger.io/ui.passthrough" //nolint: gosec // lol

	// Causes the parent span to act as if Passthrough was set.
	UIMaskAttr = "dagger.io/ui.mask"

	// Indicates that this span was a cache hit and did nothing.
	CachedAttr = "dagger.io/dag.cached"

	// Indicates that this span was interrupted.
	CanceledAttr = "dagger.io/dag.canceled"

	// The base64-encoded, protobuf-marshalled Buildkit LLB op payload that this
	// span represents.
	LLBOpAttr = "dagger.io/llb.op"

	// The digests of the LLB operations that this span depends on, allowing the
	// UI to attribute their future "cost."
	LLBDigestsAttr = "dagger.io/llb.digests"

	// The amount of progress that needs to be reached.
	ProgressTotalAttr = "dagger.io/progress.total"

	// Current value for the progress.
	ProgressCurrentAttr = "dagger.io/progress.current"

	// Indicates the units for the progress numbers.
	ProgressUnitsAttr = "dagger.io/progress.units"
)

The following attributes are used by the UI to interpret spans and control their behavior in the UI.

View Source
const (
	LogStreamAttr = "log.stream"
	LogDataAttr   = "log.data"
)
View Source
const (
	// We use this to identify which logs should be bubbled up to the user
	// "globally" regardless of which span they came from.
	GlobalLogs = "dagger.io/global"
)
View Source
const (
	LogsSource_Subscribe_FullMethodName = "/telemetry.LogsSource/Subscribe"
)
View Source
const (
	MetricsSource_Subscribe_FullMethodName = "/telemetry.MetricsSource/Subscribe"
)
View Source
const NearlyImmediate = 100 * time.Millisecond

NearlyImmediate is 100ms, below which has diminishing returns in terms of visual perception vs. performance cost.

View Source
const (
	TracesSource_Subscribe_FullMethodName = "/telemetry.TracesSource/Subscribe"
)

Variables

View Source
var File_servers_proto protoreflect.FileDescriptor
View Source
var ForceLiveTrace = os.Getenv("FORCE_LIVE_TRACE") != ""
View Source
var LogProcessors = []sdklog.LogProcessor{}
View Source
var LogsSource_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "telemetry.LogsSource",
	HandlerType: (*LogsSourceServer)(nil),
	Methods:     []grpc.MethodDesc{},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "Subscribe",
			Handler:       _LogsSource_Subscribe_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "servers.proto",
}

LogsSource_ServiceDesc is the grpc.ServiceDesc for LogsSource service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

View Source
var MetricsSource_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "telemetry.MetricsSource",
	HandlerType: (*MetricsSourceServer)(nil),
	Methods:     []grpc.MethodDesc{},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "Subscribe",
			Handler:       _MetricsSource_Subscribe_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "servers.proto",
}

MetricsSource_ServiceDesc is the grpc.ServiceDesc for MetricsSource service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

View Source
var SpanProcessors = []sdktrace.SpanProcessor{}
View Source
var TracesSource_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "telemetry.TracesSource",
	HandlerType: (*TracesSourceServer)(nil),
	Methods:     []grpc.MethodDesc{},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "Subscribe",
			Handler:       _TracesSource_Subscribe_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "servers.proto",
}

TracesSource_ServiceDesc is the grpc.ServiceDesc for TracesSource service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func AroundFunc added in v0.11.0

func AroundFunc(ctx context.Context, self dagql.Object, id *call.ID) (context.Context, func(res dagql.Typed, cached bool, rerr error))

func AttributesFromProto added in v0.11.0

func AttributesFromProto(attrs []*otlpcommonv1.KeyValue) []attribute.KeyValue

AttributesFromProto transforms a slice of OTLP attribute key-values into a slice of KeyValues

func Close added in v0.11.0

func Close()

Close shuts down the global OpenTelemetry providers, flushing any remaining data to the configured exporters.

func ConfiguredCloudExporters added in v0.11.0

func ConfiguredCloudExporters(ctx context.Context) (sdktrace.SpanExporter, sdklog.LogExporter, bool)

func ConfiguredLogExporter added in v0.11.0

func ConfiguredLogExporter(ctx context.Context) (sdklog.LogExporter, bool)

func ConfiguredSpanExporter added in v0.11.0

func ConfiguredSpanExporter(ctx context.Context) (sdktrace.SpanExporter, bool)

func ContextLogger added in v0.11.0

func ContextLogger(ctx context.Context, level slog.Level) *slog.Logger

func Encapsulate added in v0.11.0

func Encapsulate() trace.SpanStartOption

Encapsulate can be applied to a span to indicate that this span should collapse its children by default.

func End added in v0.11.0

func End(span trace.Span, fn func() error)

End is a helper to end a span with an error if the function returns an error.

It is optimized for use as a defer one-liner with a function that has a named error return value, conventionally `rerr`.

defer telemetry.End(span, func() error { return rerr })

func FallbackResource added in v0.11.0

func FallbackResource() *resource.Resource

FallbackResource is the fallback resource definition. A more specific resource should be set in Init.

func Flush added in v0.11.0

func Flush(ctx context.Context)

Flush drains telemetry data, and is typically called just before a client goes away.

NB: now that we wait for all spans to complete, this is less necessary, but it seems wise to keep it anyway, as the spots where it are needed are hard to find.

func GlobalLogger added in v0.11.0

func GlobalLogger(ctx context.Context) *slog.Logger

func Init added in v0.11.0

func Init(ctx context.Context, cfg Config) context.Context

Init sets up the global OpenTelemetry providers tracing, logging, and someday metrics providers. It is called by the CLI, the engine, and the container shim, so it needs to be versatile.

func Internal added in v0.11.0

func Internal() trace.SpanStartOption

Internal can be applied to a span to indicate that this span should not be shown to the user by default.

func Logger added in v0.11.0

func Logger(name string) log.Logger

Logger returns a logger with the given name.

func MeasuringStreamClientInterceptor added in v0.11.0

func MeasuringStreamClientInterceptor() grpc.StreamClientInterceptor

func MeasuringUnaryClientInterceptor added in v0.11.0

func MeasuringUnaryClientInterceptor() grpc.UnaryClientInterceptor

func MeasuringUnaryServerInterceptor added in v0.11.0

func MeasuringUnaryServerInterceptor() grpc.UnaryServerInterceptor

func OtelConfigured added in v0.11.0

func OtelConfigured() bool

func PrettyLogger added in v0.11.0

func PrettyLogger(dest io.Writer, level slog.Level) *slog.Logger

func PropagationEnv added in v0.11.0

func PropagationEnv(ctx context.Context) []string

func RegisterLogsSourceServer added in v0.11.0

func RegisterLogsSourceServer(s grpc.ServiceRegistrar, srv LogsSourceServer)

func RegisterMetricsSourceServer added in v0.11.0

func RegisterMetricsSourceServer(s grpc.ServiceRegistrar, srv MetricsSourceServer)

func RegisterTracesSourceServer added in v0.11.0

func RegisterTracesSourceServer(s grpc.ServiceRegistrar, srv TracesSourceServer)

func SpansFromProto added in v0.11.0

func SpansFromProto(sdl []*otlptracev1.ResourceSpans) []sdktrace.ReadOnlySpan

SpansFromProto transforms a slice of OTLP ResourceSpans into a slice of ReadOnlySpans.

func TransformPBLogs added in v0.11.0

func TransformPBLogs(resLogs []*otlplogsv1.ResourceLogs) []*sdklog.LogData

func WithStdioToOtel added in v0.11.0

func WithStdioToOtel(ctx context.Context, name string) (context.Context, io.Writer, io.Writer)

Types

type Config added in v0.11.0

type Config struct {
	// Auto-detect exporters from OTEL_* env variables.
	Detect bool

	// LiveTraceExporters are exporters that can receive updates for spans at runtime,
	// rather than waiting until the span ends.
	//
	// Example: TUI, Cloud
	LiveTraceExporters []sdktrace.SpanExporter

	// BatchedTraceExporters are exporters that receive spans in batches, after the
	// spans have ended.
	//
	// Example: Honeycomb, Jaeger, etc.
	BatchedTraceExporters []sdktrace.SpanExporter

	// LiveLogExporters are exporters that receive logs in batches of ~100ms.
	LiveLogExporters []sdklog.LogExporter

	// Resource is the resource describing this component and runtime
	// environment.
	Resource *resource.Resource
}

type FilterLiveSpansExporter added in v0.11.0

type FilterLiveSpansExporter struct {
	sdktrace.SpanExporter
}

FilterLiveSpansExporter is a SpanExporter that filters out spans that are currently running, as indicated by an end time older than its start time (typically year 1753).

func (FilterLiveSpansExporter) ExportSpans added in v0.11.0

func (exp FilterLiveSpansExporter) ExportSpans(ctx context.Context, spans []sdktrace.ReadOnlySpan) error

ExportSpans passes each span to the span processor's OnEnd hook so that it can be batched and emitted more efficiently.

type LabelFlag added in v0.11.0

type LabelFlag struct {
	Labels
}

func NewLabelFlag added in v0.11.0

func NewLabelFlag() LabelFlag

func (LabelFlag) Set added in v0.11.0

func (flag LabelFlag) Set(s string) error

func (LabelFlag) String added in v0.11.0

func (flag LabelFlag) String() string

func (LabelFlag) Type added in v0.11.0

func (flag LabelFlag) Type() string

type Labels added in v0.11.0

type Labels map[string]string

func LoadDefaultLabels added in v0.11.0

func LoadDefaultLabels(workdir, clientEngineVersion string) Labels

func (Labels) UserAgent added in v0.11.0

func (labels Labels) UserAgent() string

func (Labels) WithAnonymousGitLabels added in v0.11.0

func (labels Labels) WithAnonymousGitLabels(workdir string) Labels

func (Labels) WithCILabels added in v0.11.0

func (labels Labels) WithCILabels() Labels

func (Labels) WithCircleCILabels added in v0.11.0

func (labels Labels) WithCircleCILabels() Labels

func (Labels) WithClientLabels added in v0.11.0

func (labels Labels) WithClientLabels(engineVersion string) Labels

func (Labels) WithEngineLabel added in v0.11.0

func (labels Labels) WithEngineLabel(engineName string) Labels

func (Labels) WithGitHubLabels added in v0.11.0

func (labels Labels) WithGitHubLabels() Labels

func (Labels) WithGitLabLabels added in v0.11.0

func (labels Labels) WithGitLabLabels() Labels

func (Labels) WithGitLabels added in v0.11.0

func (labels Labels) WithGitLabels(workdir string) Labels

func (Labels) WithServerLabels added in v0.11.0

func (labels Labels) WithServerLabels(engineVersion, os, arch string, cacheEnabled bool) Labels

func (Labels) WithVCSLabels added in v0.11.0

func (labels Labels) WithVCSLabels(workdir string) Labels

type LiveSpanProcessor added in v0.11.0

type LiveSpanProcessor interface {
	sdktrace.SpanProcessor

	// OnUpdate method enqueues a trace.ReadOnlySpan for later processing.
	OnUpdate(s sdktrace.ReadOnlySpan)
}

LiveSpanProcessor is a SpanProcessor that can additionally receive updates for a span at runtime, rather than waiting until the span ends.

type LogForwarder added in v0.11.0

type LogForwarder struct {
	Processors []sdklog.LogProcessor
}

func (LogForwarder) ExportLogs added in v0.11.0

func (m LogForwarder) ExportLogs(ctx context.Context, logs []*sdklog.LogData) error

func (LogForwarder) Shutdown added in v0.11.0

func (m LogForwarder) Shutdown(ctx context.Context) error

type LogsServer added in v0.11.0

func (*LogsServer) Export added in v0.11.0

func (*LogsServer) Subscribe added in v0.11.0

func (e *LogsServer) Subscribe(req *TelemetryRequest, stream LogsSource_SubscribeServer) error

type LogsSourceClient added in v0.11.0

type LogsSourceClient interface {
	Subscribe(ctx context.Context, in *TelemetryRequest, opts ...grpc.CallOption) (LogsSource_SubscribeClient, error)
}

LogsSourceClient is the client API for LogsSource service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewLogsSourceClient added in v0.11.0

func NewLogsSourceClient(cc grpc.ClientConnInterface) LogsSourceClient

type LogsSourceServer added in v0.11.0

type LogsSourceServer interface {
	Subscribe(*TelemetryRequest, LogsSource_SubscribeServer) error
	// contains filtered or unexported methods
}

LogsSourceServer is the server API for LogsSource service. All implementations must embed UnimplementedLogsSourceServer for forward compatibility

type LogsSource_SubscribeClient added in v0.11.0

type LogsSource_SubscribeClient interface {
	Recv() (*v11.LogsData, error)
	grpc.ClientStream
}

type LogsSource_SubscribeServer added in v0.11.0

type LogsSource_SubscribeServer interface {
	Send(*v11.LogsData) error
	grpc.ServerStream
}

type MetricsServer added in v0.11.0

func (*MetricsServer) Export added in v0.11.0

func (*MetricsServer) Subscribe added in v0.11.0

type MetricsSourceClient added in v0.11.0

type MetricsSourceClient interface {
	Subscribe(ctx context.Context, in *TelemetryRequest, opts ...grpc.CallOption) (MetricsSource_SubscribeClient, error)
}

MetricsSourceClient is the client API for MetricsSource service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewMetricsSourceClient added in v0.11.0

func NewMetricsSourceClient(cc grpc.ClientConnInterface) MetricsSourceClient

type MetricsSourceServer added in v0.11.0

type MetricsSourceServer interface {
	Subscribe(*TelemetryRequest, MetricsSource_SubscribeServer) error
	// contains filtered or unexported methods
}

MetricsSourceServer is the server API for MetricsSource service. All implementations must embed UnimplementedMetricsSourceServer for forward compatibility

type MetricsSource_SubscribeClient added in v0.11.0

type MetricsSource_SubscribeClient interface {
	Recv() (*v12.MetricsData, error)
	grpc.ClientStream
}

type MetricsSource_SubscribeServer added in v0.11.0

type MetricsSource_SubscribeServer interface {
	Send(*v12.MetricsData) error
	grpc.ServerStream
}

type MultiSpanExporter added in v0.11.0

type MultiSpanExporter []sdktrace.SpanExporter

func (MultiSpanExporter) ExportSpans added in v0.11.0

func (m MultiSpanExporter) ExportSpans(ctx context.Context, spans []sdktrace.ReadOnlySpan) error

func (MultiSpanExporter) Shutdown added in v0.11.0

func (m MultiSpanExporter) Shutdown(ctx context.Context) error

type OtelWriter added in v0.11.0

type OtelWriter struct {
	Ctx    context.Context
	Logger log.Logger
	Stream int
}

func (*OtelWriter) Write added in v0.11.0

func (w *OtelWriter) Write(p []byte) (int, error)

type PubSub added in v0.11.0

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

func NewPubSub added in v0.11.0

func NewPubSub() *PubSub

func (*PubSub) Aggregation added in v0.11.0

func (ps *PubSub) Aggregation(kind sdkmetric.InstrumentKind) sdkmetric.Aggregation

func (*PubSub) Drain added in v0.11.0

func (ps *PubSub) Drain(id trace.TraceID, immediate bool)

func (*PubSub) Export added in v0.11.0

func (ps *PubSub) Export(ctx context.Context, metrics *metricdata.ResourceMetrics) error

func (*PubSub) ExportLogs added in v0.11.0

func (ps *PubSub) ExportLogs(ctx context.Context, logs []*sdklog.LogData) error

func (*PubSub) ExportSpans added in v0.11.0

func (ps *PubSub) ExportSpans(ctx context.Context, spans []sdktrace.ReadOnlySpan) error

func (*PubSub) ForceFlush added in v0.11.0

func (ps *PubSub) ForceFlush(ctx context.Context) error

NB: this is part of the Metrics exporter interface only for some reason, but it would be the same signature across the others too anyway.

func (*PubSub) LogSubscribers added in v0.11.0

func (ps *PubSub) LogSubscribers(session trace.TraceID) []sdklog.LogExporter

func (*PubSub) MetricSubscribers added in v0.11.0

func (ps *PubSub) MetricSubscribers(session trace.TraceID) []sdkmetric.Exporter

func (*PubSub) Shutdown added in v0.11.0

func (ps *PubSub) Shutdown(ctx context.Context) error

func (*PubSub) SpanSubscribers added in v0.11.0

func (ps *PubSub) SpanSubscribers(session trace.TraceID) []sdktrace.SpanExporter

func (*PubSub) SubscribeToLogs added in v0.11.0

func (ps *PubSub) SubscribeToLogs(ctx context.Context, traceID trace.TraceID, exp sdklog.LogExporter) error

func (*PubSub) SubscribeToSpans added in v0.11.0

func (ps *PubSub) SubscribeToSpans(ctx context.Context, traceID trace.TraceID, exp sdktrace.SpanExporter) error

func (*PubSub) Temporality added in v0.11.0

func (ps *PubSub) Temporality(kind sdkmetric.InstrumentKind) metricdata.Temporality

type SpanForwarder added in v0.11.0

type SpanForwarder struct {
	Processors []sdktrace.SpanProcessor
}

func (SpanForwarder) ExportSpans added in v0.11.0

func (m SpanForwarder) ExportSpans(ctx context.Context, spans []sdktrace.ReadOnlySpan) error

func (SpanForwarder) Shutdown added in v0.11.0

func (m SpanForwarder) Shutdown(ctx context.Context) error

type TelemetryRequest added in v0.11.0

type TelemetryRequest struct {
	TraceId []byte `protobuf:"bytes,1,opt,name=trace_id,json=traceId,proto3" json:"trace_id,omitempty"`
	// contains filtered or unexported fields
}

func (*TelemetryRequest) Descriptor deprecated added in v0.11.0

func (*TelemetryRequest) Descriptor() ([]byte, []int)

Deprecated: Use TelemetryRequest.ProtoReflect.Descriptor instead.

func (*TelemetryRequest) GetTraceId added in v0.11.0

func (x *TelemetryRequest) GetTraceId() []byte

func (*TelemetryRequest) ProtoMessage added in v0.11.0

func (*TelemetryRequest) ProtoMessage()

func (*TelemetryRequest) ProtoReflect added in v0.11.0

func (x *TelemetryRequest) ProtoReflect() protoreflect.Message

func (*TelemetryRequest) Reset added in v0.11.0

func (x *TelemetryRequest) Reset()

func (*TelemetryRequest) String added in v0.11.0

func (x *TelemetryRequest) String() string

type TraceServer added in v0.11.0

func (*TraceServer) Export added in v0.11.0

func (*TraceServer) Subscribe added in v0.11.0

type TracesSourceClient added in v0.11.0

type TracesSourceClient interface {
	Subscribe(ctx context.Context, in *TelemetryRequest, opts ...grpc.CallOption) (TracesSource_SubscribeClient, error)
}

TracesSourceClient is the client API for TracesSource service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewTracesSourceClient added in v0.11.0

func NewTracesSourceClient(cc grpc.ClientConnInterface) TracesSourceClient

type TracesSourceServer added in v0.11.0

type TracesSourceServer interface {
	Subscribe(*TelemetryRequest, TracesSource_SubscribeServer) error
	// contains filtered or unexported methods
}

TracesSourceServer is the server API for TracesSource service. All implementations must embed UnimplementedTracesSourceServer for forward compatibility

type TracesSource_SubscribeClient added in v0.11.0

type TracesSource_SubscribeClient interface {
	Recv() (*v1.TracesData, error)
	grpc.ClientStream
}

type TracesSource_SubscribeServer added in v0.11.0

type TracesSource_SubscribeServer interface {
	Send(*v1.TracesData) error
	grpc.ServerStream
}

type UnimplementedLogsSourceServer added in v0.11.0

type UnimplementedLogsSourceServer struct {
}

UnimplementedLogsSourceServer must be embedded to have forward compatible implementations.

func (UnimplementedLogsSourceServer) Subscribe added in v0.11.0

type UnimplementedMetricsSourceServer added in v0.11.0

type UnimplementedMetricsSourceServer struct {
}

UnimplementedMetricsSourceServer must be embedded to have forward compatible implementations.

func (UnimplementedMetricsSourceServer) Subscribe added in v0.11.0

type UnimplementedTracesSourceServer added in v0.11.0

type UnimplementedTracesSourceServer struct {
}

UnimplementedTracesSourceServer must be embedded to have forward compatible implementations.

func (UnimplementedTracesSourceServer) Subscribe added in v0.11.0

type UnsafeLogsSourceServer added in v0.11.0

type UnsafeLogsSourceServer interface {
	// contains filtered or unexported methods
}

UnsafeLogsSourceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to LogsSourceServer will result in compilation errors.

type UnsafeMetricsSourceServer added in v0.11.0

type UnsafeMetricsSourceServer interface {
	// contains filtered or unexported methods
}

UnsafeMetricsSourceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to MetricsSourceServer will result in compilation errors.

type UnsafeTracesSourceServer added in v0.11.0

type UnsafeTracesSourceServer interface {
	// contains filtered or unexported methods
}

UnsafeTracesSourceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to TracesSourceServer will result in compilation errors.

Directories

Path Synopsis
otlploggrpc/internal/retry
Package retry provides request retry functionality that can perform configurable exponential backoff for transient errors and honor any explicit throttle responses received.
Package retry provides request retry functionality that can perform configurable exponential backoff for transient errors and honor any explicit throttle responses received.

Jump to

Keyboard shortcuts

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