Skip to content

Commit

Permalink
[chore] [exporter/mezmo] Use NewDefaultClientConfig instead of manual…
Browse files Browse the repository at this point in the history
…ly creating struct

**Description:**
This PR makes usage of `NewDefaultClientConfig` instead of manually creating the confighttp.ClientConfig struct.

**Link to tracking Issue:** open-telemetry#35457
  • Loading branch information
mackjmr committed Oct 2, 2024
1 parent a191550 commit 49b3d08
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 3 additions & 3 deletions exporter/mezmoexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ type Config struct {

// returns default http client settings
func createDefaultClientConfig() confighttp.ClientConfig {
return confighttp.ClientConfig{
Timeout: defaultTimeout,
}
clientConfig := confighttp.NewDefaultClientConfig()
clientConfig.Timeout = defaultTimeout
return clientConfig
}

func (c *Config) Validate() error {
Expand Down
14 changes: 13 additions & 1 deletion exporter/mezmoexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ package mezmoexporter

import (
"context"
"net/http"
"testing"
"time"

"github.com/stretchr/testify/assert"
"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/config/confighttp"
"go.opentelemetry.io/collector/config/configopaque"
"go.opentelemetry.io/collector/config/configretry"
"go.opentelemetry.io/collector/exporter/exporterhelper"
"go.opentelemetry.io/collector/exporter/exportertest"
Expand All @@ -25,6 +27,11 @@ func TestType(t *testing.T) {
}

func TestCreateDefaultConfig(t *testing.T) {
defaultMaxIdleConns := http.DefaultTransport.(*http.Transport).MaxIdleConns
defaultMaxIdleConnsPerHost := http.DefaultTransport.(*http.Transport).MaxIdleConnsPerHost
defaultMaxConnsPerHost := http.DefaultTransport.(*http.Transport).MaxConnsPerHost
defaultIdleConnTimeout := http.DefaultTransport.(*http.Transport).IdleConnTimeout

factory := NewFactory()
cfg := factory.CreateDefaultConfig()

Expand All @@ -33,7 +40,12 @@ func TestCreateDefaultConfig(t *testing.T) {
IngestKey: "",

ClientConfig: confighttp.ClientConfig{
Timeout: 5 * time.Second,
Timeout: 5 * time.Second,
MaxIdleConns: &defaultMaxIdleConns,
MaxIdleConnsPerHost: &defaultMaxIdleConnsPerHost,
MaxConnsPerHost: &defaultMaxConnsPerHost,
IdleConnTimeout: &defaultIdleConnTimeout,
Headers: map[string]configopaque.String{},
},
BackOffConfig: configretry.NewDefaultBackOffConfig(),
QueueSettings: exporterhelper.NewDefaultQueueConfig(),
Expand Down

0 comments on commit 49b3d08

Please sign in to comment.