Skip to content

Commit

Permalink
Merge branch 'main' into scanning-alert
Browse files Browse the repository at this point in the history
  • Loading branch information
esigo authored Aug 3, 2022
2 parents 8de4450 + b4d8245 commit b2d6a35
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 6 deletions.
24 changes: 24 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug on Windows",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/build/<path-to-bin-file>",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false
},
{
"name": "Debug on Linux",
"type": "gdb",
"request": "launch",
"target": "${workspaceFolder}/bazel-bin/<path to the bin file>",
"cwd": "${workspaceRoot}",
"valuesFormatting": "parseText"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<ext::http::client::HttpClient> http_client_;
std::shared_ptr<ext::http::client::HttpClient> http_client_;
mutable opentelemetry::common::SpinLockMutex lock_;
bool isShutdown() const noexcept;
};
Expand Down
5 changes: 3 additions & 2 deletions exporters/elasticsearch/src/es_log_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

# include <sstream> // std::stringstream

# include <condition_variable>
# include <mutex>
# include "opentelemetry/exporters/elasticsearch/es_log_exporter.h"
# include "opentelemetry/exporters/elasticsearch/es_log_recordable.h"
Expand Down Expand Up @@ -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<sdklogs::Recordable> ElasticsearchLogExporter::MakeRecordable() noexcept
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
19 changes: 19 additions & 0 deletions exporters/otlp/src/otlp_grpc_metric_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<opentelemetry::common::SpinLockMutex> locked(lock_);
is_shutdown_ = true;
return true;
}

bool OtlpGrpcMetricExporter::isShutdown() const noexcept
{
const std::lock_guard<opentelemetry::common::SpinLockMutex> locked(lock_);
return is_shutdown_;
}

} // namespace otlp
} // namespace exporter
OPENTELEMETRY_END_NAMESPACE
Expand Down
3 changes: 2 additions & 1 deletion exporters/prometheus/src/collector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
9 changes: 9 additions & 0 deletions sdk/include/opentelemetry/sdk/trace/recordable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b2d6a35

Please sign in to comment.