telemetry

package
v0.0.0-...-56f61b2 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2025 License: Apache-2.0 Imports: 31 Imported by: 8

Documentation

Index

Constants

View Source
const (
	ApiOrchestratorCountMeterName GaugeIntType = "api.orchestrator.status"

	// Sandbox metrics
	SandboxRamUsedGaugeName   GaugeIntType = "e2b.sandbox.ram.used"
	SandboxRamTotalGaugeName  GaugeIntType = "e2b.sandbox.ram.total"
	SandboxCpuTotalGaugeName  GaugeIntType = "e2b.sandbox.cpu.total"
	SandboxDiskUsedGaugeName  GaugeIntType = "e2b.sandbox.disk.used"
	SandboxDiskTotalGaugeName GaugeIntType = "e2b.sandbox.disk.total"

	// Team metrics
	TeamSandboxRunningGaugeName GaugeIntType = "e2b.team.sandbox.running"

	// Build resource metrics
	BuildRootfsSizeHistogramName HistogramType = "template.build.rootfs.size"
)
View Source
const DebugID = "debug_id"

Variables

View Source
var OTELTracingPrint = os.Getenv("OTEL_TRACING_PRINT") != "false"
View Source
var OtelCollectorGRPCEndpoint = os.Getenv("OTEL_COLLECTOR_GRPC_ENDPOINT")

Functions

func GetCounter

func GetCounter(meter metric.Meter, name CounterType) (metric.Int64Counter, error)

func GetGaugeFloat

func GetGaugeFloat(meter metric.Meter, name GaugeFloatType) (metric.Float64ObservableGauge, error)

func GetGaugeInt

func GetGaugeInt(meter metric.Meter, name GaugeIntType) (metric.Int64ObservableGauge, error)

func GetHistogram

func GetHistogram(meter metric.Meter, name HistogramType) (metric.Int64Histogram, error)

func GetResource

func GetResource(ctx context.Context, nodeID, serviceName, serviceCommit, serviceVersion, serviceInstanceID string) (*resource.Resource, error)

func GetUpDownCounter

func GetUpDownCounter(meter metric.Meter, name UpDownCounterType) (metric.Int64UpDownCounter, error)

func NewEventWriter

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

func NewLogExporter

func NewLogExporter(ctx context.Context, extraOption ...otlploggrpc.Option) (sdklog.Exporter, error)

func NewLogProvider

func NewLogProvider(ctx context.Context, logsExporter sdklog.Exporter, res *resource.Resource) log.LoggerProvider

func NewMeterExporter

func NewMeterExporter(ctx context.Context, extraOption ...otlpmetricgrpc.Option) (sdkmetric.Exporter, error)

func NewMeterProvider

func NewMeterProvider(ctx context.Context, metricsExporter sdkmetric.Exporter, metricExportPeriod time.Duration, res *resource.Resource, extraOption ...sdkmetric.Option) (metric.MeterProvider, error)

func NewSpanExporter

func NewSpanExporter(ctx context.Context, extraOption ...otlptracegrpc.Option) (sdktrace.SpanExporter, error)

func NewTextPropagator

func NewTextPropagator() propagation.TextMapPropagator

func NewTracerProvider

func NewTracerProvider(ctx context.Context, spanExporter sdktrace.SpanExporter, res *resource.Resource) trace.TracerProvider

func ReportCriticalError

func ReportCriticalError(ctx context.Context, message string, err error, attrs ...attribute.KeyValue)

func ReportError

func ReportError(ctx context.Context, message string, err error, attrs ...attribute.KeyValue)

func ReportEvent

func ReportEvent(ctx context.Context, name string, attrs ...attribute.KeyValue)

func SetAttributes

func SetAttributes(ctx context.Context, attrs ...attribute.KeyValue)

func WithBuildID

func WithBuildID(buildID string) attribute.KeyValue

func WithClusterID

func WithClusterID(clusterID uuid.UUID) attribute.KeyValue

func WithNodeID

func WithNodeID(nodeID string) attribute.KeyValue

func WithSandboxID

func WithSandboxID(sandboxID string) attribute.KeyValue

func WithTeamID

func WithTeamID(teamID string) attribute.KeyValue

func WithTemplateID

