Skip to content

Commit

Permalink
More lint from opentelemetry-collector-contrib PR 32015 (#168)
Browse files Browse the repository at this point in the history
I missed some linters in the last pass, (somehow).
These changes match the merge in
open-telemetry/opentelemetry-collector-contrib@0835778.
  • Loading branch information
jmacd authored Mar 28, 2024
1 parent f846b28 commit 9225010
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 282 deletions.
6 changes: 0 additions & 6 deletions collector/receiver/otelarrowreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ import (
"go.opentelemetry.io/collector/config/configgrpc"
)

const (
// Confmap values.
protoGRPC = "protocols::grpc"
protoArrowMemoryLimitMiB = "protocols::arrow::memory_limit_mib"
)

// Protocols is the configuration for the supported protocols.
type Protocols struct {
GRPC configgrpc.ServerConfig `mapstructure:"grpc"`
Expand Down
6 changes: 3 additions & 3 deletions collector/receiver/otelarrowreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ func TestUnmarshalConfig(t *testing.T) {
GRPC: configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: "0.0.0.0:4317",
Transport: "tcp",
Transport: confignet.TransportTypeTCP,
},
TLSSetting: &configtls.TLSServerSetting{
TLSSetting: configtls.TLSSetting{
TLSSetting: &configtls.ServerConfig{
TLSSetting: configtls.Config{
CertFile: "test.crt",
KeyFile: "test.key",
},
Expand Down
122 changes: 0 additions & 122 deletions collector/receiver/otelarrowreceiver/encoder.go

This file was deleted.

14 changes: 4 additions & 10 deletions collector/receiver/otelarrowreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func createDefaultConfig() component.Config {
GRPC: configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: defaultGRPCEndpoint,
Transport: "tcp",
Transport: confignet.TransportTypeTCP,
},
// We almost write 0 bytes, so no need to tune WriteBufferSize.
ReadBufferSize: 512 * 1024,
Expand All @@ -66,9 +66,7 @@ func createTraces(
return nil, err
}

if err = r.Unwrap().registerTraceConsumer(nextConsumer); err != nil {
return nil, err
}
r.Unwrap().registerTraceConsumer(nextConsumer)
return r, nil
}

Expand All @@ -87,9 +85,7 @@ func createMetrics(
return nil, err
}

if err = r.Unwrap().registerMetricsConsumer(consumer); err != nil {
return nil, err
}
r.Unwrap().registerMetricsConsumer(consumer)
return r, nil
}

Expand All @@ -108,9 +104,7 @@ func createLog(
return nil, err
}

if err = r.Unwrap().registerLogsConsumer(consumer); err != nil {
return nil, err
}
r.Unwrap().registerLogsConsumer(consumer)
return r, nil
}

Expand Down
12 changes: 6 additions & 6 deletions collector/receiver/otelarrowreceiver/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestCreateTracesReceiver(t *testing.T) {
defaultGRPCSettings := configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: testutil.GetAvailableLocalAddress(t),
Transport: "tcp",
Transport: confignet.TransportTypeTCP,
},
}

Expand All @@ -69,7 +69,7 @@ func TestCreateTracesReceiver(t *testing.T) {
GRPC: configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: "localhost:112233",
Transport: "tcp",
Transport: confignet.TransportTypeTCP,
},
},
},
Expand Down Expand Up @@ -101,7 +101,7 @@ func TestCreateMetricReceiver(t *testing.T) {
defaultGRPCSettings := configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: testutil.GetAvailableLocalAddress(t),
Transport: "tcp",
Transport: confignet.TransportTypeTCP,
},
}

Expand All @@ -125,7 +125,7 @@ func TestCreateMetricReceiver(t *testing.T) {
GRPC: configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: "327.0.0.1:1122",
Transport: "tcp",
Transport: confignet.TransportTypeTCP,
},
},
},
Expand Down Expand Up @@ -156,7 +156,7 @@ func TestCreateLogReceiver(t *testing.T) {
defaultGRPCSettings := configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: testutil.GetAvailableLocalAddress(t),
Transport: "tcp",
Transport: confignet.TransportTypeTCP,
},
}

Expand All @@ -183,7 +183,7 @@ func TestCreateLogReceiver(t *testing.T) {
GRPC: configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: "327.0.0.1:1122",
Transport: "tcp",
Transport: confignet.TransportTypeTCP,
},
},
},
Expand Down
7 changes: 3 additions & 4 deletions collector/receiver/otelarrowreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ go 1.21
toolchain go1.21.4

