Skip to content

Commit 30c584f

Browse files
authored
Merge branch 'main' into add_tel_int_tests
2 parents 29a1418 + 431fd11 commit 30c584f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1002
-608
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: 'breaking'
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: service/telemetry
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Change default metrics address to "localhost:8888" instead of ":8888"
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [11251]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext: This behavior can be disabled by disabling the feature gate 'telemetry.UseLocalHostAsDefaultMetricsAddress'.
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: [user, api]

.chloggen/deprecate-address.yaml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: 'deprecation'
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: service/telemetry
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Deprecate service::telemetry::metrics::address in favor of service::telemetry::metrics::readers.
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [11205]
14+
15+
# Optional: The change log or logs in which this entry should be included.
16+
# e.g. '[user]' or '[user, api]'
17+
# Include 'user' if the change is relevant to end users.
18+
# Include 'api' if there is a change to a library API.
19+
# Default: '[user]'
20+
change_logs: [user]

.chloggen/json-decoded-flag.yaml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: 'bug_fix'
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: 'pdata'
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: "Unmarshal Span and SpanLink flags from JSON"
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [11267]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: []
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: confighttp
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Snappy compression to lazy read for memory efficiency
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [11177]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: [user]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: confmap
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Allow using any YAML structure as a string when loading configuration including time.Time formats
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [10659]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext: |
19+
Previously, fields with time.Time formats could not be used as strings in configurations
20+
21+
# Optional: The change log or logs in which this entry should be included.
22+
# e.g. '[user]' or '[user, api]'
23+
# Include 'user' if the change is relevant to end users.
24+
# Include 'api' if there is a change to a library API.
25+
# Default: '[user]'
26+
change_logs: []

Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ check-contrib:
262262
@$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit \
263263
-replace go.opentelemetry.io/collector=$(CURDIR) \
264264
-replace go.opentelemetry.io/collector/client=$(CURDIR)/client \
265+
-replace go.opentelemetry.io/collector/cmd/mdatagen=$(CURDIR)/cmd/mdatagen \
265266
-replace go.opentelemetry.io/collector/component=$(CURDIR)/component \
266267
-replace go.opentelemetry.io/collector/component/componentprofiles=$(CURDIR)/component/componentprofiles \
267268
-replace go.opentelemetry.io/collector/component/componentstatus=$(CURDIR)/component/componentstatus \
@@ -333,6 +334,7 @@ restore-contrib:
333334
@$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit \
334335
-dropreplace go.opentelemetry.io/collector \
335336
-dropreplace go.opentelemetry.io/collector/client \
337+
-dropreplace go.opentelemetry.io/collector/cmd/mdatagen \
336338
-dropreplace go.opentelemetry.io/collector/component \
337339
-dropreplace go.opentelemetry.io/collector/component/componentprofiles \
338340
-dropreplace go.opentelemetry.io/collector/component/componentstatus \

config/configgrpc/configgrpc.go

+10-8
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,16 @@ func NewDefaultServerConfig() *ServerConfig {
202202
}
203203
}
204204

