Skip to content

Commit

Permalink
Merge branch 'main' into msg/fix-snappy-lazy-read
Browse files Browse the repository at this point in the history
  • Loading branch information
MovieStoreGuy authored Sep 25, 2024
2 parents a80b8fa + 04379eb commit b3318bf
Show file tree
Hide file tree
Showing 38 changed files with 430 additions and 245 deletions.
20 changes: 20 additions & 0 deletions .chloggen/deprecate-address.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: 'deprecation'

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: service/telemetry

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Deprecate service::telemetry::metrics::address in favor of service::telemetry::metrics::readers.

# One or more tracking issues or pull requests related to the change
issues: [11205]

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
25 changes: 25 additions & 0 deletions .chloggen/exporterhelper-remove-deprecated.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: exporterhelper

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Removed deprecated `QueueTimeout`/`TimeoutSettings` aliases in favor of `QueueConfig`/`TimeoutConfig`.

# One or more tracking issues or pull requests related to the change
issues: [11264, 6767]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext: "`NewDefaultQueueSettings` and `NewDefaultTimeoutSettings` have been similarly renamed."

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [api]
25 changes: 25 additions & 0 deletions .chloggen/json-decoded-flag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: 'bug_fix'

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: 'pdata'

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Unmarshal Span and SpanLink flags from JSON"

# One or more tracking issues or pull requests related to the change
issues: [11267]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ check-contrib:
@$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit \
-replace go.opentelemetry.io/collector=$(CURDIR) \
-replace go.opentelemetry.io/collector/client=$(CURDIR)/client \
-replace go.opentelemetry.io/collector/cmd/mdatagen=$(CURDIR)/cmd/mdatagen \
-replace go.opentelemetry.io/collector/component=$(CURDIR)/component \
-replace go.opentelemetry.io/collector/component/componentprofiles=$(CURDIR)/component/componentprofiles \
-replace go.opentelemetry.io/collector/component/componentstatus=$(CURDIR)/component/componentstatus \
Expand Down Expand Up @@ -333,6 +334,7 @@ restore-contrib:
@$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit \
-dropreplace go.opentelemetry.io/collector \
-dropreplace go.opentelemetry.io/collector/client \
-dropreplace go.opentelemetry.io/collector/cmd/mdatagen \
-dropreplace go.opentelemetry.io/collector/component \
-dropreplace go.opentelemetry.io/collector/component/componentprofiles \
-dropreplace go.opentelemetry.io/collector/component/componentstatus \
Expand Down
4 changes: 2 additions & 2 deletions cmd/builder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ This is the recommended installation method. Download the binary for your respec

You need to have a `go` compiler in your PATH. Run the following command to install the latest version:

```
```console
go install go.opentelemetry.io/collector/cmd/builder@latest
```

If installing through this method the binary will be called `builder`. Binaries installed through this method [will incorrectly show `dev` as their version](https://github.com/open-telemetry/opentelemetry-collector/issues/8691).
If installing through this method the binary will be called `builder`.

## Running

Expand Down
18 changes: 10 additions & 8 deletions config/configgrpc/configgrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,16 @@ func NewDefaultServerConfig() *ServerConfig {
}
}

func (gcs *ClientConfig) Validate() error {
if gcs.BalancerName != "" {
if balancer.Get(gcs.BalancerName) == nil {
return fmt.Errorf("invalid balancer_name: %s", gcs.BalancerName)
}
}

return nil
}

// sanitizedEndpoint strips the prefix of either http:// or https:// from configgrpc.ClientConfig.Endpoint.
func (gcs *ClientConfig) sanitizedEndpoint() string {
switch {
Expand Down Expand Up @@ -334,10 +344,6 @@ func (gcs *ClientConfig) getGrpcDialOptions(
}

if gcs.BalancerName != "" {
valid := validateBalancerName(gcs.BalancerName)
if !valid {
return nil, fmt.Errorf("invalid balancer_name: %s", gcs.BalancerName)
}
opts = append(opts, grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"loadBalancingPolicy":"%s"}`, gcs.BalancerName)))
}

Expand All @@ -363,10 +369,6 @@ func (gcs *ClientConfig) getGrpcDialOptions(
return opts, nil
}

func validateBalancerName(balancerName string) bool {
return balancer.Get(balancerName) != nil
}