func WithTemplateID(templateID string) attribute.KeyValue

Types

type Client

type Client struct {
	MetricExporter  sdkmetric.Exporter
	MeterProvider   metric.MeterProvider
	SpanExporter    sdktrace.SpanExporter
	TracerProvider  trace.TracerProvider
	TracePropagator propagation.TextMapPropagator
	LogsExporter    sdklog.Exporter
	LogsProvider    log.LoggerProvider
}

func New

func New(ctx context.Context, nodeID, serviceName, serviceCommit, serviceVersion, serviceInstanceID string) (*Client, error)

func NewNoopClient

func NewNoopClient() *Client

func (*Client) Shutdown

func (t *Client) Shutdown(ctx context.Context) error

type CounterType

type CounterType string
const (
	ApiOrchestratorCreatedSandboxes CounterType = "api.orchestrator.created_sandboxes"
	SandboxCreateMeterName          CounterType = "api.env.instance.started"

	TeamSandboxCreated CounterType = "e2b.team.sandbox.created"
)
const (
	// Build result counters
	BuildResultCounterName      CounterType = "template.build.result"
	BuildCacheResultCounterName CounterType = "template.build.cache.result"
)

type EventWriter

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

func (*EventWriter) Write

func (w *EventWriter) Write(p []byte) (n int, err error)

type GaugeFloatType

type GaugeFloatType string
const (
	SandboxCpuUsedGaugeName GaugeFloatType = "e2b.sandbox.cpu.used"
)

type GaugeIntType

type GaugeIntType string

type HistogramType

type HistogramType string
const (
	// Build timing histograms
	BuildDurationHistogramName      HistogramType = "template.build.duration"
	BuildPhaseDurationHistogramName HistogramType = "template.build.phase.duration"
	BuildStepDurationHistogramName  HistogramType = "template.build.step.duration"
)

type ObservableCounterType

type ObservableCounterType string
const (
	ApiOrchestratorSbxCreateSuccess ObservableCounterType = "api.orchestrator.sandbox.create.success"
	ApiOrchestratorSbxCreateFailure ObservableCounterType = "api.orchestrator.sandbox.create.failure"
)

type ObservableUpDownCounterType

type ObservableUpDownCounterType string
const (
	OrchestratorSandboxCountMeterName ObservableUpDownCounterType = "orchestrator.env.sandbox.running"

	ClientProxyServerConnectionsMeterCounterName ObservableUpDownCounterType = "client_proxy.proxy.server.connections.open"
	ClientProxyPoolConnectionsMeterCounterName   ObservableUpDownCounterType = "client_proxy.proxy.pool.connections.open"
	ClientProxyPoolSizeMeterCounterName          ObservableUpDownCounterType = "client_proxy.proxy.pool.size"

	OrchestratorProxyServerConnectionsMeterCounterName ObservableUpDownCounterType = "orchestrator.proxy.server.connections.open"
	OrchestratorProxyPoolConnectionsMeterCounterName   ObservableUpDownCounterType = "orchestrator.proxy.pool.connections.open"
	OrchestratorProxyPoolSizeMeterCounterName          ObservableUpDownCounterType = "orchestrator.proxy.pool.size"

	BuildCounterMeterName ObservableUpDownCounterType = "api.env.build.running"
)

type Stopwatch

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

func (Stopwatch) End

func (t Stopwatch) End(ctx context.Context, total int64, kv ...attribute.KeyValue)

type TimerFactory

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

func NewTimerFactory

func NewTimerFactory(
	blocksMeter metric.Meter,
	metricName, durationDescription, bytesDescription, counterDescription string,
) (TimerFactory, error)

func (*TimerFactory) Begin

func (f *TimerFactory) Begin() *Stopwatch

type UpDownCounterType

type UpDownCounterType string
const (
	SandboxCountMeterName                  UpDownCounterType = "api.env.instance.running"
	NewNetworkSlotSPoolCounterMeterName    UpDownCounterType = "orchestrator.network.slots_pool.new"
	ReusedNetworkSlotSPoolCounterMeterName UpDownCounterType = "orchestrator.network.slots_pool.reused"
	NBDkSlotSReadyPoolCounterMeterName     UpDownCounterType = "orchestrator.nbd.slots_pool.read"
)