205+
func (gcs *ClientConfig) Validate() error {
206+
if gcs.BalancerName != "" {
207+
if balancer.Get(gcs.BalancerName) == nil {
208+
return fmt.Errorf("invalid balancer_name: %s", gcs.BalancerName)
209+
}
210+
}
211+
212+
return nil
213+
}
214+
205215
// sanitizedEndpoint strips the prefix of either http:// or https:// from configgrpc.ClientConfig.Endpoint.
206216
func (gcs *ClientConfig) sanitizedEndpoint() string {
207217
switch {
@@ -334,10 +344,6 @@ func (gcs *ClientConfig) getGrpcDialOptions(
334344
}
335345

336346
if gcs.BalancerName != "" {
337-
valid := validateBalancerName(gcs.BalancerName)
338-
if !valid {
339-
return nil, fmt.Errorf("invalid balancer_name: %s", gcs.BalancerName)
340-
}
341347
opts = append(opts, grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"loadBalancingPolicy":"%s"}`, gcs.BalancerName)))
342348
}
343349

@@ -363,10 +369,6 @@ func (gcs *ClientConfig) getGrpcDialOptions(
363369
return opts, nil
364370
}
365371

366-
func validateBalancerName(balancerName string) bool {
367-
return balancer.Get(balancerName) != nil
368-
}
369-
370372
func (gss *ServerConfig) Validate() error {
371373
if gss.MaxRecvMsgSizeMiB*1024*1024 < 0 {
372374
return fmt.Errorf("invalid max_recv_msg_size_mib value, must be between 1 and %d: %d", math.MaxInt/1024/1024, gss.MaxRecvMsgSizeMiB)

config/configgrpc/configgrpc_test.go

+33-51
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"go.uber.org/zap"
1919
"go.uber.org/zap/zaptest/observer"
2020
"google.golang.org/grpc"
21-
"google.golang.org/grpc/balancer"
2221
"google.golang.org/grpc/codes"
2322
"google.golang.org/grpc/metadata"
2423
"google.golang.org/grpc/peer"
@@ -92,21 +91,6 @@ func TestNewDefaultServerConfig(t *testing.T) {
9291
assert.Equal(t, expected, result)
9392
}
9493

95-
// testBalancerBuilder facilitates testing validateBalancerName().
96-
type testBalancerBuilder struct{}
97-
98-
func (testBalancerBuilder) Build(balancer.ClientConn, balancer.BuildOptions) balancer.Balancer {
99-
return nil
100-
}
101-
102-
func (testBalancerBuilder) Name() string {
103-
return "configgrpc_balancer_test"
104-
}
105-
106-
func init() {
107-
balancer.Register(testBalancerBuilder{})
108-
}
109-
11094
var (
11195
componentID = component.MustNewID("component")
11296
testAuthID = component.MustNewID("testauth")
@@ -333,7 +317,7 @@ func TestGrpcServerValidate(t *testing.T) {
333317
t.Run(tt.err, func(t *testing.T) {
334318
err := tt.gss.Validate()
335319
require.Error(t, err)
336-
assert.Regexp(t, tt.err, err)
320+
assert.ErrorContains(t, err, tt.err)
337321
})
338322
}
339323
}
@@ -390,18 +374,37 @@ func TestGrpcServerAuthSettings(t *testing.T) {
390374
assert.NotNil(t, srv)
391375
}
392376

393-
func TestGRPCClientSettingsError(t *testing.T) {
394-
tt, err := componenttest.SetupTelemetry(componentID)
395-
require.NoError(t, err)
396-
t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) })
377+
func TestGrpcClientConfigInvalidBalancer(t *testing.T) {
378+
settings := ClientConfig{
379+
Headers: map[string]configopaque.String{
380+
"test": "test",
381+
},
382+
Endpoint: "localhost:1234",
383+
Compression: "gzip",
384+
TLSSetting: configtls.ClientConfig{
385+
Insecure: false,
386+
},
387+
Keepalive: &KeepaliveClientConfig{
388+
Time: time.Second,
389+
Timeout: time.Second,
390+
PermitWithoutStream: true,
391+
},
392+
ReadBufferSize: 1024,
393+
WriteBufferSize: 1024,
394+
WaitForReady: true,
395+
BalancerName: "test",
396+
}
397+
assert.ErrorContains(t, settings.Validate(), "invalid balancer_name: test")
398+
}
397399

400+
func TestGRPCClientSettingsError(t *testing.T) {
398401
tests := []struct {
399402
settings ClientConfig
400403
err string
401404
host component.Host
402405
}{
403406
{
404-
err: "^failed to load TLS config: failed to load CA CertPool File: failed to load cert /doesnt/exist:",
407+
err: "failed to load TLS config: failed to load CA CertPool File: failed to load cert /doesnt/exist:",
405408
settings: ClientConfig{
406409
Headers: nil,
407410
Endpoint: "",
@@ -417,7 +420,7 @@ func TestGRPCClientSettingsError(t *testing.T) {
417420
},
418421
},
419422
{
420-
err: "^failed to load TLS config: failed to load TLS cert and key: for auth via TLS, provide both certificate and key, or neither",
423+
err: "failed to load TLS config: failed to load TLS cert and key: for auth via TLS, provide both certificate and key, or neither",
421424
settings: ClientConfig{
422425
Headers: nil,
423426
Endpoint: "",
@@ -432,28 +435,6 @@ func TestGRPCClientSettingsError(t *testing.T) {
432435
Keepalive: nil,
433436
},
434437
},
435-
{
436-
err: "invalid balancer_name: test",
437-
settings: ClientConfig{
438-
Headers: map[string]configopaque.String{
439-
"test": "test",
440-
},
441-
Endpoint: "localhost:1234",
442-
Compression: "gzip",
443-
TLSSetting: configtls.ClientConfig{
444-
Insecure: false,
445-
},
446-
Keepalive: &KeepaliveClientConfig{
447-
Time: time.Second,
448-
Timeout: time.Second,
449-
PermitWithoutStream: true,
450-
},
451-
ReadBufferSize: 1024,
452-
WriteBufferSize: 1024,
453-
WaitForReady: true,
454-
BalancerName: "test",
455-
},
456-
},
457438
{
458439
err: "failed to resolve authenticator \"doesntexist\": authenticator not found",
459440
settings: ClientConfig{
@@ -506,9 +487,10 @@ func TestGRPCClientSettingsError(t *testing.T) {
506487
}
507488
for _, test := range tests {
508489
t.Run(test.err, func(t *testing.T) {
509-
_, err := test.settings.ToClientConn(context.Background(), test.host, tt.TelemetrySettings())
490+
require.NoError(t, test.settings.Validate())
491+
_, err := test.settings.ToClientConn(context.Background(), test.host, componenttest.NewNopTelemetrySettings())
510492
require.Error(t, err)
511-
assert.Regexp(t, test.err, err)
493+
assert.ErrorContains(t, err, test.err)
512494
})
513495
}
514496
}
@@ -587,7 +569,7 @@ func TestGRPCServerSettingsError(t *testing.T) {
587569
err string
588570
}{
589571
{
590-
err: "^failed to load TLS config: failed to load CA CertPool File: failed to load cert /doesnt/exist:",
572+
err: "failed to load TLS config: failed to load CA CertPool File: failed to load cert /doesnt/exist:",
591573
settings: ServerConfig{
592574
NetAddr: confignet.AddrConfig{
593575
Endpoint: "127.0.0.1:1234",
@@ -601,7 +583,7 @@ func TestGRPCServerSettingsError(t *testing.T) {
601583
},
602584
},
603585
{
604-
err: "^failed to load TLS config: failed to load TLS cert and key: for auth via TLS, provide both certificate and key, or neither",
586+
err: "failed to load TLS config: failed to load TLS cert and key: for auth via TLS, provide both certificate and key, or neither",
605587
settings: ServerConfig{
606588
NetAddr: confignet.AddrConfig{
607589
Endpoint: "127.0.0.1:1234",
@@ -615,7 +597,7 @@ func TestGRPCServerSettingsError(t *testing.T) {
615597
},
616598
},
617599
{
618-
err: "^failed to load client CA CertPool: failed to load CA /doesnt/exist:",
600+
err: "failed to load client CA CertPool: failed to load CA /doesnt/exist:",
619601
settings: ServerConfig{
620602
NetAddr: confignet.AddrConfig{
621603
Endpoint: "127.0.0.1:1234",
@@ -630,7 +612,7 @@ func TestGRPCServerSettingsError(t *testing.T) {
630612
for _, test := range tests {
631613
t.Run(test.err, func(t *testing.T) {
632614
_, err := test.settings.ToServer(context.Background(), componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings())
633-
assert.Regexp(t, test.err, err)
615+
assert.ErrorContains(t, err, test.err)
634616
})
635617
}
636618
}
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package confighttp // import "go.opentelemetry.io/collector/config/confighttp"
5+
6+
import "io"
7+
8+
// compressReadCloser couples the original compressed reader
9+
// and the compression reader to ensure that the original body
10+
// is correctly closed to ensure resources are freed.
11+
type compressReadCloser struct {
12+
io.Reader
13+
orig io.ReadCloser
14+
}
15+
16+
var (
17+
_ io.Reader = (*compressReadCloser)(nil)
18+
_ io.Closer = (*compressReadCloser)(nil)
19+
)
20+
21+
func (crc *compressReadCloser) Close() error {
22+
return crc.orig.Close()
23+
}

0 commit comments

Comments
 (0)