diff --git a/connection.go b/connection.go index 2da7e84..a91893d 100644 --- a/connection.go +++ b/connection.go @@ -38,7 +38,7 @@ func (ae *Exporter) connected() bool { return atomic.LoadInt32(&ae.connectionState) == sConnected } -const defaultConnReattemptPeriod = 5000 * time.Millisecond +const defaultConnReattemptPeriod = 10 * time.Second func (ae *Exporter) indefiniteBackgroundConnection() error { defer func() { diff --git a/load_test.go b/load_test.go index 68837a7..5e5f227 100644 --- a/load_test.go +++ b/load_test.go @@ -27,6 +27,7 @@ import ( "strings" "sync" "testing" + "time" "google.golang.org/grpc" @@ -74,6 +75,7 @@ func TestExportsUnderLoad_issue13(t *testing.T) { exporter, err := ocagent.NewExporter( ocagent.WithInsecure(), ocagent.WithServiceName("go-app"), + ocagent.WithReconnectionPeriod(50*time.Millisecond), ocagent.WithAddress(agentAddr)) if err != nil { t.Fatalf("Failed to create the agent exporter: %v", err) diff --git a/ocagent_test.go b/ocagent_test.go index 43ec51f..8189e85 100644 --- a/ocagent_test.go +++ b/ocagent_test.go @@ -36,7 +36,10 @@ func TestNewExporter_endToEnd(t *testing.T) { defer ma.stop() serviceName := "endToEnd_test" - exp, err := ocagent.NewExporter(ocagent.WithInsecure(), ocagent.WithAddress(ma.address), ocagent.WithServiceName(serviceName)) + exp, err := ocagent.NewExporter(ocagent.WithInsecure(), + ocagent.WithAddress(ma.address), + ocagent.WithReconnectionPeriod(50*time.Millisecond), + ocagent.WithServiceName(serviceName)) if err != nil { t.Fatalf("Failed to create a new agent exporter: %v", err) } @@ -208,7 +211,9 @@ func TestNewExporter_invokeStartThenStopManyTimes(t *testing.T) { ma := runMockAgent(t) defer ma.stop() - exp, err := ocagent.NewExporter(ocagent.WithInsecure(), ocagent.WithAddress(ma.address)) + exp, err := ocagent.NewExporter(ocagent.WithInsecure(), + ocagent.WithReconnectionPeriod(50*time.Millisecond), + ocagent.WithAddress(ma.address)) if err != nil { t.Fatal("Surprisingly connected with a bad port") } @@ -301,7 +306,9 @@ func TestNewExporter_agentOnBadConnection(t *testing.T) { _, agentPortStr, _ := net.SplitHostPort(ln.Addr().String()) address := fmt.Sprintf("localhost:%s", agentPortStr) - exp, err := ocagent.NewExporter(ocagent.WithInsecure(), ocagent.WithAddress(address)) + exp, err := ocagent.NewExporter(ocagent.WithInsecure(), + ocagent.WithReconnectionPeriod(50*time.Millisecond), + ocagent.WithAddress(address)) if err != nil { t.Fatalf("Despite an indefinite background reconnection, got error: %v", err) } @@ -312,7 +319,10 @@ func TestNewExporter_withAddress(t *testing.T) { ma := runMockAgent(t) defer ma.stop() - exp, err := ocagent.NewUnstartedExporter(ocagent.WithInsecure(), ocagent.WithAddress(ma.address)) + exp, err := ocagent.NewUnstartedExporter( + ocagent.WithInsecure(), + ocagent.WithReconnectionPeriod(50*time.Millisecond), + ocagent.WithAddress(ma.address)) if err != nil { t.Fatal("Surprisingly connected with a bad port") } diff --git a/transform_spans_test.go b/transform_spans_test.go index 67c610f..ede86e5 100644 --- a/transform_spans_test.go +++ b/transform_spans_test.go @@ -35,7 +35,10 @@ func TestOCSpanToProtoSpan_endToEnd(t *testing.T) { defer agent.stop() serviceName := "spanTranslation" - exp, err := ocagent.NewExporter(ocagent.WithInsecure(), ocagent.WithAddress(agent.address), ocagent.WithServiceName(serviceName)) + exp, err := ocagent.NewExporter(ocagent.WithInsecure(), + ocagent.WithAddress(agent.address), + ocagent.WithReconnectionPeriod(50*time.Millisecond), + ocagent.WithServiceName(serviceName)) if err != nil { t.Fatalf("Failed to create a new agent exporter: %v", err) }