func (gss *ServerConfig) Validate() error {
if gss.MaxRecvMsgSizeMiB*1024*1024 < 0 {
return fmt.Errorf("invalid max_recv_msg_size_mib value, must be between 1 and %d: %d", math.MaxInt/1024/1024, gss.MaxRecvMsgSizeMiB)
Expand Down
84 changes: 33 additions & 51 deletions config/configgrpc/configgrpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"go.uber.org/zap"
"go.uber.org/zap/zaptest/observer"
"google.golang.org/grpc"
"google.golang.org/grpc/balancer"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/peer"
Expand Down Expand Up @@ -92,21 +91,6 @@ func TestNewDefaultServerConfig(t *testing.T) {
assert.Equal(t, expected, result)
}

// testBalancerBuilder facilitates testing validateBalancerName().
type testBalancerBuilder struct{}

func (testBalancerBuilder) Build(balancer.ClientConn, balancer.BuildOptions) balancer.Balancer {
return nil
}

func (testBalancerBuilder) Name() string {
return "configgrpc_balancer_test"
}

func init() {
balancer.Register(testBalancerBuilder{})
}

var (
componentID = component.MustNewID("component")
testAuthID = component.MustNewID("testauth")
Expand Down Expand Up @@ -333,7 +317,7 @@ func TestGrpcServerValidate(t *testing.T) {
t.Run(tt.err, func(t *testing.T) {
err := tt.gss.Validate()
require.Error(t, err)
assert.Regexp(t, tt.err, err)
assert.ErrorContains(t, err, tt.err)
})
}
}
Expand Down Expand Up @@ -390,18 +374,37 @@ func TestGrpcServerAuthSettings(t *testing.T) {
assert.NotNil(t, srv)
}

func TestGRPCClientSettingsError(t *testing.T) {
tt, err := componenttest.SetupTelemetry(componentID)
require.NoError(t, err)
t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) })
func TestGrpcClientConfigInvalidBalancer(t *testing.T) {
settings := ClientConfig{
Headers: map[string]configopaque.String{
"test": "test",
},
Endpoint: "localhost:1234",
Compression: "gzip",
TLSSetting: configtls.ClientConfig{
Insecure: false,
},
Keepalive: &KeepaliveClientConfig{
Time: time.Second,
Timeout: time.Second,
PermitWithoutStream: true,
},
ReadBufferSize: 1024,
WriteBufferSize: 1024,
WaitForReady: true,
BalancerName: "test",
}
assert.ErrorContains(t, settings.Validate(), "invalid balancer_name: test")
}

