Documentation ¶
Overview ¶
Package testutils contains helpers for OpenTelemetry tests.
Index ¶
- Variables
- func CompareMetrics(ctx context.Context, t *testing.T, mr *metric.ManualReader, ...)
- func MetricData(options MetricDataOptions) []metricdata.Metrics
- func MetricDataStreaming(options MetricDataOptions) []metricdata.Metrics
- func MetricDataUnary(options MetricDataOptions) []metricdata.Metrics
- type MetricDataOptions
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultLatencyBounds are the default bounds for latency metrics. DefaultLatencyBounds = []float64{0, 0.00001, 0.00005, 0.0001, 0.0003, 0.0006, 0.0008, 0.001, 0.002, 0.003, 0.004, 0.005, 0.006, 0.008, 0.01, 0.013, 0.016, 0.02, 0.025, 0.03, 0.04, 0.05, 0.065, 0.08, 0.1, 0.13, 0.16, 0.2, 0.25, 0.3, 0.4, 0.5, 0.65, 0.8, 1, 2, 5, 10, 20, 50, 100} // DefaultSizeBounds are the default bounds for metrics which record size. DefaultSizeBounds = []float64{0, 1024, 2048, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216, 67108864, 268435456, 1073741824, 4294967296} )
Redefine default bounds here to avoid a cyclic dependency with top level opentelemetry package. Could define once through internal, but would make external opentelemetry godoc less readable.
Functions ¶
func CompareMetrics ¶
func CompareMetrics(ctx context.Context, t *testing.T, mr *metric.ManualReader, gotMetrics map[string]metricdata.Metrics, wantMetrics []metricdata.Metrics)
CompareMetrics asserts wantMetrics are what we expect. It polls for eventual server metrics (not emitted synchronously with client side rpc returning), and for duration metrics makes sure the data point is within possible testing time (five seconds from context timeout).
func MetricData ¶
func MetricData(options MetricDataOptions) []metricdata.Metrics
MetricData returns a metricsDataSlice for A66 metrics for client and server with a unary RPC and streaming RPC with certain compression and message flow sent. If csmAttributes is set to true, the corresponding CSM Metrics (not client side call metrics, or started on client and server side).
func MetricDataStreaming ¶
func MetricDataStreaming(options MetricDataOptions) []metricdata.Metrics
MetricDataStreaming returns a list of expected metrics defined in A66 for a client and server for one streaming RPC.
func MetricDataUnary ¶
func MetricDataUnary(options MetricDataOptions) []metricdata.Metrics
MetricDataUnary returns a list of expected metrics defined in A66 for a client and server for one unary RPC.
Types ¶
type MetricDataOptions ¶
type MetricDataOptions struct { // CSMLabels are the csm labels to attach to metrics which receive csm // labels (all A66 expect client call and started RPC's client and server // side). CSMLabels []attribute.KeyValue // Target is the target of the client and server. Target string // UnaryCallFailed is whether the Unary Call failed, which would trigger // trailers only. UnaryCallFailed bool // UnaryCompressedMessageSize is the compressed message size of the Unary // RPC. This assumes both client and server sent the same message size. UnaryCompressedMessageSize float64 // StreamingCompressedMessageSize is the compressed message size of the // Streaming RPC. This assumes both client and server sent the same message // size. StreamingCompressedMessageSize float64 }
MetricDataOptions are the options used to configure the metricData emissions of expected metrics data from NewMetricData.