type ZapFieldToOTELAttributeEncoder

type ZapFieldToOTELAttributeEncoder struct {
	attribute.KeyValue
}

func (*ZapFieldToOTELAttributeEncoder) AddArray

func (*ZapFieldToOTELAttributeEncoder) AddBinary

func (z *ZapFieldToOTELAttributeEncoder) AddBinary(key string, value []byte)

func (*ZapFieldToOTELAttributeEncoder) AddBool

func (z *ZapFieldToOTELAttributeEncoder) AddBool(key string, value bool)

func (*ZapFieldToOTELAttributeEncoder) AddByteString

func (z *ZapFieldToOTELAttributeEncoder) AddByteString(key string, value []byte)

func (*ZapFieldToOTELAttributeEncoder) AddComplex128

func (z *ZapFieldToOTELAttributeEncoder) AddComplex128(key string, value complex128)

func (*ZapFieldToOTELAttributeEncoder) AddComplex64

func (z *ZapFieldToOTELAttributeEncoder) AddComplex64(key string, value complex64)

func (*ZapFieldToOTELAttributeEncoder) AddDuration

func (z *ZapFieldToOTELAttributeEncoder) AddDuration(key string, value time.Duration)

func (*ZapFieldToOTELAttributeEncoder) AddFloat32

func (z *ZapFieldToOTELAttributeEncoder) AddFloat32(key string, value float32)

func (*ZapFieldToOTELAttributeEncoder) AddFloat64

func (z *ZapFieldToOTELAttributeEncoder) AddFloat64(key string, value float64)

func (*ZapFieldToOTELAttributeEncoder) AddInt

func (z *ZapFieldToOTELAttributeEncoder) AddInt(key string, value int)

func (*ZapFieldToOTELAttributeEncoder) AddInt16

func (z *ZapFieldToOTELAttributeEncoder) AddInt16(key string, value int16)

func (*ZapFieldToOTELAttributeEncoder) AddInt32

func (z *ZapFieldToOTELAttributeEncoder) AddInt32(key string, value int32)

func (*ZapFieldToOTELAttributeEncoder) AddInt64

func (z *ZapFieldToOTELAttributeEncoder) AddInt64(key string, value int64)

func (*ZapFieldToOTELAttributeEncoder) AddInt8

func (z *ZapFieldToOTELAttributeEncoder) AddInt8(key string, value int8)

func (*ZapFieldToOTELAttributeEncoder) AddObject

func (z *ZapFieldToOTELAttributeEncoder) AddObject(key string, marshaler zapcore.ObjectMarshaler) error

func (*ZapFieldToOTELAttributeEncoder) AddReflected

func (z *ZapFieldToOTELAttributeEncoder) AddReflected(key string, value any) error

func (*ZapFieldToOTELAttributeEncoder) AddString

func (z *ZapFieldToOTELAttributeEncoder) AddString(key, value string)

func (*ZapFieldToOTELAttributeEncoder) AddTime

func (z *ZapFieldToOTELAttributeEncoder) AddTime(key string, value time.Time)

func (*ZapFieldToOTELAttributeEncoder) AddUint

func (z *ZapFieldToOTELAttributeEncoder) AddUint(key string, value uint)

func (*ZapFieldToOTELAttributeEncoder) AddUint16

func (z *ZapFieldToOTELAttributeEncoder) AddUint16(key string, value uint16)

func (*ZapFieldToOTELAttributeEncoder) AddUint32

func (z *ZapFieldToOTELAttributeEncoder) AddUint32(key string, value uint32)

func (*ZapFieldToOTELAttributeEncoder) AddUint64

func (z *ZapFieldToOTELAttributeEncoder) AddUint64(key string, value uint64)

func (*ZapFieldToOTELAttributeEncoder) AddUint8

func (z *ZapFieldToOTELAttributeEncoder) AddUint8(key string, value uint8)

func (*ZapFieldToOTELAttributeEncoder) AddUintptr

func (z *ZapFieldToOTELAttributeEncoder) AddUintptr(key string, value uintptr)

func (*ZapFieldToOTELAttributeEncoder) OpenNamespace

func (z *ZapFieldToOTELAttributeEncoder) OpenNamespace(key string)

Jump to

Keyboard shortcuts

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