Skip to content

Commit

Permalink
[receiver/otlp] Export HTTPConfig (open-telemetry#8176)
Browse files Browse the repository at this point in the history
**Description:** Make the configuration for the OTLP Receiver
httpServerSettings to be public
Fixing the bug opened  open-telemetry#8175 

**Link to tracking Issue:**open-telemetry#8175

---------

Co-authored-by: Pablo Baeyens <[email protected]>
Co-authored-by: Dmitrii Anoshin <[email protected]>
  • Loading branch information
3 people authored Aug 15, 2023
1 parent ab6a238 commit 56ed343
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 15 deletions.
25 changes: 25 additions & 0 deletions .chloggen/fix-public-api-otlpreceiver.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: enhancement

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Export HTTPConfig as part of the API for creating the otlpreceiver configuration.

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

# (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: Changes signature of receiver/otlpreceiver/config.go type httpServerSettings to HTTPConfig.

# 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]
4 changes: 2 additions & 2 deletions receiver/otlpreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const (
protoHTTP = "protocols::http"
)

type httpServerSettings struct {
type HTTPConfig struct {
*confighttp.HTTPServerSettings `mapstructure:",squash"`

// The URL path to receive traces on. If omitted "/v1/traces" will be used.
Expand All @@ -37,7 +37,7 @@ type httpServerSettings struct {
// Protocols is the configuration for the supported protocols.
type Protocols struct {
GRPC *configgrpc.GRPCServerSettings `mapstructure:"grpc"`
HTTP *httpServerSettings `mapstructure:"http"`
HTTP *HTTPConfig `mapstructure:"http"`
}

// Config defines configuration for OTLP receiver.
Expand Down
4 changes: 2 additions & 2 deletions receiver/otlpreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func TestUnmarshalConfig(t *testing.T) {
},
},
},
HTTP: &httpServerSettings{
HTTP: &HTTPConfig{
HTTPServerSettings: &confighttp.HTTPServerSettings{
Endpoint: "0.0.0.0:4318",
TLSSetting: &configtls.TLSServerSetting{
Expand Down Expand Up @@ -154,7 +154,7 @@ func TestUnmarshalConfigUnix(t *testing.T) {
},
ReadBufferSize: 512 * 1024,
},
HTTP: &httpServerSettings{
HTTP: &HTTPConfig{
HTTPServerSettings: &confighttp.HTTPServerSettings{
Endpoint: "/tmp/http_otlp.sock",
},
Expand Down
2 changes: 1 addition & 1 deletion receiver/otlpreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func createDefaultConfig() component.Config {
// We almost write 0 bytes, so no need to tune WriteBufferSize.
ReadBufferSize: 512 * 1024,
},
HTTP: &httpServerSettings{
HTTP: &HTTPConfig{
HTTPServerSettings: &confighttp.HTTPServerSettings{
Endpoint: defaultHTTPEndpoint,
},
Expand Down
14 changes: 7 additions & 7 deletions receiver/otlpreceiver/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestCreateTracesReceiver(t *testing.T) {
Transport: "tcp",
},
}
defaultHTTPSettings := &httpServerSettings{
defaultHTTPSettings := &HTTPConfig{
HTTPServerSettings: &confighttp.HTTPServerSettings{
Endpoint: testutil.GetAvailableLocalAddress(t),
},
Expand Down Expand Up @@ -94,7 +94,7 @@ func TestCreateTracesReceiver(t *testing.T) {
cfg: &Config{
Protocols: Protocols{
GRPC: defaultGRPCSettings,
HTTP: &httpServerSettings{
HTTP: &HTTPConfig{
HTTPServerSettings: &confighttp.HTTPServerSettings{
Endpoint: "localhost:112233",
},
Expand Down Expand Up @@ -132,7 +132,7 @@ func TestCreateMetricReceiver(t *testing.T) {
Transport: "tcp",
},
}
defaultHTTPSettings := &httpServerSettings{
defaultHTTPSettings := &HTTPConfig{
HTTPServerSettings: &confighttp.HTTPServerSettings{
Endpoint: testutil.GetAvailableLocalAddress(t),
},
Expand Down Expand Up @@ -175,7 +175,7 @@ func TestCreateMetricReceiver(t *testing.T) {
cfg: &Config{
Protocols: Protocols{
GRPC: defaultGRPCSettings,
HTTP: &httpServerSettings{
HTTP: &HTTPConfig{
HTTPServerSettings: &confighttp.HTTPServerSettings{
Endpoint: "327.0.0.1:1122",
},
Expand Down Expand Up @@ -212,7 +212,7 @@ func TestCreateLogReceiver(t *testing.T) {
Transport: "tcp",
},
}
defaultHTTPSettings := &httpServerSettings{
defaultHTTPSettings := &HTTPConfig{
HTTPServerSettings: &confighttp.HTTPServerSettings{
Endpoint: testutil.GetAvailableLocalAddress(t),
},
Expand Down Expand Up @@ -259,7 +259,7 @@ func TestCreateLogReceiver(t *testing.T) {
cfg: &Config{
Protocols: Protocols{
GRPC: defaultGRPCSettings,
HTTP: &httpServerSettings{
HTTP: &HTTPConfig{
HTTPServerSettings: &confighttp.HTTPServerSettings{
Endpoint: "327.0.0.1:1122",
},
Expand All @@ -275,7 +275,7 @@ func TestCreateLogReceiver(t *testing.T) {
cfg: &Config{
Protocols: Protocols{
GRPC: defaultGRPCSettings,
HTTP: &httpServerSettings{
HTTP: &HTTPConfig{
HTTPServerSettings: &confighttp.HTTPServerSettings{
Endpoint: "127.0.0.1:1122",
},
Expand Down
6 changes: 3 additions & 3 deletions receiver/otlpreceiver/otlp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func TestHandleInvalidRequests(t *testing.T) {
endpoint := testutil.GetAvailableLocalAddress(t)
cfg := &Config{
Protocols: Protocols{
HTTP: &httpServerSettings{
HTTP: &HTTPConfig{
HTTPServerSettings: &confighttp.HTTPServerSettings{
Endpoint: endpoint,
},
Expand Down Expand Up @@ -900,7 +900,7 @@ func TestGRPCMaxRecvSize(t *testing.T) {
func TestHTTPInvalidTLSCredentials(t *testing.T) {
cfg := &Config{
Protocols: Protocols{
HTTP: &httpServerSettings{
HTTP: &HTTPConfig{
HTTPServerSettings: &confighttp.HTTPServerSettings{
Endpoint: testutil.GetAvailableLocalAddress(t),
TLSSetting: &configtls.TLSServerSetting{
Expand Down Expand Up @@ -933,7 +933,7 @@ func testHTTPMaxRequestBodySizeJSON(t *testing.T, payload []byte, size int, expe
url := fmt.Sprintf("http://%s/v1/traces", endpoint)
cfg := &Config{
Protocols: Protocols{
HTTP: &httpServerSettings{
HTTP: &HTTPConfig{
HTTPServerSettings: &confighttp.HTTPServerSettings{
Endpoint: endpoint,
MaxRequestBodySize: int64(size),
Expand Down

0 comments on commit 56ed343

Please sign in to comment.