From 78551fbb535e2381fcdc6a1585b32f4999b43794 Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Tue, 2 Aug 2022 12:09:34 -0700 Subject: [PATCH 1/3] [Trace] Add SpanData getter for Span Recordable (#1508) --- sdk/include/opentelemetry/sdk/trace/recordable.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sdk/include/opentelemetry/sdk/trace/recordable.h b/sdk/include/opentelemetry/sdk/trace/recordable.h index 8f9fb460e4..04248944e9 100644 --- a/sdk/include/opentelemetry/sdk/trace/recordable.h +++ b/sdk/include/opentelemetry/sdk/trace/recordable.h @@ -28,6 +28,7 @@ namespace trace { using namespace opentelemetry::sdk::instrumentationscope; +class SpanData; /** * Maintains a representation of a span in a format that can be processed by a recorder. @@ -140,6 +141,14 @@ class Recordable */ virtual void SetDuration(std::chrono::nanoseconds duration) noexcept = 0; + /** + * Get the SpanData object for this Recordable. + * + * @return SpanData* + */ + + virtual explicit operator SpanData *() const { return nullptr; } + /** * Set the instrumentation scope of the span. * @param instrumentation_scope the instrumentation scope to set From 90fd29183e36377e6c3fa878db8349c8dc7dfd88 Mon Sep 17 00:00:00 2001 From: Ehsan Saei <71217171+esigo@users.noreply.github.com> Date: Tue, 2 Aug 2022 22:24:37 +0200 Subject: [PATCH 2/3] [dev] vscode debug launch.json (#1537) --- .vscode/launch.json | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000000..e9a256a518 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,24 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug on Windows", + "type": "cppvsdbg", + "request": "launch", + "program": "${workspaceFolder}/build/", + "args": [], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false + }, + { + "name": "Debug on Linux", + "type": "gdb", + "request": "launch", + "target": "${workspaceFolder}/bazel-bin/", + "cwd": "${workspaceRoot}", + "valuesFormatting": "parseText" + } + ] +} From b4d8245d65e47eea2d2c2ecbeea813b6475cffcf Mon Sep 17 00:00:00 2001 From: WenTao Ou Date: Wed, 3 Aug 2022 12:26:24 +0800 Subject: [PATCH 3/3] Fix several compiling/linking errors (#1539) Signed-off-by: owentou --- .../exporters/elasticsearch/es_log_exporter.h | 4 ++-- .../elasticsearch/src/es_log_exporter.cc | 5 +++-- .../exporters/otlp/otlp_http_client.h | 2 +- .../otlp/src/otlp_grpc_metric_exporter.cc | 19 +++++++++++++++++++ exporters/prometheus/src/collector.cc | 3 ++- 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_exporter.h b/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_exporter.h index ea58807e96..9b75c04eb4 100644 --- a/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_exporter.h +++ b/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_exporter.h @@ -6,7 +6,7 @@ # include "nlohmann/json.hpp" # include "opentelemetry/common/spin_lock_mutex.h" -# include "opentelemetry/ext/http/client/curl/http_client_curl.h" +# include "opentelemetry/ext/http/client/http_client_factory.h" # include "opentelemetry/nostd/type_traits.h" # include "opentelemetry/sdk/logs/exporter.h" # include "opentelemetry/sdk/logs/log_record.h" @@ -104,7 +104,7 @@ class ElasticsearchLogExporter final : public opentelemetry::sdk::logs::LogExpor ElasticsearchExporterOptions options_; // Object that stores the HTTP sessions that have been created - std::unique_ptr http_client_; + std::shared_ptr http_client_; mutable opentelemetry::common::SpinLockMutex lock_; bool isShutdown() const noexcept; }; diff --git a/exporters/elasticsearch/src/es_log_exporter.cc b/exporters/elasticsearch/src/es_log_exporter.cc index 3c21e0e2e6..f9a681ded9 100644 --- a/exporters/elasticsearch/src/es_log_exporter.cc +++ b/exporters/elasticsearch/src/es_log_exporter.cc @@ -5,6 +5,7 @@ # include // std::stringstream +# include # include # include "opentelemetry/exporters/elasticsearch/es_log_exporter.h" # include "opentelemetry/exporters/elasticsearch/es_log_recordable.h" @@ -225,11 +226,11 @@ class AsyncResponseHandler : public http_client::EventHandler ElasticsearchLogExporter::ElasticsearchLogExporter() : options_{ElasticsearchExporterOptions()}, - http_client_{new ext::http::client::curl::HttpClient()} + http_client_{ext::http::client::HttpClientFactory::Create()} {} ElasticsearchLogExporter::ElasticsearchLogExporter(const ElasticsearchExporterOptions &options) - : options_{options}, http_client_{new ext::http::client::curl::HttpClient()} + : options_{options}, http_client_{ext::http::client::HttpClientFactory::Create()} {} std::unique_ptr ElasticsearchLogExporter::MakeRecordable() noexcept diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_client.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_client.h index 70aa5ddbe6..e5102c6ca0 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_client.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_client.h @@ -186,7 +186,7 @@ class OtlpHttpClient event_handle.swap(input_handle); } - inline explicit HttpSessionData(HttpSessionData &&other) + inline HttpSessionData(HttpSessionData &&other) { session.swap(other.session); event_handle.swap(other.event_handle); diff --git a/exporters/otlp/src/otlp_grpc_metric_exporter.cc b/exporters/otlp/src/otlp_grpc_metric_exporter.cc index dfda869550..486d61dfd4 100644 --- a/exporters/otlp/src/otlp_grpc_metric_exporter.cc +++ b/exporters/otlp/src/otlp_grpc_metric_exporter.cc @@ -143,6 +143,25 @@ opentelemetry::sdk::common::ExportResult OtlpGrpcMetricExporter::Export( return opentelemetry::sdk::common::ExportResult::kSuccess; } +bool OtlpGrpcMetricExporter::ForceFlush(std::chrono::microseconds timeout) noexcept +{ + // TODO: OTLP gRPC exporter does not support concurrency exporting now. + return true; +} + +bool OtlpGrpcMetricExporter::Shutdown(std::chrono::microseconds timeout) noexcept +{ + const std::lock_guard locked(lock_); + is_shutdown_ = true; + return true; +} + +bool OtlpGrpcMetricExporter::isShutdown() const noexcept +{ + const std::lock_guard locked(lock_); + return is_shutdown_; +} + } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/prometheus/src/collector.cc b/exporters/prometheus/src/collector.cc index 03793a8eed..834e04dc55 100644 --- a/exporters/prometheus/src/collector.cc +++ b/exporters/prometheus/src/collector.cc @@ -58,7 +58,8 @@ void PrometheusCollector::AddMetricData(const sdk::metrics::ResourceMetrics &dat collection_lock_.lock(); if (metrics_to_collect_.size() + 1 <= max_collection_size_) { - metrics_to_collect_.emplace_back(new sdk::metrics::ResourceMetrics{data}); + // We can not use initializer lists here due to broken variadic capture on GCC 4.8.5 + metrics_to_collect_.emplace_back(new sdk::metrics::ResourceMetrics(data)); } collection_lock_.unlock(); }