require (
github.com/gogo/protobuf v1.3.2
github.com/klauspost/compress v1.17.7
github.com/open-telemetry/otel-arrow v0.20.0
github.com/open-telemetry/otel-arrow/collector v0.20.0
github.com/stretchr/testify v1.9.0
Expand All @@ -22,15 +20,13 @@ require (
go.opentelemetry.io/collector/extension/auth v0.97.0
go.opentelemetry.io/collector/pdata v1.4.0
go.opentelemetry.io/collector/receiver v0.97.0
go.opentelemetry.io/collector/semconv v0.97.0
go.opentelemetry.io/otel v1.24.0
go.opentelemetry.io/otel/metric v1.24.0
go.opentelemetry.io/otel/trace v1.24.0
go.uber.org/mock v0.4.0
go.uber.org/multierr v1.11.0
go.uber.org/zap v1.27.0
golang.org/x/net v0.22.0
google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c
google.golang.org/grpc v1.62.1
)

Expand All @@ -48,12 +44,14 @@ require (
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/google/flatbuffers v23.5.26+incompatible // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.7 // indirect
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/knadh/koanf/maps v0.1.1 // indirect
github.com/knadh/koanf/providers/confmap v0.1.0 // indirect
Expand Down Expand Up @@ -86,6 +84,7 @@ require (
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.15.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
2 changes: 0 additions & 2 deletions collector/receiver/otelarrowreceiver/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ go.opentelemetry.io/collector/pdata v1.4.0 h1:cA6Pr7Z2V7mE+i7FmYpavX7nefzd6H4CIC
go.opentelemetry.io/collector/pdata v1.4.0/go.mod h1:0Ttp4wQinhV5oJTd9MjyvUegmZBO9O0nrlh/+EDLw+Q=
go.opentelemetry.io/collector/receiver v0.97.0 h1:ozzE5MhIPtfnYA/UKB/NCcgxSmeLqdwErboi6B/IpLQ=
go.opentelemetry.io/collector/receiver v0.97.0/go.mod h1:1TCN9DRuB45+xKqlwv4BMQR6qXgaJeSSNezFTJhmDUo=
go.opentelemetry.io/collector/semconv v0.97.0 h1:iF3nTfThbiOwz7o5Pocn0dDnDoffd18ijDuf6Mwzi1s=
go.opentelemetry.io/collector/semconv v0.97.0/go.mod h1:8ElcRZ8Cdw5JnvhTOQOdYizkJaQ10Z2fS+R6djOnj6A=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 h1:4Pp6oUg3+e/6M4C0A/3kJ2VYa++dsWVTtGgLVj5xtHg=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0/go.mod h1:Mjt1i1INqiaoZOMGR1RIUJN+i3ChKoFRqzrRQhlkbs0=
go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo=
Expand Down
9 changes: 5 additions & 4 deletions collector/receiver/otelarrowreceiver/internal/arrow/arrow.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ func (r *Receiver) anyStream(serverStream anyStreamServer, method string) (retEr

if err != nil {
// client called CloseSend()
if err == io.EOF {
if errors.Is(err, io.EOF) {
status := &arrowpb.BatchStatus{}
status.StatusCode = arrowpb.StatusCode_CANCELED
err = serverStream.Send(status)
Expand Down Expand Up @@ -436,13 +436,14 @@ func (r *Receiver) processAndConsume(ctx context.Context, method string, arrowCo
status.StatusCode = arrowpb.StatusCode_OK
} else {
status.StatusMessage = err.Error()
if errors.Is(err, arrowRecord.ErrConsumerMemoryLimit) {
switch {
case errors.Is(err, arrowRecord.ErrConsumerMemoryLimit):
r.telemetry.Logger.Error("arrow resource exhausted", zap.Error(err))
status.StatusCode = arrowpb.StatusCode_RESOURCE_EXHAUSTED
} else if consumererror.IsPermanent(err) {
case consumererror.IsPermanent(err):
r.telemetry.Logger.Error("arrow data error", zap.Error(err))
status.StatusCode = arrowpb.StatusCode_INVALID_ARGUMENT
} else {
default:
r.telemetry.Logger.Debug("arrow consumer error", zap.Error(err))
status.StatusCode = arrowpb.StatusCode_UNAVAILABLE
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (c compareJSONLogs) MarshalJSON() ([]byte, error) {

type consumeResult struct {
Ctx context.Context
Data interface{}
Data any
}

type commonTestCase struct {
Expand Down Expand Up @@ -452,7 +452,7 @@ func TestReceiverSendError(t *testing.T) {
func TestReceiverConsumeError(t *testing.T) {
stdTesting := otelAssert.NewStdUnitTest(t)

data := []interface{}{
data := []any{
testdata.GenerateTraces(2),
testdata.GenerateMetrics(2),
testdata.GenerateLogs(2),
Expand Down Expand Up @@ -512,7 +512,7 @@ func TestReceiverConsumeError(t *testing.T) {
}

func TestReceiverInvalidData(t *testing.T) {
data := []interface{}{
data := []any{
testdata.GenerateTraces(2),
testdata.GenerateMetrics(2),
testdata.GenerateLogs(2),
Expand Down Expand Up @@ -550,7 +550,7 @@ func TestReceiverInvalidData(t *testing.T) {
}

func TestReceiverMemoryLimit(t *testing.T) {
data := []interface{}{
data := []any{
testdata.GenerateTraces(2),
testdata.GenerateMetrics(2),
testdata.GenerateLogs(2),
Expand Down
Loading

0 comments on commit 9225010

Please sign in to comment.