Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[exporter/zipkin] use confighttp.DefaultHTTPClientSettings #29931

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .chloggen/zipkinexporter_clientsettings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 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. filelogreceiver)
component: zipkinexporter

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Use default client HTTP settings in zipkinexporter, move validation to config validation

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [29931]

# (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:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# 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: []
5 changes: 5 additions & 0 deletions exporter/zipkinexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
package zipkinexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/zipkinexporter"

import (
"errors"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/confighttp"
"go.opentelemetry.io/collector/exporter/exporterhelper"
Expand All @@ -27,5 +29,8 @@ var _ component.Config = (*Config)(nil)

// Validate checks if the exporter configuration is valid
func (cfg *Config) Validate() error {
if cfg.HTTPClientSettings.Endpoint == "" {
return errors.New("endpoint required")
}
bogdandrutu marked this conversation as resolved.
Show resolved Hide resolved
return nil
}
3 changes: 3 additions & 0 deletions exporter/zipkinexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func TestLoadConfig(t *testing.T) {
// URL doesn't have a default value so set it directly.
defaultCfg := createDefaultConfig().(*Config)
defaultCfg.Endpoint = "http://some.location.org:9411/api/v2/spans"
httpDefaultClientSettings := confighttp.NewDefaultHTTPClientSettings()

tests := []struct {
id component.ID
Expand Down Expand Up @@ -61,6 +62,8 @@ func TestLoadConfig(t *testing.T) {
TLSSetting: configtls.TLSClientSetting{
InsecureSkipVerify: true,
},
MaxIdleConns: httpDefaultClientSettings.MaxIdleConns,
IdleConnTimeout: httpDefaultClientSettings.IdleConnTimeout,
atoulme marked this conversation as resolved.
Show resolved Hide resolved
},
Format: "proto",
DefaultServiceName: "test_name",
Expand Down
19 changes: 6 additions & 13 deletions exporter/zipkinexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package zipkinexporter // import "github.com/open-telemetry/opentelemetry-collec

import (
"context"
"errors"
"time"

"go.opentelemetry.io/collector/component"
Expand Down Expand Up @@ -33,14 +32,13 @@ func NewFactory() exporter.Factory {
}

func createDefaultConfig() component.Config {
defaultClientHTTPSettings := confighttp.NewDefaultHTTPClientSettings()
defaultClientHTTPSettings.Timeout = defaultTimeout
defaultClientHTTPSettings.WriteBufferSize = 512 * 1024
return &Config{
RetrySettings: exporterhelper.NewDefaultRetrySettings(),
QueueSettings: exporterhelper.NewDefaultQueueSettings(),
HTTPClientSettings: confighttp.HTTPClientSettings{
Timeout: defaultTimeout,
// We almost read 0 bytes, so no need to tune ReadBufferSize.
WriteBufferSize: 512 * 1024,
},
RetrySettings: exporterhelper.NewDefaultRetrySettings(),
QueueSettings: exporterhelper.NewDefaultQueueSettings(),
HTTPClientSettings: defaultClientHTTPSettings,
Format: defaultFormat,
DefaultServiceName: defaultServiceName,
}
Expand All @@ -53,11 +51,6 @@ func createTracesExporter(
) (exporter.Traces, error) {
zc := cfg.(*Config)

if zc.Endpoint == "" {
// TODO https://github.com/open-telemetry/opentelemetry-collector/issues/215
return nil, errors.New("exporter config requires a non-empty 'endpoint'")
}

ze, err := createZipkinExporter(zc, set.TelemetrySettings)
if err != nil {
return nil, err
Expand Down
8 changes: 1 addition & 7 deletions exporter/zipkinexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,10 @@ func TestCreateDefaultConfig(t *testing.T) {
func TestCreateInstanceViaFactory(t *testing.T) {
cfg := createDefaultConfig()

// Default config doesn't have default endpoint so creating from it should
// fail.
ze, err := createTracesExporter(context.Background(), exportertest.NewNopCreateSettings(), cfg)
assert.Error(t, err)
assert.Nil(t, ze)

// URL doesn't have a default value so set it directly.
zeCfg := cfg.(*Config)
zeCfg.Endpoint = "http://some.location.org:9411/api/v2/spans"
ze, err = createTracesExporter(context.Background(), exportertest.NewNopCreateSettings(), cfg)
ze, err := createTracesExporter(context.Background(), exportertest.NewNopCreateSettings(), cfg)
assert.NoError(t, err)
assert.NotNil(t, ze)
}