mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-02-03 13:11:53 +02:00
Use gofumpt instead of gofmt (#4623)
* Use gofumpt instead of gofmt in golangci-lint conf * Run gofumpt fixes * Format generated templates --------- Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
This commit is contained in:
parent
9900450477
commit
5dff273a1e
@ -12,7 +12,7 @@ linters:
|
|||||||
- depguard
|
- depguard
|
||||||
- errcheck
|
- errcheck
|
||||||
- godot
|
- godot
|
||||||
- gofmt
|
- gofumpt
|
||||||
- goimports
|
- goimports
|
||||||
- gosimple
|
- gosimple
|
||||||
- govet
|
- govet
|
||||||
|
@ -41,7 +41,7 @@ func TestDefined(t *testing.T) {
|
|||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
t.Run(testcase.name, func(t *testing.T) {
|
t.Run(testcase.name, func(t *testing.T) {
|
||||||
//func (k attribute.Key) Defined() bool {
|
// func (k attribute.Key) Defined() bool {
|
||||||
have := testcase.k.Defined()
|
have := testcase.k.Defined()
|
||||||
if have != testcase.want {
|
if have != testcase.want {
|
||||||
t.Errorf("Want: %v, but have: %v", testcase.want, have)
|
t.Errorf("Want: %v, but have: %v", testcase.want, have)
|
||||||
@ -91,7 +91,7 @@ func TestEmit(t *testing.T) {
|
|||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
t.Run(testcase.name, func(t *testing.T) {
|
t.Run(testcase.name, func(t *testing.T) {
|
||||||
//proto: func (v attribute.Value) Emit() string {
|
// proto: func (v attribute.Value) Emit() string {
|
||||||
have := testcase.v.Emit()
|
have := testcase.v.Emit()
|
||||||
if have != testcase.want {
|
if have != testcase.want {
|
||||||
t.Errorf("Want: %s, but have: %s", testcase.want, have)
|
t.Errorf("Want: %s, but have: %s", testcase.want, have)
|
||||||
|
@ -56,7 +56,6 @@ func TestConvertMetrics(t *testing.T) {
|
|||||||
},
|
},
|
||||||
TimeSeries: []*ocmetricdata.TimeSeries{
|
TimeSeries: []*ocmetricdata.TimeSeries{
|
||||||
{
|
{
|
||||||
|
|
||||||
LabelValues: []ocmetricdata.LabelValue{
|
LabelValues: []ocmetricdata.LabelValue{
|
||||||
{
|
{
|
||||||
Value: "hello",
|
Value: "hello",
|
||||||
@ -370,7 +369,8 @@ func TestConvertMetrics(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
desc: "histogram without data points",
|
desc: "histogram without data points",
|
||||||
input: []*ocmetricdata.Metric{
|
input: []*ocmetricdata.Metric{
|
||||||
{
|
{
|
||||||
@ -393,7 +393,8 @@ func TestConvertMetrics(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
desc: "sum without data points",
|
desc: "sum without data points",
|
||||||
input: []*ocmetricdata.Metric{
|
input: []*ocmetricdata.Metric{
|
||||||
{
|
{
|
||||||
@ -417,7 +418,8 @@ func TestConvertMetrics(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
desc: "gauge without data points",
|
desc: "gauge without data points",
|
||||||
input: []*ocmetricdata.Metric{
|
input: []*ocmetricdata.Metric{
|
||||||
{
|
{
|
||||||
@ -439,7 +441,8 @@ func TestConvertMetrics(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
desc: "histogram with negative count",
|
desc: "histogram with negative count",
|
||||||
input: []*ocmetricdata.Metric{
|
input: []*ocmetricdata.Metric{
|
||||||
{
|
{
|
||||||
@ -462,7 +465,8 @@ func TestConvertMetrics(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedErr: errNegativeDistributionCount,
|
expectedErr: errNegativeDistributionCount,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
desc: "histogram with negative bucket count",
|
desc: "histogram with negative bucket count",
|
||||||
input: []*ocmetricdata.Metric{
|
input: []*ocmetricdata.Metric{
|
||||||
{
|
{
|
||||||
@ -489,7 +493,8 @@ func TestConvertMetrics(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedErr: errNegativeBucketCount,
|
expectedErr: errNegativeBucketCount,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
desc: "histogram with non-histogram datapoint type",
|
desc: "histogram with non-histogram datapoint type",
|
||||||
input: []*ocmetricdata.Metric{
|
input: []*ocmetricdata.Metric{
|
||||||
{
|
{
|
||||||
@ -510,7 +515,8 @@ func TestConvertMetrics(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedErr: errMismatchedValueTypes,
|
expectedErr: errMismatchedValueTypes,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
desc: "sum with non-sum datapoint type",
|
desc: "sum with non-sum datapoint type",
|
||||||
input: []*ocmetricdata.Metric{
|
input: []*ocmetricdata.Metric{
|
||||||
{
|
{
|
||||||
@ -531,7 +537,8 @@ func TestConvertMetrics(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedErr: errMismatchedValueTypes,
|
expectedErr: errMismatchedValueTypes,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
desc: "gauge with non-gauge datapoint type",
|
desc: "gauge with non-gauge datapoint type",
|
||||||
input: []*ocmetricdata.Metric{
|
input: []*ocmetricdata.Metric{
|
||||||
{
|
{
|
||||||
@ -552,7 +559,8 @@ func TestConvertMetrics(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedErr: errMismatchedValueTypes,
|
expectedErr: errMismatchedValueTypes,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
desc: "unsupported Gauge Distribution type",
|
desc: "unsupported Gauge Distribution type",
|
||||||
input: []*ocmetricdata.Metric{
|
input: []*ocmetricdata.Metric{
|
||||||
{
|
{
|
||||||
|
@ -317,8 +317,10 @@ type BridgeTracer struct {
|
|||||||
propagator propagation.TextMapPropagator
|
propagator propagation.TextMapPropagator
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ ot.Tracer = &BridgeTracer{}
|
var (
|
||||||
var _ ot.TracerContextWithSpanExtension = &BridgeTracer{}
|
_ ot.Tracer = &BridgeTracer{}
|
||||||
|
_ ot.TracerContextWithSpanExtension = &BridgeTracer{}
|
||||||
|
)
|
||||||
|
|
||||||
// NewBridgeTracer creates a new BridgeTracer. The new tracer forwards
|
// NewBridgeTracer creates a new BridgeTracer. The new tracer forwards
|
||||||
// the calls to the OpenTelemetry Noop tracer, so it should be
|
// the calls to the OpenTelemetry Noop tracer, so it should be
|
||||||
@ -829,15 +831,13 @@ func newTextMapWrapperForInject(carrier interface{}) (*textMapWrapper, error) {
|
|||||||
return t, nil
|
return t, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type textMapWriter struct {
|
type textMapWriter struct{}
|
||||||
}
|
|
||||||
|
|
||||||
func (t *textMapWriter) Set(key string, value string) {
|
func (t *textMapWriter) Set(key string, value string) {
|
||||||
// maybe print a warning log.
|
// maybe print a warning log.
|
||||||
}
|
}
|
||||||
|
|
||||||
type textMapReader struct {
|
type textMapReader struct{}
|
||||||
}
|
|
||||||
|
|
||||||
func (t *textMapReader) ForeachKey(handler func(key, val string) error) error {
|
func (t *textMapReader) ForeachKey(handler func(key, val string) error) error {
|
||||||
return nil // maybe print a warning log.
|
return nil // maybe print a warning log.
|
||||||
|
@ -35,8 +35,7 @@ import (
|
|||||||
"go.opentelemetry.io/otel/trace"
|
"go.opentelemetry.io/otel/trace"
|
||||||
)
|
)
|
||||||
|
|
||||||
type testOnlyTextMapReader struct {
|
type testOnlyTextMapReader struct{}
|
||||||
}
|
|
||||||
|
|
||||||
func newTestOnlyTextMapReader() *testOnlyTextMapReader {
|
func newTestOnlyTextMapReader() *testOnlyTextMapReader {
|
||||||
return &testOnlyTextMapReader{}
|
return &testOnlyTextMapReader{}
|
||||||
@ -144,8 +143,7 @@ var (
|
|||||||
spanID trace.SpanID = [8]byte{byte(11)}
|
spanID trace.SpanID = [8]byte{byte(11)}
|
||||||
)
|
)
|
||||||
|
|
||||||
type testTextMapPropagator struct {
|
type testTextMapPropagator struct{}
|
||||||
}
|
|
||||||
|
|
||||||
func (t testTextMapPropagator) Inject(ctx context.Context, carrier propagation.TextMapCarrier) {
|
func (t testTextMapPropagator) Inject(ctx context.Context, carrier propagation.TextMapCarrier) {
|
||||||
carrier.Set(testHeader, strings.Join([]string{traceID.String(), spanID.String()}, ":"))
|
carrier.Set(testHeader, strings.Join([]string{traceID.String(), spanID.String()}, ":"))
|
||||||
@ -163,7 +161,7 @@ func (t testTextMapPropagator) Extract(ctx context.Context, carrier propagation.
|
|||||||
return ctx
|
return ctx
|
||||||
}
|
}
|
||||||
|
|
||||||
var exist = false
|
exist := false
|
||||||
|
|
||||||
for _, key := range carrier.Keys() {
|
for _, key := range carrier.Keys() {
|
||||||
if strings.EqualFold(testHeader, key) {
|
if strings.EqualFold(testHeader, key) {
|
||||||
|
@ -54,8 +54,10 @@ type MockTracer struct {
|
|||||||
rand *rand.Rand
|
rand *rand.Rand
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ trace.Tracer = &MockTracer{}
|
var (
|
||||||
var _ migration.DeferredContextSetupTracerExtension = &MockTracer{}
|
_ trace.Tracer = &MockTracer{}
|
||||||
|
_ migration.DeferredContextSetupTracerExtension = &MockTracer{}
|
||||||
|
)
|
||||||
|
|
||||||
func NewMockTracer() *MockTracer {
|
func NewMockTracer() *MockTracer {
|
||||||
return &MockTracer{
|
return &MockTracer{
|
||||||
@ -195,8 +197,10 @@ type MockSpan struct {
|
|||||||
Events []MockEvent
|
Events []MockEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ trace.Span = &MockSpan{}
|
var (
|
||||||
var _ migration.OverrideTracerSpanExtension = &MockSpan{}
|
_ trace.Span = &MockSpan{}
|
||||||
|
_ migration.OverrideTracerSpanExtension = &MockSpan{}
|
||||||
|
)
|
||||||
|
|
||||||
func (s *MockSpan) SpanContext() trace.SpanContext {
|
func (s *MockSpan) SpanContext() trace.SpanContext {
|
||||||
return s.spanContext
|
return s.spanContext
|
||||||
|
@ -38,12 +38,15 @@ type testGRPCServer struct{}
|
|||||||
func (*testGRPCServer) UnaryCall(ctx context.Context, r *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
|
func (*testGRPCServer) UnaryCall(ctx context.Context, r *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
|
||||||
return &testpb.SimpleResponse{Payload: r.Payload * 2}, nil
|
return &testpb.SimpleResponse{Payload: r.Payload * 2}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*testGRPCServer) StreamingOutputCall(*testpb.SimpleRequest, testpb.TestService_StreamingOutputCallServer) error {
|
func (*testGRPCServer) StreamingOutputCall(*testpb.SimpleRequest, testpb.TestService_StreamingOutputCallServer) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*testGRPCServer) StreamingInputCall(testpb.TestService_StreamingInputCallServer) error {
|
func (*testGRPCServer) StreamingInputCall(testpb.TestService_StreamingInputCallServer) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*testGRPCServer) StreamingBidirectionalCall(testpb.TestService_StreamingBidirectionalCallServer) error {
|
func (*testGRPCServer) StreamingBidirectionalCall(testpb.TestService_StreamingBidirectionalCallServer) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -60,8 +60,10 @@ type WrapperTracer struct {
|
|||||||
tracer trace.Tracer
|
tracer trace.Tracer
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ trace.Tracer = &WrapperTracer{}
|
var (
|
||||||
var _ migration.DeferredContextSetupTracerExtension = &WrapperTracer{}
|
_ trace.Tracer = &WrapperTracer{}
|
||||||
|
_ migration.DeferredContextSetupTracerExtension = &WrapperTracer{}
|
||||||
|
)
|
||||||
|
|
||||||
// NewWrapperTracer wraps the passed tracer and also talks to the
|
// NewWrapperTracer wraps the passed tracer and also talks to the
|
||||||
// passed bridge tracer when setting up the context with the new
|
// passed bridge tracer when setting up the context with the new
|
||||||
|
@ -22,9 +22,7 @@ import (
|
|||||||
"go.opentelemetry.io/otel/trace"
|
"go.opentelemetry.io/otel/trace"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var lemonsKey = attribute.Key("ex.com/lemons")
|
||||||
lemonsKey = attribute.Key("ex.com/lemons")
|
|
||||||
)
|
|
||||||
|
|
||||||
// SubOperation is an example to demonstrate the use of named tracer.
|
// SubOperation is an example to demonstrate the use of named tracer.
|
||||||
// It creates a named tracer with its package path.
|
// It creates a named tracer with its package path.
|
||||||
|
@ -136,9 +136,11 @@ type clientShim struct {
|
|||||||
func (clientShim) Temporality(metric.InstrumentKind) metricdata.Temporality {
|
func (clientShim) Temporality(metric.InstrumentKind) metricdata.Temporality {
|
||||||
return metricdata.CumulativeTemporality
|
return metricdata.CumulativeTemporality
|
||||||
}
|
}
|
||||||
|
|
||||||
func (clientShim) Aggregation(metric.InstrumentKind) metric.Aggregation {
|
func (clientShim) Aggregation(metric.InstrumentKind) metric.Aggregation {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (clientShim) ForceFlush(ctx context.Context) error {
|
func (clientShim) ForceFlush(ctx context.Context) error {
|
||||||
return ctx.Err()
|
return ctx.Err()
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ func TestConfigs(t *testing.T) {
|
|||||||
},
|
},
|
||||||
asserts: func(t *testing.T, c *Config, grpcOption bool) {
|
asserts: func(t *testing.T, c *Config, grpcOption bool) {
|
||||||
if grpcOption {
|
if grpcOption {
|
||||||
//TODO: make sure gRPC's credentials actually works
|
// TODO: make sure gRPC's credentials actually works
|
||||||
assert.NotNil(t, c.Metrics.GRPCCredentials)
|
assert.NotNil(t, c.Metrics.GRPCCredentials)
|
||||||
} else {
|
} else {
|
||||||
// nolint:staticcheck // ignoring tlsCert.RootCAs.Subjects is deprecated ERR because cert does not come from SystemCertPool.
|
// nolint:staticcheck // ignoring tlsCert.RootCAs.Subjects is deprecated ERR because cert does not come from SystemCertPool.
|
||||||
|
@ -38,7 +38,7 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
// Sat Jan 01 2000 00:00:00 GMT+0000.
|
// Sat Jan 01 2000 00:00:00 GMT+0000.
|
||||||
start = time.Date(2000, time.January, 01, 0, 0, 0, 0, time.FixedZone("GMT", 0))
|
start = time.Date(2000, time.January, 0o1, 0, 0, 0, 0, time.FixedZone("GMT", 0))
|
||||||
end = start.Add(30 * time.Second)
|
end = start.Add(30 * time.Second)
|
||||||
|
|
||||||
kvAlice = &cpb.KeyValue{Key: "user", Value: &cpb.AnyValue{
|
kvAlice = &cpb.KeyValue{Key: "user", Value: &cpb.AnyValue{
|
||||||
|
@ -40,7 +40,7 @@ type unknownAggT struct {
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
// Sat Jan 01 2000 00:00:00 GMT+0000.
|
// Sat Jan 01 2000 00:00:00 GMT+0000.
|
||||||
start = time.Date(2000, time.January, 01, 0, 0, 0, 0, time.FixedZone("GMT", 0))
|
start = time.Date(2000, time.January, 0o1, 0, 0, 0, 0, time.FixedZone("GMT", 0))
|
||||||
end = start.Add(30 * time.Second)
|
end = start.Add(30 * time.Second)
|
||||||
|
|
||||||
alice = attribute.NewSet(attribute.String("user", "alice"))
|
alice = attribute.NewSet(attribute.String("user", "alice"))
|
||||||
|
@ -40,9 +40,11 @@ type clientShim struct {
|
|||||||
func (clientShim) Temporality(metric.InstrumentKind) metricdata.Temporality {
|
func (clientShim) Temporality(metric.InstrumentKind) metricdata.Temporality {
|
||||||
return metricdata.CumulativeTemporality
|
return metricdata.CumulativeTemporality
|
||||||
}
|
}
|
||||||
|
|
||||||
func (clientShim) Aggregation(metric.InstrumentKind) metric.Aggregation {
|
func (clientShim) Aggregation(metric.InstrumentKind) metric.Aggregation {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (clientShim) ForceFlush(ctx context.Context) error {
|
func (clientShim) ForceFlush(ctx context.Context) error {
|
||||||
return ctx.Err()
|
return ctx.Err()
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ func TestConfigs(t *testing.T) {
|
|||||||
},
|
},
|
||||||
asserts: func(t *testing.T, c *Config, grpcOption bool) {
|
asserts: func(t *testing.T, c *Config, grpcOption bool) {
|
||||||
if grpcOption {
|
if grpcOption {
|
||||||
//TODO: make sure gRPC's credentials actually works
|
// TODO: make sure gRPC's credentials actually works
|
||||||
assert.NotNil(t, c.Metrics.GRPCCredentials)
|
assert.NotNil(t, c.Metrics.GRPCCredentials)
|
||||||
} else {
|
} else {
|
||||||
// nolint:staticcheck // ignoring tlsCert.RootCAs.Subjects is deprecated ERR because cert does not come from SystemCertPool.
|
// nolint:staticcheck // ignoring tlsCert.RootCAs.Subjects is deprecated ERR because cert does not come from SystemCertPool.
|
||||||
|
@ -38,7 +38,7 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
// Sat Jan 01 2000 00:00:00 GMT+0000.
|
// Sat Jan 01 2000 00:00:00 GMT+0000.
|
||||||
start = time.Date(2000, time.January, 01, 0, 0, 0, 0, time.FixedZone("GMT", 0))
|
start = time.Date(2000, time.January, 0o1, 0, 0, 0, 0, time.FixedZone("GMT", 0))
|
||||||
end = start.Add(30 * time.Second)
|
end = start.Add(30 * time.Second)
|
||||||
|
|
||||||
kvAlice = &cpb.KeyValue{Key: "user", Value: &cpb.AnyValue{
|
kvAlice = &cpb.KeyValue{Key: "user", Value: &cpb.AnyValue{
|
||||||
|
@ -40,7 +40,7 @@ type unknownAggT struct {
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
// Sat Jan 01 2000 00:00:00 GMT+0000.
|
// Sat Jan 01 2000 00:00:00 GMT+0000.
|
||||||
start = time.Date(2000, time.January, 01, 0, 0, 0, 0, time.FixedZone("GMT", 0))
|
start = time.Date(2000, time.January, 0o1, 0, 0, 0, 0, time.FixedZone("GMT", 0))
|
||||||
end = start.Add(30 * time.Second)
|
end = start.Add(30 * time.Second)
|
||||||
|
|
||||||
alice = attribute.NewSet(attribute.String("user", "alice"))
|
alice = attribute.NewSet(attribute.String("user", "alice"))
|
||||||
|
@ -24,9 +24,7 @@ import (
|
|||||||
tracesdk "go.opentelemetry.io/otel/sdk/trace"
|
tracesdk "go.opentelemetry.io/otel/sdk/trace"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var errAlreadyStarted = errors.New("already started")
|
||||||
errAlreadyStarted = errors.New("already started")
|
|
||||||
)
|
|
||||||
|
|
||||||
// Exporter exports trace data in the OTLP wire format.
|
// Exporter exports trace data in the OTLP wire format.
|
||||||
type Exporter struct {
|
type Exporter struct {
|
||||||
@ -55,7 +53,7 @@ func (e *Exporter) ExportSpans(ctx context.Context, ss []tracesdk.ReadOnlySpan)
|
|||||||
|
|
||||||
// Start establishes a connection to the receiving endpoint.
|
// Start establishes a connection to the receiving endpoint.
|
||||||
func (e *Exporter) Start(ctx context.Context) error {
|
func (e *Exporter) Start(ctx context.Context) error {
|
||||||
var err = errAlreadyStarted
|
err := errAlreadyStarted
|
||||||
e.startOnce.Do(func() {
|
e.startOnce.Do(func() {
|
||||||
e.mu.Lock()
|
e.mu.Lock()
|
||||||
e.started = true
|
e.started = true
|
||||||
|
@ -213,12 +213,14 @@ func TestSpanData(t *testing.T) {
|
|||||||
StartTime: startTime,
|
StartTime: startTime,
|
||||||
EndTime: endTime,
|
EndTime: endTime,
|
||||||
Events: []tracesdk.Event{
|
Events: []tracesdk.Event{
|
||||||
{Time: startTime,
|
{
|
||||||
|
Time: startTime,
|
||||||
Attributes: []attribute.KeyValue{
|
Attributes: []attribute.KeyValue{
|
||||||
attribute.Int64("CompressedByteSize", 512),
|
attribute.Int64("CompressedByteSize", 512),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{Time: endTime,
|
{
|
||||||
|
Time: endTime,
|
||||||
Attributes: []attribute.KeyValue{
|
Attributes: []attribute.KeyValue{
|
||||||
attribute.String("EventType", "Recv"),
|
attribute.String("EventType", "Recv"),
|
||||||
},
|
},
|
||||||
|
@ -201,7 +201,7 @@ func TestConfigs(t *testing.T) {
|
|||||||
},
|
},
|
||||||
asserts: func(t *testing.T, c *Config, grpcOption bool) {
|
asserts: func(t *testing.T, c *Config, grpcOption bool) {
|
||||||
if grpcOption {
|
if grpcOption {
|
||||||
//TODO: make sure gRPC's credentials actually works
|
// TODO: make sure gRPC's credentials actually works
|
||||||
assert.NotNil(t, c.Traces.GRPCCredentials)
|
assert.NotNil(t, c.Traces.GRPCCredentials)
|
||||||
} else {
|
} else {
|
||||||
// nolint:staticcheck // ignoring tlsCert.RootCAs.Subjects is deprecated ERR because cert does not come from SystemCertPool.
|
// nolint:staticcheck // ignoring tlsCert.RootCAs.Subjects is deprecated ERR because cert does not come from SystemCertPool.
|
||||||
|
@ -32,12 +32,10 @@ const (
|
|||||||
instrumentationVersion = "0.1.0"
|
instrumentationVersion = "0.1.0"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var tracer = otel.GetTracerProvider().Tracer(
|
||||||
tracer = otel.GetTracerProvider().Tracer(
|
instrumentationName,
|
||||||
instrumentationName,
|
trace.WithInstrumentationVersion(instrumentationVersion),
|
||||||
trace.WithInstrumentationVersion(instrumentationVersion),
|
trace.WithSchemaURL(semconv.SchemaURL),
|
||||||
trace.WithSchemaURL(semconv.SchemaURL),
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func add(ctx context.Context, x, y int64) int64 {
|
func add(ctx context.Context, x, y int64) int64 {
|
||||||
|
@ -201,7 +201,7 @@ func TestConfigs(t *testing.T) {
|
|||||||
},
|
},
|
||||||
asserts: func(t *testing.T, c *Config, grpcOption bool) {
|
asserts: func(t *testing.T, c *Config, grpcOption bool) {
|
||||||
if grpcOption {
|
if grpcOption {
|
||||||
//TODO: make sure gRPC's credentials actually works
|
// TODO: make sure gRPC's credentials actually works
|
||||||
assert.NotNil(t, c.Traces.GRPCCredentials)
|
assert.NotNil(t, c.Traces.GRPCCredentials)
|
||||||
} else {
|
} else {
|
||||||
// nolint:staticcheck // ignoring tlsCert.RootCAs.Subjects is deprecated ERR because cert does not come from SystemCertPool.
|
// nolint:staticcheck // ignoring tlsCert.RootCAs.Subjects is deprecated ERR because cert does not come from SystemCertPool.
|
||||||
|
@ -746,7 +746,7 @@ func TestDuplicateMetrics(t *testing.T) {
|
|||||||
|
|
||||||
tc.recordMetrics(ctx, meterA, meterB)
|
tc.recordMetrics(ctx, meterA, meterB)
|
||||||
|
|
||||||
var match = false
|
match := false
|
||||||
for _, filename := range tc.possibleExpectedFiles {
|
for _, filename := range tc.possibleExpectedFiles {
|
||||||
file, ferr := os.Open(filename)
|
file, ferr := os.Open(filename)
|
||||||
require.NoError(t, ferr)
|
require.NoError(t, ferr)
|
||||||
|
@ -31,7 +31,7 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
// Sat Jan 01 2000 00:00:00 GMT+0000.
|
// Sat Jan 01 2000 00:00:00 GMT+0000.
|
||||||
now = time.Date(2000, time.January, 01, 0, 0, 0, 0, time.FixedZone("GMT", 0))
|
now = time.Date(2000, time.January, 0o1, 0, 0, 0, 0, time.FixedZone("GMT", 0))
|
||||||
|
|
||||||
res = resource.NewSchemaless(
|
res = resource.NewSchemaless(
|
||||||
semconv.ServiceName("stdoutmetric-example"),
|
semconv.ServiceName("stdoutmetric-example"),
|
||||||
@ -158,7 +158,7 @@ func Example() {
|
|||||||
// Ensure the periodic reader is cleaned up by shutting down the sdk.
|
// Ensure the periodic reader is cleaned up by shutting down the sdk.
|
||||||
_ = sdk.Shutdown(ctx)
|
_ = sdk.Shutdown(ctx)
|
||||||
|
|
||||||
//Output:
|
// Output:
|
||||||
// {
|
// {
|
||||||
// "Resource": [
|
// "Resource": [
|
||||||
// {
|
// {
|
||||||
|
@ -106,9 +106,7 @@ func redactTimestamps(orig *metricdata.ResourceMetrics) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var errUnknownAggType = errors.New("unknown aggregation type")
|
||||||
errUnknownAggType = errors.New("unknown aggregation type")
|
|
||||||
)
|
|
||||||
|
|
||||||
func redactAggregationTimestamps(orig metricdata.Aggregation) metricdata.Aggregation {
|
func redactAggregationTimestamps(orig metricdata.Aggregation) metricdata.Aggregation {
|
||||||
switch a := orig.(type) {
|
switch a := orig.(type) {
|
||||||
|
@ -32,12 +32,10 @@ const (
|
|||||||
instrumentationVersion = "0.1.0"
|
instrumentationVersion = "0.1.0"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var tracer = otel.GetTracerProvider().Tracer(
|
||||||
tracer = otel.GetTracerProvider().Tracer(
|
instrumentationName,
|
||||||
instrumentationName,
|
trace.WithInstrumentationVersion(instrumentationVersion),
|
||||||
trace.WithInstrumentationVersion(instrumentationVersion),
|
trace.WithSchemaURL(semconv.SchemaURL),
|
||||||
trace.WithSchemaURL(semconv.SchemaURL),
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func add(ctx context.Context, x, y int64) int64 {
|
func add(ctx context.Context, x, y int64) int64 {
|
||||||
|
@ -263,7 +263,7 @@ func (h *Harness) TestTracer(subjectFactory func() trace.Tracer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *Harness) testSpan(tracerFactory func() trace.Tracer) {
|
func (h *Harness) testSpan(tracerFactory func() trace.Tracer) {
|
||||||
var methods = map[string]func(span trace.Span){
|
methods := map[string]func(span trace.Span){
|
||||||
"#End": func(span trace.Span) {
|
"#End": func(span trace.Span) {
|
||||||
span.End()
|
span.End()
|
||||||
},
|
},
|
||||||
@ -283,7 +283,7 @@ func (h *Harness) testSpan(tracerFactory func() trace.Tracer) {
|
|||||||
span.SetAttributes(attribute.String("key1", "value"), attribute.Int("key2", 123))
|
span.SetAttributes(attribute.String("key1", "value"), attribute.Int("key2", 123))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
var mechanisms = map[string]func() trace.Span{
|
mechanisms := map[string]func() trace.Span{
|
||||||
"Span created via Tracer#Start": func() trace.Span {
|
"Span created via Tracer#Start": func() trace.Span {
|
||||||
tracer := tracerFactory()
|
tracer := tracerFactory()
|
||||||
_, subject := tracer.Start(context.Background(), "test")
|
_, subject := tracer.Start(context.Background(), "test")
|
||||||
|
@ -22,9 +22,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var key, value = "test", "true"
|
||||||
key, value = "test", "true"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestTextMapCarrierKeys(t *testing.T) {
|
func TestTextMapCarrierKeys(t *testing.T) {
|
||||||
tmc := NewTextMapCarrier(map[string]string{key: value})
|
tmc := NewTextMapCarrier(map[string]string{key: value})
|
||||||
|
@ -27,9 +27,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var stackTracePruneRE = regexp.MustCompile(`runtime\/debug|testing|internal\/matchers`)
|
||||||
stackTracePruneRE = regexp.MustCompile(`runtime\/debug|testing|internal\/matchers`)
|
|
||||||
)
|
|
||||||
|
|
||||||
type Expectation struct {
|
type Expectation struct {
|
||||||
t *testing.T
|
t *testing.T
|
||||||
|
@ -39,16 +39,20 @@ var wrapBoolSliceValue = func(v interface{}) interface{} {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var wrapStringSliceValue = func(v interface{}) interface{} {
|
var wrapStringSliceValue = func(v interface{}) interface{} {
|
||||||
if vi, ok := v.([]string); ok {
|
if vi, ok := v.([]string); ok {
|
||||||
return StringSliceValue(vi)
|
return StringSliceValue(vi)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
var wrapAsBoolSlice = func(v interface{}) interface{} { return AsBoolSlice(v) }
|
|
||||||
var wrapAsInt64Slice = func(v interface{}) interface{} { return AsInt64Slice(v) }
|
var (
|
||||||
var wrapAsFloat64Slice = func(v interface{}) interface{} { return AsFloat64Slice(v) }
|
wrapAsBoolSlice = func(v interface{}) interface{} { return AsBoolSlice(v) }
|
||||||
var wrapAsStringSlice = func(v interface{}) interface{} { return AsStringSlice(v) }
|
wrapAsInt64Slice = func(v interface{}) interface{} { return AsInt64Slice(v) }
|
||||||
|
wrapAsFloat64Slice = func(v interface{}) interface{} { return AsFloat64Slice(v) }
|
||||||
|
wrapAsStringSlice = func(v interface{}) interface{} { return AsStringSlice(v) }
|
||||||
|
)
|
||||||
|
|
||||||
func TestSliceValue(t *testing.T) {
|
func TestSliceValue(t *testing.T) {
|
||||||
type args struct {
|
type args struct {
|
||||||
|
@ -34,11 +34,13 @@ type afCounter struct {
|
|||||||
name string
|
name string
|
||||||
opts []metric.Float64ObservableCounterOption
|
opts []metric.Float64ObservableCounterOption
|
||||||
|
|
||||||
delegate atomic.Value //metric.Float64ObservableCounter
|
delegate atomic.Value // metric.Float64ObservableCounter
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ unwrapper = (*afCounter)(nil)
|
var (
|
||||||
var _ metric.Float64ObservableCounter = (*afCounter)(nil)
|
_ unwrapper = (*afCounter)(nil)
|
||||||
|
_ metric.Float64ObservableCounter = (*afCounter)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func (i *afCounter) setDelegate(m metric.Meter) {
|
func (i *afCounter) setDelegate(m metric.Meter) {
|
||||||
ctr, err := m.Float64ObservableCounter(i.name, i.opts...)
|
ctr, err := m.Float64ObservableCounter(i.name, i.opts...)
|
||||||
@ -63,11 +65,13 @@ type afUpDownCounter struct {
|
|||||||
name string
|
name string
|
||||||
opts []metric.Float64ObservableUpDownCounterOption
|
opts []metric.Float64ObservableUpDownCounterOption
|
||||||
|
|
||||||
delegate atomic.Value //metric.Float64ObservableUpDownCounter
|
delegate atomic.Value // metric.Float64ObservableUpDownCounter
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ unwrapper = (*afUpDownCounter)(nil)
|
var (
|
||||||
var _ metric.Float64ObservableUpDownCounter = (*afUpDownCounter)(nil)
|
_ unwrapper = (*afUpDownCounter)(nil)
|
||||||
|
_ metric.Float64ObservableUpDownCounter = (*afUpDownCounter)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func (i *afUpDownCounter) setDelegate(m metric.Meter) {
|
func (i *afUpDownCounter) setDelegate(m metric.Meter) {
|
||||||
ctr, err := m.Float64ObservableUpDownCounter(i.name, i.opts...)
|
ctr, err := m.Float64ObservableUpDownCounter(i.name, i.opts...)
|
||||||
@ -92,11 +96,13 @@ type afGauge struct {
|
|||||||
name string
|
name string
|
||||||
opts []metric.Float64ObservableGaugeOption
|
opts []metric.Float64ObservableGaugeOption
|
||||||
|
|
||||||
delegate atomic.Value //metric.Float64ObservableGauge
|
delegate atomic.Value // metric.Float64ObservableGauge
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ unwrapper = (*afGauge)(nil)
|
var (
|
||||||
var _ metric.Float64ObservableGauge = (*afGauge)(nil)
|
_ unwrapper = (*afGauge)(nil)
|
||||||
|
_ metric.Float64ObservableGauge = (*afGauge)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func (i *afGauge) setDelegate(m metric.Meter) {
|
func (i *afGauge) setDelegate(m metric.Meter) {
|
||||||
ctr, err := m.Float64ObservableGauge(i.name, i.opts...)
|
ctr, err := m.Float64ObservableGauge(i.name, i.opts...)
|
||||||
@ -121,11 +127,13 @@ type aiCounter struct {
|
|||||||
name string
|
name string
|
||||||
opts []metric.Int64ObservableCounterOption
|
opts []metric.Int64ObservableCounterOption
|
||||||
|
|
||||||
delegate atomic.Value //metric.Int64ObservableCounter
|
delegate atomic.Value // metric.Int64ObservableCounter
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ unwrapper = (*aiCounter)(nil)
|
var (
|
||||||
var _ metric.Int64ObservableCounter = (*aiCounter)(nil)
|
_ unwrapper = (*aiCounter)(nil)
|
||||||
|
_ metric.Int64ObservableCounter = (*aiCounter)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func (i *aiCounter) setDelegate(m metric.Meter) {
|
func (i *aiCounter) setDelegate(m metric.Meter) {
|
||||||
ctr, err := m.Int64ObservableCounter(i.name, i.opts...)
|
ctr, err := m.Int64ObservableCounter(i.name, i.opts...)
|
||||||
@ -150,11 +158,13 @@ type aiUpDownCounter struct {
|
|||||||
name string
|
name string
|
||||||
opts []metric.Int64ObservableUpDownCounterOption
|
opts []metric.Int64ObservableUpDownCounterOption
|
||||||
|
|
||||||
delegate atomic.Value //metric.Int64ObservableUpDownCounter
|
delegate atomic.Value // metric.Int64ObservableUpDownCounter
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ unwrapper = (*aiUpDownCounter)(nil)
|
var (
|
||||||
var _ metric.Int64ObservableUpDownCounter = (*aiUpDownCounter)(nil)
|
_ unwrapper = (*aiUpDownCounter)(nil)
|
||||||
|
_ metric.Int64ObservableUpDownCounter = (*aiUpDownCounter)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func (i *aiUpDownCounter) setDelegate(m metric.Meter) {
|
func (i *aiUpDownCounter) setDelegate(m metric.Meter) {
|
||||||
ctr, err := m.Int64ObservableUpDownCounter(i.name, i.opts...)
|
ctr, err := m.Int64ObservableUpDownCounter(i.name, i.opts...)
|
||||||
@ -179,11 +189,13 @@ type aiGauge struct {
|
|||||||
name string
|
name string
|
||||||
opts []metric.Int64ObservableGaugeOption
|
opts []metric.Int64ObservableGaugeOption
|
||||||
|
|
||||||
delegate atomic.Value //metric.Int64ObservableGauge
|
delegate atomic.Value // metric.Int64ObservableGauge
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ unwrapper = (*aiGauge)(nil)
|
var (
|
||||||
var _ metric.Int64ObservableGauge = (*aiGauge)(nil)
|
_ unwrapper = (*aiGauge)(nil)
|
||||||
|
_ metric.Int64ObservableGauge = (*aiGauge)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func (i *aiGauge) setDelegate(m metric.Meter) {
|
func (i *aiGauge) setDelegate(m metric.Meter) {
|
||||||
ctr, err := m.Int64ObservableGauge(i.name, i.opts...)
|
ctr, err := m.Int64ObservableGauge(i.name, i.opts...)
|
||||||
@ -208,7 +220,7 @@ type sfCounter struct {
|
|||||||
name string
|
name string
|
||||||
opts []metric.Float64CounterOption
|
opts []metric.Float64CounterOption
|
||||||
|
|
||||||
delegate atomic.Value //metric.Float64Counter
|
delegate atomic.Value // metric.Float64Counter
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ metric.Float64Counter = (*sfCounter)(nil)
|
var _ metric.Float64Counter = (*sfCounter)(nil)
|
||||||
@ -234,7 +246,7 @@ type sfUpDownCounter struct {
|
|||||||
name string
|
name string
|
||||||
opts []metric.Float64UpDownCounterOption
|
opts []metric.Float64UpDownCounterOption
|
||||||
|
|
||||||
delegate atomic.Value //metric.Float64UpDownCounter
|
delegate atomic.Value // metric.Float64UpDownCounter
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ metric.Float64UpDownCounter = (*sfUpDownCounter)(nil)
|
var _ metric.Float64UpDownCounter = (*sfUpDownCounter)(nil)
|
||||||
@ -260,7 +272,7 @@ type sfHistogram struct {
|
|||||||
name string
|
name string
|
||||||
opts []metric.Float64HistogramOption
|
opts []metric.Float64HistogramOption
|
||||||
|
|
||||||
delegate atomic.Value //metric.Float64Histogram
|
delegate atomic.Value // metric.Float64Histogram
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ metric.Float64Histogram = (*sfHistogram)(nil)
|
var _ metric.Float64Histogram = (*sfHistogram)(nil)
|
||||||
@ -286,7 +298,7 @@ type siCounter struct {
|
|||||||
name string
|
name string
|
||||||
opts []metric.Int64CounterOption
|
opts []metric.Int64CounterOption
|
||||||
|
|
||||||
delegate atomic.Value //metric.Int64Counter
|
delegate atomic.Value // metric.Int64Counter
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ metric.Int64Counter = (*siCounter)(nil)
|
var _ metric.Int64Counter = (*siCounter)(nil)
|
||||||
@ -312,7 +324,7 @@ type siUpDownCounter struct {
|
|||||||
name string
|
name string
|
||||||
opts []metric.Int64UpDownCounterOption
|
opts []metric.Int64UpDownCounterOption
|
||||||
|
|
||||||
delegate atomic.Value //metric.Int64UpDownCounter
|
delegate atomic.Value // metric.Int64UpDownCounter
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ metric.Int64UpDownCounter = (*siUpDownCounter)(nil)
|
var _ metric.Int64UpDownCounter = (*siUpDownCounter)(nil)
|
||||||
@ -338,7 +350,7 @@ type siHistogram struct {
|
|||||||
name string
|
name string
|
||||||
opts []metric.Int64HistogramOption
|
opts []metric.Int64HistogramOption
|
||||||
|
|
||||||
delegate atomic.Value //metric.Int64Histogram
|
delegate atomic.Value // metric.Int64Histogram
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ metric.Int64Histogram = (*siHistogram)(nil)
|
var _ metric.Int64Histogram = (*siHistogram)(nil)
|
||||||
|
@ -168,9 +168,11 @@ type testCountingFloatInstrument struct {
|
|||||||
func (i *testCountingFloatInstrument) observe() {
|
func (i *testCountingFloatInstrument) observe() {
|
||||||
i.count++
|
i.count++
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *testCountingFloatInstrument) Add(context.Context, float64, ...metric.AddOption) {
|
func (i *testCountingFloatInstrument) Add(context.Context, float64, ...metric.AddOption) {
|
||||||
i.count++
|
i.count++
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *testCountingFloatInstrument) Record(context.Context, float64, ...metric.RecordOption) {
|
func (i *testCountingFloatInstrument) Record(context.Context, float64, ...metric.RecordOption) {
|
||||||
i.count++
|
i.count++
|
||||||
}
|
}
|
||||||
@ -190,9 +192,11 @@ type testCountingIntInstrument struct {
|
|||||||
func (i *testCountingIntInstrument) observe() {
|
func (i *testCountingIntInstrument) observe() {
|
||||||
i.count++
|
i.count++
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *testCountingIntInstrument) Add(context.Context, int64, ...metric.AddOption) {
|
func (i *testCountingIntInstrument) Add(context.Context, int64, ...metric.AddOption) {
|
||||||
i.count++
|
i.count++
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *testCountingIntInstrument) Record(context.Context, int64, ...metric.RecordOption) {
|
func (i *testCountingIntInstrument) Record(context.Context, int64, ...metric.RecordOption) {
|
||||||
i.count++
|
i.count++
|
||||||
}
|
}
|
||||||
|
@ -263,7 +263,7 @@ func (h *Harness) TestTracer(subjectFactory func() trace.Tracer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *Harness) testSpan(tracerFactory func() trace.Tracer) {
|
func (h *Harness) testSpan(tracerFactory func() trace.Tracer) {
|
||||||
var methods = map[string]func(span trace.Span){
|
methods := map[string]func(span trace.Span){
|
||||||
"#End": func(span trace.Span) {
|
"#End": func(span trace.Span) {
|
||||||
span.End()
|
span.End()
|
||||||
},
|
},
|
||||||
@ -283,7 +283,7 @@ func (h *Harness) testSpan(tracerFactory func() trace.Tracer) {
|
|||||||
span.SetAttributes(attribute.String("key1", "value"), attribute.Int("key2", 123))
|
span.SetAttributes(attribute.String("key1", "value"), attribute.Int("key2", 123))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
var mechanisms = map[string]func() trace.Span{
|
mechanisms := map[string]func() trace.Span{
|
||||||
"Span created via Tracer#Start": func() trace.Span {
|
"Span created via Tracer#Start": func() trace.Span {
|
||||||
tracer := tracerFactory()
|
tracer := tracerFactory()
|
||||||
_, subject := tracer.Start(context.Background(), "test")
|
_, subject := tracer.Start(context.Background(), "test")
|
||||||
|
@ -22,9 +22,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var key, value = "test", "true"
|
||||||
key, value = "test", "true"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestTextMapCarrierKeys(t *testing.T) {
|
func TestTextMapCarrierKeys(t *testing.T) {
|
||||||
tmc := NewTextMapCarrier(map[string]string{key: value})
|
tmc := NewTextMapCarrier(map[string]string{key: value})
|
||||||
|
@ -27,9 +27,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var stackTracePruneRE = regexp.MustCompile(`runtime\/debug|testing|internal\/matchers`)
|
||||||
stackTracePruneRE = regexp.MustCompile(`runtime\/debug|testing|internal\/matchers`)
|
|
||||||
)
|
|
||||||
|
|
||||||
type Expectation struct {
|
type Expectation struct {
|
||||||
t *testing.T
|
t *testing.T
|
||||||
|
@ -263,7 +263,7 @@ func (h *Harness) TestTracer(subjectFactory func() trace.Tracer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *Harness) testSpan(tracerFactory func() trace.Tracer) {
|
func (h *Harness) testSpan(tracerFactory func() trace.Tracer) {
|
||||||
var methods = map[string]func(span trace.Span){
|
methods := map[string]func(span trace.Span){
|
||||||
"#End": func(span trace.Span) {
|
"#End": func(span trace.Span) {
|
||||||
span.End()
|
span.End()
|
||||||
},
|
},
|
||||||
@ -283,7 +283,7 @@ func (h *Harness) testSpan(tracerFactory func() trace.Tracer) {
|
|||||||
span.SetAttributes(attribute.String("key1", "value"), attribute.Int("key2", 123))
|
span.SetAttributes(attribute.String("key1", "value"), attribute.Int("key2", 123))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
var mechanisms = map[string]func() trace.Span{
|
mechanisms := map[string]func() trace.Span{
|
||||||
"Span created via Tracer#Start": func() trace.Span {
|
"Span created via Tracer#Start": func() trace.Span {
|
||||||
tracer := tracerFactory()
|
tracer := tracerFactory()
|
||||||
_, subject := tracer.Start(context.Background(), "test")
|
_, subject := tracer.Start(context.Background(), "test")
|
||||||
|
@ -22,9 +22,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var key, value = "test", "true"
|
||||||
key, value = "test", "true"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestTextMapCarrierKeys(t *testing.T) {
|
func TestTextMapCarrierKeys(t *testing.T) {
|
||||||
tmc := NewTextMapCarrier(map[string]string{key: value})
|
tmc := NewTextMapCarrier(map[string]string{key: value})
|
||||||
|
@ -27,9 +27,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var stackTracePruneRE = regexp.MustCompile(`runtime\/debug|testing|internal\/matchers`)
|
||||||
stackTracePruneRE = regexp.MustCompile(`runtime\/debug|testing|internal\/matchers`)
|
|
||||||
)
|
|
||||||
|
|
||||||
type Expectation struct {
|
type Expectation struct {
|
||||||
t *testing.T
|
t *testing.T
|
||||||
|
@ -203,7 +203,7 @@ func TestConfigs(t *testing.T) {
|
|||||||
},
|
},
|
||||||
asserts: func(t *testing.T, c *Config, grpcOption bool) {
|
asserts: func(t *testing.T, c *Config, grpcOption bool) {
|
||||||
if grpcOption {
|
if grpcOption {
|
||||||
//TODO: make sure gRPC's credentials actually works
|
// TODO: make sure gRPC's credentials actually works
|
||||||
assert.NotNil(t, c.Metrics.GRPCCredentials)
|
assert.NotNil(t, c.Metrics.GRPCCredentials)
|
||||||
} else {
|
} else {
|
||||||
// nolint:staticcheck // ignoring tlsCert.RootCAs.Subjects is deprecated ERR because cert does not come from SystemCertPool.
|
// nolint:staticcheck // ignoring tlsCert.RootCAs.Subjects is deprecated ERR because cert does not come from SystemCertPool.
|
||||||
|
@ -38,7 +38,7 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
// Sat Jan 01 2000 00:00:00 GMT+0000.
|
// Sat Jan 01 2000 00:00:00 GMT+0000.
|
||||||
start = time.Date(2000, time.January, 01, 0, 0, 0, 0, time.FixedZone("GMT", 0))
|
start = time.Date(2000, time.January, 0o1, 0, 0, 0, 0, time.FixedZone("GMT", 0))
|
||||||
end = start.Add(30 * time.Second)
|
end = start.Add(30 * time.Second)
|
||||||
|
|
||||||
kvAlice = &cpb.KeyValue{Key: "user", Value: &cpb.AnyValue{
|
kvAlice = &cpb.KeyValue{Key: "user", Value: &cpb.AnyValue{
|
||||||
|
@ -40,7 +40,7 @@ type unknownAggT struct {
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
// Sat Jan 01 2000 00:00:00 GMT+0000.
|
// Sat Jan 01 2000 00:00:00 GMT+0000.
|
||||||
start = time.Date(2000, time.January, 01, 0, 0, 0, 0, time.FixedZone("GMT", 0))
|
start = time.Date(2000, time.January, 0o1, 0, 0, 0, 0, time.FixedZone("GMT", 0))
|
||||||
end = start.Add(30 * time.Second)
|
end = start.Add(30 * time.Second)
|
||||||
|
|
||||||
alice = attribute.NewSet(attribute.String("user", "alice"))
|
alice = attribute.NewSet(attribute.String("user", "alice"))
|
||||||
|
@ -201,7 +201,7 @@ func TestConfigs(t *testing.T) {
|
|||||||
},
|
},
|
||||||
asserts: func(t *testing.T, c *Config, grpcOption bool) {
|
asserts: func(t *testing.T, c *Config, grpcOption bool) {
|
||||||
if grpcOption {
|
if grpcOption {
|
||||||
//TODO: make sure gRPC's credentials actually works
|
// TODO: make sure gRPC's credentials actually works
|
||||||
assert.NotNil(t, c.Traces.GRPCCredentials)
|
assert.NotNil(t, c.Traces.GRPCCredentials)
|
||||||
} else {
|
} else {
|
||||||
// nolint:staticcheck // ignoring tlsCert.RootCAs.Subjects is deprecated ERR because cert does not come from SystemCertPool.
|
// nolint:staticcheck // ignoring tlsCert.RootCAs.Subjects is deprecated ERR because cert does not come from SystemCertPool.
|
||||||
|
@ -27,9 +27,7 @@ import (
|
|||||||
|
|
||||||
type ctxKeyType uint
|
type ctxKeyType uint
|
||||||
|
|
||||||
var (
|
var ctxKey ctxKeyType
|
||||||
ctxKey ctxKeyType
|
|
||||||
)
|
|
||||||
|
|
||||||
type carrier []string
|
type carrier []string
|
||||||
|
|
||||||
|
@ -40,8 +40,10 @@ const (
|
|||||||
// their proprietary information.
|
// their proprietary information.
|
||||||
type TraceContext struct{}
|
type TraceContext struct{}
|
||||||
|
|
||||||
var _ TextMapPropagator = TraceContext{}
|
var (
|
||||||
var traceCtxRegExp = regexp.MustCompile("^(?P<version>[0-9a-f]{2})-(?P<traceID>[a-f0-9]{32})-(?P<spanID>[a-f0-9]{16})-(?P<traceFlags>[a-f0-9]{2})(?:-.*)?$")
|
_ TextMapPropagator = TraceContext{}
|
||||||
|
traceCtxRegExp = regexp.MustCompile("^(?P<version>[0-9a-f]{2})-(?P<traceID>[a-f0-9]{32})-(?P<spanID>[a-f0-9]{16})-(?P<traceFlags>[a-f0-9]{2})(?:-.*)?$")
|
||||||
|
)
|
||||||
|
|
||||||
// Inject set tracecontext from the Context into the carrier.
|
// Inject set tracecontext from the Context into the carrier.
|
||||||
func (tc TraceContext) Inject(ctx context.Context, carrier TextMapCarrier) {
|
func (tc TraceContext) Inject(ctx context.Context, carrier TextMapCarrier) {
|
||||||
|
@ -263,7 +263,7 @@ func (h *Harness) TestTracer(subjectFactory func() trace.Tracer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *Harness) testSpan(tracerFactory func() trace.Tracer) {
|
func (h *Harness) testSpan(tracerFactory func() trace.Tracer) {
|
||||||
var methods = map[string]func(span trace.Span){
|
methods := map[string]func(span trace.Span){
|
||||||
"#End": func(span trace.Span) {
|
"#End": func(span trace.Span) {
|
||||||
span.End()
|
span.End()
|
||||||
},
|
},
|
||||||
@ -283,7 +283,7 @@ func (h *Harness) testSpan(tracerFactory func() trace.Tracer) {
|
|||||||
span.SetAttributes(attribute.String("key1", "value"), attribute.Int("key2", 123))
|
span.SetAttributes(attribute.String("key1", "value"), attribute.Int("key2", 123))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
var mechanisms = map[string]func() trace.Span{
|
mechanisms := map[string]func() trace.Span{
|
||||||
"Span created via Tracer#Start": func() trace.Span {
|
"Span created via Tracer#Start": func() trace.Span {
|
||||||
tracer := tracerFactory()
|
tracer := tracerFactory()
|
||||||
_, subject := tracer.Start(context.Background(), "test")
|
_, subject := tracer.Start(context.Background(), "test")
|
||||||
|
@ -22,9 +22,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var key, value = "test", "true"
|
||||||
key, value = "test", "true"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestTextMapCarrierKeys(t *testing.T) {
|
func TestTextMapCarrierKeys(t *testing.T) {
|
||||||
tmc := NewTextMapCarrier(map[string]string{key: value})
|
tmc := NewTextMapCarrier(map[string]string{key: value})
|
||||||
|
@ -27,9 +27,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var stackTracePruneRE = regexp.MustCompile(`runtime\/debug|testing|internal\/matchers`)
|
||||||
stackTracePruneRE = regexp.MustCompile(`runtime\/debug|testing|internal\/matchers`)
|
|
||||||
)
|
|
||||||
|
|
||||||
type Expectation struct {
|
type Expectation struct {
|
||||||
t *testing.T
|
t *testing.T
|
||||||
|
@ -47,6 +47,7 @@ func (r *reader) RegisterProducer(p Producer) { r.externalProducers = append(r.e
|
|||||||
func (r *reader) temporality(kind InstrumentKind) metricdata.Temporality {
|
func (r *reader) temporality(kind InstrumentKind) metricdata.Temporality {
|
||||||
return r.temporalityFunc(kind)
|
return r.temporalityFunc(kind)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *reader) Collect(ctx context.Context, rm *metricdata.ResourceMetrics) error {
|
func (r *reader) Collect(ctx context.Context, rm *metricdata.ResourceMetrics) error {
|
||||||
return r.collectFunc(ctx, rm)
|
return r.collectFunc(ctx, rm)
|
||||||
}
|
}
|
||||||
|
@ -188,9 +188,11 @@ type int64Inst struct {
|
|||||||
embedded.Int64Histogram
|
embedded.Int64Histogram
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ metric.Int64Counter = (*int64Inst)(nil)
|
var (
|
||||||
var _ metric.Int64UpDownCounter = (*int64Inst)(nil)
|
_ metric.Int64Counter = (*int64Inst)(nil)
|
||||||
var _ metric.Int64Histogram = (*int64Inst)(nil)
|
_ metric.Int64UpDownCounter = (*int64Inst)(nil)
|
||||||
|
_ metric.Int64Histogram = (*int64Inst)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func (i *int64Inst) Add(ctx context.Context, val int64, opts ...metric.AddOption) {
|
func (i *int64Inst) Add(ctx context.Context, val int64, opts ...metric.AddOption) {
|
||||||
c := metric.NewAddConfig(opts)
|
c := metric.NewAddConfig(opts)
|
||||||
@ -219,9 +221,11 @@ type float64Inst struct {
|
|||||||
embedded.Float64Histogram
|
embedded.Float64Histogram
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ metric.Float64Counter = (*float64Inst)(nil)
|
var (
|
||||||
var _ metric.Float64UpDownCounter = (*float64Inst)(nil)
|
_ metric.Float64Counter = (*float64Inst)(nil)
|
||||||
var _ metric.Float64Histogram = (*float64Inst)(nil)
|
_ metric.Float64UpDownCounter = (*float64Inst)(nil)
|
||||||
|
_ metric.Float64Histogram = (*float64Inst)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func (i *float64Inst) Add(ctx context.Context, val float64, opts ...metric.AddOption) {
|
func (i *float64Inst) Add(ctx context.Context, val float64, opts ...metric.AddOption) {
|
||||||
c := metric.NewAddConfig(opts)
|
c := metric.NewAddConfig(opts)
|
||||||
@ -260,9 +264,11 @@ type float64Observable struct {
|
|||||||
embedded.Float64ObservableGauge
|
embedded.Float64ObservableGauge
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ metric.Float64ObservableCounter = float64Observable{}
|
var (
|
||||||
var _ metric.Float64ObservableUpDownCounter = float64Observable{}
|
_ metric.Float64ObservableCounter = float64Observable{}
|
||||||
var _ metric.Float64ObservableGauge = float64Observable{}
|
_ metric.Float64ObservableUpDownCounter = float64Observable{}
|
||||||
|
_ metric.Float64ObservableGauge = float64Observable{}
|
||||||
|
)
|
||||||
|
|
||||||
func newFloat64Observable(m *meter, kind InstrumentKind, name, desc, u string, meas []aggregate.Measure[float64]) float64Observable {
|
func newFloat64Observable(m *meter, kind InstrumentKind, name, desc, u string, meas []aggregate.Measure[float64]) float64Observable {
|
||||||
return float64Observable{
|
return float64Observable{
|
||||||
@ -279,9 +285,11 @@ type int64Observable struct {
|
|||||||
embedded.Int64ObservableGauge
|
embedded.Int64ObservableGauge
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ metric.Int64ObservableCounter = int64Observable{}
|
var (
|
||||||
var _ metric.Int64ObservableUpDownCounter = int64Observable{}
|
_ metric.Int64ObservableCounter = int64Observable{}
|
||||||
var _ metric.Int64ObservableGauge = int64Observable{}
|
_ metric.Int64ObservableUpDownCounter = int64Observable{}
|
||||||
|
_ metric.Int64ObservableGauge = int64Observable{}
|
||||||
|
)
|
||||||
|
|
||||||
func newInt64Observable(m *meter, kind InstrumentKind, name, desc, u string, meas []aggregate.Measure[int64]) int64Observable {
|
func newInt64Observable(m *meter, kind InstrumentKind, name, desc, u string, meas []aggregate.Measure[int64]) int64Observable {
|
||||||
return int64Observable{
|
return int64Observable{
|
||||||
|
@ -113,7 +113,7 @@ func (p *expoHistogramDataPoint[N]) record(v N) {
|
|||||||
otel.Handle(errors.New("exponential histogram scale underflow"))
|
otel.Handle(errors.New("exponential histogram scale underflow"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//Downscale
|
// Downscale
|
||||||
p.scale -= scaleDelta
|
p.scale -= scaleDelta
|
||||||
p.posBuckets.downscale(scaleDelta)
|
p.posBuckets.downscale(scaleDelta)
|
||||||
p.negBuckets.downscale(scaleDelta)
|
p.negBuckets.downscale(scaleDelta)
|
||||||
|
@ -40,8 +40,10 @@ func BenchmarkManualReader(b *testing.B) {
|
|||||||
b.Run("Collect", benchReaderCollectFunc(NewManualReader()))
|
b.Run("Collect", benchReaderCollectFunc(NewManualReader()))
|
||||||
}
|
}
|
||||||
|
|
||||||
var deltaTemporalitySelector = func(InstrumentKind) metricdata.Temporality { return metricdata.DeltaTemporality }
|
var (
|
||||||
var cumulativeTemporalitySelector = func(InstrumentKind) metricdata.Temporality { return metricdata.CumulativeTemporality }
|
deltaTemporalitySelector = func(InstrumentKind) metricdata.Temporality { return metricdata.DeltaTemporality }
|
||||||
|
cumulativeTemporalitySelector = func(InstrumentKind) metricdata.Temporality { return metricdata.CumulativeTemporality }
|
||||||
|
)
|
||||||
|
|
||||||
func TestManualReaderTemporality(t *testing.T) {
|
func TestManualReaderTemporality(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
|
@ -26,11 +26,9 @@ import (
|
|||||||
"go.opentelemetry.io/otel/sdk/metric/internal/aggregate"
|
"go.opentelemetry.io/otel/sdk/metric/internal/aggregate"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
// ErrInstrumentName indicates the created instrument has an invalid name.
|
||||||
// ErrInstrumentName indicates the created instrument has an invalid name.
|
// Valid names must consist of 255 or fewer characters including alphanumeric, _, ., -, / and start with a letter.
|
||||||
// Valid names must consist of 255 or fewer characters including alphanumeric, _, ., -, / and start with a letter.
|
var ErrInstrumentName = errors.New("invalid instrument name")
|
||||||
ErrInstrumentName = errors.New("invalid instrument name")
|
|
||||||
)
|
|
||||||
|
|
||||||
// meter handles the creation and coordination of all metric instruments. A
|
// meter handles the creation and coordination of all metric instruments. A
|
||||||
// meter represents a single instrumentation scope; all metric telemetry
|
// meter represents a single instrumentation scope; all metric telemetry
|
||||||
@ -268,9 +266,11 @@ func validateInstrumentName(name string) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func isAlpha(c rune) bool {
|
func isAlpha(c rune) bool {
|
||||||
return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')
|
return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')
|
||||||
}
|
}
|
||||||
|
|
||||||
func isAlphanumeric(c rune) bool {
|
func isAlphanumeric(c rune) bool {
|
||||||
return isAlpha(c) || ('0' <= c && c <= '9')
|
return isAlpha(c) || ('0' <= c && c <= '9')
|
||||||
}
|
}
|
||||||
|
@ -1826,12 +1826,15 @@ func BenchmarkInstrumentCreation(b *testing.B) {
|
|||||||
func testNilAggregationSelector(InstrumentKind) Aggregation {
|
func testNilAggregationSelector(InstrumentKind) Aggregation {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func testDefaultAggregationSelector(InstrumentKind) Aggregation {
|
func testDefaultAggregationSelector(InstrumentKind) Aggregation {
|
||||||
return AggregationDefault{}
|
return AggregationDefault{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testUndefinedTemporalitySelector(InstrumentKind) metricdata.Temporality {
|
func testUndefinedTemporalitySelector(InstrumentKind) metricdata.Temporality {
|
||||||
return metricdata.Temporality(0)
|
return metricdata.Temporality(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testInvalidTemporalitySelector(InstrumentKind) metricdata.Temporality {
|
func testInvalidTemporalitySelector(InstrumentKind) metricdata.Temporality {
|
||||||
return metricdata.Temporality(255)
|
return metricdata.Temporality(255)
|
||||||
}
|
}
|
||||||
|
@ -741,6 +741,7 @@ func hasAttributesScopeMetrics(sm metricdata.ScopeMetrics, attrs ...attribute.Ke
|
|||||||
}
|
}
|
||||||
return reasons
|
return reasons
|
||||||
}
|
}
|
||||||
|
|
||||||
func hasAttributesResourceMetrics(rm metricdata.ResourceMetrics, attrs ...attribute.KeyValue) (reasons []string) {
|
func hasAttributesResourceMetrics(rm metricdata.ResourceMetrics, attrs ...attribute.KeyValue) (reasons []string) {
|
||||||
for n, sm := range rm.ScopeMetrics {
|
for n, sm := range rm.ScopeMetrics {
|
||||||
reas := hasAttributesScopeMetrics(sm, attrs...)
|
reas := hasAttributesScopeMetrics(sm, attrs...)
|
||||||
|
@ -127,7 +127,8 @@ func NewPeriodicReader(exporter Exporter, options ...PeriodicReaderOption) *Peri
|
|||||||
rmPool: sync.Pool{
|
rmPool: sync.Pool{
|
||||||
New: func() interface{} {
|
New: func() interface{} {
|
||||||
return &metricdata.ResourceMetrics{}
|
return &metricdata.ResourceMetrics{}
|
||||||
}},
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
r.externalProducers.Store(conf.producers)
|
r.externalProducers.Store(conf.producers)
|
||||||
|
|
||||||
|
@ -344,7 +344,8 @@ func TestPeriodicReaderFlushesPending(t *testing.T) {
|
|||||||
return ctx.Err()
|
return ctx.Err()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}})
|
},
|
||||||
|
})
|
||||||
assert.ErrorIs(t, r.ForceFlush(context.Background()), context.DeadlineExceeded)
|
assert.ErrorIs(t, r.ForceFlush(context.Background()), context.DeadlineExceeded)
|
||||||
assert.False(t, *called, "exporter Export method called when it should have failed before export")
|
assert.False(t, *called, "exporter Export method called when it should have failed before export")
|
||||||
|
|
||||||
@ -396,7 +397,8 @@ func TestPeriodicReaderFlushesPending(t *testing.T) {
|
|||||||
return ctx.Err()
|
return ctx.Err()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}})
|
},
|
||||||
|
})
|
||||||
assert.ErrorIs(t, r.Shutdown(context.Background()), context.DeadlineExceeded)
|
assert.ErrorIs(t, r.Shutdown(context.Background()), context.DeadlineExceeded)
|
||||||
assert.False(t, *called, "exporter Export method called when it should have failed before export")
|
assert.False(t, *called, "exporter Export method called when it should have failed before export")
|
||||||
})
|
})
|
||||||
|
@ -39,6 +39,7 @@ type invalidAggregation struct{}
|
|||||||
func (invalidAggregation) copy() Aggregation {
|
func (invalidAggregation) copy() Aggregation {
|
||||||
return invalidAggregation{}
|
return invalidAggregation{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (invalidAggregation) err() error {
|
func (invalidAggregation) err() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -155,7 +156,7 @@ func testCreateAggregators[N int64 | float64](t *testing.T) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
instruments := []Instrument{
|
instruments := []Instrument{
|
||||||
{Name: "foo", Kind: InstrumentKind(0)}, //Unknown kind
|
{Name: "foo", Kind: InstrumentKind(0)}, // Unknown kind
|
||||||
{Name: "foo", Kind: InstrumentKindCounter},
|
{Name: "foo", Kind: InstrumentKindCounter},
|
||||||
{Name: "foo", Kind: InstrumentKindUpDownCounter},
|
{Name: "foo", Kind: InstrumentKindUpDownCounter},
|
||||||
{Name: "foo", Kind: InstrumentKindHistogram},
|
{Name: "foo", Kind: InstrumentKindHistogram},
|
||||||
|
@ -138,7 +138,8 @@ func (ts *readerTestSuite) TestSDKFailureBlocksExternalProducer() {
|
|||||||
produceFunc: func(ctx context.Context, rm *metricdata.ResourceMetrics) error {
|
produceFunc: func(ctx context.Context, rm *metricdata.ResourceMetrics) error {
|
||||||
*rm = metricdata.ResourceMetrics{}
|
*rm = metricdata.ResourceMetrics{}
|
||||||
return assert.AnError
|
return assert.AnError
|
||||||
}})
|
},
|
||||||
|
})
|
||||||
|
|
||||||
m := metricdata.ResourceMetrics{}
|
m := metricdata.ResourceMetrics{}
|
||||||
err := ts.Reader.Collect(context.Background(), &m)
|
err := ts.Reader.Collect(context.Background(), &m)
|
||||||
|
@ -21,12 +21,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
// ErrPartialResource is returned by a detector when complete source
|
||||||
// ErrPartialResource is returned by a detector when complete source
|
// information for a Resource is unavailable or the source information
|
||||||
// information for a Resource is unavailable or the source information
|
// contains invalid values that are omitted from the returned Resource.
|
||||||
// contains invalid values that are omitted from the returned Resource.
|
var ErrPartialResource = errors.New("partial resource")
|
||||||
ErrPartialResource = errors.New("partial resource")
|
|
||||||
)
|
|
||||||
|
|
||||||
// Detector detects OpenTelemetry resource information.
|
// Detector detects OpenTelemetry resource information.
|
||||||
type Detector interface {
|
type Detector interface {
|
||||||
|
@ -63,21 +63,27 @@ func benchmarkMergeResource(b *testing.B, size int) {
|
|||||||
func BenchmarkMergeResource_1(b *testing.B) {
|
func BenchmarkMergeResource_1(b *testing.B) {
|
||||||
benchmarkMergeResource(b, 1)
|
benchmarkMergeResource(b, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkMergeResource_2(b *testing.B) {
|
func BenchmarkMergeResource_2(b *testing.B) {
|
||||||
benchmarkMergeResource(b, 2)
|
benchmarkMergeResource(b, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkMergeResource_3(b *testing.B) {
|
func BenchmarkMergeResource_3(b *testing.B) {
|
||||||
benchmarkMergeResource(b, 3)
|
benchmarkMergeResource(b, 3)
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkMergeResource_4(b *testing.B) {
|
func BenchmarkMergeResource_4(b *testing.B) {
|
||||||
benchmarkMergeResource(b, 4)
|
benchmarkMergeResource(b, 4)
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkMergeResource_6(b *testing.B) {
|
func BenchmarkMergeResource_6(b *testing.B) {
|
||||||
benchmarkMergeResource(b, 6)
|
benchmarkMergeResource(b, 6)
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkMergeResource_8(b *testing.B) {
|
func BenchmarkMergeResource_8(b *testing.B) {
|
||||||
benchmarkMergeResource(b, 8)
|
benchmarkMergeResource(b, 8)
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkMergeResource_16(b *testing.B) {
|
func BenchmarkMergeResource_16(b *testing.B) {
|
||||||
benchmarkMergeResource(b, 16)
|
benchmarkMergeResource(b, 16)
|
||||||
}
|
}
|
||||||
|
@ -34,10 +34,8 @@ const (
|
|||||||
svcNameKey = "OTEL_SERVICE_NAME"
|
svcNameKey = "OTEL_SERVICE_NAME"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
// errMissingValue is returned when a resource value is missing.
|
||||||
// errMissingValue is returned when a resource value is missing.
|
var errMissingValue = fmt.Errorf("%w: missing value", ErrPartialResource)
|
||||||
errMissingValue = fmt.Errorf("%w: missing value", ErrPartialResource)
|
|
||||||
)
|
|
||||||
|
|
||||||
// fromEnv is a Detector that implements the Detector and collects
|
// fromEnv is a Detector that implements the Detector and collects
|
||||||
// resources from environment. This Detector is included as a
|
// resources from environment. This Detector is included as a
|
||||||
|
@ -34,6 +34,4 @@ var (
|
|||||||
RuntimeArch = runtimeArch
|
RuntimeArch = runtimeArch
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var MapRuntimeOSToSemconvOSType = mapRuntimeOSToSemconvOSType
|
||||||
MapRuntimeOSToSemconvOSType = mapRuntimeOSToSemconvOSType
|
|
||||||
)
|
|
||||||
|
@ -36,8 +36,10 @@ func setOSDescriptionProvider(osDescriptionProvider osDescriptionProvider) {
|
|||||||
osDescription = osDescriptionProvider
|
osDescription = osDescriptionProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
type osTypeDetector struct{}
|
type (
|
||||||
type osDescriptionDetector struct{}
|
osTypeDetector struct{}
|
||||||
|
osDescriptionDetector struct{}
|
||||||
|
)
|
||||||
|
|
||||||
// Detect returns a *Resource that describes the operating system type the
|
// Detect returns a *Resource that describes the operating system type the
|
||||||
// service is running on.
|
// service is running on.
|
||||||
@ -56,7 +58,6 @@ func (osTypeDetector) Detect(ctx context.Context) (*Resource, error) {
|
|||||||
// service is running on.
|
// service is running on.
|
||||||
func (osDescriptionDetector) Detect(ctx context.Context) (*Resource, error) {
|
func (osDescriptionDetector) Detect(ctx context.Context) (*Resource, error) {
|
||||||
description, err := osDescription()
|
description, err := osDescription()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -25,14 +25,16 @@ import (
|
|||||||
semconv "go.opentelemetry.io/otel/semconv/v1.21.0"
|
semconv "go.opentelemetry.io/otel/semconv/v1.21.0"
|
||||||
)
|
)
|
||||||
|
|
||||||
type pidProvider func() int
|
type (
|
||||||
type executablePathProvider func() (string, error)
|
pidProvider func() int
|
||||||
type commandArgsProvider func() []string
|
executablePathProvider func() (string, error)
|
||||||
type ownerProvider func() (*user.User, error)
|
commandArgsProvider func() []string
|
||||||
type runtimeNameProvider func() string
|
ownerProvider func() (*user.User, error)
|
||||||
type runtimeVersionProvider func() string
|
runtimeNameProvider func() string
|
||||||
type runtimeOSProvider func() string
|
runtimeVersionProvider func() string
|
||||||
type runtimeArchProvider func() string
|
runtimeOSProvider func() string
|
||||||
|
runtimeArchProvider func() string
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
defaultPidProvider pidProvider = os.Getpid
|
defaultPidProvider pidProvider = os.Getpid
|
||||||
@ -108,14 +110,16 @@ func setUserProviders(ownerProvider ownerProvider) {
|
|||||||
owner = ownerProvider
|
owner = ownerProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
type processPIDDetector struct{}
|
type (
|
||||||
type processExecutableNameDetector struct{}
|
processPIDDetector struct{}
|
||||||
type processExecutablePathDetector struct{}
|
processExecutableNameDetector struct{}
|
||||||
type processCommandArgsDetector struct{}
|
processExecutablePathDetector struct{}
|
||||||
type processOwnerDetector struct{}
|
processCommandArgsDetector struct{}
|
||||||
type processRuntimeNameDetector struct{}
|
processOwnerDetector struct{}
|
||||||
type processRuntimeVersionDetector struct{}
|
processRuntimeNameDetector struct{}
|
||||||
type processRuntimeDescriptionDetector struct{}
|
processRuntimeVersionDetector struct{}
|
||||||
|
processRuntimeDescriptionDetector struct{}
|
||||||
|
)
|
||||||
|
|
||||||
// Detect returns a *Resource that describes the process identifier (PID) of the
|
// Detect returns a *Resource that describes the process identifier (PID) of the
|
||||||
// executing process.
|
// executing process.
|
||||||
|
@ -285,6 +285,7 @@ func BenchmarkSpanWithEvents_WithStackTrace(b *testing.B) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkSpanWithEvents_WithTimestamp(b *testing.B) {
|
func BenchmarkSpanWithEvents_WithTimestamp(b *testing.B) {
|
||||||
traceBenchmark(b, "Benchmark Start With 4 Attributes", func(b *testing.B, t trace.Tracer) {
|
traceBenchmark(b, "Benchmark Start With 4 Attributes", func(b *testing.B, t trace.Tracer) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
@ -158,8 +158,10 @@ type recordingSpan struct {
|
|||||||
tracer *tracer
|
tracer *tracer
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ ReadWriteSpan = (*recordingSpan)(nil)
|
var (
|
||||||
var _ runtimeTracer = (*recordingSpan)(nil)
|
_ ReadWriteSpan = (*recordingSpan)(nil)
|
||||||
|
_ runtimeTracer = (*recordingSpan)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
// SpanContext returns the SpanContext of this span.
|
// SpanContext returns the SpanContext of this span.
|
||||||
func (s *recordingSpan) SpanContext() trace.SpanContext {
|
func (s *recordingSpan) SpanContext() trace.SpanContext {
|
||||||
|
@ -66,6 +66,7 @@ func (f InstrumentationBlacklist) Shutdown(ctx context.Context) error { return f
|
|||||||
func (f InstrumentationBlacklist) ForceFlush(ctx context.Context) error {
|
func (f InstrumentationBlacklist) ForceFlush(ctx context.Context) error {
|
||||||
return f.Next.ForceFlush(ctx)
|
return f.Next.ForceFlush(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f InstrumentationBlacklist) OnEnd(s ReadOnlySpan) {
|
func (f InstrumentationBlacklist) OnEnd(s ReadOnlySpan) {
|
||||||
if f.Blacklist != nil && f.Blacklist[s.InstrumentationScope().Name] {
|
if f.Blacklist != nil && f.Blacklist[s.InstrumentationScope().Name] {
|
||||||
// Drop spans from this instrumentation
|
// Drop spans from this instrumentation
|
||||||
|
@ -1407,7 +1407,8 @@ func TestWithResource(t *testing.T) {
|
|||||||
name: "last resource wins",
|
name: "last resource wins",
|
||||||
options: []TracerProviderOption{
|
options: []TracerProviderOption{
|
||||||
WithResource(resource.NewSchemaless(attribute.String("rk1", "vk1"), attribute.Int64("rk2", 5))),
|
WithResource(resource.NewSchemaless(attribute.String("rk1", "vk1"), attribute.Int64("rk2", 5))),
|
||||||
WithResource(resource.NewSchemaless(attribute.String("rk3", "rv3"), attribute.Int64("rk4", 10)))},
|
WithResource(resource.NewSchemaless(attribute.String("rk3", "rv3"), attribute.Int64("rk4", 10))),
|
||||||
|
},
|
||||||
want: mergeResource(t, resource.Environment(), resource.NewSchemaless(attribute.String("rk3", "rv3"), attribute.Int64("rk4", 10))),
|
want: mergeResource(t, resource.Environment(), resource.NewSchemaless(attribute.String("rk3", "rv3"), attribute.Int64("rk4", 10))),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -162,6 +162,7 @@ func (s spanSnapshot) Resource() *resource.Resource { return s.resource }
|
|||||||
func (s spanSnapshot) InstrumentationScope() instrumentation.Scope {
|
func (s spanSnapshot) InstrumentationScope() instrumentation.Scope {
|
||||||
return s.instrumentationScope
|
return s.instrumentationScope
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s spanSnapshot) InstrumentationLibrary() instrumentation.Library {
|
func (s spanSnapshot) InstrumentationLibrary() instrumentation.Library {
|
||||||
return s.instrumentationScope
|
return s.instrumentationScope
|
||||||
}
|
}
|
||||||
|
@ -268,6 +268,7 @@ func (o stackTraceOption) applyEvent(c EventConfig) EventConfig {
|
|||||||
c.stackTrace = bool(o)
|
c.stackTrace = bool(o)
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o stackTraceOption) applySpan(c SpanConfig) SpanConfig {
|
func (o stackTraceOption) applySpan(c SpanConfig) SpanConfig {
|
||||||
c.stackTrace = bool(o)
|
c.stackTrace = bool(o)
|
||||||
return c
|
return c
|
||||||
|
@ -48,8 +48,10 @@ func (e errorConst) Error() string {
|
|||||||
// nolint:revive // revive complains about stutter of `trace.TraceID`.
|
// nolint:revive // revive complains about stutter of `trace.TraceID`.
|
||||||
type TraceID [16]byte
|
type TraceID [16]byte
|
||||||
|
|
||||||
var nilTraceID TraceID
|
var (
|
||||||
var _ json.Marshaler = nilTraceID
|
nilTraceID TraceID
|
||||||
|
_ json.Marshaler = nilTraceID
|
||||||
|
)
|
||||||
|
|
||||||
// IsValid checks whether the trace TraceID is valid. A valid trace ID does
|
// IsValid checks whether the trace TraceID is valid. A valid trace ID does
|
||||||
// not consist of zeros only.
|
// not consist of zeros only.
|
||||||
@ -71,8 +73,10 @@ func (t TraceID) String() string {
|
|||||||
// SpanID is a unique identity of a span in a trace.
|
// SpanID is a unique identity of a span in a trace.
|
||||||
type SpanID [8]byte
|
type SpanID [8]byte
|
||||||
|
|
||||||
var nilSpanID SpanID
|
var (
|
||||||
var _ json.Marshaler = nilSpanID
|
nilSpanID SpanID
|
||||||
|
_ json.Marshaler = nilSpanID
|
||||||
|
)
|
||||||
|
|
||||||
// IsValid checks whether the SpanID is valid. A valid SpanID does not consist
|
// IsValid checks whether the SpanID is valid. A valid SpanID does not consist
|
||||||
// of zeros only.
|
// of zeros only.
|
||||||
|
@ -309,7 +309,7 @@ func TestSpanContextHasTraceID(t *testing.T) {
|
|||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
t.Run(testcase.name, func(t *testing.T) {
|
t.Run(testcase.name, func(t *testing.T) {
|
||||||
//proto: func (sc SpanContext) HasTraceID() bool{}
|
// proto: func (sc SpanContext) HasTraceID() bool{}
|
||||||
sc := SpanContext{traceID: testcase.tid}
|
sc := SpanContext{traceID: testcase.tid}
|
||||||
have := sc.HasTraceID()
|
have := sc.HasTraceID()
|
||||||
if have != testcase.want {
|
if have != testcase.want {
|
||||||
@ -336,7 +336,7 @@ func TestSpanContextHasSpanID(t *testing.T) {
|
|||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
t.Run(testcase.name, func(t *testing.T) {
|
t.Run(testcase.name, func(t *testing.T) {
|
||||||
//proto: func (sc SpanContext) HasSpanID() bool {}
|
// proto: func (sc SpanContext) HasSpanID() bool {}
|
||||||
have := testcase.sc.HasSpanID()
|
have := testcase.sc.HasSpanID()
|
||||||
if have != testcase.want {
|
if have != testcase.want {
|
||||||
t.Errorf("Want: %v, but have: %v", testcase.want, have)
|
t.Errorf("Want: %v, but have: %v", testcase.want, have)
|
||||||
@ -435,7 +435,7 @@ func TestStringTraceID(t *testing.T) {
|
|||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
t.Run(testcase.name, func(t *testing.T) {
|
t.Run(testcase.name, func(t *testing.T) {
|
||||||
//proto: func (t TraceID) String() string {}
|
// proto: func (t TraceID) String() string {}
|
||||||
have := testcase.tid.String()
|
have := testcase.tid.String()
|
||||||
if have != testcase.want {
|
if have != testcase.want {
|
||||||
t.Errorf("Want: %s, but have: %s", testcase.want, have)
|
t.Errorf("Want: %s, but have: %s", testcase.want, have)
|
||||||
@ -462,7 +462,7 @@ func TestStringSpanID(t *testing.T) {
|
|||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
t.Run(testcase.name, func(t *testing.T) {
|
t.Run(testcase.name, func(t *testing.T) {
|
||||||
//proto: func (t TraceID) String() string {}
|
// proto: func (t TraceID) String() string {}
|
||||||
have := testcase.sid.String()
|
have := testcase.sid.String()
|
||||||
if have != testcase.want {
|
if have != testcase.want {
|
||||||
t.Errorf("Want: %s, but have: %s", testcase.want, have)
|
t.Errorf("Want: %s, but have: %s", testcase.want, have)
|
||||||
@ -481,17 +481,14 @@ func TestValidateSpanKind(t *testing.T) {
|
|||||||
SpanKindInternal,
|
SpanKindInternal,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
SpanKindInternal,
|
SpanKindInternal,
|
||||||
SpanKindInternal,
|
SpanKindInternal,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
SpanKindServer,
|
SpanKindServer,
|
||||||
SpanKindServer,
|
SpanKindServer,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
SpanKindClient,
|
SpanKindClient,
|
||||||
SpanKindClient,
|
SpanKindClient,
|
||||||
},
|
},
|
||||||
@ -521,17 +518,14 @@ func TestSpanKindString(t *testing.T) {
|
|||||||
"unspecified",
|
"unspecified",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
SpanKindInternal,
|
SpanKindInternal,
|
||||||
"internal",
|
"internal",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
SpanKindServer,
|
SpanKindServer,
|
||||||
"server",
|
"server",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
SpanKindClient,
|
SpanKindClient,
|
||||||
"client",
|
"client",
|
||||||
},
|
},
|
||||||
|
@ -495,7 +495,8 @@ func TestTraceStateInsert(t *testing.T) {
|
|||||||
),
|
),
|
||||||
}
|
}
|
||||||
}(),
|
}(),
|
||||||
}}
|
},
|
||||||
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user