Skip to content

Commit

Permalink
Run fieldalignment -fix ./..., fix error and commit changes on non-…
Browse files Browse the repository at this point in the history
…test files
  • Loading branch information
mx-psi committed Nov 19, 2021
1 parent bdcb989 commit 1950238
Show file tree
Hide file tree
Showing 40 changed files with 165 additions and 347 deletions.
81 changes: 18 additions & 63 deletions config/configgrpc/configgrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,42 +68,16 @@ type KeepaliveClientConfig struct {

// GRPCClientSettings defines common settings for a gRPC client configuration.
type GRPCClientSettings struct {
// The target to which the exporter is going to send traces or metrics,
// using the gRPC protocol. The valid syntax is described at
// https://github.com/grpc/grpc/blob/master/doc/naming.md.
Endpoint string `mapstructure:"endpoint"`

// The compression key for supported compression types within collector.
Compression string `mapstructure:"compression"`

// TLSSetting struct exposes TLS client configuration.
TLSSetting configtls.TLSClientSetting `mapstructure:"tls,omitempty"`

// The keepalive parameters for gRPC client. See grpc.WithKeepaliveParams.
// (https://godoc.org/google.golang.org/grpc#WithKeepaliveParams).
Keepalive *KeepaliveClientConfig `mapstructure:"keepalive"`

// ReadBufferSize for gRPC client. See grpc.WithReadBufferSize.
// (https://godoc.org/google.golang.org/grpc#WithReadBufferSize).
ReadBufferSize int `mapstructure:"read_buffer_size"`

// WriteBufferSize for gRPC gRPC. See grpc.WithWriteBufferSize.
// (https://godoc.org/google.golang.org/grpc#WithWriteBufferSize).
WriteBufferSize int `mapstructure:"write_buffer_size"`

// WaitForReady parameter configures client to wait for ready state before sending data.
// (https://github.com/grpc/grpc/blob/master/doc/wait-for-ready.md)
WaitForReady bool `mapstructure:"wait_for_ready"`

// The headers associated with gRPC requests.
Headers map[string]string `mapstructure:"headers"`

// Sets the balancer in grpclb_policy to discover the servers. Default is pick_first.
// https://github.com/grpc/grpc-go/blob/master/examples/features/load_balancing/README.md
BalancerName string `mapstructure:"balancer_name"`

// Auth configuration for outgoing RPCs.
Auth *configauth.Authentication `mapstructure:"auth,omitempty"`
Headers map[string]string `mapstructure:"headers"`
Keepalive *KeepaliveClientConfig `mapstructure:"keepalive"`
Auth *configauth.Authentication `mapstructure:"auth,omitempty"`
Endpoint string `mapstructure:"endpoint"`
Compression string `mapstructure:"compression"`
BalancerName string `mapstructure:"balancer_name"`
TLSSetting configtls.TLSClientSetting `mapstructure:"tls,omitempty"`
ReadBufferSize int `mapstructure:"read_buffer_size"`
WriteBufferSize int `mapstructure:"write_buffer_size"`
WaitForReady bool `mapstructure:"wait_for_ready"`
}

// KeepaliveServerConfig is the configuration for keepalive.
Expand Down Expand Up @@ -133,33 +107,14 @@ type KeepaliveEnforcementPolicy struct {

// GRPCServerSettings defines common settings for a gRPC server configuration.
type GRPCServerSettings struct {
// Server net.Addr config. For transport only "tcp" and "unix" are valid options.
NetAddr confignet.NetAddr `mapstructure:",squash"`

// Configures the protocol to use TLS.
// The default value is nil, which will cause the protocol to not use TLS.
TLSSetting *configtls.TLSServerSetting `mapstructure:"tls,omitempty"`

// MaxRecvMsgSizeMiB sets the maximum size (in MiB) of messages accepted by the server.
MaxRecvMsgSizeMiB uint64 `mapstructure:"max_recv_msg_size_mib"`

// MaxConcurrentStreams sets the limit on the number of concurrent streams to each ServerTransport.
// It has effect only for streaming RPCs.
MaxConcurrentStreams uint32 `mapstructure:"max_concurrent_streams"`

// ReadBufferSize for gRPC server. See grpc.ReadBufferSize.
// (https://godoc.org/google.golang.org/grpc#ReadBufferSize).
ReadBufferSize int `mapstructure:"read_buffer_size"`

// WriteBufferSize for gRPC server. See grpc.WriteBufferSize.
// (https://godoc.org/google.golang.org/grpc#WriteBufferSize).
WriteBufferSize int `mapstructure:"write_buffer_size"`

// Keepalive anchor for all the settings related to keepalive.
Keepalive *KeepaliveServerConfig `mapstructure:"keepalive,omitempty"`

// Auth for this receiver
Auth *configauth.Authentication `mapstructure:"auth,omitempty"`
Keepalive *KeepaliveServerConfig `mapstructure:"keepalive,omitempty"`
TLSSetting *configtls.TLSServerSetting `mapstructure:"tls,omitempty"`
Auth *configauth.Authentication `mapstructure:"auth,omitempty"`
NetAddr confignet.NetAddr `mapstructure:",squash"`
MaxRecvMsgSizeMiB uint64 `mapstructure:"max_recv_msg_size_mib"`
ReadBufferSize int `mapstructure:"read_buffer_size"`
WriteBufferSize int `mapstructure:"write_buffer_size"`
MaxConcurrentStreams uint32 `mapstructure:"max_concurrent_streams"`
}

// SanitizedEndpoint strips the prefix of either http:// or https:// from configgrpc.GRPCClientSettings.Endpoint.
Expand Down
30 changes: 7 additions & 23 deletions config/confighttp/confighttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,14 @@ import (

// HTTPClientSettings defines settings for creating an HTTP client.
type HTTPClientSettings struct {
// The target URL to send data to (e.g.: http://some.url:9411/v1/traces).
Endpoint string `mapstructure:"endpoint"`

// TLSSetting struct exposes TLS client configuration.
TLSSetting configtls.TLSClientSetting `mapstructure:"tls,omitempty"`

// ReadBufferSize for HTTP client. See http.Transport.ReadBufferSize.
ReadBufferSize int `mapstructure:"read_buffer_size"`

// WriteBufferSize for HTTP client. See http.Transport.WriteBufferSize.
WriteBufferSize int `mapstructure:"write_buffer_size"`

// Timeout parameter configures `http.Client.Timeout`.
Timeout time.Duration `mapstructure:"timeout,omitempty"`

// Additional headers attached to each HTTP request sent by the client.
// Existing header values are overwritten if collision happens.
Headers map[string]string `mapstructure:"headers,omitempty"`

// Custom Round Tripper to allow for individual components to intercept HTTP requests
CustomRoundTripper func(next http.RoundTripper) (http.RoundTripper, error)

// Auth configuration for outgoing HTTP calls.
Auth *configauth.Authentication `mapstructure:"auth,omitempty"`
Auth *configauth.Authentication `mapstructure:"auth,omitempty"`
Headers map[string]string `mapstructure:"headers,omitempty"`
Endpoint string `mapstructure:"endpoint"`
TLSSetting configtls.TLSClientSetting `mapstructure:"tls,omitempty"`
ReadBufferSize int `mapstructure:"read_buffer_size"`
WriteBufferSize int `mapstructure:"write_buffer_size"`
Timeout time.Duration `mapstructure:"timeout,omitempty"`
}

// ToClient creates an HTTP client.
Expand Down
22 changes: 4 additions & 18 deletions config/configtls/configtls.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,10 @@ type TLSSetting struct {
// connections in addition to the common configurations. This should be used by
// components configuring TLS client connections.
type TLSClientSetting struct {
// squash ensures fields are correctly decoded in embedded struct.
TLSSetting `mapstructure:",squash"`

// These are config options specific to client connections.

// In gRPC when set to true, this is used to disable the client transport security.
// See https://godoc.org/google.golang.org/grpc#WithInsecure.
// In HTTP, this disables verifying the server's certificate chain and host name
// (InsecureSkipVerify in the tls Config). Please refer to
// https://godoc.org/crypto/tls#Config for more information.
// (optional, default false)
Insecure bool `mapstructure:"insecure"`
// InsecureSkipVerify will enable TLS but not verify the certificate.
InsecureSkipVerify bool `mapstructure:"insecure_skip_verify"`
// ServerName requested by client for virtual hosting.
// This sets the ServerName in the TLSConfig. Please refer to
// https://godoc.org/crypto/tls#Config for more information. (optional)
ServerName string `mapstructure:"server_name_override"`
TLSSetting `mapstructure:",squash"`
ServerName string `mapstructure:"server_name_override"`
Insecure bool `mapstructure:"insecure"`
InsecureSkipVerify bool `mapstructure:"insecure_skip_verify"`
}

// TLSServerSetting contains TLS configurations that are specific to server
Expand Down
17 changes: 4 additions & 13 deletions config/internal/configsource/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,20 +163,11 @@ type (
//
// For an overview about the internals of the Manager refer to the package README.md.
type Manager struct {
// configSources is map from ConfigSource names (as defined in the configuration)
// and the respective instances.
configSources map[string]configsource.ConfigSource
// watchers keeps track of all WatchForUpdate functions for retrieved values.
watchers []configsource.Watchable
// watchersWG is used to ensure that Close waits for all WatchForUpdate calls
// to complete.
watchersWG sync.WaitGroup
// watchingCh is used to notify users of the Manager that the WatchForUpdate function
// is ready and waiting for notifications.
watchingCh chan struct{}
// closeCh is used to notify the Manager WatchForUpdate function that the manager
// is being closed.
closeCh chan struct{}
watchingCh chan struct{}
closeCh chan struct{}
watchers []configsource.Watchable
watchersWG sync.WaitGroup
}

// NewManager creates a new instance of a Manager to be used to inject data from
Expand Down
24 changes: 6 additions & 18 deletions config/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,9 @@ import (

// Service defines the configurable components of the service.
type Service struct {
// Telemetry is the configuration for collector's own telemetry.
Telemetry ServiceTelemetry `mapstructure:"telemetry"`

// Extensions are the ordered list of extensions configured for the service.
Extensions []ComponentID `mapstructure:"extensions"`

// Pipelines are the set of data pipelines configured for the service.
Pipelines Pipelines `mapstructure:"pipelines"`
Pipelines Pipelines `mapstructure:"pipelines"`
Telemetry ServiceTelemetry `mapstructure:"telemetry"`
Extensions []ComponentID `mapstructure:"extensions"`
}

// ServiceTelemetry defines the configurable settings for service telemetry.
Expand All @@ -45,16 +40,9 @@ func (srvT *ServiceTelemetry) validate() error {
// This MUST be compatible with zap.Config. Cannot use directly zap.Config because
// the collector uses mapstructure and not yaml tags.
type ServiceTelemetryLogs struct {
// Level is the minimum enabled logging level.
Level zapcore.Level `mapstructure:"level"`

// Development puts the logger in development mode, which changes the
// behavior of DPanicLevel and takes stacktraces more liberally.
Development bool `mapstructure:"development"`

// Encoding sets the logger's encoding.
// Valid values are "json" and "console".
Encoding string `mapstructure:"encoding"`
Encoding string `mapstructure:"encoding"`
Level zapcore.Level `mapstructure:"level"`
Development bool `mapstructure:"development"`
}

func (srvTL *ServiceTelemetryLogs) validate() error {
Expand Down
6 changes: 3 additions & 3 deletions consumer/consumertest/sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import (
// stores all traces and allows querying them for testing.
type TracesSink struct {
nonMutatingConsumer
mu sync.Mutex
traces []pdata.Traces
spanCount int
mu sync.Mutex
}

var _ consumer.Traces = (*TracesSink)(nil)
Expand Down Expand Up @@ -74,9 +74,9 @@ func (ste *TracesSink) Reset() {
// stores all metrics and allows querying them for testing.
type MetricsSink struct {
nonMutatingConsumer
mu sync.Mutex
metrics []pdata.Metrics
dataPointCount int
mu sync.Mutex
}

var _ consumer.Metrics = (*MetricsSink)(nil)
Expand Down Expand Up @@ -122,9 +122,9 @@ func (sme *MetricsSink) Reset() {
// stores all logs and allows querying them for testing.
type LogsSink struct {
nonMutatingConsumer
mu sync.Mutex
logs []pdata.Logs
logRecordCount int
mu sync.Mutex
}

var _ consumer.Logs = (*LogsSink)(nil)
Expand Down
2 changes: 1 addition & 1 deletion exporter/exporterhelper/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ type CreateLogsExporter func(context.Context, component.ExporterCreateSettings,

type factory struct {
internalinterface.BaseInternal
cfgType config.Type
createDefaultConfig CreateDefaultConfig
createTracesExporter CreateTracesExporter
createMetricsExporter CreateMetricsExporter
createLogsExporter CreateLogsExporter
cfgType config.Type
}

// WithTraces overrides the default "error not supported" implementation for CreateTracesReceiver.
Expand Down
8 changes: 4 additions & 4 deletions exporter/exporterhelper/internal/bounded_memory_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ import (
// channels, with a special Reaper goroutine that wakes up when the queue is full and consumers
// the items from the top of the queue until its size drops back to maxSize
type boundedMemoryQueue struct {
workers int
stopWG sync.WaitGroup
onDroppedItem func(item interface{})
factory func() consumer
size *uatomic.Uint32
capacity *uatomic.Uint32
stopped *uatomic.Uint32
items *chan interface{}
onDroppedItem func(item interface{})
factory func() consumer
stopCh chan struct{}
workers int
stopWG sync.WaitGroup
}

// NewBoundedMemoryQueue constructs the new queue of specified capacity, and with an optional
Expand Down
2 changes: 1 addition & 1 deletion exporter/exporterhelper/queued_retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ type onRequestHandlingFinishedFunc func(*zap.Logger, request, error) error

type retrySender struct {
traceAttribute attribute.KeyValue
cfg RetrySettings
nextSender requestSender
stopCh chan struct{}
logger *zap.Logger
onTemporaryFailure onRequestHandlingFinishedFunc
cfg RetrySettings
}

// send implements the requestSender interface
Expand Down
6 changes: 3 additions & 3 deletions exporter/exporterhelper/queued_retry_inmemory.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ func DefaultQueueSettings() QueueSettings {
}

type queuedRetrySender struct {
fullName string
cfg QueueSettings
consumerSender requestSender
queue internal.ProducerConsumerQueue
logger *zap.Logger
retryStopCh chan struct{}
fullName string
traceAttributes []attribute.KeyValue
logger *zap.Logger
cfg QueueSettings
}

func newQueuedRetrySender(id config.ComponentID, _ config.DataType, qCfg QueueSettings, rCfg RetrySettings, _ internal.RequestUnmarshaler, nextSender requestSender, logger *zap.Logger) *queuedRetrySender {
Expand Down
9 changes: 4 additions & 5 deletions exporter/otlpexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ import (

// Config defines configuration for OpenCensus exporter.
type Config struct {
config.ExporterSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
exporterhelper.TimeoutSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.
exporterhelper.QueueSettings `mapstructure:"sending_queue"`
config.ExporterSettings `mapstructure:",squash"`
configgrpc.GRPCClientSettings `mapstructure:",squash"`
exporterhelper.RetrySettings `mapstructure:"retry_on_failure"`

configgrpc.GRPCClientSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.
exporterhelper.QueueSettings `mapstructure:"sending_queue"`
exporterhelper.TimeoutSettings `mapstructure:",squash"`
}

var _ config.Exporter = (*Config)(nil)
Expand Down
10 changes: 3 additions & 7 deletions exporter/otlpexporter/otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,14 @@ import (
)

type exporter struct {
// Input configuration.
config *Config

// gRPC clients and connection.
traceExporter otlpgrpc.TracesClient
settings component.TelemetrySettings
metricExporter otlpgrpc.MetricsClient
logExporter otlpgrpc.LogsClient
traceExporter otlpgrpc.TracesClient
config *Config
clientConn *grpc.ClientConn
metadata metadata.MD
callOptions []grpc.CallOption

settings component.TelemetrySettings
}

// Crete new exporter and start it. The exporter will begin connecting but
Expand Down
23 changes: 7 additions & 16 deletions exporter/otlphttpexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,14 @@ import (

// Config defines configuration for OTLP/HTTP exporter.
type Config struct {
config.ExporterSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
confighttp.HTTPClientSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.
exporterhelper.QueueSettings `mapstructure:"sending_queue"`
config.ExporterSettings `mapstructure:",squash"`
TracesEndpoint string `mapstructure:"traces_endpoint"`
MetricsEndpoint string `mapstructure:"metrics_endpoint"`
LogsEndpoint string `mapstructure:"logs_endpoint"`
Compression string `mapstructure:"compression"`
confighttp.HTTPClientSettings `mapstructure:",squash"`
exporterhelper.RetrySettings `mapstructure:"retry_on_failure"`

// The URL to send traces to. If omitted the Endpoint + "/v1/traces" will be used.
TracesEndpoint string `mapstructure:"traces_endpoint"`

// The URL to send metrics to. If omitted the Endpoint + "/v1/metrics" will be used.
MetricsEndpoint string `mapstructure:"metrics_endpoint"`

// The URL to send logs to. If omitted the Endpoint + "/v1/logs" will be used.
LogsEndpoint string `mapstructure:"logs_endpoint"`

// The compression key for supported compression types within
// collector. Currently the only supported mode is `gzip`.
Compression string `mapstructure:"compression"`
exporterhelper.QueueSettings `mapstructure:"sending_queue"`
}

var _ config.Exporter = (*Config)(nil)
Expand Down
Loading

0 comments on commit 1950238

Please sign in to comment.