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