From a55084d4c3b6ea5ec18c7b789879575c2588a795 Mon Sep 17 00:00:00 2001 From: Tom Tan Date: Tue, 23 Mar 2021 20:25:23 -0700 Subject: [PATCH 1/3] Intialize default Zipkin endpoint from env var if exists --- .../opentelemetry/exporters/zipkin/zipkin_exporter.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter.h b/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter.h index 31f6244bdf..f1697da504 100644 --- a/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter.h +++ b/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter.h @@ -30,7 +30,13 @@ namespace exporter namespace zipkin { -const std::string kZipkinEndpointDefault = "http://localhost:9411/api/v2/spans"; +const char *kZipkinEndpointDefault = "http://localhost:9411/api/v2/spans"; + +static const std::string GetDefaultZipkinEndpoint() +{ + auto endpoint_from_env = std::getenv("OTEL_EXPORTER_ZIPKIN_ENDPOINT"); + return std::string{endpoint_from_env ? endpoint_from_env : kZipkinEndpointDefault}; +} /** * Struct to hold Zipkin exporter options. @@ -38,7 +44,7 @@ const std::string kZipkinEndpointDefault = "http://localhost:9411/api/v2/spans"; struct ZipkinExporterOptions { // The endpoint to export to. By default the OpenTelemetry Collector's default endpoint. - std::string endpoint = kZipkinEndpointDefault; + std::string endpoint = GetDefaultZipkinEndpoint(); TransportFormat format = TransportFormat::kJson; std::string service_name = "default-service"; std::string ipv4; From 30ba3d57d8191761eaa41ff0eb440c8373e1d979 Mon Sep 17 00:00:00 2001 From: Tom Tan Date: Tue, 23 Mar 2021 20:32:49 -0700 Subject: [PATCH 2/3] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d8238314b..36038e746b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ Increment the: * PATCH version when you make backwards compatible bug fixes. ## [Unreleased] +* [SDK] Read Zipkin endpoint from environment variable. ([#24](https://github.com/open-telemetry/opentelemetry-cpp/pull/624)) ## [0.3.0] 2021-03-19 From 8514d4792a02b855f151b6aa8e71d119229176b3 Mon Sep 17 00:00:00 2001 From: Tom Tan Date: Tue, 23 Mar 2021 20:45:44 -0700 Subject: [PATCH 3/3] Fix markdown lint --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 36038e746b..36678ac7c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ Increment the: * PATCH version when you make backwards compatible bug fixes. ## [Unreleased] + * [SDK] Read Zipkin endpoint from environment variable. ([#24](https://github.com/open-telemetry/opentelemetry-cpp/pull/624)) ## [0.3.0] 2021-03-19