|
24 | 24 | #include "opentelemetry/sdk/common/thread_instrumentation.h" |
25 | 25 | #include "opentelemetry/version.h" |
26 | 26 |
|
27 | | -// forward declare google::protobuf::Message |
| 27 | +// forward declare google::protobuf::Message and google::protobuf::Arena |
28 | 28 | namespace google |
29 | 29 | { |
30 | 30 | namespace protobuf |
31 | 31 | { |
| 32 | +class Arena; |
32 | 33 | class Message; |
33 | | -} |
| 34 | +} // namespace protobuf |
34 | 35 | } // namespace google |
35 | 36 |
|
36 | 37 | OPENTELEMETRY_BEGIN_NAMESPACE |
@@ -183,35 +184,23 @@ class OtlpHttpClient |
183 | 184 | OtlpHttpClient &operator=(OtlpHttpClient &&) = delete; |
184 | 185 |
|
185 | 186 | /** |
186 | | - * Sync export |
187 | | - * @param message message to export, it should be ExportTraceServiceRequest, |
188 | | - * ExportMetricsServiceRequest or ExportLogsServiceRequest |
189 | | - * @return return the status of this operation |
190 | | - */ |
191 | | - sdk::common::ExportResult Export(const google::protobuf::Message &message) noexcept; |
192 | | - |
193 | | - /** |
194 | | - * Async export |
195 | | - * @param message message to export, it should be ExportTraceServiceRequest, |
196 | | - * ExportMetricsServiceRequest or ExportLogsServiceRequest |
197 | | - * @param result_callback callback to call when the exporting is done |
198 | | - * @return return the status of this operation |
199 | | - */ |
200 | | - sdk::common::ExportResult Export( |
201 | | - const google::protobuf::Message &message, |
202 | | - std::function<bool(opentelemetry::sdk::common::ExportResult)> &&result_callback) noexcept; |
203 | | - |
204 | | - /** |
205 | | - * Async export |
| 187 | + * Export message with typed response. Synchronous when max_running_requests is 0, |
| 188 | + * asynchronous otherwise. |
206 | 189 | * @param message message to export, it should be ExportTraceServiceRequest, |
207 | 190 | * ExportMetricsServiceRequest or ExportLogsServiceRequest |
| 191 | + * @param arena protobuf arena that owns response |
| 192 | + * @param response the parsed body is written here on 2xx |
208 | 193 | * @param result_callback callback to call when the exporting is done |
209 | 194 | * @param max_running_requests wait for at most max_running_requests running requests |
210 | | - * @return return the status of this operation |
| 195 | + * @return the export result; kSuccess for asynchronous exports (final result via |
| 196 | + * result_callback) |
211 | 197 | */ |
212 | 198 | sdk::common::ExportResult Export( |
213 | 199 | const google::protobuf::Message &message, |
214 | | - std::function<bool(opentelemetry::sdk::common::ExportResult)> &&result_callback, |
| 200 | + std::unique_ptr<google::protobuf::Arena> &&arena, |
| 201 | + google::protobuf::Message *response, |
| 202 | + std::function<bool(opentelemetry::sdk::common::ExportResult, google::protobuf::Message *)> |
| 203 | + &&result_callback, |
215 | 204 | std::size_t max_running_requests) noexcept; |
216 | 205 |
|
217 | 206 | /** |
@@ -252,23 +241,36 @@ class OtlpHttpClient |
252 | 241 | std::shared_ptr<opentelemetry::ext::http::client::Session> session; |
253 | 242 | std::shared_ptr<opentelemetry::ext::http::client::EventHandler> event_handle; |
254 | 243 |
|
255 | | - HttpSessionData() = default; |
| 244 | + std::unique_ptr<google::protobuf::Arena> arena; |
| 245 | + google::protobuf::Message *response = nullptr; |
| 246 | + |
| 247 | + HttpSessionData() noexcept; |
| 248 | + HttpSessionData(std::shared_ptr<opentelemetry::ext::http::client::Session> &&input_session, |
| 249 | + std::shared_ptr<opentelemetry::ext::http::client::EventHandler> &&input_handle, |
| 250 | + std::unique_ptr<google::protobuf::Arena> &&input_arena, |
| 251 | + google::protobuf::Message *input_response) noexcept; |
256 | 252 |
|
257 | | - explicit HttpSessionData( |
258 | | - std::shared_ptr<opentelemetry::ext::http::client::Session> &&input_session, |
259 | | - std::shared_ptr<opentelemetry::ext::http::client::EventHandler> &&input_handle) |
260 | | - : session(std::move(input_session)), event_handle(std::move(input_handle)) |
261 | | - {} |
| 253 | + ~HttpSessionData(); |
| 254 | + HttpSessionData(HttpSessionData &&) noexcept; |
| 255 | + HttpSessionData &operator=(HttpSessionData &&) noexcept; |
| 256 | + HttpSessionData(const HttpSessionData &) = delete; |
| 257 | + HttpSessionData &operator=(const HttpSessionData &) = delete; |
262 | 258 | }; |
263 | 259 |
|
264 | 260 | /** |
265 | | - * @brief Create a Session object or return a error result |
| 261 | + * @brief Create a Session object that deserializes the response body or return an error result. |
266 | 262 | * |
267 | 263 | * @param message The message to send |
| 264 | + * @param arena Protobuf arena that owns response |
| 265 | + * @param response the parsed body is written here on 2xx |
| 266 | + * @param result_callback Callback for the export result; receives the populated response |
268 | 267 | */ |
269 | 268 | nostd::variant<sdk::common::ExportResult, HttpSessionData> createSession( |
270 | 269 | const google::protobuf::Message &message, |
271 | | - std::function<bool(opentelemetry::sdk::common::ExportResult)> &&result_callback) noexcept; |
| 270 | + std::unique_ptr<google::protobuf::Arena> &&arena, |
| 271 | + google::protobuf::Message *response, |
| 272 | + std::function<bool(opentelemetry::sdk::common::ExportResult, google::protobuf::Message *)> |
| 273 | + &&result_callback) noexcept; |
272 | 274 |
|
273 | 275 | /** |
274 | 276 | * Add http session and hold it's lifetime. |
|
0 commit comments