func TestGRPCClientSettingsError(t *testing.T) {
tests := []struct {
settings ClientConfig
err string
host component.Host
}{
{
err: "^failed to load TLS config: failed to load CA CertPool File: failed to load cert /doesnt/exist:",
err: "failed to load TLS config: failed to load CA CertPool File: failed to load cert /doesnt/exist:",
settings: ClientConfig{
Headers: nil,
Endpoint: "",
Expand All @@ -417,7 +420,7 @@ func TestGRPCClientSettingsError(t *testing.T) {
},
},
{
err: "^failed to load TLS config: failed to load TLS cert and key: for auth via TLS, provide both certificate and key, or neither",
err: "failed to load TLS config: failed to load TLS cert and key: for auth via TLS, provide both certificate and key, or neither",
settings: ClientConfig{
Headers: nil,
Endpoint: "",
Expand All @@ -432,28 +435,6 @@ func TestGRPCClientSettingsError(t *testing.T) {
Keepalive: nil,
},
},
{
err: "invalid balancer_name: test",
settings: ClientConfig{
Headers: map[string]configopaque.String{
"test": "test",
},
Endpoint: "localhost:1234",
Compression: "gzip",
TLSSetting: configtls.ClientConfig{
Insecure: false,
},
Keepalive: &KeepaliveClientConfig{
Time: time.Second,
Timeout: time.Second,
PermitWithoutStream: true,
},
ReadBufferSize: 1024,
WriteBufferSize: 1024,
WaitForReady: true,
BalancerName: "test",
},
},
{
err: "failed to resolve authenticator \"doesntexist\": authenticator not found",
settings: ClientConfig{
Expand Down Expand Up @@ -506,9 +487,10 @@ func TestGRPCClientSettingsError(t *testing.T) {
}
for _, test := range tests {
t.Run(test.err, func(t *testing.T) {
_, err := test.settings.ToClientConn(context.Background(), test.host, tt.TelemetrySettings())
require.NoError(t, test.settings.Validate())
_, err := test.settings.ToClientConn(context.Background(), test.host, componenttest.NewNopTelemetrySettings())
require.Error(t, err)
assert.Regexp(t, test.err, err)
assert.ErrorContains(t, err, test.err)
})
}
}
Expand Down Expand Up @@ -587,7 +569,7 @@ func TestGRPCServerSettingsError(t *testing.T) {
err string
}{
{
err: "^failed to load TLS config: failed to load CA CertPool File: failed to load cert /doesnt/exist:",
err: "failed to load TLS config: failed to load CA CertPool File: failed to load cert /doesnt/exist:",
settings: ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: "127.0.0.1:1234",
Expand All @@ -601,7 +583,7 @@ func TestGRPCServerSettingsError(t *testing.T) {
},
},
{
err: "^failed to load TLS config: failed to load TLS cert and key: for auth via TLS, provide both certificate and key, or neither",
err: "failed to load TLS config: failed to load TLS cert and key: for auth via TLS, provide both certificate and key, or neither",
settings: ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: "127.0.0.1:1234",
Expand All @@ -615,7 +597,7 @@ func TestGRPCServerSettingsError(t *testing.T) {
},
},
{
err: "^failed to load client CA CertPool: failed to load CA /doesnt/exist:",
err: "failed to load client CA CertPool: failed to load CA /doesnt/exist:",
settings: ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: "127.0.0.1:1234",
Expand All @@ -630,7 +612,7 @@ func TestGRPCServerSettingsError(t *testing.T) {
for _, test := range tests {
t.Run(test.err, func(t *testing.T) {
_, err := test.settings.ToServer(context.Background(), componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings())
assert.Regexp(t, test.err, err)
assert.ErrorContains(t, err, test.err)
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions exporter/exporterhelper/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ func WithShutdown(shutdown component.ShutdownFunc) Option {
return internal.WithShutdown(shutdown)
}

// WithTimeout overrides the default TimeoutSettings for an exporter.
// The default TimeoutSettings is 5 seconds.
// WithTimeout overrides the default TimeoutConfig for an exporter.
// The default TimeoutConfig is 5 seconds.
func WithTimeout(timeoutConfig TimeoutConfig) Option {
return internal.WithTimeout(timeoutConfig)
}
Expand Down
8 changes: 0 additions & 8 deletions exporter/exporterhelper/internal/queue_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ import (

const defaultQueueSize = 1000

// Deprecated: [v0.110.0] Use QueueConfig instead.
type QueueSettings = QueueConfig

// QueueConfig defines configuration for queueing batches before sending to the consumerSender.
type QueueConfig struct {
// Enabled indicates whether to not enqueue batches before sending to the consumerSender.
Expand All @@ -40,11 +37,6 @@ type QueueConfig struct {
StorageID *component.ID `mapstructure:"storage"`
}

// Deprecated: [v0.110.0] Use NewDefaultQueueConfig instead.
func NewDefaultQueueSettings() QueueSettings {
return NewDefaultQueueConfig()
}

// NewDefaultQueueConfig returns the default config for QueueConfig.
func NewDefaultQueueConfig() QueueConfig {
return QueueConfig{
Expand Down
8 changes: 0 additions & 8 deletions exporter/exporterhelper/queue_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,9 @@ package exporterhelper // import "go.opentelemetry.io/collector/exporter/exporte

import "go.opentelemetry.io/collector/exporter/exporterhelper/internal"

// Deprecated: [v0.110.0] Use QueueConfig instead.
type QueueSettings = internal.QueueConfig

// QueueConfig defines configuration for queueing batches before sending to the consumerSender.
type QueueConfig = internal.QueueConfig

// Deprecated: [v0.110.0] Use NewDefaultQueueConfig instead.
func NewDefaultQueueSettings() QueueSettings {
return internal.NewDefaultQueueConfig()
}

// NewDefaultQueueConfig returns the default config for QueueConfig.
func NewDefaultQueueConfig() QueueConfig {
return internal.NewDefaultQueueConfig()
Expand Down
8 changes: 0 additions & 8 deletions exporter/exporterhelper/timeout_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,8 @@ import (
"go.opentelemetry.io/collector/exporter/exporterhelper/internal"
)

// Deprecated: [v0.110.0] Use TimeoutConfig instead.
type TimeoutSettings = TimeoutConfig

type TimeoutConfig = internal.TimeoutConfig

// Deprecated: [v0.110.0] Use NewDefaultTimeoutConfig instead.
func NewDefaultTimeoutSettings() TimeoutSettings {
return internal.NewDefaultTimeoutConfig()
}

// NewDefaultTimeoutConfig returns the default config for TimeoutConfig.
func NewDefaultTimeoutConfig() TimeoutConfig {
return internal.NewDefaultTimeoutConfig()
Expand Down
4 changes: 2 additions & 2 deletions otelcol/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,8 @@ func TestCollectorRun(t *testing.T) {
tests := []struct {
file string
}{
{file: "otelcol-nometrics.yaml"},
{file: "otelcol-noaddress.yaml"},
{file: "otelcol-noreaders.yaml"},
{file: "otelcol-emptyreaders.yaml"},
}

for _, tt := range tests {
Expand Down
Loading

0 comments on commit b3318bf

Please sign in to comment.