]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/exporters/otlp/src/otlp_http_exporter.cc
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / exporters / otlp / src / otlp_http_exporter.cc
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 #include "opentelemetry/exporters/otlp/otlp_http_exporter.h"
5 #include "opentelemetry/exporters/otlp/otlp_recordable.h"
6 #include "opentelemetry/exporters/otlp/otlp_recordable_utils.h"
7
8 #include "opentelemetry/exporters/otlp/protobuf_include_prefix.h"
9
10 #include "opentelemetry/proto/collector/trace/v1/trace_service.pb.h"
11
12 #include "opentelemetry/exporters/otlp/protobuf_include_suffix.h"
13
14 namespace nostd = opentelemetry::nostd;
15
16 OPENTELEMETRY_BEGIN_NAMESPACE
17 namespace exporter
18 {
19 namespace otlp
20 {
21
22 OtlpHttpExporter::OtlpHttpExporter() : OtlpHttpExporter(OtlpHttpExporterOptions()) {}
23
24 OtlpHttpExporter::OtlpHttpExporter(const OtlpHttpExporterOptions &options)
25 : options_(options),
26 http_client_(new OtlpHttpClient(OtlpHttpClientOptions(options.url,
27 options.content_type,
28 options.json_bytes_mapping,
29 options.use_json_name,
30 options.console_debug,
31 options.timeout,
32 options.http_headers)))
33 {}
34
35 OtlpHttpExporter::OtlpHttpExporter(std::unique_ptr<OtlpHttpClient> http_client)
36 : options_(OtlpHttpExporterOptions()), http_client_(std::move(http_client))
37 {}
38 // ----------------------------- Exporter methods ------------------------------
39
40 std::unique_ptr<opentelemetry::sdk::trace::Recordable> OtlpHttpExporter::MakeRecordable() noexcept
41 {
42 return std::unique_ptr<opentelemetry::sdk::trace::Recordable>(
43 new exporter::otlp::OtlpRecordable());
44 }
45
46 opentelemetry::sdk::common::ExportResult OtlpHttpExporter::Export(
47 const nostd::span<std::unique_ptr<opentelemetry::sdk::trace::Recordable>> &spans) noexcept
48 {
49 if (spans.empty())
50 {
51 return opentelemetry::sdk::common::ExportResult::kSuccess;
52 }
53
54 proto::collector::trace::v1::ExportTraceServiceRequest service_request;
55 OtlpRecordableUtils::PopulateRequest(spans, &service_request);
56 return http_client_->Export(service_request);
57 }
58
59 bool OtlpHttpExporter::Shutdown(std::chrono::microseconds timeout) noexcept
60 {
61 return http_client_->Shutdown(timeout);
62 }
63
64 } // namespace otlp
65 } // namespace exporter
66 OPENTELEMETRY_END_NAMESPACE