Skip to content

Commit 3b824a2

Browse files
authored
Merge branch 'main' into reduce-blocked-ranges-on-gh-windows-runners
2 parents 3f106ab + b521ed4 commit 3b824a2

File tree

7 files changed

+69
-16
lines changed

7 files changed

+69
-16
lines changed

.chloggen/add_default_timeout.yaml

Lines changed: 25 additions & 0 deletions
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: configtelemetry
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Add 10s read header timeout on the configtelemetry Prometheus HTTP server.
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [5699]
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: []
Lines changed: 25 additions & 0 deletions
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: Add `NewDefaultCORSConfig` function to initialize the default `confighttp.CORSConfig`
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [9655]
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: [api]

.golangci.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,6 @@ issues:
147147
- text: "G402:"
148148
linters:
149149
- gosec
150-
# https://github.com/open-telemetry/opentelemetry-collector/issues/5699
151-
- text: "G112:"
152-
linters:
153-
- gosec
154150

155151
# The list of ids of default excludes to include or disable. By default it's empty.
156152
# See the list of default excludes here https://golangci-lint.run/usage/configuration.

cmd/builder/internal/builder/main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func TestGenerateDefault(t *testing.T) {
112112

113113
func TestGenerateInvalidOutputPath(t *testing.T) {
114114
cfg := newInitializedConfig(t)
115-
cfg.Distribution.OutputPath = "/:invalid"
115+
cfg.Distribution.OutputPath = ":/invalid"
116116
err := Generate(cfg)
117117
require.Error(t, err)
118118
require.Contains(t, err.Error(), "failed to create output path")

config/confighttp/confighttp.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ func NewDefaultServerConfig() ServerConfig {
332332
return ServerConfig{
333333
ResponseHeaders: map[string]configopaque.String{},
334334
TLSSetting: &tlsDefaultServerConfig,
335-
CORS: &CORSConfig{},
335+
CORS: NewDefaultCORSConfig(),
336336
WriteTimeout: 30 * time.Second,
337337
ReadHeaderTimeout: 1 * time.Minute,
338338
IdleTimeout: 1 * time.Minute,
@@ -469,12 +469,12 @@ func (hss *ServerConfig) ToServer(_ context.Context, host component.Host, settin
469469
}
470470

471471
server := &http.Server{
472-
Handler: handler,
472+
Handler: handler,
473+
ReadTimeout: hss.ReadTimeout,
474+
ReadHeaderTimeout: hss.ReadHeaderTimeout,
475+
WriteTimeout: hss.WriteTimeout,
476+
IdleTimeout: hss.IdleTimeout,
473477
}
474-
server.ReadTimeout = hss.ReadTimeout
475-
server.ReadHeaderTimeout = hss.ReadHeaderTimeout
476-
server.WriteTimeout = hss.WriteTimeout
477-
server.IdleTimeout = hss.IdleTimeout
478478

479479
return server, nil
480480
}
@@ -513,6 +513,11 @@ type CORSConfig struct {
513513
MaxAge int `mapstructure:"max_age"`
514514
}
515515

516+
// NewDefaultCORSConfig creates a default cross-origin resource sharing (CORS) configuration.
517+
func NewDefaultCORSConfig() *CORSConfig {
518+
return &CORSConfig{}
519+
}
520+
516521
func authInterceptor(next http.Handler, server auth.Server, requestParams []string) http.Handler {
517522
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
518523
sources := r.Header

config/confighttp/confighttp_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ func TestHttpCors(t *testing.T) {
762762
},
763763
{
764764
name: "emptyCORS",
765-
CORSConfig: &CORSConfig{},
765+
CORSConfig: NewDefaultCORSConfig(),
766766
allowedWorks: false,
767767
disallowedWorks: false,
768768
extraHeaderWorks: false,

service/internal/proctelemetry/config.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ const (
4141
HTTPInstrumentation = "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
4242

4343
// supported protocols
44-
protocolProtobufHTTP = "http/protobuf"
45-
protocolProtobufGRPC = "grpc/protobuf"
44+
protocolProtobufHTTP = "http/protobuf"
45+
protocolProtobufGRPC = "grpc/protobuf"
46+
defaultReadHeaderTimeout = 10 * time.Second
4647
)
4748

4849
var (
@@ -96,8 +97,9 @@ func InitPrometheusServer(registry *prometheus.Registry, address string, asyncEr
9697
mux := http.NewServeMux()
9798
mux.Handle("/metrics", promhttp.HandlerFor(registry, promhttp.HandlerOpts{}))
9899
server := &http.Server{
99-
Addr: address,
100-
Handler: mux,
100+
Addr: address,
101+
Handler: mux,
102+
ReadHeaderTimeout: defaultReadHeaderTimeout,
101103
}
102104
go func() {
103105
if serveErr := server.ListenAndServe(); serveErr != nil && !errors.Is(serveErr, http.ErrServerClosed) {

0 commit comments

Comments
 (0)