diff --git a/Makefile b/Makefile index f84e6bae5d2..9d5b11ab466 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,7 @@ all-srcs: .DEFAULT_GOAL := addlicense-fmt-vet-lint-goimports-misspell-staticcheck-test .PHONY: addlicense-fmt-vet-lint-goimports-misspell-staticcheck-test -addlicense-fmt-vet-lint-goimports-misspell-test: addlicense fmt vet lint goimports misspell staticcheck test +addlicense-fmt-vet-lint-goimports-misspell-staticcheck-test: addlicense fmt vet lint goimports misspell staticcheck test .PHONY: e2e-test e2e-test: otelsvc diff --git a/config/config.go b/config/config.go index ba00e914502..28ad4a9aa0a 100644 --- a/config/config.go +++ b/config/config.go @@ -176,7 +176,7 @@ func loadReceivers(v *viper.Viper, factories map[string]receiver.Factory) (confi keyMap := v.GetStringMap(receiversKeyName) // Prepare resulting map - receivers := make(configmodels.Receivers, 0) + receivers := make(configmodels.Receivers) // Iterate over input map and create a config for each. for key := range keyMap { @@ -242,7 +242,7 @@ func loadExporters(v *viper.Viper, factories map[string]exporter.Factory) (confi keyMap := v.GetStringMap(exportersKeyName) // Prepare resulting map - exporters := make(configmodels.Exporters, 0) + exporters := make(configmodels.Exporters) // Iterate over exporters and create a config for each. for key := range keyMap { @@ -299,7 +299,7 @@ func loadProcessors(v *viper.Viper, factories map[string]processor.Factory) (con keyMap := v.GetStringMap(processorsKeyName) // Prepare resulting map. - processors := make(configmodels.Processors, 0) + processors := make(configmodels.Processors) // Iterate over processors and create a config for each. for key := range keyMap { @@ -356,7 +356,7 @@ func loadPipelines(v *viper.Viper) (configmodels.Pipelines, error) { keyMap := v.GetStringMap(pipelinesKeyName) // Prepare resulting map. - pipelines := make(configmodels.Pipelines, 0) + pipelines := make(configmodels.Pipelines) // Iterate over input map and create a config for each. for key := range keyMap { diff --git a/exporter/exporterhelper/metricshelper_test.go b/exporter/exporterhelper/metricshelper_test.go index 80f54614a2f..22c0faceb6b 100644 --- a/exporter/exporterhelper/metricshelper_test.go +++ b/exporter/exporterhelper/metricshelper_test.go @@ -94,7 +94,7 @@ func newPushMetricsData(droppedSpans int, retError error) PushMetricsData { } func generateMetricsTraffic(t *testing.T, te exporter.MetricsExporter, numRequests int, wantError error) { - td := consumerdata.MetricsData{Metrics: make([]*metricspb.Metric, 1, 1)} + td := consumerdata.MetricsData{Metrics: make([]*metricspb.Metric, 1)} ctx, span := trace.StartSpan(context.Background(), fakeParentSpanName, trace.WithSampler(trace.AlwaysSample())) defer span.End() for i := 0; i < numRequests; i++ { diff --git a/exporter/exporterhelper/tracehelper_test.go b/exporter/exporterhelper/tracehelper_test.go index dd1440d7eef..d4a8c859744 100644 --- a/exporter/exporterhelper/tracehelper_test.go +++ b/exporter/exporterhelper/tracehelper_test.go @@ -132,7 +132,7 @@ func checkRecordedMetricsForTraceExporter(t *testing.T, te exporter.TraceExporte doneFn := observabilitytest.SetupRecordedMetricsTest() defer doneFn() - spans := make([]*tracepb.Span, 2, 2) + spans := make([]*tracepb.Span, 2) td := consumerdata.TraceData{Spans: spans} ctx := observability.ContextWithReceiverName(context.Background(), fakeReceiverName) const numBatches = 7 @@ -151,7 +151,7 @@ func checkRecordedMetricsForTraceExporter(t *testing.T, te exporter.TraceExporte } func generateTraceTraffic(t *testing.T, te exporter.TraceExporter, numRequests int, wantError error) { - td := consumerdata.TraceData{Spans: make([]*tracepb.Span, 1, 1)} + td := consumerdata.TraceData{Spans: make([]*tracepb.Span, 1)} ctx, span := trace.StartSpan(context.Background(), fakeParentSpanName, trace.WithSampler(trace.AlwaysSample())) defer span.End() for i := 0; i < numRequests; i++ { diff --git a/exporter/exportertest/nop_exporter_test.go b/exporter/exportertest/nop_exporter_test.go index 52f484ff250..38114497a29 100644 --- a/exporter/exportertest/nop_exporter_test.go +++ b/exporter/exportertest/nop_exporter_test.go @@ -31,7 +31,7 @@ func TestNopTraceExporter_NoErrors(t *testing.T) { if err := nte.ConsumeTraceData(context.Background(), td); err != nil { t.Fatalf("Wanted nil got error") } - if "nop_trace" != nte.TraceExportFormat() { + if nte.TraceExportFormat() != "nop_trace" { t.Fatalf("Wanted nop_trace got %s", nte.TraceExportFormat()) } } @@ -45,7 +45,7 @@ func TestNopTraceExporter_WithErrors(t *testing.T) { if got := nte.ConsumeTraceData(context.Background(), td); got != want { t.Fatalf("Want %v Got %v", want, got) } - if "nop_trace" != nte.TraceExportFormat() { + if nte.TraceExportFormat() != "nop_trace" { t.Fatalf("Wanted nop_trace got %s", nte.TraceExportFormat()) } } @@ -58,7 +58,7 @@ func TestNopMetricsExporter_NoErrors(t *testing.T) { if err := nme.ConsumeMetricsData(context.Background(), md); err != nil { t.Fatalf("Wanted nil got error") } - if "nop_metrics" != nme.MetricsExportFormat() { + if nme.MetricsExportFormat() != "nop_metrics" { t.Fatalf("Wanted nop_metrics got %s", nme.MetricsExportFormat()) } } @@ -72,7 +72,7 @@ func TestNopMetricsExporter_WithErrors(t *testing.T) { if got := nme.ConsumeMetricsData(context.Background(), md); got != want { t.Fatalf("Want %v Got %v", want, got) } - if "nop_metrics" != nme.MetricsExportFormat() { + if nme.MetricsExportFormat() != "nop_metrics" { t.Fatalf("Wanted nop_metrics got %s", nme.MetricsExportFormat()) } } diff --git a/exporter/exportertest/sink_exporter_test.go b/exporter/exportertest/sink_exporter_test.go index ac76c9a7730..fb50f8f0b8e 100644 --- a/exporter/exportertest/sink_exporter_test.go +++ b/exporter/exportertest/sink_exporter_test.go @@ -39,7 +39,7 @@ func TestSinkTraceExporter(t *testing.T) { if !reflect.DeepEqual(got, want) { t.Errorf("Mismatches responses\nGot:\n\t%v\nWant:\n\t%v\n", got, want) } - if "sink_trace" != sink.TraceExportFormat() { + if sink.TraceExportFormat() != "sink_trace" { t.Errorf("Wanted sink_trace got %s", sink.TraceExportFormat()) } } @@ -60,7 +60,7 @@ func TestSinkMetricsExporter(t *testing.T) { if !reflect.DeepEqual(got, want) { t.Errorf("Mismatches responses\nGot:\n\t%v\nWant:\n\t%v\n", got, want) } - if "sink_metrics" != sink.MetricsExportFormat() { + if sink.MetricsExportFormat() != "sink_metrics" { t.Errorf("Wanted sink_metrics got %s", sink.MetricsExportFormat()) } } diff --git a/exporter/jaegerexporter/jaeger_thrift_http_sender.go b/exporter/jaegerexporter/jaeger_thrift_http_sender.go index 39ef5008ef4..984f7a95dfd 100644 --- a/exporter/jaegerexporter/jaeger_thrift_http_sender.go +++ b/exporter/jaegerexporter/jaeger_thrift_http_sender.go @@ -111,7 +111,7 @@ func (s *JaegerThriftHTTPSender) ConsumeTraceData(ctx context.Context, td consum io.Copy(ioutil.Discard, resp.Body) resp.Body.Close() if resp.StatusCode >= http.StatusBadRequest { - return fmt.Errorf("Jaeger Thirft HTTP sender error: %d", resp.StatusCode) + return fmt.Errorf("jaeger Thirft HTTP sender error: %d", resp.StatusCode) } return nil } diff --git a/exporter/loggingexporter/logging_exporter_test.go b/exporter/loggingexporter/logging_exporter_test.go index 1af99b4b9b4..2d2d976a162 100644 --- a/exporter/loggingexporter/logging_exporter_test.go +++ b/exporter/loggingexporter/logging_exporter_test.go @@ -34,7 +34,7 @@ func TestLoggingTraceExporterNoErrors(t *testing.T) { if err := lte.ConsumeTraceData(context.Background(), td); err != nil { t.Fatalf("Wanted nil got %v", err) } - if "logging_trace" != lte.TraceExportFormat() { + if lte.TraceExportFormat() != "logging_trace" { t.Errorf("Wanted logging_trace got %v", lte.TraceExportFormat()) } } @@ -50,7 +50,7 @@ func TestLoggingMetricsExporterNoErrors(t *testing.T) { if err := lme.ConsumeMetricsData(context.Background(), md); err != nil { t.Fatalf("Wanted nil got %v", err) } - if "logging_metrics" != lme.MetricsExportFormat() { + if lme.MetricsExportFormat() != "logging_metrics" { t.Errorf("Wanted logging_metrics got %v", lme.MetricsExportFormat()) } } diff --git a/exporter/opencensusexporter/opencensus.go b/exporter/opencensusexporter/opencensus.go index 14033a208ae..930efa6f9a2 100644 --- a/exporter/opencensusexporter/opencensus.go +++ b/exporter/opencensusexporter/opencensus.go @@ -57,7 +57,6 @@ type opencensusConfig struct { } type ocagentExporter struct { - counter uint32 exporters chan *ocagent.Exporter } diff --git a/exporter/prometheusexporter/factory_test.go b/exporter/prometheusexporter/factory_test.go index 3de2f4cb5dd..a587acaa152 100644 --- a/exporter/prometheusexporter/factory_test.go +++ b/exporter/prometheusexporter/factory_test.go @@ -41,7 +41,6 @@ func TestCreateTraceExporter(t *testing.T) { } func TestCreateMetricsExporter(t *testing.T) { - const defaultTestEndPoint = "127.0.0.1:55678" tests := []struct { name string config Config diff --git a/exporter/zipkinexporter/zipkin.go b/exporter/zipkinexporter/zipkin.go index eb3ff1d3fde..77c38962db5 100644 --- a/exporter/zipkinexporter/zipkin.go +++ b/exporter/zipkinexporter/zipkin.go @@ -107,7 +107,7 @@ func ZipkinExportersFromViper(v *viper.Viper) (tps []consumer.TraceConsumer, mps } zle, err := newZipkinExporter(endpoint, serviceName, localEndpointURI, uploadPeriod) if err != nil { - return nil, nil, nil, fmt.Errorf("Cannot configure Zipkin exporter: %v", err) + return nil, nil, nil, fmt.Errorf("cannot configure Zipkin exporter: %v", err) } tps = append(tps, zle) doneFns = append(doneFns, zle.stop) diff --git a/internal/collector/processor/idbatcher/id_batcher.go b/internal/collector/processor/idbatcher/id_batcher.go index 6b04437d35a..47f60f406cb 100644 --- a/internal/collector/processor/idbatcher/id_batcher.go +++ b/internal/collector/processor/idbatcher/id_batcher.go @@ -67,7 +67,6 @@ type batcher struct { cbMutex sync.Mutex currentBatch Batch - numBatches uint64 newBatchesInitialCapacity uint64 stopchan chan bool stopped bool @@ -127,8 +126,8 @@ func (b *batcher) CloseCurrentAndTakeFirstBatch() (Batch, bool) { b.batches <- b.currentBatch b.currentBatch = nextBatch b.cbMutex.Unlock() + return readBatch, true } - return readBatch, true } readBatch := b.currentBatch diff --git a/internal/collector/processor/metrics.go b/internal/collector/processor/metrics.go index 0f6a3b56610..fa371d8dcbc 100644 --- a/internal/collector/processor/metrics.go +++ b/internal/collector/processor/metrics.go @@ -55,7 +55,6 @@ func MetricTagKeys(level telemetry.Level) []tag.Key { fallthrough case telemetry.Basic: tagKeys = append(tagKeys, TagExporterNameKey) - break default: return nil } diff --git a/observability/observabilitytest/observabilitytest.go b/observability/observabilitytest/observabilitytest.go index 41e654c9463..8c361662aeb 100644 --- a/observability/observabilitytest/observabilitytest.go +++ b/observability/observabilitytest/observabilitytest.go @@ -90,7 +90,7 @@ func checkValueForView(vName string, wantTags []tag.Tag, value int64) error { rows, err := view.RetrieveData(vName) if err != nil { - return fmt.Errorf("Error retrieving view data for view Name %s", vName) + return fmt.Errorf("error retrieving view data for view Name %s", vName) } for _, row := range rows { @@ -99,13 +99,13 @@ func checkValueForView(vName string, wantTags []tag.Tag, value int64) error { if reflect.DeepEqual(wantTags, row.Tags) { sum := row.Data.(*view.SumData) if float64(value) != sum.Value { - return fmt.Errorf("Different recorded value: want %v got %v", float64(value), sum.Value) + return fmt.Errorf("different recorded value: want %v got %v", float64(value), sum.Value) } // We found the result return nil } } - return fmt.Errorf("Could not find wantTags: %s in rows %v", wantTags, rows) + return fmt.Errorf("could not find wantTags: %s in rows %v", wantTags, rows) } func wantsTagsForExporterView(receiverName string, exporterTagName string) []tag.Tag { diff --git a/processor/addattributesprocessor/addattributesprocessor.go b/processor/addattributesprocessor/addattributesprocessor.go index 3874837f961..18598a65fe8 100644 --- a/processor/addattributesprocessor/addattributesprocessor.go +++ b/processor/addattributesprocessor/addattributesprocessor.go @@ -27,7 +27,7 @@ import ( ) var ( - errUnsupportedType = errors.New("Unsupported type") + errUnsupportedType = errors.New("unsupported type") ) type addattributesprocessor struct { diff --git a/processor/attributekeyprocessor/attributekeyprocessor_test.go b/processor/attributekeyprocessor/attributekeyprocessor_test.go index e3ce08f9d08..7c365cef37c 100644 --- a/processor/attributekeyprocessor/attributekeyprocessor_test.go +++ b/processor/attributekeyprocessor/attributekeyprocessor_test.go @@ -158,11 +158,11 @@ func Test_attributekeyprocessor_ConsumeTraceData(t *testing.T) { }, }, td: consumerdata.TraceData{ - Spans: make([]*tracepb.Span, 1, 1), + Spans: make([]*tracepb.Span, 1), }, want: []consumerdata.TraceData{ { - Spans: make([]*tracepb.Span, 1, 1), + Spans: make([]*tracepb.Span, 1), }, }, }, diff --git a/processor/attributekeyprocessor/config_test.go b/processor/attributekeyprocessor/config_test.go index 9c628ef1df6..ffe570bb18e 100644 --- a/processor/attributekeyprocessor/config_test.go +++ b/processor/attributekeyprocessor/config_test.go @@ -28,6 +28,7 @@ import ( func TestLoadConfig(t *testing.T) { receivers, _, exporters, err := config.ExampleComponents() + require.NoError(t, err) processors, err := processor.Build(&Factory{}) require.NotNil(t, processors) require.NoError(t, err) @@ -76,6 +77,7 @@ func TestLoadConfig(t *testing.T) { func TestLoadConfigEmpty(t *testing.T) { receivers, _, exporters, err := config.ExampleComponents() + require.NoError(t, err) processors, err := processor.Build(&Factory{}) require.NotNil(t, processors) require.NoError(t, err) diff --git a/processor/attributekeyprocessor/factory.go b/processor/attributekeyprocessor/factory.go index 4e6968c1b37..8400ab65ed1 100644 --- a/processor/attributekeyprocessor/factory.go +++ b/processor/attributekeyprocessor/factory.go @@ -44,7 +44,7 @@ func (f *Factory) CreateDefaultConfig() configmodels.Processor { TypeVal: typeStr, NameVal: typeStr, }, - Keys: make(map[string]NewKeyProperties, 0), + Keys: make(map[string]NewKeyProperties), } } diff --git a/processor/nodebatcher/node_batcher.go b/processor/nodebatcher/node_batcher.go index 9fd04c23016..4dad033a2e8 100644 --- a/processor/nodebatcher/node_batcher.go +++ b/processor/nodebatcher/node_batcher.go @@ -71,8 +71,6 @@ type batcher struct { numTickers int tickTime time.Duration timeout time.Duration - - bucketMu sync.RWMutex } var _ consumer.TraceConsumer = (*batcher)(nil) diff --git a/processor/probabilisticsampler/config_test.go b/processor/probabilisticsampler/config_test.go index 5d44d817574..a75a6147e0d 100644 --- a/processor/probabilisticsampler/config_test.go +++ b/processor/probabilisticsampler/config_test.go @@ -54,6 +54,7 @@ func TestLoadConfig(t *testing.T) { func TestLoadConfigEmpty(t *testing.T) { receivers, _, exporters, err := config.ExampleComponents() + require.NoError(t, err) processors, err := processor.Build(&Factory{}) require.NotNil(t, processors) require.NoError(t, err) diff --git a/processor/tailsampling/processor.go b/processor/tailsampling/processor.go index a14cd961b12..26892bff9a7 100644 --- a/processor/tailsampling/processor.go +++ b/processor/tailsampling/processor.go @@ -68,10 +68,6 @@ type tailSamplingSpanProcessor struct { numTracesOnMap uint64 } -const ( - sourceFormat = "tail-sampling" -) - var _ processor.TraceProcessor = (*tailSamplingSpanProcessor)(nil) // NewTraceProcessor returns a processor.TraceProcessor that will perform tail sampling according to the given @@ -201,7 +197,7 @@ func (tsp *tailSamplingSpanProcessor) ConsumeTraceData(ctx context.Context, td c for id, spans := range idToSpans { lenSpans := int64(len(spans)) lenPolicies := len(tsp.policies) - initialDecisions := make([]sampling.Decision, lenPolicies, lenPolicies) + initialDecisions := make([]sampling.Decision, lenPolicies) for i := 0; i < lenPolicies; i++ { initialDecisions[i] = sampling.Pending } diff --git a/processor/tailsampling/processor_test.go b/processor/tailsampling/processor_test.go index a2755f58a52..da690aee3a2 100644 --- a/processor/tailsampling/processor_test.go +++ b/processor/tailsampling/processor_test.go @@ -213,7 +213,7 @@ func TestSamplingPolicyTypicalPath(t *testing.T) { } func generateIdsAndBatches(numIds int) ([][]byte, []consumerdata.TraceData) { - traceIds := make([][]byte, numIds, numIds) + traceIds := make([][]byte, numIds) for i := 0; i < numIds; i++ { traceIds[i] = tracetranslator.UInt64ToByteTraceID(1, uint64(i+1)) } @@ -241,16 +241,6 @@ func generateIdsAndBatches(numIds int) ([][]byte, []consumerdata.TraceData) { return traceIds, tds } -func newTestPolicy() []*Policy { - return []*Policy{ - { - Name: "test", - Evaluator: sampling.NewAlwaysSample(), - Destination: &mockSpanProcessor{}, - }, - } -} - type mockPolicyEvaluator struct { NextDecision sampling.Decision NextError error diff --git a/receiver/jaegerreceiver/trace_receiver.go b/receiver/jaegerreceiver/trace_receiver.go index a3e982936b1..803f87bf555 100644 --- a/receiver/jaegerreceiver/trace_receiver.go +++ b/receiver/jaegerreceiver/trace_receiver.go @@ -70,8 +70,7 @@ type jReceiver struct { config *Configuration - agent *agentapp.Agent - agentServer *http.Server + agent *agentapp.Agent grpc *grpc.Server tchannel *tchannel.Channel @@ -93,7 +92,6 @@ const ( // 5775 UDP accept zipkin.thrift over compact thrift protocol // 6831 UDP accept jaeger.thrift over compact thrift protocol // 6832 UDP accept jaeger.thrift over binary thrift protocol - defaultZipkinThriftUDPPort = 5775 defaultCompactThriftUDPPort = 6831 defaultBinaryThriftUDPPort = 6832 diff --git a/receiver/jaegerreceiver/trace_receiver_test.go b/receiver/jaegerreceiver/trace_receiver_test.go index 73e19769143..eebcf3a4824 100644 --- a/receiver/jaegerreceiver/trace_receiver_test.go +++ b/receiver/jaegerreceiver/trace_receiver_test.go @@ -28,6 +28,7 @@ import ( model "github.com/jaegertracing/jaeger/model" "github.com/jaegertracing/jaeger/proto-gen/api_v2" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "go.opencensus.io/trace" "google.golang.org/grpc" @@ -106,6 +107,7 @@ func TestGRPCReception(t *testing.T) { t.Log("StartTraceReception") conn, err := grpc.Dial(fmt.Sprintf("0.0.0.0:%d", config.CollectorGRPCPort), grpc.WithInsecure()) + require.NoError(t, err) defer conn.Close() cl := api_v2.NewCollectorServiceClient(conn) diff --git a/receiver/opencensusreceiver/octrace/opencensus.go b/receiver/opencensusreceiver/octrace/opencensus.go index c647ccf0ab7..420f9f740ae 100644 --- a/receiver/opencensusreceiver/octrace/opencensus.go +++ b/receiver/opencensusreceiver/octrace/opencensus.go @@ -154,7 +154,6 @@ func (ocr *Receiver) Stop() { type receiverWorker struct { receiver *Receiver - tes agenttracepb.TraceService_ExportServer cancel chan struct{} } diff --git a/receiver/opencensusreceiver/opencensus.go b/receiver/opencensusreceiver/opencensus.go index 9195c98cc48..eccda325b84 100644 --- a/receiver/opencensusreceiver/opencensus.go +++ b/receiver/opencensusreceiver/opencensus.go @@ -76,7 +76,7 @@ func New(addr string, tc consumer.TraceConsumer, mc consumer.MetricsConsumer, op // TODO: (@odeke-em) use options to enable address binding changes. ln, err := net.Listen("tcp", addr) if err != nil { - return nil, fmt.Errorf("Failed to bind to address %q: %v", addr, err) + return nil, fmt.Errorf("failed to bind to address %q: %v", addr, err) } ocr := &Receiver{ diff --git a/receiver/opencensusreceiver/options.go b/receiver/opencensusreceiver/options.go index 40e2242dde1..9d499c2c284 100644 --- a/receiver/opencensusreceiver/options.go +++ b/receiver/opencensusreceiver/options.go @@ -94,9 +94,7 @@ type noopOption int var _ Option = (noopOption)(0) -func (noopOpt noopOption) withReceiver(ocr *Receiver) { - return -} +func (noopOpt noopOption) withReceiver(ocr *Receiver) {} // WithNoopOption returns an option that doesn't mutate the receiver. func WithNoopOption() Option { return noopOption(0) } diff --git a/receiver/prometheusreceiver/internal/metricsbuilder.go b/receiver/prometheusreceiver/internal/metricsbuilder.go index 13d75de532f..78c7070d84e 100644 --- a/receiver/prometheusreceiver/internal/metricsbuilder.go +++ b/receiver/prometheusreceiver/internal/metricsbuilder.go @@ -52,7 +52,6 @@ var dummyMetric = &consumerdata.MetricsData{ type metricBuilder struct { node *commonpb.Node - ts int64 hasData bool hasInternalMetric bool mc MetadataCache diff --git a/receiver/prometheusreceiver/internal/metricsbuilder_test.go b/receiver/prometheusreceiver/internal/metricsbuilder_test.go index ff65bb27a4d..19b038ee43c 100644 --- a/receiver/prometheusreceiver/internal/metricsbuilder_test.go +++ b/receiver/prometheusreceiver/internal/metricsbuilder_test.go @@ -196,11 +196,10 @@ func Test_metricBuilder(t *testing.T) { } tests := []struct { - name string - pts []*pt - processErr bool - buildErr bool - metrics []*metricspb.Metric + name string + pts []*pt + buildErr bool + metrics []*metricspb.Metric }{ { name: "counters", diff --git a/receiver/prometheusreceiver/metrics_receiver.go b/receiver/prometheusreceiver/metrics_receiver.go index 3ef6a83b737..d42f09d26f7 100644 --- a/receiver/prometheusreceiver/metrics_receiver.go +++ b/receiver/prometheusreceiver/metrics_receiver.go @@ -23,7 +23,6 @@ import ( "github.com/prometheus/prometheus/discovery" "github.com/prometheus/prometheus/scrape" - "github.com/prometheus/prometheus/storage" "go.uber.org/zap" "github.com/open-telemetry/opentelemetry-service/consumer" @@ -47,7 +46,6 @@ type Configuration struct { type Preceiver struct { startOnce sync.Once stopOnce sync.Once - ocaStore storage.Appender cfg *Configuration consumer consumer.MetricsConsumer cancel context.CancelFunc @@ -57,9 +55,7 @@ type Preceiver struct { var _ receiver.MetricsReceiver = (*Preceiver)(nil) var ( - errAlreadyStarted = errors.New("already started the Prometheus receiver") - errNilMetricsReceiverSink = errors.New("expecting a non-nil MetricsReceiverSink") - errNilScrapeConfig = errors.New("expecting a non-nil ScrapeConfig") + errNilScrapeConfig = errors.New("expecting a non-nil ScrapeConfig") ) const ( diff --git a/receiver/vmmetricsreceiver/metrics_receiver.go b/receiver/vmmetricsreceiver/metrics_receiver.go index 4c320d46e51..8c2297bc6a8 100644 --- a/receiver/vmmetricsreceiver/metrics_receiver.go +++ b/receiver/vmmetricsreceiver/metrics_receiver.go @@ -22,9 +22,8 @@ import ( ) var ( - errAlreadyStarted = errors.New("already started") - errAlreadyStopped = errors.New("already stopped") - errNilMetricsConsumer = errors.New("expecting a non-nil MetricsConsumer") + errAlreadyStarted = errors.New("already started") + errAlreadyStopped = errors.New("already stopped") ) // Receiver is the type used to handle metrics from VM metrics. diff --git a/receiver/zipkinreceiver/trace_receiver.go b/receiver/zipkinreceiver/trace_receiver.go index ce2fb8f0f14..853da800ef4 100644 --- a/receiver/zipkinreceiver/trace_receiver.go +++ b/receiver/zipkinreceiver/trace_receiver.go @@ -338,13 +338,14 @@ func (zr *ZipkinReceiver) ServeHTTP(w http.ResponseWriter, r *http.Request) { } pr := processBodyIfNecessary(r) - slurp, err := ioutil.ReadAll(pr) + slurp, _ := ioutil.ReadAll(pr) if c, ok := pr.(io.Closer); ok { _ = c.Close() } _ = r.Body.Close() var tds []consumerdata.TraceData + var err error if asZipkinv1 { tds, err = zr.v1ToTraceSpans(slurp, r.Header) } else { diff --git a/receiver/zipkinreceiver/trace_receiver_test.go b/receiver/zipkinreceiver/trace_receiver_test.go index 0276791d1dc..351fc734d4d 100644 --- a/receiver/zipkinreceiver/trace_receiver_test.go +++ b/receiver/zipkinreceiver/trace_receiver_test.go @@ -125,7 +125,6 @@ func TestNew(t *testing.T) { tests := []struct { name string args args - want *ZipkinReceiver wantErr error }{ { diff --git a/service/builder/pipelines_builder_test.go b/service/builder/pipelines_builder_test.go index 3f1e3445b19..f74a70c72de 100644 --- a/service/builder/pipelines_builder_test.go +++ b/service/builder/pipelines_builder_test.go @@ -69,6 +69,7 @@ func testPipeline(t *testing.T, pipelineName string, exporterNames []string) { // Build the pipeline allExporters, err := NewExportersBuilder(zap.NewNop(), cfg, exporterFactories).Build() + assert.NoError(t, err) pipelineProcessors, err := NewPipelinesBuilder(zap.NewNop(), cfg, allExporters, processorsFactories).Build() assert.NoError(t, err) @@ -140,6 +141,7 @@ func TestPipelinesBuilder_Error(t *testing.T) { pipeline.InputType = configmodels.MetricsDataType exporters, err := NewExportersBuilder(zap.NewNop(), cfg, exporterFactories).Build() + assert.NoError(t, err) // This should fail because "attributes" processor defined in the config does // not support metrics data type. diff --git a/service/builder/receivers_builder_test.go b/service/builder/receivers_builder_test.go index d446b9e81c3..98be414edbd 100644 --- a/service/builder/receivers_builder_test.go +++ b/service/builder/receivers_builder_test.go @@ -103,7 +103,9 @@ func testReceivers( // Build the pipeline allExporters, err := NewExportersBuilder(zap.NewNop(), cfg, exporterFactories).Build() + assert.NoError(t, err) pipelineProcessors, err := NewPipelinesBuilder(zap.NewNop(), cfg, allExporters, processorsFactories).Build() + assert.NoError(t, err) receivers, err := NewReceiversBuilder(zap.NewNop(), cfg, pipelineProcessors, receiverFactories).Build() assert.NoError(t, err) @@ -220,7 +222,9 @@ func TestReceiversBuilder_DataTypeError(t *testing.T) { // Build the pipeline allExporters, err := NewExportersBuilder(zap.NewNop(), cfg, exporterFactories).Build() + assert.NoError(t, err) pipelineProcessors, err := NewPipelinesBuilder(zap.NewNop(), cfg, allExporters, processorsFactories).Build() + assert.NoError(t, err) receivers, err := NewReceiversBuilder(zap.NewNop(), cfg, pipelineProcessors, receiverFactories).Build() // This should fail because "examplereceiver" is attached to "traces" pipeline diff --git a/service/service.go b/service/service.go index b0ec6f8bd1c..97c0c2f8d15 100644 --- a/service/service.go +++ b/service/service.go @@ -30,7 +30,6 @@ import ( "go.uber.org/zap" "github.com/open-telemetry/opentelemetry-service/config" - "github.com/open-telemetry/opentelemetry-service/consumer" "github.com/open-telemetry/opentelemetry-service/exporter" "github.com/open-telemetry/opentelemetry-service/internal/config/viperutils" "github.com/open-telemetry/opentelemetry-service/internal/pprofserver" @@ -45,8 +44,6 @@ type Application struct { v *viper.Viper logger *zap.Logger healthCheck *healthcheck.HealthCheck - processor consumer.TraceConsumer - receivers []receiver.TraceReceiver exporters builder.Exporters builtReceivers builder.Receivers @@ -192,12 +189,6 @@ func (app *Application) runAndWaitForShutdownEvent() { } } -func (app *Application) shutdownReceivers() { - for _, receiver := range app.receivers { - receiver.StopTraceReception() - } -} - func (app *Application) shutdownClosableComponents() { for _, closeFn := range app.closeFns { closeFn() diff --git a/translator/trace/jaeger/constants.go b/translator/trace/jaeger/constants.go index 08fa225e20e..ff6eb8d64c3 100644 --- a/translator/trace/jaeger/constants.go +++ b/translator/trace/jaeger/constants.go @@ -34,10 +34,6 @@ const ( ) var ( - errZeroTraceID = errors.New("OC span has an all zeros trace ID") - errNilTraceID = errors.New("OC trace ID is nil") - errWrongLenTraceID = errors.New("TraceID does not have 16 bytes") - errZeroSpanID = errors.New("OC span has an all zeros span ID") - errNilID = errors.New("OC ID is nil") - errWrongLenID = errors.New("ID does not have 8 bytes") + errZeroTraceID = errors.New("OC span has an all zeros trace ID") + errZeroSpanID = errors.New("OC span has an all zeros span ID") ) diff --git a/translator/trace/jaeger/jaegerthrift_to_protospan_test.go b/translator/trace/jaeger/jaegerthrift_to_protospan_test.go index eac21277050..185be540996 100644 --- a/translator/trace/jaeger/jaegerthrift_to_protospan_test.go +++ b/translator/trace/jaeger/jaegerthrift_to_protospan_test.go @@ -107,7 +107,7 @@ func TestThriftBatchToOCProto_Roundtrip(t *testing.T) { func TestThriftBatchToOCProto(t *testing.T) { const numOfFiles = 2 - for i := 1; i <= 2; i++ { + for i := 1; i <= numOfFiles; i++ { thriftInFile := fmt.Sprintf("./testdata/thrift_batch_%02d.json", i) jb := &jaeger.Batch{} if err := loadFromJSON(thriftInFile, jb); err != nil { diff --git a/translator/trace/jaeger/protospan_to_jaegerproto.go b/translator/trace/jaeger/protospan_to_jaegerproto.go index 02d0a019949..fc11791c8ac 100644 --- a/translator/trace/jaeger/protospan_to_jaegerproto.go +++ b/translator/trace/jaeger/protospan_to_jaegerproto.go @@ -455,7 +455,7 @@ func ocSpansToJaegerSpansProto(ocSpans []*tracepb.Span) ([]*jaeger.Span, error) } var spanID jaeger.SpanID - uSpanID, err := tracetranslator.BytesToUInt64SpanID(ocSpan.SpanId) + uSpanID, _ := tracetranslator.BytesToUInt64SpanID(ocSpan.SpanId) if uSpanID == 0 { return nil, errZeroSpanID } @@ -463,7 +463,7 @@ func ocSpansToJaegerSpansProto(ocSpans []*tracepb.Span) ([]*jaeger.Span, error) jReferences, err := ocLinksToJaegerReferencesProto(ocSpan.Links) if err != nil { - return nil, fmt.Errorf("Error converting OC links to Jaeger references: %v", err) + return nil, fmt.Errorf("error converting OC links to Jaeger references: %v", err) } // OC ParentSpanId can be nil/empty: only attempt conversion if not nil/empty. diff --git a/translator/trace/jaeger/protospan_to_jaegerthrift.go b/translator/trace/jaeger/protospan_to_jaegerthrift.go index 7f85981f4d5..da4a11fcbdf 100644 --- a/translator/trace/jaeger/protospan_to_jaegerthrift.go +++ b/translator/trace/jaeger/protospan_to_jaegerthrift.go @@ -162,7 +162,7 @@ func ocSpansToJaegerSpans(ocSpans []*tracepb.Span) ([]*jaeger.Span, error) { } jReferences, err := ocLinksToJaegerReferences(ocSpan.Links) if err != nil { - return nil, fmt.Errorf("Error converting OC links to Jaeger references: %v", err) + return nil, fmt.Errorf("error converting OC links to Jaeger references: %v", err) } spanID, err := tracetranslator.BytesToInt64SpanID(ocSpan.SpanId) if err != nil {