From 1519d959829b2fd7a7a1b9b904b57235eb54e114 Mon Sep 17 00:00:00 2001 From: Injun Song Date: Tue, 2 Mar 2021 01:03:55 +0900 Subject: [PATCH] Use reasonable interval in sdktrace.WithBatchTimeout (#1621) * Use reasonable interval in sdktrace.WithBatchTimeout This patch resolves #1564. * Add pull request ID to CHANGELOG.md --- CHANGELOG.md | 1 + exporters/otlp/internal/otlptest/otlptest.go | 2 +- exporters/otlp/otlpgrpc/example_test.go | 6 +++--- exporters/otlp/otlpgrpc/otlp_integration_test.go | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 463d3403c13..4ef3b996415 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - AttributePerEventCountLimit and AttributePerLinkCountLimit for SpanLimits. (#1535) - Added `Keys()` method to `propagation.TextMapCarrier` and `propagation.HeaderCarrier` to adapt `http.Header` to this interface. (#1544) - Added `code` attributes to `go.opentelemetry.io/otel/semconv` package. (#1558) +- Changed all examples to use `WithBatchTimeout(5 * time.Second)` rather than `WithBatchTimeout(5)` (#1621) ### Changed diff --git a/exporters/otlp/internal/otlptest/otlptest.go b/exporters/otlp/internal/otlptest/otlptest.go index fa95a08d3a0..ac21f893750 100644 --- a/exporters/otlp/internal/otlptest/otlptest.go +++ b/exporters/otlp/internal/otlptest/otlptest.go @@ -44,7 +44,7 @@ func RunEndToEndTest(ctx context.Context, t *testing.T, exp *otlp.Exporter, mcTr sdktrace.WithBatcher( exp, // add following two options to ensure flush - sdktrace.WithBatchTimeout(5), + sdktrace.WithBatchTimeout(5*time.Second), sdktrace.WithMaxExportBatchSize(10), ), } diff --git a/exporters/otlp/otlpgrpc/example_test.go b/exporters/otlp/otlpgrpc/example_test.go index 96959dac387..d2e7785fa42 100644 --- a/exporters/otlp/otlpgrpc/example_test.go +++ b/exporters/otlp/otlpgrpc/example_test.go @@ -53,7 +53,7 @@ func Example_insecure() { sdktrace.WithBatcher( exp, // add following two options to ensure flush - sdktrace.WithBatchTimeout(5), + sdktrace.WithBatchTimeout(5*time.Second), sdktrace.WithMaxExportBatchSize(10), ), ) @@ -106,7 +106,7 @@ func Example_withTLS() { sdktrace.WithBatcher( exp, // add following two options to ensure flush - sdktrace.WithBatchTimeout(5), + sdktrace.WithBatchTimeout(5*time.Second), sdktrace.WithMaxExportBatchSize(10), ), ) @@ -167,7 +167,7 @@ func Example_withDifferentSignalCollectors() { sdktrace.WithBatcher( exp, // add following two options to ensure flush - sdktrace.WithBatchTimeout(5), + sdktrace.WithBatchTimeout(5*time.Second), sdktrace.WithMaxExportBatchSize(10), ), ) diff --git a/exporters/otlp/otlpgrpc/otlp_integration_test.go b/exporters/otlp/otlpgrpc/otlp_integration_test.go index 499be757372..2004f691abf 100644 --- a/exporters/otlp/otlpgrpc/otlp_integration_test.go +++ b/exporters/otlp/otlpgrpc/otlp_integration_test.go @@ -337,7 +337,7 @@ func TestNewExporter_withMultipleAttributeTypes(t *testing.T) { sdktrace.WithBatcher( exp, // add following two options to ensure flush - sdktrace.WithBatchTimeout(5), + sdktrace.WithBatchTimeout(5*time.Second), sdktrace.WithMaxExportBatchSize(10), ), )