From eb2b9753ea2df64079e07d40489388ea1b323108 Mon Sep 17 00:00:00 2001 From: Siddhartha Malladi Date: Thu, 11 Jul 2024 05:45:17 -0400 Subject: [PATCH 01/89] [Code Health] clang-tidy cleanup, part 1 (#2990) --- .clang-tidy | 69 ++++ api/test/baggage/baggage_benchmark.cc | 2 +- api/test/baggage/baggage_test.cc | 2 +- .../propagation/baggage_propagator_test.cc | 2 +- api/test/common/kv_properties_test.cc | 2 +- api/test/context/context_test.cc | 6 +- api/test/context/runtime_context_test.cc | 2 + api/test/logs/logger_benchmark.cc | 10 +- api/test/logs/logger_test.cc | 1 - api/test/metrics/meter_provider_test.cc | 1 - api/test/nostd/shared_ptr_test.cc | 10 +- api/test/nostd/unique_ptr_test.cc | 12 +- api/test/trace/trace_state_test.cc | 4 +- examples/etw_threads/main.cc | 2 +- examples/grpc/client.cc | 7 +- examples/grpc/server.cc | 9 +- examples/logs_simple/main.cc | 4 +- examples/multi_processor/main.cc | 18 +- examples/multithreaded/main.cc | 1 + examples/otlp/http_log_main.cc | 4 +- examples/simple/main.cc | 2 +- .../elasticsearch/es_log_recordable.h | 6 +- .../elasticsearch/src/es_log_recordable.cc | 6 +- .../memory/test/in_memory_span_data_test.cc | 1 - .../exporters/ostream/log_record_exporter.h | 4 +- .../exporters/ostream/metric_exporter.h | 2 +- .../exporters/ostream/span_exporter.h | 2 +- exporters/ostream/src/log_record_exporter.cc | 10 +- exporters/ostream/src/metric_exporter.cc | 2 +- exporters/ostream/src/span_exporter.cc | 8 +- exporters/ostream/test/ostream_log_test.cc | 60 ++- exporters/ostream/test/ostream_span_test.cc | 2 +- exporters/otlp/src/otlp_file_client.cc | 9 +- exporters/otlp/src/otlp_grpc_client.cc | 6 +- exporters/otlp/src/otlp_http_client.cc | 10 +- .../otlp/test/otlp_http_exporter_test.cc | 215 ++++++----- .../otlp_http_log_record_exporter_test.cc | 363 +++++++++--------- .../test/otlp_http_metric_exporter_test.cc | 265 ++++++------- .../test/otlp_metrics_serialization_test.cc | 6 +- exporters/otlp/test/otlp_recordable_test.cc | 6 +- exporters/prometheus/src/exporter_utils.cc | 4 +- exporters/prometheus/test/exporter_test.cc | 1 - .../prometheus/test/exporter_utils_test.cc | 7 +- exporters/zipkin/src/zipkin_exporter.cc | 2 +- exporters/zipkin/test/zipkin_exporter_test.cc | 3 +- .../http/client/curl/http_operation_curl.h | 3 +- ext/src/dll/dllmain.cc | 2 +- ext/src/http/client/curl/http_client_curl.cc | 2 +- .../http/client/curl/http_operation_curl.cc | 8 +- ext/test/http/curl_http_test.cc | 5 +- ext/test/w3c_tracecontext_test/main.cc | 6 +- functional/otlp/func_http_main.cc | 24 +- .../opentelemetry/sdk/logs/logger_context.h | 2 +- .../opentelemetry/sdk/logs/logger_provider.h | 4 +- .../opentelemetry/sdk/metrics/meter_context.h | 4 +- .../sdk/metrics/meter_provider.h | 4 +- .../metrics/state/temporal_metric_storage.h | 2 +- .../sdk/metrics/sync_instruments.h | 12 +- .../opentelemetry/sdk/trace/samplers/parent.h | 2 +- .../sdk/trace/samplers/parent_factory.h | 2 +- .../opentelemetry/sdk/trace/tracer_context.h | 2 +- .../opentelemetry/sdk/trace/tracer_provider.h | 4 +- sdk/src/common/global_log_handler.cc | 2 +- sdk/src/logs/event_logger.cc | 2 +- sdk/src/logs/logger.cc | 2 +- sdk/src/logs/logger_context.cc | 2 +- sdk/src/logs/logger_provider.cc | 4 +- sdk/src/metrics/async_instruments.cc | 4 +- sdk/src/metrics/exemplar/reservoir.cc | 10 +- sdk/src/metrics/meter.cc | 4 +- sdk/src/metrics/meter_context.cc | 6 +- sdk/src/metrics/meter_provider.cc | 4 +- sdk/src/metrics/state/metric_collector.cc | 4 +- .../metrics/state/temporal_metric_storage.cc | 4 +- sdk/src/metrics/sync_instruments.cc | 12 +- sdk/src/metrics/view/view_factory.cc | 5 +- sdk/src/trace/batch_span_processor.cc | 1 - sdk/src/trace/samplers/parent.cc | 2 +- sdk/src/trace/samplers/parent_factory.cc | 8 +- sdk/src/trace/span.cc | 2 +- sdk/src/trace/tracer.cc | 2 +- sdk/src/trace/tracer_context.cc | 2 +- sdk/src/trace/tracer_provider.cc | 4 +- sdk/test/common/empty_attributes_test.cc | 2 +- .../logs/batch_log_record_processor_test.cc | 12 +- sdk/test/logs/logger_sdk_test.cc | 3 +- .../logs/simple_log_record_processor_test.cc | 3 +- sdk/test/metrics/async_instruments_test.cc | 1 + sdk/test/metrics/async_metric_storage_test.cc | 4 +- sdk/test/metrics/cardinality_limit_test.cc | 4 +- .../instrument_metadata_validator_test.cc | 6 +- sdk/test/metrics/meter_test.cc | 2 +- ...ync_metric_storage_up_down_counter_test.cc | 12 +- sdk/test/resource/resource_test.cc | 11 +- sdk/test/trace/batch_span_processor_test.cc | 11 +- sdk/test/trace/span_data_test.cc | 4 +- sdk/test/trace/tracer_test.cc | 1 - 97 files changed, 759 insertions(+), 661 deletions(-) create mode 100644 .clang-tidy diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000000..5abedb62fd --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,69 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +Checks: > + -*, + abseil-*, + -abseil-string-find-str-contains, + bugprone-*, + -bugprone-easily-swappable-parameters, + -bugprone-implicit-widening-of-multiplication-result, + -bugprone-inc-dec-in-conditions, + -bugprone-narrowing-conversions, + -bugprone-unchecked-optional-access, + -bugprone-unhandled-exception-at-new, + -bugprone-unused-local-non-trivial-variable, + -bugprone-unused-return-value, + google-*, + -google-build-using-namespace, + -google-default-arguments, + -google-explicit-constructor, + -google-readability-avoid-underscore-in-googletest-name, + -google-readability-braces-around-statements, + -google-readability-namespace-comments, + -google-readability-todo, + -google-runtime-references, + misc-*, + -misc-const-correctness, + -misc-include-cleaner, + -misc-non-private-member-variables-in-classes, + -misc-unused-alias-decls, + -misc-use-anonymous-namespace, + performance-*, + -performance-move-const-arg, + portability-* +# readability-*, +# -readability-convert-member-functions-to-static, +# -readability-else-after-return, +# -readability-function-cognitive-complexity, +# -readability-identifier-length, +# -readability-implicit-bool-conversion, +# -readability-isolate-declaration, +# -readability-magic-numbers, +# -readability-named-parameter, +# -readability-redundant-*, +# -readability-string-compare, +# cppcoreguidelines-*, +# -cppcoreguidelines-avoid-c-arrays, +# -cppcoreguidelines-avoid-magic-numbers, +# -cppcoreguidelines-init-variables, +# -cppcoreguidelines-macro-usage, +# -cppcoreguidelines-non-private-member-variables-in-classes, +# -cppcoreguidelines-pro-*, +# modernize-*, +# -modernize-use-default-member-init, +# -modernize-use-nodiscard, +# -modernize-use-trailing-return-type, +# -modernize-avoid-c-arrays, +# -modernize-use-using + +# Use existing clang-format for formatting the code +# FormatStyle: 'file' + +# TODO: include checks: readability, cppcoreguidelines, modernize , google-readability-namespace-comments, google-readability-avoid-underscore-in-googletest-name, performance-move-const-arg + + + + + + diff --git a/api/test/baggage/baggage_benchmark.cc b/api/test/baggage/baggage_benchmark.cc index 0f2efa9939..4ced142327 100644 --- a/api/test/baggage/baggage_benchmark.cc +++ b/api/test/baggage/baggage_benchmark.cc @@ -22,7 +22,7 @@ std::string header_with_custom_entries(size_t num_entries) { std::string key = "ADecentlyLargekey" + std::to_string(i); std::string value = "ADecentlyLargeValue" + std::to_string(i); - header += key + "=" + value; + header.append(key).append("=").append(value); if (i != num_entries - 1) { header += ","; diff --git a/api/test/baggage/baggage_test.cc b/api/test/baggage/baggage_test.cc index 9c14fc892f..f29615c983 100644 --- a/api/test/baggage/baggage_test.cc +++ b/api/test/baggage/baggage_test.cc @@ -19,7 +19,7 @@ std::string header_with_custom_entries(size_t num_entries) { std::string key = "key" + std::to_string(i); std::string value = "value" + std::to_string(i); - header += key + "=" + value; + header.append(key).append("=").append(value); if (i != num_entries - 1) { header += ","; diff --git a/api/test/baggage/propagation/baggage_propagator_test.cc b/api/test/baggage/propagation/baggage_propagator_test.cc index 94fe8b005b..83de75757b 100644 --- a/api/test/baggage/propagation/baggage_propagator_test.cc +++ b/api/test/baggage/propagation/baggage_propagator_test.cc @@ -62,7 +62,7 @@ TEST(BaggagePropagatorTest, ExtractAndInjectBaggage) {"invalid_header", ""}, // invalid header {very_large_baggage_header, ""}}; // baggage header larger than allowed size. - for (auto baggage : baggages) + for (const auto &baggage : baggages) { BaggageCarrierTest carrier1; carrier1.headers_[baggage::kBaggageHeader.data()] = baggage.first; diff --git a/api/test/common/kv_properties_test.cc b/api/test/common/kv_properties_test.cc index e5d9a2439e..f616664265 100644 --- a/api/test/common/kv_properties_test.cc +++ b/api/test/common/kv_properties_test.cc @@ -31,7 +31,7 @@ TEST(EntryTest, KeyValueConstruction) TEST(EntryTest, Copy) { KeyValueProperties::Entry e("test_key", "test_value"); - KeyValueProperties::Entry copy(e); + const KeyValueProperties::Entry ©(e); EXPECT_EQ(copy.GetKey(), e.GetKey()); EXPECT_EQ(copy.GetValue(), e.GetValue()); } diff --git a/api/test/context/context_test.cc b/api/test/context/context_test.cc index 764dac6477..294f1cd180 100644 --- a/api/test/context/context_test.cc +++ b/api/test/context/context_test.cc @@ -105,8 +105,8 @@ TEST(ContextTest, ContextCopyOperator) {"foo_key", static_cast(456)}, {"other_key", static_cast(789)}}; - context::Context test_context = context::Context(test_map); - context::Context copied_context = test_context; + context::Context test_context = context::Context(test_map); + const context::Context &copied_context = test_context; EXPECT_EQ(nostd::get(copied_context.GetValue("test_key")), 123); EXPECT_EQ(nostd::get(copied_context.GetValue("foo_key")), 456); @@ -135,7 +135,7 @@ TEST(ContextTest, ContextCopyCompare) { std::map map_test = {{"test_key", static_cast(123)}}; context::Context context_test = context::Context(map_test); - context::Context copied_test = context_test; + const context::Context &copied_test = context_test; EXPECT_TRUE(context_test == copied_test); } diff --git a/api/test/context/runtime_context_test.cc b/api/test/context/runtime_context_test.cc index c2ec732fe0..cd551c599c 100644 --- a/api/test/context/runtime_context_test.cc +++ b/api/test/context/runtime_context_test.cc @@ -113,6 +113,7 @@ TEST(RuntimeContextTest, DetachOutOfOrder) indices.push_back(3); std::vector contexts; + contexts.reserve(indices.size()); for (auto i : indices) { contexts.push_back(context::Context("index", static_cast(i))); @@ -122,6 +123,7 @@ TEST(RuntimeContextTest, DetachOutOfOrder) { std::vector> tokens; + tokens.reserve(contexts.size()); for (auto &c : contexts) { tokens.push_back(context::RuntimeContext::Attach(c)); diff --git a/api/test/logs/logger_benchmark.cc b/api/test/logs/logger_benchmark.cc index 098b9c7df8..db225d496a 100644 --- a/api/test/logs/logger_benchmark.cc +++ b/api/test/logs/logger_benchmark.cc @@ -16,13 +16,8 @@ #include using opentelemetry::logs::EventId; -using opentelemetry::logs::Logger; -using opentelemetry::logs::LoggerProvider; using opentelemetry::logs::Provider; using opentelemetry::logs::Severity; -using opentelemetry::nostd::shared_ptr; -using opentelemetry::nostd::span; -using opentelemetry::nostd::string_view; namespace common = opentelemetry::common; namespace nostd = opentelemetry::nostd; @@ -66,7 +61,7 @@ class Barrier static void ThreadRoutine(Barrier &barrier, benchmark::State &state, int thread_id, - std::function func) + const std::function &func) { barrier.Wait(); @@ -87,7 +82,7 @@ static void ThreadRoutine(Barrier &barrier, barrier.Wait(); } -void MultiThreadRunner(benchmark::State &state, std::function func) +void MultiThreadRunner(benchmark::State &state, const std::function &func) { int num_threads = std::thread::hardware_concurrency(); @@ -95,6 +90,7 @@ void MultiThreadRunner(benchmark::State &state, std::function func) std::vector threads; + threads.reserve(num_threads); for (int i = 0; i < num_threads; i++) { threads.emplace_back(ThreadRoutine, std::ref(barrier), std::ref(state), i, func); diff --git a/api/test/logs/logger_test.cc b/api/test/logs/logger_test.cc index 43d7afc685..848f053453 100644 --- a/api/test/logs/logger_test.cc +++ b/api/test/logs/logger_test.cc @@ -16,7 +16,6 @@ using opentelemetry::logs::LoggerProvider; using opentelemetry::logs::Provider; using opentelemetry::logs::Severity; using opentelemetry::nostd::shared_ptr; -using opentelemetry::nostd::span; using opentelemetry::nostd::string_view; namespace common = opentelemetry::common; namespace nostd = opentelemetry::nostd; diff --git a/api/test/metrics/meter_provider_test.cc b/api/test/metrics/meter_provider_test.cc index 878c5e9a3b..b8fb083799 100644 --- a/api/test/metrics/meter_provider_test.cc +++ b/api/test/metrics/meter_provider_test.cc @@ -6,7 +6,6 @@ #include "opentelemetry/metrics/provider.h" #include "opentelemetry/nostd/shared_ptr.h" -using opentelemetry::metrics::Meter; using opentelemetry::metrics::MeterProvider; using opentelemetry::metrics::NoopMeterProvider; using opentelemetry::metrics::Provider; diff --git a/api/test/nostd/shared_ptr_test.cc b/api/test/nostd/shared_ptr_test.cc index 0c79c7efd2..5c290c6284 100644 --- a/api/test/nostd/shared_ptr_test.cc +++ b/api/test/nostd/shared_ptr_test.cc @@ -63,7 +63,7 @@ TEST(SharedPtrTest, MoveConstruction) auto value = new int{123}; shared_ptr ptr1{value}; shared_ptr ptr2{std::move(ptr1)}; - EXPECT_EQ(ptr1.get(), nullptr); + EXPECT_EQ(ptr1.get(), nullptr); // NOLINT EXPECT_EQ(ptr2.get(), value); } @@ -72,7 +72,7 @@ TEST(SharedPtrTest, MoveConstructionFromDifferentType) auto value = new int{123}; shared_ptr ptr1{value}; shared_ptr ptr2{std::move(ptr1)}; - EXPECT_EQ(ptr1.get(), nullptr); + EXPECT_EQ(ptr1.get(), nullptr); // NOLINT EXPECT_EQ(ptr2.get(), value); } @@ -81,14 +81,14 @@ TEST(SharedPtrTest, MoveConstructionFromStdSharedPtr) auto value = new int{123}; std::shared_ptr ptr1{value}; shared_ptr ptr2{std::move(ptr1)}; - EXPECT_EQ(ptr1.get(), nullptr); + EXPECT_EQ(ptr1.get(), nullptr); // NOLINT EXPECT_EQ(ptr2.get(), value); } TEST(SharedPtrTest, Destruction) { bool was_destructed; - shared_ptr{new A{was_destructed}}; + shared_ptr{new A{was_destructed}}; // NOLINT EXPECT_TRUE(was_destructed); } @@ -173,7 +173,7 @@ static void SharedPtrTest_Sort(size_t size = 10) auto nums2 = nums; std::sort(nums.begin(), nums.end(), - [](shared_ptr a, shared_ptr b) { return *a < *b; }); + [](const shared_ptr &a, const shared_ptr &b) { return *a < *b; }); EXPECT_NE(nums, nums2); diff --git a/api/test/nostd/unique_ptr_test.cc b/api/test/nostd/unique_ptr_test.cc index f3684be0b8..893525c266 100644 --- a/api/test/nostd/unique_ptr_test.cc +++ b/api/test/nostd/unique_ptr_test.cc @@ -49,7 +49,7 @@ TEST(UniquePtrTest, MoveConstruction) auto value = new int{123}; unique_ptr ptr1{value}; unique_ptr ptr2{std::move(ptr1)}; - EXPECT_EQ(ptr1.get(), nullptr); + EXPECT_EQ(ptr1.get(), nullptr); // NOLINT EXPECT_EQ(ptr2.get(), value); } @@ -58,7 +58,7 @@ TEST(UniquePtrTest, MoveConstructionFromDifferentType) auto value = new int{123}; unique_ptr ptr1{value}; unique_ptr ptr2{std::move(ptr1)}; - EXPECT_EQ(ptr1.get(), nullptr); + EXPECT_EQ(ptr1.get(), nullptr); // NOLINT EXPECT_EQ(ptr2.get(), value); } @@ -67,14 +67,14 @@ TEST(UniquePtrTest, MoveConstructionFromStdUniquePtr) auto value = new int{123}; std::unique_ptr ptr1{value}; unique_ptr ptr2{std::move(ptr1)}; - EXPECT_EQ(ptr1.get(), nullptr); + EXPECT_EQ(ptr1.get(), nullptr); // NOLINT EXPECT_EQ(ptr2.get(), value); } TEST(UniquePtrTest, Destruction) { bool was_destructed; - unique_ptr{new A{was_destructed}}; + unique_ptr{new A{was_destructed}}; // NOLINT EXPECT_TRUE(was_destructed); } @@ -83,13 +83,13 @@ TEST(UniquePtrTest, StdUniquePtrConversionOperator) auto value = new int{123}; unique_ptr ptr1{value}; std::unique_ptr ptr2{std::move(ptr1)}; - EXPECT_EQ(ptr1.get(), nullptr); + EXPECT_EQ(ptr1.get(), nullptr); // NOLINT EXPECT_EQ(ptr2.get(), value); value = new int{456}; ptr1 = unique_ptr{value}; ptr2 = std::move(ptr1); - EXPECT_EQ(ptr1.get(), nullptr); + EXPECT_EQ(ptr1.get(), nullptr); // NOLINT EXPECT_EQ(ptr2.get(), value); ptr2 = nullptr; diff --git a/api/test/trace/trace_state_test.cc b/api/test/trace/trace_state_test.cc index 7f5a05cfe6..e6ed73c1f4 100644 --- a/api/test/trace/trace_state_test.cc +++ b/api/test/trace/trace_state_test.cc @@ -20,7 +20,7 @@ const char *kLongString = // -------------------------- TraceState class tests --------------------------- -std::string create_ts_return_header(std::string header) +std::string create_ts_return_header(const std::string &header) { auto ts = TraceState::FromHeader(header); return ts->ToHeader(); @@ -34,7 +34,7 @@ std::string header_with_max_members() { std::string key = "key" + std::to_string(i); std::string value = "value" + std::to_string(i); - header += key + "=" + value; + header.append(key).append("=").append(value); if (i != max_members - 1) { header += ","; diff --git a/examples/etw_threads/main.cc b/examples/etw_threads/main.cc index d25883d1d1..e5b8dbac9f 100644 --- a/examples/etw_threads/main.cc +++ b/examples/etw_threads/main.cc @@ -113,7 +113,7 @@ void beep() // Max number of threads to spawn constexpr int kMaxThreads = 10; -int main(int arc, char **argv) +int main(int /*arc*/, char ** /*argv*/) { std::thread pool[kMaxThreads]; diff --git a/examples/grpc/client.cc b/examples/grpc/client.cc index b8f233dcc7..9ca41c6958 100644 --- a/examples/grpc/client.cc +++ b/examples/grpc/client.cc @@ -20,7 +20,6 @@ using grpc::Channel; using grpc::ClientContext; -using grpc::ClientReader; using grpc::Status; using grpc_example::Greeter; @@ -34,7 +33,7 @@ using namespace opentelemetry::trace; class GreeterClient { public: - GreeterClient(std::shared_ptr channel) : stub_(Greeter::NewStub(channel)) {} + GreeterClient(const std::shared_ptr &channel) : stub_(Greeter::NewStub(channel)) {} std::string Greet(std::string ip, uint16_t port) { @@ -77,7 +76,7 @@ class GreeterClient } else { - std::cout << status.error_code() << ": " << status.error_message() << std::endl; + std::cout << status.error_code() << ": " << status.error_message() << '\n'; span->SetStatus(StatusCode::kError); span->SetAttribute(SemanticConventions::kRpcGrpcStatusCode, status.error_code()); // Make sure to end your spans! @@ -95,7 +94,7 @@ void RunClient(uint16_t port) GreeterClient greeter( grpc::CreateChannel("0.0.0.0:" + std::to_string(port), grpc::InsecureChannelCredentials())); std::string response = greeter.Greet("0.0.0.0", port); - std::cout << "grpc_server says: " << response << std::endl; + std::cout << "grpc_server says: " << response << '\n'; } } // namespace diff --git a/examples/grpc/server.cc b/examples/grpc/server.cc index a8fac8b5f0..3c3fcede4f 100644 --- a/examples/grpc/server.cc +++ b/examples/grpc/server.cc @@ -27,7 +27,6 @@ using grpc::Server; using grpc::ServerBuilder; using grpc::ServerContext; -using grpc::ServerWriter; using grpc::Status; using grpc_example::Greeter; @@ -49,7 +48,7 @@ class GreeterServer final : public Greeter::Service const GreetRequest *request, GreetResponse *response) override { - for (auto elem : context->client_metadata()) + for (const auto &elem : context->client_metadata()) { std::cout << "ELEM: " << elem.first << " " << elem.second << "\n"; } @@ -78,8 +77,8 @@ class GreeterServer final : public Greeter::Service // Fetch and parse whatever HTTP headers we can from the gRPC request. span->AddEvent("Processing client attributes"); - std::string req = request->request(); - std::cout << std::endl << "grpc_client says: " << req << std::endl; + const std::string &req = request->request(); + std::cout << '\n' << "grpc_client says: " << req << '\n'; std::string message = "The pleasure is mine."; // Send response to client response->set_response(message); @@ -102,7 +101,7 @@ void RunServer(uint16_t port) builder.AddListeningPort(address, grpc::InsecureServerCredentials()); std::unique_ptr server(builder.BuildAndStart()); - std::cout << "Server listening on port: " << address << std::endl; + std::cout << "Server listening on port: " << address << '\n'; server->Wait(); server->Shutdown(); } diff --git a/examples/logs_simple/main.cc b/examples/logs_simple/main.cc index 35827b6502..444775dc59 100644 --- a/examples/logs_simple/main.cc +++ b/examples/logs_simple/main.cc @@ -53,7 +53,7 @@ void InitTracer() #endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ // Set the global trace provider - std::shared_ptr api_provider = provider; + const std::shared_ptr &api_provider = provider; trace_api::Provider::SetTracerProvider(api_provider); } @@ -79,7 +79,7 @@ void InitLogger() #endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ // Set the global logger provider - std::shared_ptr api_provider = provider; + const std::shared_ptr &api_provider = provider; logs_api::Provider::SetLoggerProvider(api_provider); } diff --git a/examples/multi_processor/main.cc b/examples/multi_processor/main.cc index ceb7cdfcf9..d99d77de7d 100644 --- a/examples/multi_processor/main.cc +++ b/examples/multi_processor/main.cc @@ -70,29 +70,29 @@ void dumpSpans(std::vector> &spans) char span_buf[trace_api::SpanId::kSize * 2]; char trace_buf[trace_api::TraceId::kSize * 2]; char parent_span_buf[trace_api::SpanId::kSize * 2]; - std::cout << "\nSpans from memory :" << std::endl; + std::cout << "\nSpans from memory :" << '\n'; for (auto &span : spans) { - std::cout << "\n\tSpan: " << std::endl; - std::cout << "\t\tName: " << span->GetName() << std::endl; + std::cout << "\n\tSpan: " << '\n'; + std::cout << "\t\tName: " << span->GetName() << '\n'; span->GetSpanId().ToLowerBase16(span_buf); span->GetTraceId().ToLowerBase16(trace_buf); span->GetParentSpanId().ToLowerBase16(parent_span_buf); - std::cout << "\t\tTraceId: " << std::string(trace_buf, sizeof(trace_buf)) << std::endl; - std::cout << "\t\tSpanId: " << std::string(span_buf, sizeof(span_buf)) << std::endl; + std::cout << "\t\tTraceId: " << std::string(trace_buf, sizeof(trace_buf)) << '\n'; + std::cout << "\t\tSpanId: " << std::string(span_buf, sizeof(span_buf)) << '\n'; std::cout << "\t\tParentSpanId: " << std::string(parent_span_buf, sizeof(parent_span_buf)) - << std::endl; + << '\n'; - std::cout << "\t\tDescription: " << span->GetDescription() << std::endl; + std::cout << "\t\tDescription: " << span->GetDescription() << '\n'; std::cout << "\t\tSpan kind:" << static_cast::type>( span->GetSpanKind()) - << std::endl; + << '\n'; std::cout << "\t\tSpan Status: " << static_cast::type>( span->GetStatus()) - << std::endl; + << '\n'; } } } // namespace diff --git a/examples/multithreaded/main.cc b/examples/multithreaded/main.cc index d92a4ab2ac..675a6053ec 100644 --- a/examples/multithreaded/main.cc +++ b/examples/multithreaded/main.cc @@ -55,6 +55,7 @@ void run_threads() auto thread_span = get_tracer()->StartSpan(__func__); std::vector threads; + threads.reserve(5); for (int thread_num = 0; thread_num < 5; ++thread_num) { // This shows how one can effectively use Scope objects to correctly diff --git a/examples/otlp/http_log_main.cc b/examples/otlp/http_log_main.cc index 38aa009d04..37bace2b0f 100644 --- a/examples/otlp/http_log_main.cc +++ b/examples/otlp/http_log_main.cc @@ -71,7 +71,7 @@ void InitTracer() trace_opts.url = opentelemetry::exporter::otlp::GetOtlpDefaultHttpTracesEndpoint(); } } - std::cout << "Using " << trace_opts.url << " to export trace spans." << std::endl; + std::cout << "Using " << trace_opts.url << " to export trace spans." << '\n'; // Create OTLP exporter instance auto exporter = otlp::OtlpHttpExporterFactory::Create(trace_opts); @@ -110,7 +110,7 @@ std::shared_ptr logger_provider; void InitLogger() { - std::cout << "Using " << logger_opts.url << " to export log records." << std::endl; + std::cout << "Using " << logger_opts.url << " to export log records." << '\n'; logger_opts.console_debug = true; // Create OTLP exporter instance auto exporter = otlp::OtlpHttpLogRecordExporterFactory::Create(logger_opts); diff --git a/examples/simple/main.cc b/examples/simple/main.cc index a872816ba1..349aec500a 100644 --- a/examples/simple/main.cc +++ b/examples/simple/main.cc @@ -40,7 +40,7 @@ void InitTracer() #endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ // Set the global trace provider - std::shared_ptr api_provider = provider; + const std::shared_ptr &api_provider = provider; trace_api::Provider::SetTracerProvider(api_provider); } diff --git a/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h b/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h index feb68f7f9c..af4ccb16ef 100644 --- a/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h +++ b/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h @@ -33,13 +33,13 @@ class ElasticSearchRecordable final : public sdk::logs::Recordable */ void WriteKeyValue(nostd::string_view key, const opentelemetry::common::AttributeValue &value, - std::string name); + const std::string &name); void WriteKeyValue(nostd::string_view key, const opentelemetry::sdk::common::OwnedAttributeValue &value, - std::string name); + const std::string &name); - void WriteValue(const opentelemetry::common::AttributeValue &value, std::string name); + void WriteValue(const opentelemetry::common::AttributeValue &value, const std::string &name); public: /** diff --git a/exporters/elasticsearch/src/es_log_recordable.cc b/exporters/elasticsearch/src/es_log_recordable.cc index 139d22e863..663691273b 100644 --- a/exporters/elasticsearch/src/es_log_recordable.cc +++ b/exporters/elasticsearch/src/es_log_recordable.cc @@ -16,7 +16,7 @@ namespace logs { void ElasticSearchRecordable::WriteKeyValue(nostd::string_view key, const opentelemetry::common::AttributeValue &value, - std::string name) + const std::string &name) { switch (value.index()) { @@ -53,7 +53,7 @@ void ElasticSearchRecordable::WriteKeyValue(nostd::string_view key, void ElasticSearchRecordable::WriteKeyValue( nostd::string_view key, const opentelemetry::sdk::common::OwnedAttributeValue &value, - std::string name) + const std::string &name) { namespace common = opentelemetry::sdk::common; switch (value.index()) @@ -85,7 +85,7 @@ void ElasticSearchRecordable::WriteKeyValue( } void ElasticSearchRecordable::WriteValue(const opentelemetry::common::AttributeValue &value, - std::string name) + const std::string &name) { // Assert size of variant to ensure that this method gets updated if the variant diff --git a/exporters/memory/test/in_memory_span_data_test.cc b/exporters/memory/test/in_memory_span_data_test.cc index bc19550264..be013734ef 100644 --- a/exporters/memory/test/in_memory_span_data_test.cc +++ b/exporters/memory/test/in_memory_span_data_test.cc @@ -8,7 +8,6 @@ #include using opentelemetry::exporter::memory::InMemorySpanData; -using opentelemetry::sdk::trace::Recordable; using opentelemetry::sdk::trace::SpanData; TEST(InMemorySpanData, AddRecordable) diff --git a/exporters/ostream/include/opentelemetry/exporters/ostream/log_record_exporter.h b/exporters/ostream/include/opentelemetry/exporters/ostream/log_record_exporter.h index 24bc8e5be7..840d7d5b8a 100644 --- a/exporters/ostream/include/opentelemetry/exporters/ostream/log_record_exporter.h +++ b/exporters/ostream/include/opentelemetry/exporters/ostream/log_record_exporter.h @@ -66,10 +66,10 @@ class OStreamLogRecordExporter final : public opentelemetry::sdk::logs::LogRecor bool isShutdown() const noexcept; void printAttributes( const std::unordered_map &map, - const std::string prefix = "\n\t"); + const std::string &prefix = "\n\t"); void printAttributes( const std::unordered_map &map, - const std::string prefix = "\n\t"); + const std::string &prefix = "\n\t"); }; } // namespace logs } // namespace exporter diff --git a/exporters/ostream/include/opentelemetry/exporters/ostream/metric_exporter.h b/exporters/ostream/include/opentelemetry/exporters/ostream/metric_exporter.h index 1ad124a9ab..f1b2cd6ef9 100644 --- a/exporters/ostream/include/opentelemetry/exporters/ostream/metric_exporter.h +++ b/exporters/ostream/include/opentelemetry/exporters/ostream/metric_exporter.h @@ -79,7 +79,7 @@ class OStreamMetricExporter final : public opentelemetry::sdk::metrics::PushMetr void printPointData(const opentelemetry::sdk::metrics::PointType &point_data); void printPointAttributes(const opentelemetry::sdk::metrics::PointAttributes &point_attributes); void printAttributes(const std::map &map, - const std::string prefix); + const std::string &prefix); void printResources(const opentelemetry::sdk::resource::Resource &resources); }; } // namespace metrics diff --git a/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h b/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h index a7de9a5eb4..e22eb77f3e 100644 --- a/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h +++ b/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h @@ -69,7 +69,7 @@ class OStreamSpanExporter final : public opentelemetry::sdk::trace::SpanExporter // various print helpers void printAttributes( const std::unordered_map &map, - const std::string prefix = "\n\t"); + const std::string &prefix = "\n\t"); void printEvents(const std::vector &events); diff --git a/exporters/ostream/src/log_record_exporter.cc b/exporters/ostream/src/log_record_exporter.cc index 7f661276c8..26266161c3 100644 --- a/exporters/ostream/src/log_record_exporter.cc +++ b/exporters/ostream/src/log_record_exporter.cc @@ -75,11 +75,11 @@ sdk::common::ExportResult OStreamLogRecordExporter::Export( // Convert trace, spanid, traceflags into exportable representation constexpr int trace_id_len = 32; - constexpr int span_id__len = 16; + constexpr int span_id_len = 16; constexpr int trace_flags_len = 2; char trace_id[trace_id_len] = {0}; - char span_id[span_id__len] = {0}; + char span_id[span_id_len] = {0}; char trace_flags[trace_flags_len] = {0}; log_record->GetTraceId().ToLowerBase16(trace_id); @@ -120,7 +120,7 @@ sdk::common::ExportResult OStreamLogRecordExporter::Export( << " event_id : " << event_id << "\n" << " event_name : " << log_record->GetEventName() << "\n" << " trace_id : " << std::string(trace_id, trace_id_len) << "\n" - << " span_id : " << std::string(span_id, span_id__len) << "\n" + << " span_id : " << std::string(span_id, span_id_len) << "\n" << " trace_flags : " << std::string(trace_flags, trace_flags_len) << "\n" << " scope : \n" << " name : " << log_record->GetInstrumentationScope().GetName() << "\n" @@ -155,7 +155,7 @@ bool OStreamLogRecordExporter::isShutdown() const noexcept void OStreamLogRecordExporter::printAttributes( const std::unordered_map &map, - const std::string prefix) + const std::string &prefix) { for (const auto &kv : map) { @@ -166,7 +166,7 @@ void OStreamLogRecordExporter::printAttributes( void OStreamLogRecordExporter::printAttributes( const std::unordered_map &map, - const std::string prefix) + const std::string &prefix) { for (const auto &kv : map) { diff --git a/exporters/ostream/src/metric_exporter.cc b/exporters/ostream/src/metric_exporter.cc index 08bfe340c7..4bdd122492 100644 --- a/exporters/ostream/src/metric_exporter.cc +++ b/exporters/ostream/src/metric_exporter.cc @@ -117,7 +117,7 @@ sdk::common::ExportResult OStreamMetricExporter::Export( void OStreamMetricExporter::printAttributes( const std::map &map, - const std::string prefix) + const std::string &prefix) { for (const auto &kv : map) { diff --git a/exporters/ostream/src/span_exporter.cc b/exporters/ostream/src/span_exporter.cc index 9437ae561a..f41d33ae6c 100644 --- a/exporters/ostream/src/span_exporter.cc +++ b/exporters/ostream/src/span_exporter.cc @@ -100,7 +100,7 @@ sdk::common::ExportResult OStreamSpanExporter::Export( << "\n duration : " << span->GetDuration().count() << "\n description : " << span->GetDescription() << "\n span kind : " << span->GetSpanKind() - << "\n status : " << statusMap[int(span->GetStatus())] + << "\n status : " << statusMap[static_cast(span->GetStatus())] << "\n attributes : "; printAttributes(span->GetAttributes()); sout_ << "\n events : "; @@ -137,7 +137,7 @@ bool OStreamSpanExporter::isShutdown() const noexcept void OStreamSpanExporter::printAttributes( const std::unordered_map &map, - const std::string prefix) + const std::string &prefix) { for (const auto &kv : map) { @@ -177,7 +177,7 @@ void OStreamSpanExporter::printLinks(const std::vector void OStreamSpanExporter::printResources(const opentelemetry::sdk::resource::Resource &resources) { - auto attributes = resources.GetAttributes(); + const auto &attributes = resources.GetAttributes(); if (attributes.size()) { printAttributes(attributes, "\n\t"); @@ -188,7 +188,7 @@ void OStreamSpanExporter::printInstrumentationScope( const opentelemetry::sdk::instrumentationscope::InstrumentationScope &instrumentation_scope) { sout_ << instrumentation_scope.GetName(); - auto version = instrumentation_scope.GetVersion(); + const auto &version = instrumentation_scope.GetVersion(); if (version.size()) { sout_ << "-" << version; diff --git a/exporters/ostream/test/ostream_log_test.cc b/exporters/ostream/test/ostream_log_test.cc index 7b22d9b3fd..b7708f3153 100644 --- a/exporters/ostream/test/ostream_log_test.cc +++ b/exporters/ostream/test/ostream_log_test.cc @@ -97,17 +97,17 @@ TEST(OstreamLogExporter, DefaultLogRecordToCout) std::cout.rdbuf(original); std::vector expected_output{ - "{\n" + "{\n", " timestamp : 0\n", - " severity_num : 0\n" - " severity_text : INVALID\n" + " severity_num : 0\n", + " severity_text : INVALID\n", " body : \n", " resource : \n", " telemetry.sdk.version: " OPENTELEMETRY_VERSION "\n", " telemetry.sdk.name: opentelemetry\n", " telemetry.sdk.language: cpp\n", " attributes : \n", - " event_id : 0\n" + " event_id : 0\n", " event_name : \n", " trace_id : 00000000000000000000000000000000\n", " span_id : 0000000000000000\n", @@ -126,7 +126,7 @@ TEST(OstreamLogExporter, DefaultLogRecordToCout) std::string::size_type result = ostream_output.find(expected); if (result == std::string::npos) { - std::cout << "Can not find: \"" << expected << "\" in\n" << ostream_output << std::endl; + std::cout << "Can not find: \"" << expected << "\" in\n" << ostream_output << '\n'; } ASSERT_NE(result, std::string::npos); } @@ -167,9 +167,8 @@ TEST(OStreamLogRecordExporter, SimpleLogToCout) std::cout.rdbuf(original); std::vector expected_output{ - "{\n" - " timestamp : " + - std::to_string(now.time_since_epoch().count()) + + "{\n", + " timestamp : " + std::to_string(now.time_since_epoch().count()) + "\n" " observed_timestamp : " + std::to_string(now.time_since_epoch().count()) + @@ -182,7 +181,7 @@ TEST(OStreamLogRecordExporter, SimpleLogToCout) " telemetry.sdk.name: opentelemetry\n", " telemetry.sdk.language: cpp\n", " attributes : \n", - " event_id : 0\n" + " event_id : 0\n", " event_name : \n", " trace_id : 00000000000000000000000000000000\n", " span_id : 0000000000000000\n", @@ -201,7 +200,7 @@ TEST(OStreamLogRecordExporter, SimpleLogToCout) std::string::size_type result = ostream_output.find(expected); if (result == std::string::npos) { - std::cout << "Can not find: \"" << expected << "\" in\n" << ostream_output << std::endl; + std::cout << "Can not find: \"" << expected << "\" in\n" << ostream_output << '\n'; } ASSERT_NE(result, std::string::npos); } @@ -243,10 +242,10 @@ TEST(OStreamLogRecordExporter, LogWithStringAttributesToCerr) std::cerr.rdbuf(original); std::vector expected_output{ - "{\n" + "{\n", " timestamp : 0\n", - " severity_num : 0\n" - " severity_text : INVALID\n" + " severity_num : 0\n", + " severity_text : INVALID\n", " body : \n", " resource : \n", " telemetry.sdk.version: " OPENTELEMETRY_VERSION "\n", @@ -256,7 +255,7 @@ TEST(OStreamLogRecordExporter, LogWithStringAttributesToCerr) " key1: val1\n", " attributes : \n", " a: 1\n", - " event_id : 0\n" + " event_id : 0\n", " event_name : \n", " trace_id : 00000000000000000000000000000000\n", " span_id : 0000000000000000\n", @@ -275,7 +274,7 @@ TEST(OStreamLogRecordExporter, LogWithStringAttributesToCerr) std::string::size_type result = ostream_output.find(expected); if (result == std::string::npos) { - std::cout << "Can not find: \"" << expected << "\" in\n" << ostream_output << std::endl; + std::cout << "Can not find: \"" << expected << "\" in\n" << ostream_output << '\n'; } ASSERT_NE(result, std::string::npos); } @@ -324,10 +323,10 @@ TEST(OStreamLogRecordExporter, LogWithVariantTypesToClog) std::clog.rdbuf(original); std::vector expected_output{ - "{\n" + "{\n", " timestamp : 0\n", - " severity_num : 0\n" - " severity_text : INVALID\n" + " severity_num : 0\n", + " severity_text : INVALID\n", " body : \n", " resource : \n", " service.name: unknown_service\n", @@ -337,7 +336,7 @@ TEST(OStreamLogRecordExporter, LogWithVariantTypesToClog) " res1: [1,2,3]\n", " attributes : \n", " attr1: [0,1,0]\n", - " event_id : 0\n" + " event_id : 0\n", " event_name : \n", " trace_id : 00000000000000000000000000000000\n", " span_id : 0000000000000000\n", @@ -356,7 +355,7 @@ TEST(OStreamLogRecordExporter, LogWithVariantTypesToClog) std::string::size_type result = ostream_output.find(expected); if (result == std::string::npos) { - std::cout << "Can not find: \"" << expected << "\" in\n" << ostream_output << std::endl; + std::cout << "Can not find: \"" << expected << "\" in\n" << ostream_output << '\n'; } ASSERT_NE(result, std::string::npos); } @@ -398,11 +397,10 @@ TEST(OStreamLogRecordExporter, IntegrationTest) // Compare actual vs expected outputs std::vector expected_output{ - "{\n" - " timestamp : " + - std::to_string(now.time_since_epoch().count()) + "\n", - " severity_num : 5\n" - " severity_text : DEBUG\n" + "{\n", + " timestamp : " + std::to_string(now.time_since_epoch().count()) + "\n", + " severity_num : 5\n", + " severity_text : DEBUG\n", " body : Hello\n", " resource : \n", " telemetry.sdk.version: " OPENTELEMETRY_VERSION "\n", @@ -410,7 +408,7 @@ TEST(OStreamLogRecordExporter, IntegrationTest) " telemetry.sdk.name: opentelemetry\n", " telemetry.sdk.language: cpp\n", " attributes : \n", - " event_id : 0\n" + " event_id : 0\n", " event_name : \n", " trace_id : 00000000000000000000000000000000\n", " span_id : 0000000000000000\n", @@ -429,7 +427,7 @@ TEST(OStreamLogRecordExporter, IntegrationTest) std::string::size_type result = ostream_output.find(expected); if (result == std::string::npos) { - std::cout << "Can not find: \"" << expected << "\" in\n" << ostream_output << std::endl; + std::cout << "Can not find: \"" << expected << "\" in\n" << ostream_output << '\n'; } ASSERT_NE(result, std::string::npos); } @@ -472,8 +470,8 @@ TEST(OStreamLogRecordExporter, IntegrationTestWithEventId) // Compare actual vs expected outputs std::vector expected_output{ - " severity_num : 5\n" - " severity_text : DEBUG\n" + " severity_num : 5\n", + " severity_text : DEBUG\n", " body : Hello {key1} {key2}\n", " resource : \n", " telemetry.sdk.version: " OPENTELEMETRY_VERSION "\n", @@ -481,7 +479,7 @@ TEST(OStreamLogRecordExporter, IntegrationTestWithEventId) " telemetry.sdk.name: opentelemetry\n", " telemetry.sdk.language: cpp\n", " attributes : \n", - " event_id : 12345678\n" + " event_id : 12345678\n", " event_name : test_event_id\n", " trace_id : 00000000000000000000000000000000\n", " span_id : 0000000000000000\n", @@ -500,7 +498,7 @@ TEST(OStreamLogRecordExporter, IntegrationTestWithEventId) std::string::size_type result = ostream_output.find(expected); if (result == std::string::npos) { - std::cout << "Can not find: \"" << expected << "\" in\n" << ostream_output << std::endl; + std::cout << "Can not find: \"" << expected << "\" in\n" << ostream_output << '\n'; } ASSERT_NE(result, std::string::npos); } diff --git a/exporters/ostream/test/ostream_span_test.cc b/exporters/ostream/test/ostream_span_test.cc index f92f1bbffd..cadc1b9d38 100644 --- a/exporters/ostream/test/ostream_span_test.cc +++ b/exporters/ostream/test/ostream_span_test.cc @@ -31,7 +31,7 @@ using Attributes = std::initializer_listEXPRESS; \ + (VAR) = tm_obj_ptr->EXPRESS; \ } \ else \ { \ - VAR = tm_obj_ptr->EXPRESS; \ + (VAR) = tm_obj_ptr->EXPRESS; \ } for (size_t i = 0; i < fmt.size() && ret < bufz && running; ++i) @@ -619,7 +619,7 @@ class OPENTELEMETRY_LOCAL_SYMBOL FileSystemUtil } #if !defined(UTIL_FS_DISABLE_LINK) - enum class LinkOption : int32_t + enum class LinkOption : uint8_t { kDefault = 0x00, // hard link for default kSymbolicLink = 0x01, // or soft link @@ -749,6 +749,7 @@ static void ConvertListFieldToJson(nlohmann::json &value, const google::protobuf::Message &message, const google::protobuf::FieldDescriptor *field_descriptor); +// NOLINTBEGIN(misc-no-recursion) static void ConvertGenericMessageToJson(nlohmann::json &value, const google::protobuf::Message &message) { @@ -952,6 +953,8 @@ void ConvertListFieldToJson(nlohmann::json &value, } } +// NOLINTEND(misc-no-recursion) suppressing for performance as if implemented with stack needs +// Dynamic memory allocation } // namespace class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileSystemBackend : public OtlpFileAppender diff --git a/exporters/otlp/src/otlp_grpc_client.cc b/exporters/otlp/src/otlp_grpc_client.cc index 3410726cf8..a5760bdd81 100644 --- a/exporters/otlp/src/otlp_grpc_client.cc +++ b/exporters/otlp/src/otlp_grpc_client.cc @@ -132,7 +132,7 @@ static std::string GetFileContentsOrInMemoryContents(const std::string &file_pat #ifdef ENABLE_ASYNC_EXPORT template static sdk::common::ExportResult InternalDelegateAsyncExport( - std::shared_ptr async_data, + const std::shared_ptr &async_data, StubType *stub, std::unique_ptr &&context, std::unique_ptr &&arena, @@ -163,8 +163,8 @@ static sdk::common::ExportResult InternalDelegateAsyncExport( call_data->arena.swap(arena); call_data->result_callback.swap(result_callback); - call_data->request = - google::protobuf::Arena::Create(call_data->arena.get(), std::move(request)); + call_data->request = google::protobuf::Arena::Create( + call_data->arena.get(), std::forward(request)); call_data->response = google::protobuf::Arena::Create(call_data->arena.get()); if (call_data->request == nullptr || call_data->response == nullptr) diff --git a/exporters/otlp/src/otlp_http_client.cc b/exporters/otlp/src/otlp_http_client.cc index 03eb5fb434..94f02a9967 100644 --- a/exporters/otlp/src/otlp_http_client.cc +++ b/exporters/otlp/src/otlp_http_client.cc @@ -434,6 +434,7 @@ static void ConvertListFieldToJson(nlohmann::json &value, const google::protobuf::FieldDescriptor *field_descriptor, const OtlpHttpClientOptions &options); +// NOLINTBEGIN(misc-no-recursion) static void ConvertGenericMessageToJson(nlohmann::json &value, const google::protobuf::Message &message, const OtlpHttpClientOptions &options) @@ -654,6 +655,9 @@ void ConvertListFieldToJson(nlohmann::json &value, } } +// NOLINTEND(misc-no-recursion) suppressing for performance, if implemented iterative process needs +// Dynamic memory allocation + } // namespace OtlpHttpClient::OtlpHttpClient(OtlpHttpClientOptions &&options) @@ -696,7 +700,7 @@ OtlpHttpClient::~OtlpHttpClient() OtlpHttpClient::OtlpHttpClient(OtlpHttpClientOptions &&options, std::shared_ptr http_client) - : is_shutdown_(false), options_(options), http_client_(http_client) + : is_shutdown_(false), options_(options), http_client_(std::move(http_client)) { http_client_->SetMaxSessionsPerConnection(options_.max_requests_per_connection); } @@ -881,7 +885,7 @@ OtlpHttpClient::createSession( std::string error_message = "[OTLP HTTP Client] Export failed, invalid url: " + options_.url; if (options_.console_debug) { - std::cerr << error_message << std::endl; + std::cerr << error_message << '\n'; } OTEL_INTERNAL_LOG_ERROR(error_message.c_str()); @@ -946,7 +950,7 @@ OtlpHttpClient::createSession( const char *error_message = "[OTLP HTTP Client] Export failed, exporter is shutdown"; if (options_.console_debug) { - std::cerr << error_message << std::endl; + std::cerr << error_message << '\n'; } OTEL_INTERNAL_LOG_ERROR(error_message); diff --git a/exporters/otlp/test/otlp_http_exporter_test.cc b/exporters/otlp/test/otlp_http_exporter_test.cc index e4f69f502b..4c4a6dbeb2 100644 --- a/exporters/otlp/test/otlp_http_exporter_test.cc +++ b/exporters/otlp/test/otlp_http_exporter_test.cc @@ -58,8 +58,7 @@ OtlpHttpClientOptions MakeOtlpHttpClientOptions(HttpRequestContentType content_t options.content_type = content_type; options.console_debug = true; options.timeout = std::chrono::system_clock::duration::zero(); - options.http_headers.insert( - std::make_pair("Custom-Header-Key", "Custom-Header-Value")); + options.http_headers.insert(std::make_pair("Custom-Header-Key", "Custom-Header-Value")); OtlpHttpClientOptions otlp_http_client_options( options.url, false, /* ssl_insecure_skip_verify */ "", /* ssl_ca_cert_path */ "", /* ssl_ca_cert_string */ @@ -158,34 +157,35 @@ class OtlpHttpExporterTestPeer : public ::testing::Test auto mock_session = std::static_pointer_cast(no_send_client->session_); EXPECT_CALL(*mock_session, SendRequest) - .WillOnce([&mock_session, report_trace_id]( - std::shared_ptr callback) { - auto check_json = - nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); - auto resource_span = *check_json["resourceSpans"].begin(); - auto scope_span = *resource_span["scopeSpans"].begin(); - auto span = *scope_span["spans"].begin(); - auto received_trace_id = span["traceId"].get(); - EXPECT_EQ(received_trace_id, report_trace_id); - - auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); - ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); - if (custom_header != mock_session->GetRequest()->headers_.end()) - { - EXPECT_EQ("Custom-Header-Value", custom_header->second); - } - - auto user_agent_header = mock_session->GetRequest()->headers_.find("User-Agent"); - ASSERT_TRUE(user_agent_header != mock_session->GetRequest()->headers_.end()); - if (user_agent_header != mock_session->GetRequest()->headers_.end()) - { - EXPECT_EQ(GetOtlpDefaultUserAgent(), user_agent_header->second); - } - - // let the otlp_http_client to continue - http_client::nosend::Response response; - response.Finish(*callback.get()); - }); + .WillOnce( + [&mock_session, report_trace_id]( + const std::shared_ptr &callback) { + auto check_json = + nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); + auto resource_span = *check_json["resourceSpans"].begin(); + auto scope_span = *resource_span["scopeSpans"].begin(); + auto span = *scope_span["spans"].begin(); + auto received_trace_id = span["traceId"].get(); + EXPECT_EQ(received_trace_id, report_trace_id); + + auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); + ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); + if (custom_header != mock_session->GetRequest()->headers_.end()) + { + EXPECT_EQ("Custom-Header-Value", custom_header->second); + } + + auto user_agent_header = mock_session->GetRequest()->headers_.find("User-Agent"); + ASSERT_TRUE(user_agent_header != mock_session->GetRequest()->headers_.end()); + if (user_agent_header != mock_session->GetRequest()->headers_.end()) + { + EXPECT_EQ(GetOtlpDefaultUserAgent(), user_agent_header->second); + } + + // let the otlp_http_client to continue + http_client::nosend::Response response; + response.Finish(*callback.get()); + }); child_span->End(); parent_span->End(); @@ -249,38 +249,39 @@ class OtlpHttpExporterTestPeer : public ::testing::Test auto mock_session = std::static_pointer_cast(no_send_client->session_); EXPECT_CALL(*mock_session, SendRequest) - .WillOnce([&mock_session, report_trace_id]( - std::shared_ptr callback) { - auto check_json = - nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); - auto resource_span = *check_json["resourceSpans"].begin(); - auto scope_span = *resource_span["scopeSpans"].begin(); - auto span = *scope_span["spans"].begin(); - auto received_trace_id = span["traceId"].get(); - EXPECT_EQ(received_trace_id, report_trace_id); - - auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); - ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); - if (custom_header != mock_session->GetRequest()->headers_.end()) - { - EXPECT_EQ("Custom-Header-Value", custom_header->second); - } - - auto user_agent_header = mock_session->GetRequest()->headers_.find("User-Agent"); - ASSERT_TRUE(user_agent_header != mock_session->GetRequest()->headers_.end()); - if (user_agent_header != mock_session->GetRequest()->headers_.end()) - { - EXPECT_EQ(GetOtlpDefaultUserAgent(), user_agent_header->second); - } - - // let the otlp_http_client to continue - std::thread async_finish{[callback]() { - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - http_client::nosend::Response response; - response.Finish(*callback.get()); - }}; - async_finish.detach(); - }); + .WillOnce( + [&mock_session, report_trace_id]( + const std::shared_ptr &callback) { + auto check_json = + nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); + auto resource_span = *check_json["resourceSpans"].begin(); + auto scope_span = *resource_span["scopeSpans"].begin(); + auto span = *scope_span["spans"].begin(); + auto received_trace_id = span["traceId"].get(); + EXPECT_EQ(received_trace_id, report_trace_id); + + auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); + ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); + if (custom_header != mock_session->GetRequest()->headers_.end()) + { + EXPECT_EQ("Custom-Header-Value", custom_header->second); + } + + auto user_agent_header = mock_session->GetRequest()->headers_.find("User-Agent"); + ASSERT_TRUE(user_agent_header != mock_session->GetRequest()->headers_.end()); + if (user_agent_header != mock_session->GetRequest()->headers_.end()) + { + EXPECT_EQ(GetOtlpDefaultUserAgent(), user_agent_header->second); + } + + // let the otlp_http_client to continue + std::thread async_finish{[callback]() { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + http_client::nosend::Response response; + response.Finish(*callback.get()); + }}; + async_finish.detach(); + }); child_span->End(); parent_span->End(); @@ -343,25 +344,27 @@ class OtlpHttpExporterTestPeer : public ::testing::Test auto mock_session = std::static_pointer_cast(no_send_client->session_); EXPECT_CALL(*mock_session, SendRequest) - .WillOnce([&mock_session, report_trace_id]( - std::shared_ptr callback) { - opentelemetry::proto::collector::trace::v1::ExportTraceServiceRequest request_body; - request_body.ParseFromArray(&mock_session->GetRequest()->body_[0], - static_cast(mock_session->GetRequest()->body_.size())); - auto received_trace_id = - request_body.resource_spans(0).scope_spans(0).spans(0).trace_id(); - EXPECT_EQ(received_trace_id, report_trace_id); - - auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); - ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); - if (custom_header != mock_session->GetRequest()->headers_.end()) - { - EXPECT_EQ("Custom-Header-Value", custom_header->second); - } - - http_client::nosend::Response response; - response.Finish(*callback.get()); - }); + .WillOnce( + [&mock_session, report_trace_id]( + const std::shared_ptr &callback) { + opentelemetry::proto::collector::trace::v1::ExportTraceServiceRequest request_body; + request_body.ParseFromArray( + &mock_session->GetRequest()->body_[0], + static_cast(mock_session->GetRequest()->body_.size())); + auto received_trace_id = + request_body.resource_spans(0).scope_spans(0).spans(0).trace_id(); + EXPECT_EQ(received_trace_id, report_trace_id); + + auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); + ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); + if (custom_header != mock_session->GetRequest()->headers_.end()) + { + EXPECT_EQ("Custom-Header-Value", custom_header->second); + } + + http_client::nosend::Response response; + response.Finish(*callback.get()); + }); child_span->End(); parent_span->End(); @@ -424,30 +427,32 @@ class OtlpHttpExporterTestPeer : public ::testing::Test auto mock_session = std::static_pointer_cast(no_send_client->session_); EXPECT_CALL(*mock_session, SendRequest) - .WillOnce([&mock_session, report_trace_id]( - std::shared_ptr callback) { - opentelemetry::proto::collector::trace::v1::ExportTraceServiceRequest request_body; - request_body.ParseFromArray(&mock_session->GetRequest()->body_[0], - static_cast(mock_session->GetRequest()->body_.size())); - auto received_trace_id = - request_body.resource_spans(0).scope_spans(0).spans(0).trace_id(); - EXPECT_EQ(received_trace_id, report_trace_id); - - auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); - ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); - if (custom_header != mock_session->GetRequest()->headers_.end()) - { - EXPECT_EQ("Custom-Header-Value", custom_header->second); - } - - // let the otlp_http_client to continue - std::thread async_finish{[callback]() { - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - http_client::nosend::Response response; - response.Finish(*callback.get()); - }}; - async_finish.detach(); - }); + .WillOnce( + [&mock_session, report_trace_id]( + const std::shared_ptr &callback) { + opentelemetry::proto::collector::trace::v1::ExportTraceServiceRequest request_body; + request_body.ParseFromArray( + &mock_session->GetRequest()->body_[0], + static_cast(mock_session->GetRequest()->body_.size())); + auto received_trace_id = + request_body.resource_spans(0).scope_spans(0).spans(0).trace_id(); + EXPECT_EQ(received_trace_id, report_trace_id); + + auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); + ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); + if (custom_header != mock_session->GetRequest()->headers_.end()) + { + EXPECT_EQ("Custom-Header-Value", custom_header->second); + } + + // let the otlp_http_client to continue + std::thread async_finish{[callback]() { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + http_client::nosend::Response response; + response.Finish(*callback.get()); + }}; + async_finish.detach(); + }); child_span->End(); parent_span->End(); diff --git a/exporters/otlp/test/otlp_http_log_record_exporter_test.cc b/exporters/otlp/test/otlp_http_log_record_exporter_test.cc index 5fbf95798f..35a0bb62e2 100644 --- a/exporters/otlp/test/otlp_http_log_record_exporter_test.cc +++ b/exporters/otlp/test/otlp_http_log_record_exporter_test.cc @@ -57,8 +57,7 @@ OtlpHttpClientOptions MakeOtlpHttpClientOptions(HttpRequestContentType content_t OtlpHttpLogRecordExporterOptions options; options.content_type = content_type; options.console_debug = true; - options.http_headers.insert( - std::make_pair("Custom-Header-Key", "Custom-Header-Value")); + options.http_headers.insert(std::make_pair("Custom-Header-Key", "Custom-Header-Value")); OtlpHttpClientOptions otlp_http_client_options( options.url, false, /* ssl_insecure_skip_verify */ "", /* ssl_ca_cert_path */ "", /* ssl_ca_cert_string */ @@ -151,46 +150,47 @@ class OtlpHttpLogRecordExporterTestPeer : public ::testing::Test auto mock_session = std::static_pointer_cast(no_send_client->session_); EXPECT_CALL(*mock_session, SendRequest) - .WillOnce([&mock_session, report_trace_id, report_span_id]( - std::shared_ptr callback) { - auto check_json = - nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); - auto resource_logs = *check_json["resourceLogs"].begin(); - auto scope_logs = *resource_logs["scopeLogs"].begin(); - auto scope = scope_logs["scope"]; - auto log = *scope_logs["logRecords"].begin(); - auto received_trace_id = log["traceId"].get(); - auto received_span_id = log["spanId"].get(); - EXPECT_EQ(received_trace_id, report_trace_id); - EXPECT_EQ(received_span_id, report_span_id); - EXPECT_EQ("Log message", log["body"]["stringValue"].get()); - EXPECT_LE(15, log["attributes"].size()); - auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); - ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); - if (custom_header != mock_session->GetRequest()->headers_.end()) - { - EXPECT_EQ("Custom-Header-Value", custom_header->second); - } - - bool check_scope_attribute = false; - auto scope_attributes = scope["attributes"]; - for (auto &attribute : scope_attributes) - { - if (!attribute.is_object()) - { - continue; - } - if ("scope_key1" == attribute["key"]) - { - check_scope_attribute = true; - EXPECT_EQ("scope_value", attribute["value"]["stringValue"].get()); - } - } - ASSERT_TRUE(check_scope_attribute); - - http_client::nosend::Response response; - response.Finish(*callback.get()); - }); + .WillOnce( + [&mock_session, report_trace_id, report_span_id]( + const std::shared_ptr &callback) { + auto check_json = + nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); + auto resource_logs = *check_json["resourceLogs"].begin(); + auto scope_logs = *resource_logs["scopeLogs"].begin(); + auto scope = scope_logs["scope"]; + auto log = *scope_logs["logRecords"].begin(); + auto received_trace_id = log["traceId"].get(); + auto received_span_id = log["spanId"].get(); + EXPECT_EQ(received_trace_id, report_trace_id); + EXPECT_EQ(received_span_id, report_span_id); + EXPECT_EQ("Log message", log["body"]["stringValue"].get()); + EXPECT_LE(15, log["attributes"].size()); + auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); + ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); + if (custom_header != mock_session->GetRequest()->headers_.end()) + { + EXPECT_EQ("Custom-Header-Value", custom_header->second); + } + + bool check_scope_attribute = false; + auto scope_attributes = scope["attributes"]; + for (auto &attribute : scope_attributes) + { + if (!attribute.is_object()) + { + continue; + } + if ("scope_key1" == attribute["key"]) + { + check_scope_attribute = true; + EXPECT_EQ("scope_value", attribute["value"]["stringValue"].get()); + } + } + ASSERT_TRUE(check_scope_attribute); + + http_client::nosend::Response response; + response.Finish(*callback.get()); + }); logger->EmitLogRecord( opentelemetry::logs::Severity::kInfo, "Log message", @@ -268,57 +268,58 @@ class OtlpHttpLogRecordExporterTestPeer : public ::testing::Test auto mock_session = std::static_pointer_cast(no_send_client->session_); EXPECT_CALL(*mock_session, SendRequest) - .WillOnce([&mock_session, report_trace_id, report_span_id]( - std::shared_ptr callback) { - auto check_json = - nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); - auto resource_logs = *check_json["resourceLogs"].begin(); - auto scope_logs = *resource_logs["scopeLogs"].begin(); - auto schema_url = scope_logs["schemaUrl"].get(); - auto scope = scope_logs["scope"]; - auto scope_name = scope["name"]; - auto scope_version = scope["version"]; - auto log = *scope_logs["logRecords"].begin(); - auto received_trace_id = log["traceId"].get(); - auto received_span_id = log["spanId"].get(); - EXPECT_EQ(schema_url, "https://opentelemetry.io/schemas/1.2.0"); - EXPECT_EQ(scope_name, "opentelelemtry_library"); - EXPECT_EQ(scope_version, "1.2.0"); - EXPECT_EQ(received_trace_id, report_trace_id); - EXPECT_EQ(received_span_id, report_span_id); - EXPECT_EQ("Log message", log["body"]["stringValue"].get()); - EXPECT_LE(15, log["attributes"].size()); - auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); - ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); - if (custom_header != mock_session->GetRequest()->headers_.end()) - { - EXPECT_EQ("Custom-Header-Value", custom_header->second); - } - - bool check_scope_attribute = false; - auto scope_attributes = scope["attributes"]; - for (auto &attribute : scope_attributes) - { - if (!attribute.is_object()) - { - continue; - } - if ("scope_key1" == attribute["key"]) - { - check_scope_attribute = true; - EXPECT_EQ("scope_value", attribute["value"]["stringValue"].get()); - } - } - ASSERT_TRUE(check_scope_attribute); - - // let the otlp_http_client to continue - std::thread async_finish{[callback]() { - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - http_client::nosend::Response response; - response.Finish(*callback.get()); - }}; - async_finish.detach(); - }); + .WillOnce( + [&mock_session, report_trace_id, report_span_id]( + const std::shared_ptr &callback) { + auto check_json = + nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); + auto resource_logs = *check_json["resourceLogs"].begin(); + auto scope_logs = *resource_logs["scopeLogs"].begin(); + auto schema_url = scope_logs["schemaUrl"].get(); + auto scope = scope_logs["scope"]; + auto scope_name = scope["name"]; + auto scope_version = scope["version"]; + auto log = *scope_logs["logRecords"].begin(); + auto received_trace_id = log["traceId"].get(); + auto received_span_id = log["spanId"].get(); + EXPECT_EQ(schema_url, "https://opentelemetry.io/schemas/1.2.0"); + EXPECT_EQ(scope_name, "opentelelemtry_library"); + EXPECT_EQ(scope_version, "1.2.0"); + EXPECT_EQ(received_trace_id, report_trace_id); + EXPECT_EQ(received_span_id, report_span_id); + EXPECT_EQ("Log message", log["body"]["stringValue"].get()); + EXPECT_LE(15, log["attributes"].size()); + auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); + ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); + if (custom_header != mock_session->GetRequest()->headers_.end()) + { + EXPECT_EQ("Custom-Header-Value", custom_header->second); + } + + bool check_scope_attribute = false; + auto scope_attributes = scope["attributes"]; + for (auto &attribute : scope_attributes) + { + if (!attribute.is_object()) + { + continue; + } + if ("scope_key1" == attribute["key"]) + { + check_scope_attribute = true; + EXPECT_EQ("scope_value", attribute["value"]["stringValue"].get()); + } + } + ASSERT_TRUE(check_scope_attribute); + + // let the otlp_http_client to continue + std::thread async_finish{[callback]() { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + http_client::nosend::Response response; + response.Finish(*callback.get()); + }}; + async_finish.detach(); + }); logger->EmitLogRecord( opentelemetry::logs::Severity::kInfo, "Log message", @@ -390,47 +391,49 @@ class OtlpHttpLogRecordExporterTestPeer : public ::testing::Test auto mock_session = std::static_pointer_cast(no_send_client->session_); EXPECT_CALL(*mock_session, SendRequest) - .WillOnce([&mock_session, report_trace_id, report_span_id]( - std::shared_ptr callback) { - opentelemetry::proto::collector::logs::v1::ExportLogsServiceRequest request_body; - request_body.ParseFromArray(&mock_session->GetRequest()->body_[0], - static_cast(mock_session->GetRequest()->body_.size())); - auto scope_log = request_body.resource_logs(0).scope_logs(0); - EXPECT_EQ(scope_log.schema_url(), "https://opentelemetry.io/schemas/1.2.0"); - EXPECT_EQ(scope_log.scope().name(), "opentelelemtry_library"); - EXPECT_EQ(scope_log.scope().version(), "1.2.0"); - auto received_log = scope_log.log_records(0); - EXPECT_EQ(received_log.trace_id(), report_trace_id); - EXPECT_EQ(received_log.span_id(), report_span_id); - EXPECT_EQ("Log message", received_log.body().string_value()); - EXPECT_LE(15, received_log.attributes_size()); - bool check_service_name = false; - for (auto &attribute : received_log.attributes()) - { - if ("service.name" == attribute.key()) - { - check_service_name = true; - EXPECT_EQ("unit_test_service", attribute.value().string_value()); - } - } - ASSERT_TRUE(check_service_name); - - bool check_scope_attribute = false; - for (auto &attribute : scope_log.scope().attributes()) - { - if ("scope_key1" == attribute.key()) - { - check_scope_attribute = true; - EXPECT_EQ("scope_value", attribute.value().string_value()); - } - } - ASSERT_TRUE(check_scope_attribute); - - // let the otlp_http_client to continue - - http_client::nosend::Response response; - response.Finish(*callback.get()); - }); + .WillOnce( + [&mock_session, report_trace_id, report_span_id]( + const std::shared_ptr &callback) { + opentelemetry::proto::collector::logs::v1::ExportLogsServiceRequest request_body; + request_body.ParseFromArray( + &mock_session->GetRequest()->body_[0], + static_cast(mock_session->GetRequest()->body_.size())); + auto scope_log = request_body.resource_logs(0).scope_logs(0); + EXPECT_EQ(scope_log.schema_url(), "https://opentelemetry.io/schemas/1.2.0"); + EXPECT_EQ(scope_log.scope().name(), "opentelelemtry_library"); + EXPECT_EQ(scope_log.scope().version(), "1.2.0"); + const auto &received_log = scope_log.log_records(0); + EXPECT_EQ(received_log.trace_id(), report_trace_id); + EXPECT_EQ(received_log.span_id(), report_span_id); + EXPECT_EQ("Log message", received_log.body().string_value()); + EXPECT_LE(15, received_log.attributes_size()); + bool check_service_name = false; + for (auto &attribute : received_log.attributes()) + { + if ("service.name" == attribute.key()) + { + check_service_name = true; + EXPECT_EQ("unit_test_service", attribute.value().string_value()); + } + } + ASSERT_TRUE(check_service_name); + + bool check_scope_attribute = false; + for (auto &attribute : scope_log.scope().attributes()) + { + if ("scope_key1" == attribute.key()) + { + check_scope_attribute = true; + EXPECT_EQ("scope_value", attribute.value().string_value()); + } + } + ASSERT_TRUE(check_scope_attribute); + + // let the otlp_http_client to continue + + http_client::nosend::Response response; + response.Finish(*callback.get()); + }); logger->EmitLogRecord( opentelemetry::logs::Severity::kInfo, "Log message", @@ -503,51 +506,53 @@ class OtlpHttpLogRecordExporterTestPeer : public ::testing::Test auto mock_session = std::static_pointer_cast(no_send_client->session_); EXPECT_CALL(*mock_session, SendRequest) - .WillOnce([&mock_session, report_trace_id, report_span_id, schema_url]( - std::shared_ptr callback) { - opentelemetry::proto::collector::logs::v1::ExportLogsServiceRequest request_body; - request_body.ParseFromArray(&mock_session->GetRequest()->body_[0], - static_cast(mock_session->GetRequest()->body_.size())); - auto &scope_log = request_body.resource_logs(0).scope_logs(0); - auto received_log = scope_log.log_records(0); - EXPECT_EQ(received_log.trace_id(), report_trace_id); - EXPECT_EQ(received_log.span_id(), report_span_id); - EXPECT_EQ("Log message", received_log.body().string_value()); - EXPECT_LE(15, received_log.attributes_size()); - bool check_service_name = false; - for (auto &attribute : received_log.attributes()) - { - if ("service.name" == attribute.key()) - { - check_service_name = true; - EXPECT_EQ("unit_test_service", attribute.value().string_value()); - } - } - ASSERT_TRUE(check_service_name); - - auto &scope = scope_log.scope(); - EXPECT_EQ(scope.name(), "opentelelemtry_library"); - EXPECT_EQ(scope_log.schema_url(), schema_url); - bool check_scope_attribute = false; - for (auto &attribute : scope.attributes()) - { - if ("scope_key1" == attribute.key()) - { - check_scope_attribute = true; - EXPECT_EQ("scope_value", attribute.value().string_value()); - } - } - ASSERT_TRUE(check_scope_attribute); - - // let the otlp_http_client to continue - - std::thread async_finish{[callback]() { - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - http_client::nosend::Response response; - response.Finish(*callback.get()); - }}; - async_finish.detach(); - }); + .WillOnce( + [&mock_session, report_trace_id, report_span_id, schema_url]( + const std::shared_ptr &callback) { + opentelemetry::proto::collector::logs::v1::ExportLogsServiceRequest request_body; + request_body.ParseFromArray( + &mock_session->GetRequest()->body_[0], + static_cast(mock_session->GetRequest()->body_.size())); + auto &scope_log = request_body.resource_logs(0).scope_logs(0); + auto received_log = scope_log.log_records(0); + EXPECT_EQ(received_log.trace_id(), report_trace_id); + EXPECT_EQ(received_log.span_id(), report_span_id); + EXPECT_EQ("Log message", received_log.body().string_value()); + EXPECT_LE(15, received_log.attributes_size()); + bool check_service_name = false; + for (auto &attribute : received_log.attributes()) + { + if ("service.name" == attribute.key()) + { + check_service_name = true; + EXPECT_EQ("unit_test_service", attribute.value().string_value()); + } + } + ASSERT_TRUE(check_service_name); + + auto &scope = scope_log.scope(); + EXPECT_EQ(scope.name(), "opentelelemtry_library"); + EXPECT_EQ(scope_log.schema_url(), schema_url); + bool check_scope_attribute = false; + for (auto &attribute : scope.attributes()) + { + if ("scope_key1" == attribute.key()) + { + check_scope_attribute = true; + EXPECT_EQ("scope_value", attribute.value().string_value()); + } + } + ASSERT_TRUE(check_scope_attribute); + + // let the otlp_http_client to continue + + std::thread async_finish{[callback]() { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + http_client::nosend::Response response; + response.Finish(*callback.get()); + }}; + async_finish.detach(); + }); logger->EmitLogRecord( opentelemetry::logs::Severity::kInfo, "Log message", diff --git a/exporters/otlp/test/otlp_http_metric_exporter_test.cc b/exporters/otlp/test/otlp_http_metric_exporter_test.cc index 1e5fe6469f..174597248b 100644 --- a/exporters/otlp/test/otlp_http_metric_exporter_test.cc +++ b/exporters/otlp/test/otlp_http_metric_exporter_test.cc @@ -64,8 +64,7 @@ OtlpHttpClientOptions MakeOtlpHttpClientOptions(HttpRequestContentType content_t OtlpHttpMetricExporterOptions options; options.content_type = content_type; options.console_debug = true; - options.http_headers.insert( - std::make_pair("Custom-Header-Key", "Custom-Header-Value")); + options.http_headers.insert(std::make_pair("Custom-Header-Key", "Custom-Header-Value")); OtlpHttpClientOptions otlp_http_client_options( options.url, false, /* ssl_insecure_skip_verify */ "", /* ssl_ca_cert_path */ "", /* ssl_ca_cert_string */ @@ -154,36 +153,37 @@ class OtlpHttpMetricExporterTestPeer : public ::testing::Test auto mock_session = std::static_pointer_cast(no_send_client->session_); EXPECT_CALL(*mock_session, SendRequest) - .WillOnce([&mock_session]( - std::shared_ptr callback) { - auto check_json = - nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); - - auto resource_metrics = *check_json["resourceMetrics"].begin(); - auto scope_metrics = *resource_metrics["scopeMetrics"].begin(); - auto scope = scope_metrics["scope"]; - EXPECT_EQ("library_name", scope["name"].get()); - EXPECT_EQ("1.5.0", scope["version"].get()); - - auto metric = *scope_metrics["metrics"].begin(); - EXPECT_EQ("metrics_library_name", metric["name"].get()); - EXPECT_EQ("metrics_description", metric["description"].get()); - EXPECT_EQ("metrics_unit", metric["unit"].get()); - - auto data_points = metric["sum"]["dataPoints"]; - EXPECT_EQ(10.0, data_points[0]["asDouble"].get()); - EXPECT_EQ(20.0, data_points[1]["asDouble"].get()); - - auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); - ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); - if (custom_header != mock_session->GetRequest()->headers_.end()) - { - EXPECT_EQ("Custom-Header-Value", custom_header->second); - } - - http_client::nosend::Response response; - response.Finish(*callback.get()); - }); + .WillOnce( + [&mock_session]( + const std::shared_ptr &callback) { + auto check_json = + nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); + + auto resource_metrics = *check_json["resourceMetrics"].begin(); + auto scope_metrics = *resource_metrics["scopeMetrics"].begin(); + auto scope = scope_metrics["scope"]; + EXPECT_EQ("library_name", scope["name"].get()); + EXPECT_EQ("1.5.0", scope["version"].get()); + + auto metric = *scope_metrics["metrics"].begin(); + EXPECT_EQ("metrics_library_name", metric["name"].get()); + EXPECT_EQ("metrics_description", metric["description"].get()); + EXPECT_EQ("metrics_unit", metric["unit"].get()); + + auto data_points = metric["sum"]["dataPoints"]; + EXPECT_EQ(10.0, data_points[0]["asDouble"].get()); + EXPECT_EQ(20.0, data_points[1]["asDouble"].get()); + + auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); + ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); + if (custom_header != mock_session->GetRequest()->headers_.end()) + { + EXPECT_EQ("Custom-Header-Value", custom_header->second); + } + + http_client::nosend::Response response; + response.Finish(*callback.get()); + }); auto result = exporter->Export(data); EXPECT_EQ(result, opentelemetry::sdk::common::ExportResult::kSuccess); @@ -237,7 +237,8 @@ class OtlpHttpMetricExporterTestPeer : public ::testing::Test EXPECT_CALL(*mock_session, SendRequest) .WillOnce([&mock_session]( - std::shared_ptr callback) { + const std::shared_ptr + &callback) { opentelemetry::proto::collector::metrics::v1::ExportMetricsServiceRequest request_body; request_body.ParseFromArray(&mock_session->GetRequest()->body_[0], static_cast(mock_session->GetRequest()->body_.size())); @@ -335,36 +336,37 @@ class OtlpHttpMetricExporterTestPeer : public ::testing::Test auto mock_session = std::static_pointer_cast(no_send_client->session_); EXPECT_CALL(*mock_session, SendRequest) - .WillOnce([&mock_session]( - std::shared_ptr callback) { - auto check_json = - nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); - - auto resource_metrics = *check_json["resourceMetrics"].begin(); - auto scope_metrics = *resource_metrics["scopeMetrics"].begin(); - auto scope = scope_metrics["scope"]; - EXPECT_EQ("library_name", scope["name"].get()); - EXPECT_EQ("1.5.0", scope["version"].get()); - - auto metric = *scope_metrics["metrics"].begin(); - EXPECT_EQ("metrics_library_name", metric["name"].get()); - EXPECT_EQ("metrics_description", metric["description"].get()); - EXPECT_EQ("metrics_unit", metric["unit"].get()); - - auto data_points = metric["gauge"]["dataPoints"]; - EXPECT_EQ(10.0, data_points[0]["asDouble"].get()); - EXPECT_EQ(20l, JsonToInteger(data_points[1]["asInt"])); - - auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); - ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); - if (custom_header != mock_session->GetRequest()->headers_.end()) - { - EXPECT_EQ("Custom-Header-Value", custom_header->second); - } - - http_client::nosend::Response response; - response.Finish(*callback.get()); - }); + .WillOnce( + [&mock_session]( + const std::shared_ptr &callback) { + auto check_json = + nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); + + auto resource_metrics = *check_json["resourceMetrics"].begin(); + auto scope_metrics = *resource_metrics["scopeMetrics"].begin(); + auto scope = scope_metrics["scope"]; + EXPECT_EQ("library_name", scope["name"].get()); + EXPECT_EQ("1.5.0", scope["version"].get()); + + auto metric = *scope_metrics["metrics"].begin(); + EXPECT_EQ("metrics_library_name", metric["name"].get()); + EXPECT_EQ("metrics_description", metric["description"].get()); + EXPECT_EQ("metrics_unit", metric["unit"].get()); + + auto data_points = metric["gauge"]["dataPoints"]; + EXPECT_EQ(10.0, data_points[0]["asDouble"].get()); + EXPECT_EQ(20l, JsonToInteger(data_points[1]["asInt"])); + + auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); + ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); + if (custom_header != mock_session->GetRequest()->headers_.end()) + { + EXPECT_EQ("Custom-Header-Value", custom_header->second); + } + + http_client::nosend::Response response; + response.Finish(*callback.get()); + }); auto result = exporter->Export(data); EXPECT_EQ(result, opentelemetry::sdk::common::ExportResult::kSuccess); @@ -427,7 +429,8 @@ class OtlpHttpMetricExporterTestPeer : public ::testing::Test EXPECT_CALL(*mock_session, SendRequest) .WillOnce([&mock_session]( - std::shared_ptr callback) { + const std::shared_ptr + &callback) { opentelemetry::proto::collector::metrics::v1::ExportMetricsServiceRequest request_body; request_body.ParseFromArray(&mock_session->GetRequest()->body_[0], static_cast(mock_session->GetRequest()->body_.size())); @@ -530,71 +533,72 @@ class OtlpHttpMetricExporterTestPeer : public ::testing::Test auto mock_session = std::static_pointer_cast(no_send_client->session_); EXPECT_CALL(*mock_session, SendRequest) - .WillOnce([&mock_session]( - std::shared_ptr callback) { - auto check_json = - nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); - - auto resource_metrics = *check_json["resourceMetrics"].begin(); - auto scope_metrics = *resource_metrics["scopeMetrics"].begin(); - auto scope = scope_metrics["scope"]; - EXPECT_EQ("library_name", scope["name"].get()); - EXPECT_EQ("1.5.0", scope["version"].get()); - - auto metric = *scope_metrics["metrics"].begin(); - EXPECT_EQ("metrics_library_name", metric["name"].get()); - EXPECT_EQ("metrics_description", metric["description"].get()); - EXPECT_EQ("metrics_unit", metric["unit"].get()); - - auto data_points = metric["histogram"]["dataPoints"]; - EXPECT_EQ(3, JsonToInteger(data_points[0]["count"])); - EXPECT_EQ(900.5, data_points[0]["sum"].get()); - EXPECT_EQ(1.8, data_points[0]["min"].get()); - EXPECT_EQ(19, data_points[0]["max"].get()); - EXPECT_EQ(4, data_points[0]["bucketCounts"].size()); - if (4 == data_points[0]["bucketCounts"].size()) - { - EXPECT_EQ(200, JsonToInteger(data_points[0]["bucketCounts"][0])); - EXPECT_EQ(300, JsonToInteger(data_points[0]["bucketCounts"][1])); - EXPECT_EQ(400, JsonToInteger(data_points[0]["bucketCounts"][2])); - EXPECT_EQ(500, JsonToInteger(data_points[0]["bucketCounts"][3])); - } - EXPECT_EQ(3, data_points[0]["explicitBounds"].size()); - if (3 == data_points[0]["explicitBounds"].size()) - { - EXPECT_EQ(10.1, data_points[0]["explicitBounds"][0].get()); - EXPECT_EQ(20.2, data_points[0]["explicitBounds"][1].get()); - EXPECT_EQ(30.2, data_points[0]["explicitBounds"][2].get()); - } - - EXPECT_EQ(3, JsonToInteger(data_points[1]["count"])); - EXPECT_EQ(900.0, data_points[1]["sum"].get()); - EXPECT_EQ(4, data_points[1]["bucketCounts"].size()); - if (4 == data_points[1]["bucketCounts"].size()) - { - EXPECT_EQ(200, JsonToInteger(data_points[1]["bucketCounts"][0])); - EXPECT_EQ(300, JsonToInteger(data_points[1]["bucketCounts"][1])); - EXPECT_EQ(400, JsonToInteger(data_points[1]["bucketCounts"][2])); - EXPECT_EQ(500, JsonToInteger(data_points[1]["bucketCounts"][3])); - } - EXPECT_EQ(3, data_points[1]["explicitBounds"].size()); - if (3 == data_points[1]["explicitBounds"].size()) - { - EXPECT_EQ(10.0, data_points[1]["explicitBounds"][0].get()); - EXPECT_EQ(20.0, data_points[1]["explicitBounds"][1].get()); - EXPECT_EQ(30.0, data_points[1]["explicitBounds"][2].get()); - } - - auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); - ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); - if (custom_header != mock_session->GetRequest()->headers_.end()) - { - EXPECT_EQ("Custom-Header-Value", custom_header->second); - } - - http_client::nosend::Response response; - response.Finish(*callback.get()); - }); + .WillOnce( + [&mock_session]( + const std::shared_ptr &callback) { + auto check_json = + nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); + + auto resource_metrics = *check_json["resourceMetrics"].begin(); + auto scope_metrics = *resource_metrics["scopeMetrics"].begin(); + auto scope = scope_metrics["scope"]; + EXPECT_EQ("library_name", scope["name"].get()); + EXPECT_EQ("1.5.0", scope["version"].get()); + + auto metric = *scope_metrics["metrics"].begin(); + EXPECT_EQ("metrics_library_name", metric["name"].get()); + EXPECT_EQ("metrics_description", metric["description"].get()); + EXPECT_EQ("metrics_unit", metric["unit"].get()); + + auto data_points = metric["histogram"]["dataPoints"]; + EXPECT_EQ(3, JsonToInteger(data_points[0]["count"])); + EXPECT_EQ(900.5, data_points[0]["sum"].get()); + EXPECT_EQ(1.8, data_points[0]["min"].get()); + EXPECT_EQ(19, data_points[0]["max"].get()); + EXPECT_EQ(4, data_points[0]["bucketCounts"].size()); + if (4 == data_points[0]["bucketCounts"].size()) + { + EXPECT_EQ(200, JsonToInteger(data_points[0]["bucketCounts"][0])); + EXPECT_EQ(300, JsonToInteger(data_points[0]["bucketCounts"][1])); + EXPECT_EQ(400, JsonToInteger(data_points[0]["bucketCounts"][2])); + EXPECT_EQ(500, JsonToInteger(data_points[0]["bucketCounts"][3])); + } + EXPECT_EQ(3, data_points[0]["explicitBounds"].size()); + if (3 == data_points[0]["explicitBounds"].size()) + { + EXPECT_EQ(10.1, data_points[0]["explicitBounds"][0].get()); + EXPECT_EQ(20.2, data_points[0]["explicitBounds"][1].get()); + EXPECT_EQ(30.2, data_points[0]["explicitBounds"][2].get()); + } + + EXPECT_EQ(3, JsonToInteger(data_points[1]["count"])); + EXPECT_EQ(900.0, data_points[1]["sum"].get()); + EXPECT_EQ(4, data_points[1]["bucketCounts"].size()); + if (4 == data_points[1]["bucketCounts"].size()) + { + EXPECT_EQ(200, JsonToInteger(data_points[1]["bucketCounts"][0])); + EXPECT_EQ(300, JsonToInteger(data_points[1]["bucketCounts"][1])); + EXPECT_EQ(400, JsonToInteger(data_points[1]["bucketCounts"][2])); + EXPECT_EQ(500, JsonToInteger(data_points[1]["bucketCounts"][3])); + } + EXPECT_EQ(3, data_points[1]["explicitBounds"].size()); + if (3 == data_points[1]["explicitBounds"].size()) + { + EXPECT_EQ(10.0, data_points[1]["explicitBounds"][0].get()); + EXPECT_EQ(20.0, data_points[1]["explicitBounds"][1].get()); + EXPECT_EQ(30.0, data_points[1]["explicitBounds"][2].get()); + } + + auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); + ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); + if (custom_header != mock_session->GetRequest()->headers_.end()) + { + EXPECT_EQ("Custom-Header-Value", custom_header->second); + } + + http_client::nosend::Response response; + response.Finish(*callback.get()); + }); auto result = exporter->Export(data); EXPECT_EQ(result, opentelemetry::sdk::common::ExportResult::kSuccess); @@ -661,7 +665,8 @@ class OtlpHttpMetricExporterTestPeer : public ::testing::Test EXPECT_CALL(*mock_session, SendRequest) .WillOnce([&mock_session]( - std::shared_ptr callback) { + const std::shared_ptr + &callback) { opentelemetry::proto::collector::metrics::v1::ExportMetricsServiceRequest request_body; request_body.ParseFromArray(&mock_session->GetRequest()->body_[0], static_cast(mock_session->GetRequest()->body_.size())); diff --git a/exporters/otlp/test/otlp_metrics_serialization_test.cc b/exporters/otlp/test/otlp_metrics_serialization_test.cc index b945cb28fe..2ad76dfd1d 100644 --- a/exporters/otlp/test/otlp_metrics_serialization_test.cc +++ b/exporters/otlp/test/otlp_metrics_serialization_test.cc @@ -200,7 +200,7 @@ TEST(OtlpMetricSerializationTest, Counter) EXPECT_EQ(sum.is_monotonic(), true); for (size_t i = 0; i < 1; i++) { - auto proto_number_point = sum.data_points(i); + const auto &proto_number_point = sum.data_points(i); EXPECT_EQ(proto_number_point.as_double(), i == 0 ? 10.2 : 20.2); } @@ -230,7 +230,7 @@ TEST(OtlpMetricSerializationTest, Histogram) proto::metrics::v1::AggregationTemporality::AGGREGATION_TEMPORALITY_CUMULATIVE); for (size_t i = 0; i < 1; i++) { - auto proto_number_point = histogram.data_points(i); + const auto &proto_number_point = histogram.data_points(i); EXPECT_EQ(proto_number_point.sum(), i == 0 ? 100.2 : 200.2); } @@ -244,7 +244,7 @@ TEST(OtlpMetricSerializationTest, ObservableGauge) otlp_exporter::OtlpMetricUtils::ConvertGaugeMetric(data, &gauge); for (size_t i = 0; i < 1; i++) { - auto proto_number_point = gauge.data_points(i); + const auto &proto_number_point = gauge.data_points(i); EXPECT_EQ(proto_number_point.as_double(), i == 0 ? 30.2 : 50.2); } diff --git a/exporters/otlp/test/otlp_recordable_test.cc b/exporters/otlp/test/otlp_recordable_test.cc index caa17c8a46..537f10340d 100644 --- a/exporters/otlp/test/otlp_recordable_test.cc +++ b/exporters/otlp/test/otlp_recordable_test.cc @@ -216,7 +216,7 @@ TEST(OtlpRecordable, SetResource) bool found_service_name = false; for (int i = 0; i < proto_resource.attributes_size(); i++) { - auto attr = proto_resource.attributes(static_cast(i)); + const auto &attr = proto_resource.attributes(static_cast(i)); if (attr.key() == service_name_key && attr.value().string_value() == service_name) { found_service_name = true; @@ -322,7 +322,7 @@ TEST(OtlpRecordable, PopulateRequest) OtlpRecordableUtils::PopulateRequest(spans_span, &req); EXPECT_EQ(req.resource_spans().size(), 2); - for (auto resource_spans : req.resource_spans()) + for (const auto &resource_spans : req.resource_spans()) { auto service_name = resource_spans.resource().attributes(0).value().string_value(); auto scope_spans_size = resource_spans.scope_spans().size(); @@ -359,7 +359,7 @@ TEST(OtlpRecordable, PopulateRequestMissing) OtlpRecordableUtils::PopulateRequest(spans_span, &req); EXPECT_EQ(req.resource_spans().size(), 2); - for (auto resource_spans : req.resource_spans()) + for (const auto &resource_spans : req.resource_spans()) { // Both should have scope spans EXPECT_EQ(resource_spans.scope_spans().size(), 1); diff --git a/exporters/prometheus/src/exporter_utils.cc b/exporters/prometheus/src/exporter_utils.cc index 68d8586bcc..35ee748273 100644 --- a/exporters/prometheus/src/exporter_utils.cc +++ b/exporters/prometheus/src/exporter_utils.cc @@ -88,7 +88,7 @@ inline std::string Sanitize(std::string name, const T &valid) */ std::string SanitizeLabel(std::string label_key) { - return Sanitize(label_key, [](int i, char c) { + return Sanitize(std::move(label_key), [](int i, char c) { return (c >= 'a' && c <= 'z') || // (c >= 'A' && c <= 'Z') || // c == '_' || // @@ -396,7 +396,7 @@ std::string PrometheusExporterUtils::RemoveUnitPortionInBraces(const std::string std::string PrometheusExporterUtils::ConvertRateExpressedToPrometheusUnit( const std::string &rate_expressed_unit) { - size_t pos = rate_expressed_unit.find("/"); + size_t pos = rate_expressed_unit.find('/'); if (pos == std::string::npos) { return rate_expressed_unit; diff --git a/exporters/prometheus/test/exporter_test.cc b/exporters/prometheus/test/exporter_test.cc index 3bda4c3d7b..b268ac8514 100644 --- a/exporters/prometheus/test/exporter_test.cc +++ b/exporters/prometheus/test/exporter_test.cc @@ -16,7 +16,6 @@ * private constructor is only to be used here for testing */ -using opentelemetry::exporter::metrics::PrometheusCollector; using opentelemetry::exporter::metrics::PrometheusExporter; using opentelemetry::exporter::metrics::PrometheusExporterOptions; using opentelemetry::sdk::metrics::AggregationTemporality; diff --git a/exporters/prometheus/test/exporter_utils_test.cc b/exporters/prometheus/test/exporter_utils_test.cc index b876e7369c..7ad5eee1fd 100644 --- a/exporters/prometheus/test/exporter_utils_test.cc +++ b/exporters/prometheus/test/exporter_utils_test.cc @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 #include + +#include #include "prometheus/metric_family.h" #include "prometheus/metric_type.h" @@ -24,7 +26,7 @@ class SanitizeNameTester public: static std::string sanitize(std::string name) { - return PrometheusExporterUtils::SanitizeNames(name); + return PrometheusExporterUtils::SanitizeNames(std::move(name)); } static std::string getPrometheusUnit(const std::string &unit_abbreviation) { @@ -104,14 +106,13 @@ void assert_basic(prometheus_client::MetricFamily &metric, ASSERT_TRUE(false); break; case prometheus::MetricType::Untyped: - break; default: break; } } void assert_histogram(prometheus_client::MetricFamily &metric, - std::list boundaries, + const std::list &boundaries, std::vector correct) { int cumulative_count = 0; diff --git a/exporters/zipkin/src/zipkin_exporter.cc b/exporters/zipkin/src/zipkin_exporter.cc index e6d3ce8b26..a554cbf4cc 100644 --- a/exporters/zipkin/src/zipkin_exporter.cc +++ b/exporters/zipkin/src/zipkin_exporter.cc @@ -1,6 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +// NOLINTNEXTLINE #define _WINSOCKAPI_ // stops including winsock.h #include @@ -105,7 +106,6 @@ sdk::common::ExportResult ZipkinExporter::Export( } return sdk::common::ExportResult::kFailure; } - return sdk::common::ExportResult::kSuccess; } void ZipkinExporter::InitializeLocalEndpoint() diff --git a/exporters/zipkin/test/zipkin_exporter_test.cc b/exporters/zipkin/test/zipkin_exporter_test.cc index 18c47bcab5..8e58f83d2e 100644 --- a/exporters/zipkin/test/zipkin_exporter_test.cc +++ b/exporters/zipkin/test/zipkin_exporter_test.cc @@ -17,6 +17,7 @@ # include "nlohmann/json.hpp" # include +# include # if defined(_MSC_VER) # include "opentelemetry/sdk/common/env_variables.h" @@ -47,7 +48,7 @@ class ZipkinExporterTestPeer : public ::testing::Test std::unique_ptr GetExporter( std::shared_ptr http_client) { - return std::unique_ptr(new ZipkinExporter(http_client)); + return std::unique_ptr(new ZipkinExporter(std::move(http_client))); } // Get the options associated with the given exporter. diff --git a/ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h b/ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h index 58dd154bb7..b6654ce3ad 100644 --- a/ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h +++ b/ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h @@ -124,7 +124,8 @@ class HttpOperation double ulnow); #endif public: - void DispatchEvent(opentelemetry::ext::http::client::SessionState type, std::string reason = ""); + void DispatchEvent(opentelemetry::ext::http::client::SessionState type, + const std::string &reason = ""); /** * Create local CURL instance for url and body diff --git a/ext/src/dll/dllmain.cc b/ext/src/dll/dllmain.cc index 1812377374..df1d2bc70d 100644 --- a/ext/src/dll/dllmain.cc +++ b/ext/src/dll/dllmain.cc @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include +#include // NOLINT // Include API header files here for exporting #include diff --git a/ext/src/http/client/curl/http_client_curl.cc b/ext/src/http/client/curl/http_client_curl.cc index 38ca2e7348..67b0b93a54 100644 --- a/ext/src/http/client/curl/http_client_curl.cc +++ b/ext/src/http/client/curl/http_client_curl.cc @@ -562,7 +562,7 @@ bool HttpClient::doAbortSessions() } bool has_data = false; - for (auto session : pending_to_abort_sessions) + for (const auto &session : pending_to_abort_sessions) { if (!session.second) { diff --git a/ext/src/http/client/curl/http_operation_curl.cc b/ext/src/http/client/curl/http_operation_curl.cc index f82c17ccc5..4de014fd82 100644 --- a/ext/src/http/client/curl/http_operation_curl.cc +++ b/ext/src/http/client/curl/http_operation_curl.cc @@ -240,7 +240,7 @@ int HttpOperation::OnProgressCallback(void *clientp, #endif void HttpOperation::DispatchEvent(opentelemetry::ext::http::client::SessionState type, - std::string reason) + const std::string &reason) { if (event_handle_ != nullptr) { @@ -273,7 +273,7 @@ HttpOperation::HttpOperation(opentelemetry::ext::http::client::Method method, last_curl_result_(CURLE_OK), event_handle_(event_handle), method_(method), - url_(url), + url_(std::move(url)), ssl_options_(ssl_options), // Local vars request_headers_(request_headers), @@ -453,7 +453,7 @@ void HttpOperation::Cleanup() # define HAVE_TLS_VERSION #endif -static long parse_min_ssl_version(std::string version) +static long parse_min_ssl_version(const std::string &version) { #ifdef HAVE_TLS_VERSION if (version == "1.2") @@ -470,7 +470,7 @@ static long parse_min_ssl_version(std::string version) return 0; } -static long parse_max_ssl_version(std::string version) +static long parse_max_ssl_version(const std::string &version) { #ifdef HAVE_TLS_VERSION if (version == "1.2") diff --git a/ext/test/http/curl_http_test.cc b/ext/test/http/curl_http_test.cc index 6e30323eeb..0dc6e5d5e8 100644 --- a/ext/test/http/curl_http_test.cc +++ b/ext/test/http/curl_http_test.cc @@ -12,6 +12,7 @@ #include #include #include +#include #include #define HTTP_PORT 19000 @@ -74,7 +75,9 @@ class PostEventHandler : public CustomEventHandler class FinishInCallbackHandler : public CustomEventHandler { public: - FinishInCallbackHandler(std::shared_ptr session) : session_(session) {} + FinishInCallbackHandler(std::shared_ptr session) + : session_(std::move(session)) + {} void OnResponse(http_client::Response &response) noexcept override { diff --git a/ext/test/w3c_tracecontext_test/main.cc b/ext/test/w3c_tracecontext_test/main.cc index 349626e219..d9819cde0d 100644 --- a/ext/test/w3c_tracecontext_test/main.cc +++ b/ext/test/w3c_tracecontext_test/main.cc @@ -75,10 +75,10 @@ struct Uri uint16_t port; std::string path; - Uri(std::string uri) + Uri(const std::string &uri) { - size_t host_end = uri.substr(7, std::string::npos).find(":"); - size_t port_end = uri.substr(host_end + 1, std::string::npos).find("/"); + size_t host_end = uri.substr(7, std::string::npos).find(':'); + size_t port_end = uri.substr(host_end + 1, std::string::npos).find('/'); host = uri.substr(0, host_end + 7); port = std::stoi(uri.substr(7 + host_end + 1, port_end)); diff --git a/functional/otlp/func_http_main.cc b/functional/otlp/func_http_main.cc index 4f6c144a43..ece1588425 100644 --- a/functional/otlp/func_http_main.cc +++ b/functional/otlp/func_http_main.cc @@ -39,7 +39,7 @@ const int TEST_FAILED = 1; Command line parameters. */ -enum test_mode +enum test_mode : std::uint8_t { MODE_NONE, MODE_HTTP, @@ -84,7 +84,7 @@ struct TestResult struct TestResult g_test_result; -void parse_error_msg(TestResult *result, std::string msg) +void parse_error_msg(TestResult *result, const std::string &msg) { static std::string connection_failed("Session state: connection failed."); @@ -129,11 +129,11 @@ void parse_error_msg(TestResult *result, std::string msg) } } -void parse_warning_msg(TestResult * /* result */, std::string /* msg */) {} +void parse_warning_msg(TestResult * /* result */, const std::string & /* msg */) {} -void parse_info_msg(TestResult * /* result */, std::string /* msg */) {} +void parse_info_msg(TestResult * /* result */, const std::string & /* msg */) {} -void parse_debug_msg(TestResult *result, std::string msg) +void parse_debug_msg(TestResult *result, const std::string &msg) { static std::string export_success("Export 1 trace span(s) success"); @@ -162,19 +162,19 @@ class TestLogHandler : public opentelemetry::sdk::common::internal_log::LogHandl case opentelemetry::sdk::common::internal_log::LogLevel::None: break; case opentelemetry::sdk::common::internal_log::LogLevel::Error: - std::cout << " - [E] " << msg << std::endl; + std::cout << " - [E] " << msg << '\n'; parse_error_msg(&g_test_result, msg); break; case opentelemetry::sdk::common::internal_log::LogLevel::Warning: - std::cout << " - [W] " << msg << std::endl; + std::cout << " - [W] " << msg << '\n'; parse_warning_msg(&g_test_result, msg); break; case opentelemetry::sdk::common::internal_log::LogLevel::Info: - std::cout << " - [I] " << msg << std::endl; + std::cout << " - [I] " << msg << '\n'; parse_info_msg(&g_test_result, msg); break; case opentelemetry::sdk::common::internal_log::LogLevel::Debug: - std::cout << " - [D] " << msg << std::endl; + std::cout << " - [D] " << msg << '\n'; parse_debug_msg(&g_test_result, msg); break; } @@ -429,12 +429,12 @@ void list_test_cases() while (current->m_func != nullptr) { - std::cout << current->m_name << std::endl; + std::cout << current->m_name << '\n'; current++; } } -int run_test_case(std::string name) +int run_test_case(const std::string &name) { const test_case *current = all_tests; @@ -448,7 +448,7 @@ int run_test_case(std::string name) current++; } - std::cerr << "Unknown test <" << name << ">" << std::endl; + std::cerr << "Unknown test <" << name << ">" << '\n'; return 1; } diff --git a/sdk/include/opentelemetry/sdk/logs/logger_context.h b/sdk/include/opentelemetry/sdk/logs/logger_context.h index bab002b231..11eca41d16 100644 --- a/sdk/include/opentelemetry/sdk/logs/logger_context.h +++ b/sdk/include/opentelemetry/sdk/logs/logger_context.h @@ -34,7 +34,7 @@ class LoggerContext { public: explicit LoggerContext(std::vector> &&processors, - opentelemetry::sdk::resource::Resource resource = + const opentelemetry::sdk::resource::Resource &resource = opentelemetry::sdk::resource::Resource::Create({})) noexcept; /** diff --git a/sdk/include/opentelemetry/sdk/logs/logger_provider.h b/sdk/include/opentelemetry/sdk/logs/logger_provider.h index 6c035ad5e9..dd2a52789d 100644 --- a/sdk/include/opentelemetry/sdk/logs/logger_provider.h +++ b/sdk/include/opentelemetry/sdk/logs/logger_provider.h @@ -38,11 +38,11 @@ class OPENTELEMETRY_EXPORT LoggerProvider final : public opentelemetry::logs::Lo * @param resource The resources for this logger provider. */ explicit LoggerProvider(std::unique_ptr &&processor, - opentelemetry::sdk::resource::Resource resource = + const opentelemetry::sdk::resource::Resource &resource = opentelemetry::sdk::resource::Resource::Create({})) noexcept; explicit LoggerProvider(std::vector> &&processors, - opentelemetry::sdk::resource::Resource resource = + const opentelemetry::sdk::resource::Resource &resource = opentelemetry::sdk::resource::Resource::Create({})) noexcept; /** diff --git a/sdk/include/opentelemetry/sdk/metrics/meter_context.h b/sdk/include/opentelemetry/sdk/metrics/meter_context.h index 40a57a6f88..fe85fe04cc 100644 --- a/sdk/include/opentelemetry/sdk/metrics/meter_context.h +++ b/sdk/include/opentelemetry/sdk/metrics/meter_context.h @@ -54,7 +54,7 @@ class MeterContext : public std::enable_shared_from_this */ MeterContext( std::unique_ptr views = std::unique_ptr(new ViewRegistry()), - opentelemetry::sdk::resource::Resource resource = + const opentelemetry::sdk::resource::Resource &resource = opentelemetry::sdk::resource::Resource::Create({})) noexcept; /** @@ -131,7 +131,7 @@ class MeterContext : public std::enable_shared_from_this * * @param meter */ - void AddMeter(std::shared_ptr meter); + void AddMeter(const std::shared_ptr &meter); void RemoveMeter(nostd::string_view name, nostd::string_view version, diff --git a/sdk/include/opentelemetry/sdk/metrics/meter_provider.h b/sdk/include/opentelemetry/sdk/metrics/meter_provider.h index a838f2a96a..c34f16e0a1 100644 --- a/sdk/include/opentelemetry/sdk/metrics/meter_provider.h +++ b/sdk/include/opentelemetry/sdk/metrics/meter_provider.h @@ -39,8 +39,8 @@ class OPENTELEMETRY_EXPORT MeterProvider final : public opentelemetry::metrics:: * @param resource The resources for this meter provider. */ MeterProvider( - std::unique_ptr views = std::unique_ptr(new ViewRegistry()), - sdk::resource::Resource resource = sdk::resource::Resource::Create({})) noexcept; + std::unique_ptr views = std::unique_ptr(new ViewRegistry()), + const sdk::resource::Resource &resource = sdk::resource::Resource::Create({})) noexcept; /** * Initialize a new meter provider with a specified context diff --git a/sdk/include/opentelemetry/sdk/metrics/state/temporal_metric_storage.h b/sdk/include/opentelemetry/sdk/metrics/state/temporal_metric_storage.h index 2d01710e47..007b3c74cd 100644 --- a/sdk/include/opentelemetry/sdk/metrics/state/temporal_metric_storage.h +++ b/sdk/include/opentelemetry/sdk/metrics/state/temporal_metric_storage.h @@ -40,7 +40,7 @@ class TemporalMetricStorage nostd::span> collectors, opentelemetry::common::SystemTimestamp sdk_start_ts, opentelemetry::common::SystemTimestamp collection_ts, - std::shared_ptr delta_metrics, + const std::shared_ptr &delta_metrics, nostd::function_ref callback) noexcept; private: diff --git a/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h b/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h index 1d2c5bf25f..1d5f8dbc55 100644 --- a/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h +++ b/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h @@ -37,7 +37,7 @@ class Synchronous class LongCounter : public Synchronous, public opentelemetry::metrics::Counter { public: - LongCounter(InstrumentDescriptor instrument_descriptor, + LongCounter(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage); void Add(uint64_t value, @@ -56,7 +56,7 @@ class DoubleCounter : public Synchronous, public opentelemetry::metrics::Counter { public: - DoubleCounter(InstrumentDescriptor instrument_descriptor, + DoubleCounter(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage); void Add(double value, @@ -72,7 +72,7 @@ class DoubleCounter : public Synchronous, public opentelemetry::metrics::Counter class LongUpDownCounter : public Synchronous, public opentelemetry::metrics::UpDownCounter { public: - LongUpDownCounter(InstrumentDescriptor instrument_descriptor, + LongUpDownCounter(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage); void Add(int64_t value, @@ -88,7 +88,7 @@ class LongUpDownCounter : public Synchronous, public opentelemetry::metrics::UpD class DoubleUpDownCounter : public Synchronous, public opentelemetry::metrics::UpDownCounter { public: - DoubleUpDownCounter(InstrumentDescriptor instrument_descriptor, + DoubleUpDownCounter(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage); void Add(double value, @@ -104,7 +104,7 @@ class DoubleUpDownCounter : public Synchronous, public opentelemetry::metrics::U class LongHistogram : public Synchronous, public opentelemetry::metrics::Histogram { public: - LongHistogram(InstrumentDescriptor instrument_descriptor, + LongHistogram(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage); #if OPENTELEMETRY_ABI_VERSION_NO >= 2 @@ -124,7 +124,7 @@ class LongHistogram : public Synchronous, public opentelemetry::metrics::Histogr class DoubleHistogram : public Synchronous, public opentelemetry::metrics::Histogram { public: - DoubleHistogram(InstrumentDescriptor instrument_descriptor, + DoubleHistogram(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage); #if OPENTELEMETRY_ABI_VERSION_NO >= 2 diff --git a/sdk/include/opentelemetry/sdk/trace/samplers/parent.h b/sdk/include/opentelemetry/sdk/trace/samplers/parent.h index d5054d9218..e44e9fa320 100644 --- a/sdk/include/opentelemetry/sdk/trace/samplers/parent.h +++ b/sdk/include/opentelemetry/sdk/trace/samplers/parent.h @@ -27,7 +27,7 @@ namespace trace class ParentBasedSampler : public Sampler { public: - explicit ParentBasedSampler(std::shared_ptr delegate_sampler) noexcept; + explicit ParentBasedSampler(const std::shared_ptr &delegate_sampler) noexcept; /** The decision either respects the parent span's sampling decision or delegates to * delegateSampler for root spans * @return Returns DROP always diff --git a/sdk/include/opentelemetry/sdk/trace/samplers/parent_factory.h b/sdk/include/opentelemetry/sdk/trace/samplers/parent_factory.h index 68557ace79..d5cf598311 100644 --- a/sdk/include/opentelemetry/sdk/trace/samplers/parent_factory.h +++ b/sdk/include/opentelemetry/sdk/trace/samplers/parent_factory.h @@ -23,7 +23,7 @@ class ParentBasedSamplerFactory /** * Create a ParentBasedSampler. */ - static std::unique_ptr Create(std::shared_ptr delegate_sampler); + static std::unique_ptr Create(const std::shared_ptr &delegate_sampler); }; } // namespace trace diff --git a/sdk/include/opentelemetry/sdk/trace/tracer_context.h b/sdk/include/opentelemetry/sdk/trace/tracer_context.h index 73bbe4f84b..e1b2cb25d2 100644 --- a/sdk/include/opentelemetry/sdk/trace/tracer_context.h +++ b/sdk/include/opentelemetry/sdk/trace/tracer_context.h @@ -39,7 +39,7 @@ class TracerContext public: explicit TracerContext( std::vector> &&processor, - opentelemetry::sdk::resource::Resource resource = + const opentelemetry::sdk::resource::Resource &resource = opentelemetry::sdk::resource::Resource::Create({}), std::unique_ptr sampler = std::unique_ptr(new AlwaysOnSampler), std::unique_ptr id_generator = diff --git a/sdk/include/opentelemetry/sdk/trace/tracer_provider.h b/sdk/include/opentelemetry/sdk/trace/tracer_provider.h index 0d05a94043..13a65a2d87 100644 --- a/sdk/include/opentelemetry/sdk/trace/tracer_provider.h +++ b/sdk/include/opentelemetry/sdk/trace/tracer_provider.h @@ -43,7 +43,7 @@ class OPENTELEMETRY_EXPORT TracerProvider final : public opentelemetry::trace::T */ explicit TracerProvider( std::unique_ptr processor, - opentelemetry::sdk::resource::Resource resource = + const opentelemetry::sdk::resource::Resource &resource = opentelemetry::sdk::resource::Resource::Create({}), std::unique_ptr sampler = std::unique_ptr(new AlwaysOnSampler), std::unique_ptr id_generator = @@ -51,7 +51,7 @@ class OPENTELEMETRY_EXPORT TracerProvider final : public opentelemetry::trace::T explicit TracerProvider( std::vector> &&processors, - opentelemetry::sdk::resource::Resource resource = + const opentelemetry::sdk::resource::Resource &resource = opentelemetry::sdk::resource::Resource::Create({}), std::unique_ptr sampler = std::unique_ptr(new AlwaysOnSampler), std::unique_ptr id_generator = diff --git a/sdk/src/common/global_log_handler.cc b/sdk/src/common/global_log_handler.cc index 40968f2b7e..f60527eee8 100644 --- a/sdk/src/common/global_log_handler.cc +++ b/sdk/src/common/global_log_handler.cc @@ -31,7 +31,7 @@ void DefaultLogHandler::Handle(LogLevel level, { output_s << msg; } - output_s << std::endl; + output_s << '\n'; // TBD - print attributes switch (level) diff --git a/sdk/src/logs/event_logger.cc b/sdk/src/logs/event_logger.cc index 6b0afacfaf..df9ba44c31 100644 --- a/sdk/src/logs/event_logger.cc +++ b/sdk/src/logs/event_logger.cc @@ -21,7 +21,7 @@ namespace logs EventLogger::EventLogger( opentelemetry::nostd::shared_ptr delegate_logger, opentelemetry::nostd::string_view event_domain) noexcept - : delegate_logger_(delegate_logger), event_domain_(event_domain) + : delegate_logger_(std::move(delegate_logger)), event_domain_(event_domain) {} const opentelemetry::nostd::string_view EventLogger::GetName() noexcept diff --git a/sdk/src/logs/logger.cc b/sdk/src/logs/logger.cc index e9935c5107..2d57ab9faa 100644 --- a/sdk/src/logs/logger.cc +++ b/sdk/src/logs/logger.cc @@ -38,7 +38,7 @@ Logger::Logger( std::unique_ptr instrumentation_scope) noexcept : logger_name_(std::string(name)), instrumentation_scope_(std::move(instrumentation_scope)), - context_(context) + context_(std::move(context)) {} const opentelemetry::nostd::string_view Logger::GetName() noexcept diff --git a/sdk/src/logs/logger_context.cc b/sdk/src/logs/logger_context.cc index 2bfb89161e..a6eb063661 100644 --- a/sdk/src/logs/logger_context.cc +++ b/sdk/src/logs/logger_context.cc @@ -19,7 +19,7 @@ namespace logs { LoggerContext::LoggerContext(std::vector> &&processors, - opentelemetry::sdk::resource::Resource resource) noexcept + const opentelemetry::sdk::resource::Resource &resource) noexcept : resource_(resource), processor_( std::unique_ptr(new MultiLogRecordProcessor(std::move(processors)))) diff --git a/sdk/src/logs/logger_provider.cc b/sdk/src/logs/logger_provider.cc index 1eaa0d186e..fdea3eb51a 100644 --- a/sdk/src/logs/logger_provider.cc +++ b/sdk/src/logs/logger_provider.cc @@ -27,7 +27,7 @@ namespace logs { LoggerProvider::LoggerProvider(std::unique_ptr &&processor, - opentelemetry::sdk::resource::Resource resource) noexcept + const opentelemetry::sdk::resource::Resource &resource) noexcept { std::vector> processors; processors.emplace_back(std::move(processor)); @@ -36,7 +36,7 @@ LoggerProvider::LoggerProvider(std::unique_ptr &&processor, } LoggerProvider::LoggerProvider(std::vector> &&processors, - opentelemetry::sdk::resource::Resource resource) noexcept + const opentelemetry::sdk::resource::Resource &resource) noexcept : context_{std::make_shared(std::move(processors), std::move(resource))} {} diff --git a/sdk/src/metrics/async_instruments.cc b/sdk/src/metrics/async_instruments.cc index 311efc1e7e..709957d68e 100644 --- a/sdk/src/metrics/async_instruments.cc +++ b/sdk/src/metrics/async_instruments.cc @@ -20,9 +20,9 @@ namespace metrics ObservableInstrument::ObservableInstrument(InstrumentDescriptor instrument_descriptor, std::unique_ptr storage, std::shared_ptr observable_registry) - : instrument_descriptor_(instrument_descriptor), + : instrument_descriptor_(std::move(instrument_descriptor)), storage_(std::move(storage)), - observable_registry_{observable_registry} + observable_registry_{std::move(observable_registry)} {} diff --git a/sdk/src/metrics/exemplar/reservoir.cc b/sdk/src/metrics/exemplar/reservoir.cc index 4e7501799e..264a000828 100644 --- a/sdk/src/metrics/exemplar/reservoir.cc +++ b/sdk/src/metrics/exemplar/reservoir.cc @@ -3,9 +3,11 @@ #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW -# include "opentelemetry/sdk/metrics/exemplar/reservoir.h" +# include + # include "opentelemetry/sdk/metrics/exemplar/aligned_histogram_bucket_exemplar_reservoir.h" # include "opentelemetry/sdk/metrics/exemplar/no_exemplar_reservoir.h" +# include "opentelemetry/sdk/metrics/exemplar/reservoir.h" # include "opentelemetry/sdk/metrics/exemplar/reservoir_cell.h" # include "opentelemetry/sdk/metrics/exemplar/simple_fixed_size_exemplar_reservoir.h" @@ -20,8 +22,8 @@ nostd::shared_ptr ExemplarReservoir::GetSimpleFixedSizeExempl std::shared_ptr reservoir_cell_selector, MapAndResetCellType map_and_reset_cell) { - return nostd::shared_ptr{ - new SimpleFixedSizeExemplarReservoir{size, reservoir_cell_selector, map_and_reset_cell}}; + return nostd::shared_ptr{new SimpleFixedSizeExemplarReservoir{ + size, std::move(reservoir_cell_selector), map_and_reset_cell}}; } nostd::shared_ptr ExemplarReservoir::GetAlignedHistogramBucketExemplarReservoir( @@ -30,7 +32,7 @@ nostd::shared_ptr ExemplarReservoir::GetAlignedHistogramBucke MapAndResetCellType map_and_reset_cell) { return nostd::shared_ptr{new AlignedHistogramBucketExemplarReservoir{ - size, reservoir_cell_selector, map_and_reset_cell}}; + size, std::move(reservoir_cell_selector), map_and_reset_cell}}; } nostd::shared_ptr ExemplarReservoir::GetNoExemplarReservoir() diff --git a/sdk/src/metrics/meter.cc b/sdk/src/metrics/meter.cc index 8b4413113b..c61f3a8d31 100644 --- a/sdk/src/metrics/meter.cc +++ b/sdk/src/metrics/meter.cc @@ -53,7 +53,7 @@ Meter::Meter( std::weak_ptr meter_context, std::unique_ptr instrumentation_scope) noexcept : scope_{std::move(instrumentation_scope)}, - meter_context_{meter_context}, + meter_context_{std::move(meter_context)}, observable_registry_(new ObservableRegistry()) {} @@ -455,7 +455,7 @@ std::vector Meter::Collect(CollectorHandle *collector, for (auto &metric_storage : storage_registry_) { metric_storage.second->Collect(collector, ctx->GetCollectors(), ctx->GetSDKStartTime(), - collect_ts, [&metric_data_list](MetricData metric_data) { + collect_ts, [&metric_data_list](const MetricData &metric_data) { metric_data_list.push_back(metric_data); return true; }); diff --git a/sdk/src/metrics/meter_context.cc b/sdk/src/metrics/meter_context.cc index de32c469d8..40b9da42b2 100644 --- a/sdk/src/metrics/meter_context.cc +++ b/sdk/src/metrics/meter_context.cc @@ -36,7 +36,7 @@ namespace metrics { MeterContext::MeterContext(std::unique_ptr views, - opentelemetry::sdk::resource::Resource resource) noexcept + const opentelemetry::sdk::resource::Resource &resource) noexcept : resource_{resource}, views_(std::move(views)), sdk_start_ts_{std::chrono::system_clock::now()} {} @@ -82,7 +82,7 @@ opentelemetry::common::SystemTimestamp MeterContext::GetSDKStartTime() noexcept void MeterContext::AddMetricReader(std::shared_ptr reader) noexcept { - auto collector = std::shared_ptr{new MetricCollector(this, reader)}; + auto collector = std::shared_ptr{new MetricCollector(this, std::move(reader))}; collectors_.push_back(collector); } @@ -107,7 +107,7 @@ ExemplarFilterType MeterContext::GetExemplarFilter() const noexcept #endif // ENABLE_METRICS_EXEMPLAR_PREVIEW -void MeterContext::AddMeter(std::shared_ptr meter) +void MeterContext::AddMeter(const std::shared_ptr &meter) { std::lock_guard guard(meter_lock_); meters_.push_back(meter); diff --git a/sdk/src/metrics/meter_provider.cc b/sdk/src/metrics/meter_provider.cc index 6ddba6aa7c..4f2ca4b44f 100644 --- a/sdk/src/metrics/meter_provider.cc +++ b/sdk/src/metrics/meter_provider.cc @@ -37,7 +37,7 @@ MeterProvider::MeterProvider(std::unique_ptr context) noexcept {} MeterProvider::MeterProvider(std::unique_ptr views, - sdk::resource::Resource resource) noexcept + const sdk::resource::Resource &resource) noexcept : context_(std::make_shared(std::move(views), resource)) { OTEL_INTERNAL_LOG_DEBUG("[MeterProvider] MeterProvider created."); @@ -110,7 +110,7 @@ const resource::Resource &MeterProvider::GetResource() const noexcept void MeterProvider::AddMetricReader(std::shared_ptr reader) noexcept { - context_->AddMetricReader(reader); + context_->AddMetricReader(std::move(reader)); } void MeterProvider::AddView(std::unique_ptr instrument_selector, diff --git a/sdk/src/metrics/state/metric_collector.cc b/sdk/src/metrics/state/metric_collector.cc index 5ecf41cecf..a790a6b6a1 100644 --- a/sdk/src/metrics/state/metric_collector.cc +++ b/sdk/src/metrics/state/metric_collector.cc @@ -27,7 +27,7 @@ namespace metrics MetricCollector::MetricCollector(opentelemetry::sdk::metrics::MeterContext *context, std::shared_ptr metric_reader) - : meter_context_{context}, metric_reader_{metric_reader} + : meter_context_{context}, metric_reader_{std::move(metric_reader)} { metric_reader_->SetMetricProducer(this); } @@ -48,7 +48,7 @@ bool MetricCollector::Collect( return false; } ResourceMetrics resource_metrics; - meter_context_->ForEachMeter([&](std::shared_ptr meter) noexcept { + meter_context_->ForEachMeter([&](const std::shared_ptr &meter) noexcept { auto collection_ts = std::chrono::system_clock::now(); auto metric_data = meter->Collect(this, collection_ts); if (!metric_data.empty()) diff --git a/sdk/src/metrics/state/temporal_metric_storage.cc b/sdk/src/metrics/state/temporal_metric_storage.cc index 2ba74d9213..c26339a79f 100644 --- a/sdk/src/metrics/state/temporal_metric_storage.cc +++ b/sdk/src/metrics/state/temporal_metric_storage.cc @@ -35,7 +35,7 @@ namespace metrics TemporalMetricStorage::TemporalMetricStorage(InstrumentDescriptor instrument_descriptor, AggregationType aggregation_type, const AggregationConfig *aggregation_config) - : instrument_descriptor_(instrument_descriptor), + : instrument_descriptor_(std::move(instrument_descriptor)), aggregation_type_(aggregation_type), aggregation_config_(aggregation_config) {} @@ -44,7 +44,7 @@ bool TemporalMetricStorage::buildMetrics(CollectorHandle *collector, nostd::span> collectors, opentelemetry::common::SystemTimestamp sdk_start_ts, opentelemetry::common::SystemTimestamp collection_ts, - std::shared_ptr delta_metrics, + const std::shared_ptr &delta_metrics, nostd::function_ref callback) noexcept { std::lock_guard guard(lock_); diff --git a/sdk/src/metrics/sync_instruments.cc b/sdk/src/metrics/sync_instruments.cc index a99fa80868..56429a079f 100644 --- a/sdk/src/metrics/sync_instruments.cc +++ b/sdk/src/metrics/sync_instruments.cc @@ -20,7 +20,7 @@ namespace sdk { namespace metrics { -LongCounter::LongCounter(InstrumentDescriptor instrument_descriptor, +LongCounter::LongCounter(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage) : Synchronous(instrument_descriptor, std::move(storage)) { @@ -80,7 +80,7 @@ void LongCounter::Add(uint64_t value, const opentelemetry::context::Context &con return storage_->RecordLong(value, context); } -DoubleCounter::DoubleCounter(InstrumentDescriptor instrument_descriptor, +DoubleCounter::DoubleCounter(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage) : Synchronous(instrument_descriptor, std::move(storage)) { @@ -164,7 +164,7 @@ void DoubleCounter::Add(double value, const opentelemetry::context::Context &con return storage_->RecordDouble(value, context); } -LongUpDownCounter::LongUpDownCounter(InstrumentDescriptor instrument_descriptor, +LongUpDownCounter::LongUpDownCounter(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage) : Synchronous(instrument_descriptor, std::move(storage)) { @@ -228,7 +228,7 @@ void LongUpDownCounter::Add(int64_t value, const opentelemetry::context::Context return storage_->RecordLong(value, context); } -DoubleUpDownCounter::DoubleUpDownCounter(InstrumentDescriptor instrument_descriptor, +DoubleUpDownCounter::DoubleUpDownCounter(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage) : Synchronous(instrument_descriptor, std::move(storage)) { @@ -292,7 +292,7 @@ void DoubleUpDownCounter::Add(double value, const opentelemetry::context::Contex return storage_->RecordDouble(value, context); } -LongHistogram::LongHistogram(InstrumentDescriptor instrument_descriptor, +LongHistogram::LongHistogram(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage) : Synchronous(instrument_descriptor, std::move(storage)) { @@ -355,7 +355,7 @@ void LongHistogram::Record(uint64_t value) noexcept } #endif -DoubleHistogram::DoubleHistogram(InstrumentDescriptor instrument_descriptor, +DoubleHistogram::DoubleHistogram(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage) : Synchronous(instrument_descriptor, std::move(storage)) { diff --git a/sdk/src/metrics/view/view_factory.cc b/sdk/src/metrics/view/view_factory.cc index 36496f62d6..319c10b956 100644 --- a/sdk/src/metrics/view/view_factory.cc +++ b/sdk/src/metrics/view/view_factory.cc @@ -53,7 +53,7 @@ std::unique_ptr ViewFactory::Create(const std::string &name, auto attributes_processor = std::unique_ptr(new DefaultAttributesProcessor()); - return Create(name, description, unit, aggregation_type, aggregation_config, + return Create(name, description, unit, aggregation_type, std::move(aggregation_config), std::move(attributes_processor)); } @@ -64,7 +64,8 @@ std::unique_ptr ViewFactory::Create(const std::string &name, std::shared_ptr aggregation_config, std::unique_ptr attributes_processor) { - std::unique_ptr view(new View(name, description, unit, aggregation_type, aggregation_config, + std::unique_ptr view(new View(name, description, unit, aggregation_type, + std::move(aggregation_config), std::move(attributes_processor))); return view; } diff --git a/sdk/src/trace/batch_span_processor.cc b/sdk/src/trace/batch_span_processor.cc index 03b79f6ebb..6aa6a49949 100644 --- a/sdk/src/trace/batch_span_processor.cc +++ b/sdk/src/trace/batch_span_processor.cc @@ -29,7 +29,6 @@ #include "opentelemetry/version.h" using opentelemetry::sdk::common::AtomicUniquePtr; -using opentelemetry::sdk::common::CircularBuffer; using opentelemetry::sdk::common::CircularBufferRange; using opentelemetry::trace::SpanContext; diff --git a/sdk/src/trace/samplers/parent.cc b/sdk/src/trace/samplers/parent.cc index a69ede92d4..9bffb7b030 100644 --- a/sdk/src/trace/samplers/parent.cc +++ b/sdk/src/trace/samplers/parent.cc @@ -22,7 +22,7 @@ namespace sdk { namespace trace { -ParentBasedSampler::ParentBasedSampler(std::shared_ptr delegate_sampler) noexcept +ParentBasedSampler::ParentBasedSampler(const std::shared_ptr &delegate_sampler) noexcept : delegate_sampler_(delegate_sampler), description_("ParentBased{" + std::string{delegate_sampler->GetDescription()} + "}") {} diff --git a/sdk/src/trace/samplers/parent_factory.cc b/sdk/src/trace/samplers/parent_factory.cc index 978fb75946..7f1bc088d6 100644 --- a/sdk/src/trace/samplers/parent_factory.cc +++ b/sdk/src/trace/samplers/parent_factory.cc @@ -1,8 +1,10 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/trace/samplers/parent_factory.h" +#include + #include "opentelemetry/sdk/trace/samplers/parent.h" +#include "opentelemetry/sdk/trace/samplers/parent_factory.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -12,9 +14,9 @@ namespace trace { std::unique_ptr ParentBasedSamplerFactory::Create( - std::shared_ptr delegate_sampler) + const std::shared_ptr &delegate_sampler) { - std::unique_ptr sampler(new ParentBasedSampler(delegate_sampler)); + std::unique_ptr sampler(new ParentBasedSampler(std::move(delegate_sampler))); return sampler; } diff --git a/sdk/src/trace/span.cc b/sdk/src/trace/span.cc index ca3a475707..2b9e9d2908 100644 --- a/sdk/src/trace/span.cc +++ b/sdk/src/trace/span.cc @@ -78,7 +78,7 @@ Span::Span(std::shared_ptr &&tracer, return true; }); - links.ForEachKeyValue([&](opentelemetry::trace::SpanContext span_context, + links.ForEachKeyValue([&](const opentelemetry::trace::SpanContext &span_context, const common::KeyValueIterable &attributes) { recordable_->AddLink(span_context, attributes); return true; diff --git a/sdk/src/trace/tracer.cc b/sdk/src/trace/tracer.cc index fd02548c7b..73fc08d5dc 100644 --- a/sdk/src/trace/tracer.cc +++ b/sdk/src/trace/tracer.cc @@ -39,7 +39,7 @@ namespace trace Tracer::Tracer(std::shared_ptr context, std::unique_ptr instrumentation_scope) noexcept - : instrumentation_scope_{std::move(instrumentation_scope)}, context_{context} + : instrumentation_scope_{std::move(instrumentation_scope)}, context_{std::move(context)} {} nostd::shared_ptr Tracer::StartSpan( diff --git a/sdk/src/trace/tracer_context.cc b/sdk/src/trace/tracer_context.cc index 0fb4fd35cf..65300d6f22 100644 --- a/sdk/src/trace/tracer_context.cc +++ b/sdk/src/trace/tracer_context.cc @@ -22,7 +22,7 @@ namespace trace namespace resource = opentelemetry::sdk::resource; TracerContext::TracerContext(std::vector> &&processors, - resource::Resource resource, + const resource::Resource &resource, std::unique_ptr sampler, std::unique_ptr id_generator) noexcept : resource_(resource), diff --git a/sdk/src/trace/tracer_provider.cc b/sdk/src/trace/tracer_provider.cc index 9440e3d469..3b5462a083 100644 --- a/sdk/src/trace/tracer_provider.cc +++ b/sdk/src/trace/tracer_provider.cc @@ -38,7 +38,7 @@ TracerProvider::TracerProvider(std::unique_ptr context) noexcept } TracerProvider::TracerProvider(std::unique_ptr processor, - resource::Resource resource, + const resource::Resource &resource, std::unique_ptr sampler, std::unique_ptr id_generator) noexcept { @@ -49,7 +49,7 @@ TracerProvider::TracerProvider(std::unique_ptr processor, } TracerProvider::TracerProvider(std::vector> &&processors, - resource::Resource resource, + const resource::Resource &resource, std::unique_ptr sampler, std::unique_ptr id_generator) noexcept { diff --git a/sdk/test/common/empty_attributes_test.cc b/sdk/test/common/empty_attributes_test.cc index f37ea0a5c4..894cafc8a7 100644 --- a/sdk/test/common/empty_attributes_test.cc +++ b/sdk/test/common/empty_attributes_test.cc @@ -15,5 +15,5 @@ TEST(EmptyAttributesTest, TestMemory) { auto attributes1 = opentelemetry::sdk::GetEmptyAttributes(); auto attributes2 = opentelemetry::sdk::GetEmptyAttributes(); - EXPECT_EQ(memcmp(&attributes1, &attributes2, sizeof(attributes1)), 0); + EXPECT_EQ(memcmp(&attributes1, &attributes2, sizeof(attributes1)), 0); // NOLINT } diff --git a/sdk/test/logs/batch_log_record_processor_test.cc b/sdk/test/logs/batch_log_record_processor_test.cc index 33db0da479..3bdd849938 100644 --- a/sdk/test/logs/batch_log_record_processor_test.cc +++ b/sdk/test/logs/batch_log_record_processor_test.cc @@ -9,6 +9,7 @@ #include #include #include +#include using namespace opentelemetry::sdk::logs; using namespace opentelemetry::sdk::common; @@ -74,10 +75,10 @@ class MockLogExporter final : public LogRecordExporter std::shared_ptr> is_shutdown, std::shared_ptr> is_export_completed, const std::chrono::milliseconds export_delay = std::chrono::milliseconds(0)) - : logs_received_(logs_received), - force_flush_counter_(force_flush_counter), - is_shutdown_(is_shutdown), - is_export_completed_(is_export_completed), + : logs_received_(std::move(logs_received)), + force_flush_counter_(std::move(force_flush_counter)), + is_shutdown_(std::move(is_shutdown)), + is_export_completed_(std::move(is_export_completed)), export_delay_(export_delay) {} @@ -154,7 +155,8 @@ class BatchLogRecordProcessorTest : public testing::Test // ::testing::Test { return std::shared_ptr(new BatchLogRecordProcessor( std::unique_ptr(new MockLogExporter( - logs_received, force_flush_counter, is_shutdown, is_export_completed, export_delay)), + std::move(logs_received), std::move(force_flush_counter), std::move(is_shutdown), + std::move(is_export_completed), export_delay)), max_queue_size, scheduled_delay_millis, max_export_batch_size)); } }; diff --git a/sdk/test/logs/logger_sdk_test.cc b/sdk/test/logs/logger_sdk_test.cc index 62d523b92a..9e63672d3c 100644 --- a/sdk/test/logs/logger_sdk_test.cc +++ b/sdk/test/logs/logger_sdk_test.cc @@ -3,6 +3,7 @@ #include #include +#include #include "opentelemetry/logs/logger_provider.h" #include "opentelemetry/nostd/string_view.h" @@ -172,7 +173,7 @@ class MockProcessor final : public LogRecordProcessor public: // A processor used for testing that keeps a track of the recordable it received explicit MockProcessor(std::shared_ptr record_received) noexcept - : record_received_(record_received) + : record_received_(std::move(record_received)) {} std::unique_ptr MakeRecordable() noexcept override diff --git a/sdk/test/logs/simple_log_record_processor_test.cc b/sdk/test/logs/simple_log_record_processor_test.cc index 484cc63e71..30e5771394 100644 --- a/sdk/test/logs/simple_log_record_processor_test.cc +++ b/sdk/test/logs/simple_log_record_processor_test.cc @@ -10,6 +10,7 @@ #include #include +#include using namespace opentelemetry::sdk::logs; using namespace opentelemetry::sdk::common; @@ -75,7 +76,7 @@ class TestExporter final : public LogRecordExporter size_t *batch_size_received) : force_flush_counter_(force_flush_counter), shutdown_counter_(shutdown_counter), - logs_received_(logs_received), + logs_received_(std::move(logs_received)), batch_size_received(batch_size_received) {} diff --git a/sdk/test/metrics/async_instruments_test.cc b/sdk/test/metrics/async_instruments_test.cc index 10c0335559..b7ad885bbd 100644 --- a/sdk/test/metrics/async_instruments_test.cc +++ b/sdk/test/metrics/async_instruments_test.cc @@ -12,6 +12,7 @@ using namespace opentelemetry::sdk::metrics; using M = std::map; +// NOLINTNEXTLINE void asyc_generate_measurements(opentelemetry::metrics::ObserverResult /* observer */, void * /* state */) {} diff --git a/sdk/test/metrics/async_metric_storage_test.cc b/sdk/test/metrics/async_metric_storage_test.cc index 3b72e99d96..dcbe105418 100644 --- a/sdk/test/metrics/async_metric_storage_test.cc +++ b/sdk/test/metrics/async_metric_storage_test.cc @@ -262,7 +262,7 @@ TEST_P(WritableMetricStorageTestObservableGaugeFixture, TestAggregation) opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now())); storage.Collect( - collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData metric_data) { + collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData &metric_data) { for (auto data_attr : metric_data.point_data_attr_) { auto data = opentelemetry::nostd::get(data_attr.point_data); @@ -288,7 +288,7 @@ TEST_P(WritableMetricStorageTestObservableGaugeFixture, TestAggregation) storage.RecordLong(measurements2, opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now())); storage.Collect( - collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData metric_data) { + collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData &metric_data) { for (auto data_attr : metric_data.point_data_attr_) { auto data = opentelemetry::nostd::get(data_attr.point_data); diff --git a/sdk/test/metrics/cardinality_limit_test.cc b/sdk/test/metrics/cardinality_limit_test.cc index 8c2edb4b0c..3f9483ac1c 100644 --- a/sdk/test/metrics/cardinality_limit_test.cc +++ b/sdk/test/metrics/cardinality_limit_test.cc @@ -26,7 +26,7 @@ TEST(CardinalityLimit, AttributesHashMapBasicTests) return std::unique_ptr(new LongSumAggregation(true)); }; // add 10 unique metric points. 9 should be added to hashmap, 10th should be overflow. - long record_value = 100; + int64_t record_value = 100; for (auto i = 0; i < 10; i++) { FilteredOrderedAttributeMap attributes = {{"key", std::to_string(i)}}; @@ -76,7 +76,7 @@ TEST_P(WritableMetricStorageCardinalityLimitTestFixture, LongCounterSumAggregati #endif nullptr, attributes_limit); - long record_value = 100; + int64_t record_value = 100; // add 9 unique metric points, and 6 more above limit. for (auto i = 0; i < 15; i++) { diff --git a/sdk/test/metrics/instrument_metadata_validator_test.cc b/sdk/test/metrics/instrument_metadata_validator_test.cc index 172df1af3c..28c6d4a4fd 100644 --- a/sdk/test/metrics/instrument_metadata_validator_test.cc +++ b/sdk/test/metrics/instrument_metadata_validator_test.cc @@ -19,9 +19,9 @@ TEST(InstrumentMetadataValidator, TestName) { opentelemetry::sdk::metrics::InstrumentMetaDataValidator validator; std::vector invalid_names = { - "", // empty string - "1sdf", // string starting with number - "\x31\x32\x33\xe2\x82\xac\x41\x41\x41\xe2\x82\xac\x42\x42\x42" // unicode characters + "", // empty string + "1sdf", // string starting with number + "\x31\x32\x33\xe2\x82\xac\x41\x41\x41\xe2\x82\xac\x42\x42\x42", // unicode characters "/\\sdsd", // string starting with special character "***sSSs", // string starting with special character "a\\broken\\path", // contains backward slash diff --git a/sdk/test/metrics/meter_test.cc b/sdk/test/metrics/meter_test.cc index 084f50fc09..b5ed86f55a 100644 --- a/sdk/test/metrics/meter_test.cc +++ b/sdk/test/metrics/meter_test.cc @@ -18,7 +18,7 @@ using namespace opentelemetry::sdk::metrics; namespace { nostd::shared_ptr InitMeter(MetricReader **metricReaderPtr, - std::string meter_name = "meter_name") + const std::string &meter_name = "meter_name") { static std::shared_ptr provider(new MeterProvider()); std::unique_ptr metric_reader(new MockMetricReader()); diff --git a/sdk/test/metrics/sync_metric_storage_up_down_counter_test.cc b/sdk/test/metrics/sync_metric_storage_up_down_counter_test.cc index 216574a587..88ae56eb3f 100644 --- a/sdk/test/metrics/sync_metric_storage_up_down_counter_test.cc +++ b/sdk/test/metrics/sync_metric_storage_up_down_counter_test.cc @@ -71,7 +71,7 @@ TEST_P(WritableMetricStorageTestFixture, LongUpDownCounterSumAggregation) auto collection_ts = std::chrono::system_clock::now(); size_t count_attributes = 0; storage.Collect(collector.get(), collectors, sdk_start_ts, collection_ts, - [&](const MetricData data) { + [&](const MetricData &data) { for (auto data_attr : data.point_data_attr_) { auto sum_data = opentelemetry::nostd::get(data_attr.point_data); @@ -105,7 +105,7 @@ TEST_P(WritableMetricStorageTestFixture, LongUpDownCounterSumAggregation) collection_ts = std::chrono::system_clock::now(); count_attributes = 0; storage.Collect(collector.get(), collectors, sdk_start_ts, collection_ts, - [&](const MetricData data) { + [&](const MetricData &data) { if (temporality == AggregationTemporality::kCumulative) { EXPECT_EQ(data.start_ts, sdk_start_ts); @@ -147,7 +147,7 @@ TEST_P(WritableMetricStorageTestFixture, LongUpDownCounterSumAggregation) collection_ts = std::chrono::system_clock::now(); count_attributes = 0; storage.Collect(collector.get(), collectors, sdk_start_ts, collection_ts, - [&](const MetricData data) { + [&](const MetricData &data) { for (auto data_attr : data.point_data_attr_) { auto sum_data = opentelemetry::nostd::get(data_attr.point_data); @@ -224,7 +224,7 @@ TEST_P(WritableMetricStorageTestFixture, DoubleUpDownCounterSumAggregation) auto collection_ts = std::chrono::system_clock::now(); size_t count_attributes = 0; storage.Collect(collector.get(), collectors, sdk_start_ts, collection_ts, - [&](const MetricData data) { + [&](const MetricData &data) { for (auto data_attr : data.point_data_attr_) { auto sum_data = opentelemetry::nostd::get(data_attr.point_data); @@ -259,7 +259,7 @@ TEST_P(WritableMetricStorageTestFixture, DoubleUpDownCounterSumAggregation) collection_ts = std::chrono::system_clock::now(); count_attributes = 0; storage.Collect(collector.get(), collectors, sdk_start_ts, collection_ts, - [&](const MetricData data) { + [&](const MetricData &data) { if (temporality == AggregationTemporality::kCumulative) { EXPECT_EQ(data.start_ts, sdk_start_ts); @@ -301,7 +301,7 @@ TEST_P(WritableMetricStorageTestFixture, DoubleUpDownCounterSumAggregation) collection_ts = std::chrono::system_clock::now(); count_attributes = 0; storage.Collect(collector.get(), collectors, sdk_start_ts, collection_ts, - [&](const MetricData data) { + [&](const MetricData &data) { for (auto data_attr : data.point_data_attr_) { auto sum_data = opentelemetry::nostd::get(data_attr.point_data); diff --git a/sdk/test/resource/resource_test.cc b/sdk/test/resource/resource_test.cc index e6b56cae43..419264862c 100644 --- a/sdk/test/resource/resource_test.cc +++ b/sdk/test/resource/resource_test.cc @@ -25,7 +25,8 @@ namespace nostd = opentelemetry::nostd; class TestResource : public Resource { public: - TestResource(ResourceAttributes attributes = ResourceAttributes(), std::string schema_url = {}) + TestResource(const ResourceAttributes &attributes = ResourceAttributes(), + const std::string &schema_url = {}) : Resource(attributes, schema_url) {} }; @@ -122,10 +123,10 @@ TEST(ResourceTest, create_with_emptyatrributes) TEST(ResourceTest, create_with_schemaurl) { - const std::string schema_url = "https://opentelemetry.io/schemas/1.2.0"; - ResourceAttributes attributes = {}; - auto resource = Resource::Create(attributes, schema_url); - auto received_schema_url = resource.GetSchemaURL(); + const std::string schema_url = "https://opentelemetry.io/schemas/1.2.0"; + ResourceAttributes attributes = {}; + auto resource = Resource::Create(attributes, schema_url); + const auto &received_schema_url = resource.GetSchemaURL(); EXPECT_EQ(received_schema_url, schema_url); } diff --git a/sdk/test/trace/batch_span_processor_test.cc b/sdk/test/trace/batch_span_processor_test.cc index 411b4dacfe..9bb09d6e55 100644 --- a/sdk/test/trace/batch_span_processor_test.cc +++ b/sdk/test/trace/batch_span_processor_test.cc @@ -16,6 +16,7 @@ #include #include #include +#include OPENTELEMETRY_BEGIN_NAMESPACE @@ -32,10 +33,10 @@ class MockSpanExporter final : public sdk::trace::SpanExporter std::shared_ptr> is_export_completed = std::shared_ptr>(new std::atomic(false)), const std::chrono::milliseconds export_delay = std::chrono::milliseconds(0)) noexcept - : spans_received_(spans_received), - shut_down_counter_(shut_down_counter), - is_shutdown_(is_shutdown), - is_export_completed_(is_export_completed), + : spans_received_(std::move(spans_received)), + shut_down_counter_(std::move(shut_down_counter)), + is_shutdown_(std::move(is_shutdown)), + is_export_completed_(std::move(is_export_completed)), export_delay_(export_delay) {} @@ -96,7 +97,7 @@ class BatchSpanProcessorTestPeer : public testing::Test { public: std::unique_ptr>> GetTestSpans( - std::shared_ptr processor, + const std::shared_ptr &processor, const int num_spans) { std::unique_ptr>> test_spans( diff --git a/sdk/test/trace/span_data_test.cc b/sdk/test/trace/span_data_test.cc index 98d00843dd..6dfc09bd12 100644 --- a/sdk/test/trace/span_data_test.cc +++ b/sdk/test/trace/span_data_test.cc @@ -96,8 +96,8 @@ TEST(SpanData, EventAttributes) TEST(SpanData, Resources) { SpanData data; - auto resource = opentelemetry::sdk::resource::Resource::Create({}); - auto input_attr = resource.GetAttributes(); + auto resource = opentelemetry::sdk::resource::Resource::Create({}); + const auto &input_attr = resource.GetAttributes(); data.SetResource(resource); auto output_attr = data.GetResource().GetAttributes(); EXPECT_EQ(input_attr, output_attr); diff --git a/sdk/test/trace/tracer_test.cc b/sdk/test/trace/tracer_test.cc index 99bab95b0f..c57b638e3d 100644 --- a/sdk/test/trace/tracer_test.cc +++ b/sdk/test/trace/tracer_test.cc @@ -20,7 +20,6 @@ using opentelemetry::common::SystemTimestamp; namespace nostd = opentelemetry::nostd; namespace common = opentelemetry::common; namespace trace_api = opentelemetry::trace; -using opentelemetry::common::KeyValueIterableView; using opentelemetry::exporter::memory::InMemorySpanData; using opentelemetry::exporter::memory::InMemorySpanExporter; using opentelemetry::trace::SpanContext; From 63fa4fde4ec7d1151cbf4095e442ec1f96dcb4a1 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Fri, 12 Jul 2024 12:17:04 +0200 Subject: [PATCH 02/89] [CI] Build failures with ABSEIL 20240116 and CMAKE 3.30 (#3002) --- ci/fix-abseil-cpp-issue-1536.patch | 23 +++++++++++++++++++ ci/install_abseil.sh | 37 ++++++++++++++++++++++++++++++ tools/format.sh | 4 ++-- 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 ci/fix-abseil-cpp-issue-1536.patch diff --git a/ci/fix-abseil-cpp-issue-1536.patch b/ci/fix-abseil-cpp-issue-1536.patch new file mode 100644 index 0000000000..7004cf0479 --- /dev/null +++ b/ci/fix-abseil-cpp-issue-1536.patch @@ -0,0 +1,23 @@ +commit 779a3565ac6c5b69dd1ab9183e500a27633117d5 +Author: Derek Mauro +Date: Tue Jan 30 10:13:25 2024 -0800 + + Avoid export of testonly target absl::test_allocator in CMake builds + + Closes #1536 + + PiperOrigin-RevId: 602764437 + Change-Id: Ia5c20a3874262a2ddb8797f608af17d7e86dd6d6 + +diff --git a/absl/container/CMakeLists.txt b/absl/container/CMakeLists.txt +index 449a2cad..ee9ca9c3 100644 +--- a/absl/container/CMakeLists.txt ++++ b/absl/container/CMakeLists.txt +@@ -213,6 +213,7 @@ absl_cc_library( + DEPS + absl::config + GTest::gmock ++ TESTONLY + ) + + absl_cc_test( diff --git a/ci/install_abseil.sh b/ci/install_abseil.sh index 46a7870627..ced090cc64 100755 --- a/ci/install_abseil.sh +++ b/ci/install_abseil.sh @@ -7,6 +7,8 @@ set -ex export DEBIAN_FRONTEND=noninteractive [ -z "${ABSEIL_CPP_VERSION}" ] && export ABSEIL_CPP_VERSION="20240116.1" +TOPDIR=`pwd` + BUILD_DIR=/tmp/ INSTALL_DIR=/usr/local/ pushd $BUILD_DIR @@ -22,6 +24,41 @@ if [ ! -z "${CXX_STANDARD}" ]; then ABSEIL_CPP_BUILD_OPTIONS=(${ABSEIL_CPP_BUILD_OPTIONS[@]} "-DCMAKE_CXX_STANDARD=${CXX_STANDARD}") fi +# +# ABSEIL_CPP_VERSION="20240116.1" fails to build with CMake 3.30 +# ABSEIL_CPP_VERSION="20240116.2" fails to build with CMake 3.30 +# note that somehow the same builds with CMake 3.29.6 +# +# Error reported: +# CMake Error at CMake/AbseilHelpers.cmake:317 (target_link_libraries): +# The link interface of target "test_allocator" contains: +# +# GTest::gmock +# +# but the target was not found. Possible reasons include: +# +# * There is a typo in the target name. +# * A find_package call is missing for an IMPORTED target. +# * An ALIAS target is missing. +# +# Call Stack (most recent call first): +# absl/container/CMakeLists.txt:206 (absl_cc_library) +# +# Root cause: +# https://github.com/abseil/abseil-cpp/pull/1536 +# +# Applying fix from abseil commit 779a3565ac6c5b69dd1ab9183e500a27633117d5 +# +# TODO(marcalff) Cleanup once abseil is upgraded to the next LTS + + +if [ "${ABSEIL_CPP_VERSION}" = "20240116.1" ] || [ "${ABSEIL_CPP_VERSION}" = "20240116.2" ]; then + echo "Patching abseil" + patch -p1 < ${TOPDIR}/ci/fix-abseil-cpp-issue-1536.patch +else + echo "Not patching abseil" +fi + mkdir build && pushd build cmake "${ABSEIL_CPP_BUILD_OPTIONS[@]}" .. make -j $(nproc) diff --git a/tools/format.sh b/tools/format.sh index 65728b385f..3a3863a8ea 100755 --- a/tools/format.sh +++ b/tools/format.sh @@ -23,8 +23,8 @@ fi # No CRLF line endings, except Windows files. "${SED[@]}" 's/\r$//' $($FIND -name '*.ps1' -prune -o \ -name '*.cmd' -prune -o -type f -print) -# No trailing spaces. -"${SED[@]}" 's/ \+$//' $($FIND -type f -print) +# No trailing spaces, except in patch. +"${SED[@]}" 's/ \+$//' $($FIND -name "*.patch" -prune -o -type f -print) # If not overridden, try to use clang-format-18 or clang-format. if [[ -z "$CLANG_FORMAT" ]]; then From 323a279ec5b2e91f26630830464fb45a3ad10564 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Fri, 12 Jul 2024 14:03:17 -0700 Subject: [PATCH 03/89] [CI] Enable bzlmod (#2995) --- .bazelrc | 3 --- MODULE.bazel | 4 ++-- ci/do_ci.ps1 | 4 ++-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.bazelrc b/.bazelrc index fc170b0e8b..f169347647 100644 --- a/.bazelrc +++ b/.bazelrc @@ -4,9 +4,6 @@ # bazel configurations for running tests under sanitizers. # Based on https://github.com/bazelment/trunk/blob/master/tools/bazel.rc -# TODO: Remove once support is added, avoid MODULE.bazel creation for now -common --enable_bzlmod=false - # Enable automatic configs based on platform common --enable_platform_specific_config diff --git a/MODULE.bazel b/MODULE.bazel index 7b84c2b719..4a03753e15 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -10,8 +10,8 @@ module( bazel_dep(name = "abseil-cpp", version = "20240116.1", repo_name = "com_google_absl") bazel_dep(name = "bazel_skylib", version = "1.5.0") -bazel_dep(name = "curl", version = "8.4.0") -bazel_dep(name = "grpc", version = "1.62.1", repo_name = "com_github_grpc_grpc") +bazel_dep(name = "curl", version = "8.8.0") +bazel_dep(name = "grpc", version = "1.63.1.bcr.1", repo_name = "com_github_grpc_grpc") bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "github_nlohmann_json") bazel_dep(name = "opentelemetry-proto", version = "1.3.1", repo_name = "com_github_opentelemetry_proto") bazel_dep(name = "opentracing-cpp", version = "1.6.0", repo_name = "com_github_opentracing") diff --git a/ci/do_ci.ps1 b/ci/do_ci.ps1 index 62e174854e..bcae6359bb 100644 --- a/ci/do_ci.ps1 +++ b/ci/do_ci.ps1 @@ -11,8 +11,8 @@ $nproc = (Get-ComputerInfo).CsNumberOfLogicalProcessors $SRC_DIR = (Get-Item -Path ".\").FullName # Workaround https://github.com/bazelbuild/bazel/issues/18683 -$BAZEL_STARTUP_OPTIONS = "--output_base=C:\Out" -$BAZEL_OPTIONS = "--copt=-DENABLE_ASYNC_EXPORT" +$BAZEL_STARTUP_OPTIONS = "--output_base=C:\O" +$BAZEL_OPTIONS = "--copt=-DENABLE_ASYNC_EXPORT --compilation_mode=dbg" $BAZEL_TEST_OPTIONS = "$BAZEL_OPTIONS --test_output=errors" if (!(test-path build)) { From d8ae09e53d6988a063364c86a8362053432a3f9f Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Wed, 17 Jul 2024 07:00:20 -0700 Subject: [PATCH 04/89] [Metrics SDK] Fix hash calculation for nostd::string (#2999) * add test to validate cardinaity limit * format * warning * Format * maint mode CI * modify test to reproduce the issue * Format * remove vscode settings * remove redundant test * remove unused code * fix to calculate hash on string_view * remove iostream * template specialization for const char *, and varous string type tests * unused variable warning * more warnings * format * fix use-after-stack-scope * format * another try * format --------- Co-authored-by: Tom Tan --- .../sdk/common/attributemap_hash.h | 11 ++- sdk/test/metrics/attributes_hashmap_test.cc | 76 ++++++++++++++++++- sdk/test/metrics/cardinality_limit_test.cc | 41 +++++++++- 3 files changed, 122 insertions(+), 6 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/common/attributemap_hash.h b/sdk/include/opentelemetry/sdk/common/attributemap_hash.h index 408070255a..e09b03d08b 100644 --- a/sdk/include/opentelemetry/sdk/common/attributemap_hash.h +++ b/sdk/include/opentelemetry/sdk/common/attributemap_hash.h @@ -35,6 +35,15 @@ inline void GetHash(size_t &seed, const std::vector &arg) } } +// Specialization for const char* +// this creates an intermediate string. +template <> +inline void GetHash(size_t &seed, const char *const &arg) +{ + std::hash hasher; + seed ^= hasher(std::string(arg)) + 0x9e3779b9 + (seed << 6) + (seed >> 2); +} + struct GetHashForAttributeValueVisitor { GetHashForAttributeValueVisitor(size_t &seed) : seed_(seed) {} @@ -71,7 +80,7 @@ inline size_t GetHashForAttributeMap( { return true; } - GetHash(seed, key.data()); + GetHash(seed, key); auto attr_val = nostd::visit(converter, value); nostd::visit(GetHashForAttributeValueVisitor(seed), attr_val); return true; diff --git a/sdk/test/metrics/attributes_hashmap_test.cc b/sdk/test/metrics/attributes_hashmap_test.cc index 7e03deed47..9ae8f5cfd5 100644 --- a/sdk/test/metrics/attributes_hashmap_test.cc +++ b/sdk/test/metrics/attributes_hashmap_test.cc @@ -13,7 +13,6 @@ namespace nostd = opentelemetry::nostd; TEST(AttributesHashMap, BasicTests) { - // Empty map AttributesHashMap hash_map; EXPECT_EQ(hash_map.Size(), 0); @@ -73,3 +72,78 @@ TEST(AttributesHashMap, BasicTests) }); EXPECT_EQ(count, hash_map.Size()); } + +std::string make_unique_string(const char *str) +{ + return std::string(str); +} + +TEST(AttributesHashMap, HashWithKeyValueIterable) +{ + std::string key1 = make_unique_string("k1"); + std::string value1 = make_unique_string("v1"); + std::string key2 = make_unique_string("k2"); + std::string value2 = make_unique_string("v2"); + std::string key3 = make_unique_string("k3"); + std::string value3 = make_unique_string("v3"); + + // Create mock KeyValueIterable instances with the same content but different variables + std::map attributes1({{key1, value1}, {key2, value2}}); + std::map attributes2({{key1, value1}, {key2, value2}}); + std::map attributes3({{key1, value1}, {key2, value2}, {key3, value3}}); + + // Create a callback that filters "k3" key + auto is_key_filter_k3_callback = [](nostd::string_view key) { + if (key == "k3") + { + return false; + } + return true; + }; + // Calculate hash + size_t hash1 = opentelemetry::sdk::common::GetHashForAttributeMap( + opentelemetry::common::KeyValueIterableView>(attributes1), + is_key_filter_k3_callback); + size_t hash2 = opentelemetry::sdk::common::GetHashForAttributeMap( + opentelemetry::common::KeyValueIterableView>(attributes2), + is_key_filter_k3_callback); + + size_t hash3 = opentelemetry::sdk::common::GetHashForAttributeMap( + opentelemetry::common::KeyValueIterableView>(attributes3), + is_key_filter_k3_callback); + + // Expect the hashes to be the same because the content is the same + EXPECT_EQ(hash1, hash2); + // Expect the hashes to be the same because the content is the same + EXPECT_EQ(hash1, hash3); +} + +TEST(AttributesHashMap, HashConsistencyAcrossStringTypes) +{ + const char *c_str = "teststring"; + std::string std_str = "teststring"; + nostd::string_view nostd_str_view = "teststring"; +#if __cplusplus >= 201703L + std::string_view std_str_view = "teststring"; +#endif + + size_t hash_c_str = 0; + size_t hash_std_str = 0; + size_t hash_nostd_str_view = 0; +#if __cplusplus >= 201703L + size_t hash_std_str_view = 0; +#endif + + opentelemetry::sdk::common::GetHash(hash_c_str, c_str); + opentelemetry::sdk::common::GetHash(hash_std_str, std_str); + opentelemetry::sdk::common::GetHash(hash_nostd_str_view, nostd_str_view); +#if __cplusplus >= 201703L + opentelemetry::sdk::common::GetHash(hash_std_str_view, std_str_view); +#endif + + EXPECT_EQ(hash_c_str, hash_std_str); + EXPECT_EQ(hash_c_str, hash_nostd_str_view); +#if __cplusplus >= 201703L + EXPECT_EQ(hash_c_str, hash_std_str_view); +#endif +} diff --git a/sdk/test/metrics/cardinality_limit_test.cc b/sdk/test/metrics/cardinality_limit_test.cc index 3f9483ac1c..cf94112f1a 100644 --- a/sdk/test/metrics/cardinality_limit_test.cc +++ b/sdk/test/metrics/cardinality_limit_test.cc @@ -47,14 +47,47 @@ TEST(CardinalityLimit, AttributesHashMapBasicTests) ->Aggregate(record_value); } EXPECT_EQ(hash_map.Size(), 10); // only one more metric point should be added as overflow. + // record 5 more measurements to already existing (and not-overflow) metric points. They + // should get aggregated to these existing metric points. + for (auto i = 0; i < 5; i++) + { + FilteredOrderedAttributeMap attributes = {{"key", std::to_string(i)}}; + auto hash = opentelemetry::sdk::common::GetHashForAttributeMap(attributes); + static_cast( + hash_map.GetOrSetDefault(attributes, aggregation_callback, hash)) + ->Aggregate(record_value); + } + EXPECT_EQ(hash_map.Size(), 10); // no new metric point added + // get the overflow metric point - auto agg = hash_map.GetOrSetDefault( + auto agg1 = hash_map.GetOrSetDefault( FilteredOrderedAttributeMap({{kAttributesLimitOverflowKey, kAttributesLimitOverflowValue}}), aggregation_callback, kOverflowAttributesHash); - EXPECT_NE(agg, nullptr); - auto sum_agg = static_cast(agg); - EXPECT_EQ(nostd::get(nostd::get(sum_agg->ToPoint()).value_), + EXPECT_NE(agg1, nullptr); + auto sum_agg1 = static_cast(agg1); + EXPECT_EQ(nostd::get(nostd::get(sum_agg1->ToPoint()).value_), record_value * 6); // 1 from previous 10, 5 from current 5. + // get remaining metric points + for (auto i = 0; i < 9; i++) + { + FilteredOrderedAttributeMap attributes = {{"key", std::to_string(i)}}; + auto hash = opentelemetry::sdk::common::GetHashForAttributeMap(attributes); + auto agg2 = hash_map.GetOrSetDefault( + FilteredOrderedAttributeMap({{kAttributesLimitOverflowKey, kAttributesLimitOverflowValue}}), + aggregation_callback, hash); + EXPECT_NE(agg2, nullptr); + auto sum_agg2 = static_cast(agg2); + if (i < 5) + { + EXPECT_EQ(nostd::get(nostd::get(sum_agg2->ToPoint()).value_), + record_value * 2); // 1 from first recording, 1 from third recording + } + else + { + EXPECT_EQ(nostd::get(nostd::get(sum_agg2->ToPoint()).value_), + record_value); // 1 from first recording + } + } } class WritableMetricStorageCardinalityLimitTestFixture From baecbb95bd63df53e0af16e87bc683967962c5f8 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Wed, 17 Jul 2024 22:04:10 +0200 Subject: [PATCH 05/89] [RELEASE] Release opentelemetry-cpp version 1.16.1 (#3007) --- CHANGELOG.md | 39 ++++++++++++++++++- api/include/opentelemetry/version.h | 4 +- docs/public/conf.py | 2 +- .../opentelemetry/sdk/version/version.h | 2 +- sdk/src/version/version.cc | 8 ++-- 5 files changed, 45 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92e234a77b..fad2b0cc78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,15 +15,50 @@ Increment the: ## [Unreleased] +## [1.16.1 2024-07-17] + +* [BUILD] Add bazel missing BUILD file + [#2720](https://github.com/open-telemetry/opentelemetry-cpp/pull/2720) + +* [SDK] Added reserve for spans array in BatchSpanProcessor. + [#2724](https://github.com/open-telemetry/opentelemetry-cpp/pull/2724) + +* [DOC] Update "Using triplets" section in building-with-vcpkg documentation. + [#2726](https://github.com/open-telemetry/opentelemetry-cpp/pull/2726) + +* [DOC] Remove comment for unused LoggerProvider initialization params + [#2972](https://github.com/open-telemetry/opentelemetry-cpp/pull/2972) + * [SECURITY] Remove OTLP HTTP support for TLS 1.0 and TLS 1.1, require TLS 1.2 or better - [#2721](https://github.com/open-telemetry/opentelemetry-cpp/pull/2721) + [#2722](https://github.com/open-telemetry/opentelemetry-cpp/pull/2722) + +* [TEST] Fix opentelemetry-collector bind address + [#2989](https://github.com/open-telemetry/opentelemetry-cpp/pull/2989) + +* [EXPORTER] Fix references in AttributeValueVisitor + [#2985](https://github.com/open-telemetry/opentelemetry-cpp/pull/2985) + +* [Code health] include-what-you-use cleanup, part 2 + [#2704](https://github.com/open-telemetry/opentelemetry-cpp/pull/2704) + +* [Code Health] clang-tidy cleanup, part 1 + [#2990](https://github.com/open-telemetry/opentelemetry-cpp/pull/2990) + +* [CI] Build failures with ABSEIL 20240116 and CMAKE 3.30 + [#3002](https://github.com/open-telemetry/opentelemetry-cpp/pull/3002) + +* [CI] Enable bzlmod + [#2995](https://github.com/open-telemetry/opentelemetry-cpp/pull/2995) + +* [Metrics SDK] Fix hash calculation for nostd::string + [#2999](https://github.com/open-telemetry/opentelemetry-cpp/pull/2999) Breaking changes: * [SECURITY] Remove OTLP HTTP support for TLS 1.0 and TLS 1.1, require TLS 1.2 or better - [#2721](https://github.com/open-telemetry/opentelemetry-cpp/pull/2721) + [#2722](https://github.com/open-telemetry/opentelemetry-cpp/pull/2722) * The OTLP HTTP exporter no longer accept options like: * min_TLS = 1.0 * min_TLS = 1.1 diff --git a/api/include/opentelemetry/version.h b/api/include/opentelemetry/version.h index e09c193659..d98ac978f2 100644 --- a/api/include/opentelemetry/version.h +++ b/api/include/opentelemetry/version.h @@ -10,10 +10,10 @@ # define OPENTELEMETRY_ABI_VERSION_NO 1 #endif -#define OPENTELEMETRY_VERSION "1.16.0" +#define OPENTELEMETRY_VERSION "1.16.1" #define OPENTELEMETRY_VERSION_MAJOR 1 #define OPENTELEMETRY_VERSION_MINOR 16 -#define OPENTELEMETRY_VERSION_PATCH 0 +#define OPENTELEMETRY_VERSION_PATCH 1 #define OPENTELEMETRY_ABI_VERSION OPENTELEMETRY_STRINGIFY(OPENTELEMETRY_ABI_VERSION_NO) diff --git a/docs/public/conf.py b/docs/public/conf.py index 927e07751a..96caa2b43a 100644 --- a/docs/public/conf.py +++ b/docs/public/conf.py @@ -24,7 +24,7 @@ author = 'OpenTelemetry authors' # The full version, including alpha/beta/rc tags -release = "1.16.0" +release = "1.16.1" # Run sphinx on subprojects and copy output # ----------------------------------------- diff --git a/sdk/include/opentelemetry/sdk/version/version.h b/sdk/include/opentelemetry/sdk/version/version.h index bfc93238b4..86b815e3bc 100644 --- a/sdk/include/opentelemetry/sdk/version/version.h +++ b/sdk/include/opentelemetry/sdk/version/version.h @@ -3,7 +3,7 @@ #pragma once -#define OPENTELEMETRY_SDK_VERSION "1.16.0" +#define OPENTELEMETRY_SDK_VERSION "1.16.1" #include "opentelemetry/version.h" diff --git a/sdk/src/version/version.cc b/sdk/src/version/version.cc index e5fdbda99d..80f2226400 100644 --- a/sdk/src/version/version.cc +++ b/sdk/src/version/version.cc @@ -13,12 +13,12 @@ namespace version { const int major_version = 1; const int minor_version = 16; -const int patch_version = 0; +const int patch_version = 1; const char *pre_release = "NONE"; const char *build_metadata = "NONE"; -const char *short_version = "1.16.0"; -const char *full_version = "1.16.0-NONE-NONE"; -const char *build_date = "Fri Jun 21 16:41:17 UTC 2024"; +const char *short_version = "1.16.1"; +const char *full_version = "1.16.1-NONE-NONE"; +const char *build_date = "Wed Jul 17 17:34:38 UTC 2024"; } // namespace version } // namespace sdk OPENTELEMETRY_END_NAMESPACE From aac2b775afa77840b91a37b4a959c9afae03a06b Mon Sep 17 00:00:00 2001 From: Siddhartha Malladi Date: Wed, 17 Jul 2024 17:19:41 -0400 Subject: [PATCH 06/89] [CI] Add a clang-tidy build (#3001) --- .clang-tidy | 48 ++++-------------- .github/workflows/clang-tidy.yaml | 84 +++++++++++++++++++++++++++++++ CHANGELOG.md | 3 ++ CMakeLists.txt | 6 +++ 4 files changed, 102 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/clang-tidy.yaml diff --git a/.clang-tidy b/.clang-tidy index 5abedb62fd..9a30fbef54 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -3,6 +3,8 @@ Checks: > -*, + performance-*, + portability-*, abseil-*, -abseil-string-find-str-contains, bugprone-*, @@ -13,7 +15,6 @@ Checks: > -bugprone-unchecked-optional-access, -bugprone-unhandled-exception-at-new, -bugprone-unused-local-non-trivial-variable, - -bugprone-unused-return-value, google-*, -google-build-using-namespace, -google-default-arguments, @@ -29,41 +30,10 @@ Checks: > -misc-non-private-member-variables-in-classes, -misc-unused-alias-decls, -misc-use-anonymous-namespace, - performance-*, - -performance-move-const-arg, - portability-* -# readability-*, -# -readability-convert-member-functions-to-static, -# -readability-else-after-return, -# -readability-function-cognitive-complexity, -# -readability-identifier-length, -# -readability-implicit-bool-conversion, -# -readability-isolate-declaration, -# -readability-magic-numbers, -# -readability-named-parameter, -# -readability-redundant-*, -# -readability-string-compare, -# cppcoreguidelines-*, -# -cppcoreguidelines-avoid-c-arrays, -# -cppcoreguidelines-avoid-magic-numbers, -# -cppcoreguidelines-init-variables, -# -cppcoreguidelines-macro-usage, -# -cppcoreguidelines-non-private-member-variables-in-classes, -# -cppcoreguidelines-pro-*, -# modernize-*, -# -modernize-use-default-member-init, -# -modernize-use-nodiscard, -# -modernize-use-trailing-return-type, -# -modernize-avoid-c-arrays, -# -modernize-use-using - -# Use existing clang-format for formatting the code -# FormatStyle: 'file' - -# TODO: include checks: readability, cppcoreguidelines, modernize , google-readability-namespace-comments, google-readability-avoid-underscore-in-googletest-name, performance-move-const-arg - - - - - - + cppcoreguidelines-*, + -cppcoreguidelines-avoid-c-arrays, + -cppcoreguidelines-avoid-magic-numbers, + -cppcoreguidelines-init-variables, + -cppcoreguidelines-macro-usage, + -cppcoreguidelines-non-private-member-variables-in-classes, + -cppcoreguidelines-pro-* \ No newline at end of file diff --git a/.github/workflows/clang-tidy.yaml b/.github/workflows/clang-tidy.yaml new file mode 100644 index 0000000000..9e5f6c26db --- /dev/null +++ b/.github/workflows/clang-tidy.yaml @@ -0,0 +1,84 @@ +name: clang-tidy + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + clang-tidy: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Setup Environment + env: + PROTOBUF_VERSION: '23.3' + ABSEIL_CPP_VERSION: '20230125.3' + CXX_STANDARD: '14' + run: | + sudo apt update -y + sudo apt install -y --no-install-recommends --no-install-suggests \ + build-essential \ + iwyu \ + cmake \ + libssl-dev \ + libcurl4-openssl-dev \ + libprotobuf-dev \ + protobuf-compiler \ + libgmock-dev \ + libgtest-dev \ + libbenchmark-dev + + if ! command -v clang-tidy &> /dev/null; then + echo "clang-tidy could not be found" + exit 1 + fi + echo "Using clang-tidy version: $(clang-tidy --version)" + echo "clang-tidy installed at: $(which clang-tidy)" + + + - name: Prepare CMake + env: + CC: clang + CXX: clang++ + run: | + mkdir -p build && cd build + echo "Running cmake..." + cmake .. \ + -DCMAKE_CXX_STANDARD=14 \ + -DWITH_STL=CXX14 \ + -DWITH_OTLP_HTTP=ON \ + -DWITH_OTLP_FILE=ON \ + -DWITH_PROMETHEUS=ON \ + -DWITH_ZIPKIN=ON \ + -DWITH_ELASTICSEARCH=ON \ + -DWITH_OTLP_HTTP_COMPRESSION=ON \ + -DWITH_EXAMPLES=ON \ + -DWITH_EXAMPLES_HTTP=ON \ + -DBUILD_W3CTRACECONTEXT_TEST=ON \ + -DWITH_METRICS_EXEMPLAR_PREVIEW=ON \ + -DWITH_ASYNC_EXPORT_PREVIEW=ON \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ + -DCMAKE_CXX_CLANG_TIDY="clang-tidy" + + - name: Run clang-tidy + run: | + cd build + make -j$(nproc) 2>&1 | tee -a clang-tidy.log || exit 1 + + - uses: actions/upload-artifact@v4 + with: + name: Logs (clang-tidy) + path: ./build/clang-tidy.log + + - name: Count warnings + run: | + cd build + COUNT=$(grep -c "warning:" clang-tidy.log) + echo "clang-tidy reported ${COUNT} warning(s)" + +# TODO: include WITH_OTLP_GRPC and WITH_ABSEIL flags. \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index fad2b0cc78..e7e13ec3d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,9 @@ Increment the: ## [Unreleased] +* [CI] Add a clang-tidy build + [#3001](https://github.com/open-telemetry/opentelemetry-cpp/pull/3001) + ## [1.16.1 2024-07-17] * [BUILD] Add bazel missing BUILD file diff --git a/CMakeLists.txt b/CMakeLists.txt index 711ac14c4c..44ddd05e1c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -364,9 +364,12 @@ if(WITH_PROMETHEUS) message(STATUS "Trying to use local prometheus-cpp from submodule") if(EXISTS ${PROJECT_SOURCE_DIR}/third_party/prometheus-cpp/.git) set(SAVED_ENABLE_TESTING ${ENABLE_TESTING}) + set(SAVED_CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY}) set(ENABLE_TESTING OFF) + set(CMAKE_CXX_CLANG_TIDY "") add_subdirectory(third_party/prometheus-cpp) set(ENABLE_TESTING ${SAVED_ENABLE_TESTING}) + set(CMAKE_CXX_CLANG_TIDY ${SAVED_CMAKE_CXX_CLANG_TIDY}) else() message( FATAL_ERROR @@ -444,7 +447,10 @@ if(WITH_OTLP_GRPC include(CMakeDependentOption) message(STATUS "PROTOBUF_PROTOC_EXECUTABLE=${PROTOBUF_PROTOC_EXECUTABLE}") + set(SAVED_CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY}) + set(CMAKE_CXX_CLANG_TIDY "") include(cmake/opentelemetry-proto.cmake) + set(CMAKE_CXX_CLANG_TIDY ${SAVED_CMAKE_CXX_CLANG_TIDY}) endif() # From 0a43c1f2b16e2636e7c768c88957c4f0e4d3f8ce Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Thu, 18 Jul 2024 00:48:26 +0200 Subject: [PATCH 07/89] [BUILD] Upgrade to opentelemetry-proto 1.3.2 (#2991) --- MODULE.bazel | 2 +- bazel/repository.bzl | 6 +- cmake/opentelemetry-proto.cmake | 2 +- docs/maintaining-dependencies.md | 321 +++++++++++++++++++++++++++++++ third_party/opentelemetry-proto | 2 +- third_party_release | 2 +- 6 files changed, 328 insertions(+), 7 deletions(-) create mode 100644 docs/maintaining-dependencies.md diff --git a/MODULE.bazel b/MODULE.bazel index 4a03753e15..311d4cbc16 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -13,7 +13,7 @@ bazel_dep(name = "bazel_skylib", version = "1.5.0") bazel_dep(name = "curl", version = "8.8.0") bazel_dep(name = "grpc", version = "1.63.1.bcr.1", repo_name = "com_github_grpc_grpc") bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "github_nlohmann_json") -bazel_dep(name = "opentelemetry-proto", version = "1.3.1", repo_name = "com_github_opentelemetry_proto") +bazel_dep(name = "opentelemetry-proto", version = "1.3.2", repo_name = "com_github_opentelemetry_proto") bazel_dep(name = "opentracing-cpp", version = "1.6.0", repo_name = "com_github_opentracing") bazel_dep(name = "platforms", version = "0.0.8") bazel_dep(name = "prometheus-cpp", version = "1.2.4", repo_name = "com_github_jupp0r_prometheus_cpp") diff --git a/bazel/repository.bzl b/bazel/repository.bzl index bac1e45b34..508b95a39a 100644 --- a/bazel/repository.bzl +++ b/bazel/repository.bzl @@ -88,10 +88,10 @@ def opentelemetry_cpp_deps(): http_archive, name = "com_github_opentelemetry_proto", build_file = "@io_opentelemetry_cpp//bazel:opentelemetry_proto.BUILD", - sha256 = "bed250ceec8e4a83aa5604d7d5595a61945059dc662edd058a9da082283f7a00", - strip_prefix = "opentelemetry-proto-1.3.1", + sha256 = "c069c0d96137cf005d34411fa67dd3b6f1f8c64af1e7fb2fe0089a41c425acd7", + strip_prefix = "opentelemetry-proto-1.3.2", urls = [ - "https://github.com/open-telemetry/opentelemetry-proto/archive/v1.3.1.tar.gz", + "https://github.com/open-telemetry/opentelemetry-proto/archive/v1.3.2.tar.gz", ], ) diff --git a/cmake/opentelemetry-proto.cmake b/cmake/opentelemetry-proto.cmake index 62197068e2..498a7e5681 100644 --- a/cmake/opentelemetry-proto.cmake +++ b/cmake/opentelemetry-proto.cmake @@ -49,7 +49,7 @@ else() "opentelemetry-proto=[ \\t]*([A-Za-z0-9_\\.\\-]+)") set(opentelemetry-proto "${CMAKE_MATCH_1}") else() - set(opentelemetry-proto "v1.3.1") + set(opentelemetry-proto "v1.3.2") endif() unset(OTELCPP_THIRD_PARTY_RELEASE_CONTENT) endif() diff --git a/docs/maintaining-dependencies.md b/docs/maintaining-dependencies.md new file mode 100644 index 0000000000..a1969785d8 --- /dev/null +++ b/docs/maintaining-dependencies.md @@ -0,0 +1,321 @@ + +# Maintaining dependencies + +In general, several places in the code base need to be adjusted when +upgrading a dependency to a new version. + +This documentation contains notes about which place to fix, +to make maintenance easier and less error prone. + +This doc is only useful when up to date, +so make sure to add details about missing parts if any. + +Also, another good place to start when upgrading something to N+1 +is to find the commit that upgraded to version N (use `git blame`), +and inspect the commit for the last upgrade. + +## opentelemetry-proto + +### Comments + +Unlike other opentelemetry SIGs, opentelemetry-cpp generates code +from opentelemetry-proto as part of the opentelemetry-cpp build. + +Only the source code of opentelemetry-proto is required, +which is why this repository is used as a git submodule under third_party. + +Code is generated by the protobuf compiler during the build, +so that generated code is never checked in. + +This allows more flexibility, should the compiler (protobuf) be +upgraded even when the source code (opentelemetry-proto) is unchanged. + +### Origin + +The repository for opentelemetry-proto is: + +* [repository](https://github.com/open-telemetry/opentelemetry-proto) + +Check release notes at: + +* [release-notes](https://github.com/open-telemetry/opentelemetry-proto/releases) + +### Upgrade + +When upgrading opentelemetry-proto to a newer release, +a few places in the code need adjustment. + +In this example, we upgrade from 1.3.1 to 1.3.2 + +#### directory third_party/opentelemetry-proto + +This is a `git submodule`, it needs to point to the new tag. + +```shell +cd third_party/opentelemetry-proto +git log -1 +``` + +The current submodule show something like: + +```shell +commit b3060d2104df364136d75a35779e6bd48bac449a (HEAD, tag: v1.3.1) +Author: Damien Mathieu <42@dmathieu.com> +Date: Thu Apr 25 17:55:35 2024 +0200 + + generate profiles proto for CI (#552) +``` + +Pull new tags: + +```shell +git pull --tag origin +``` + +Upgrade to a new tag: + +```shell +git pull origin v1.3.2 +``` + +Check the new state: + +```shell +git log -1 +``` + +```shell +commit 40b3c1b746767cbc13c2e39da3eaf1a23e54ffdd (HEAD, tag: v1.3.2) +Author: jack-berg <34418638+jack-berg@users.noreply.github.com> +Date: Fri Jun 28 08:19:11 2024 -0500 + + Prepare changelog for 1.3.2 release (#563) + + Co-authored-by: Armin Ruech <7052238+arminru@users.noreply.github.com> +``` + +Go back to the root of opentelemetry-cpp + +```shell +cd ../.. +git status +``` + +```shell +On branch upgrade_proto_1.3.2 +Changes not staged for commit: + (use "git add ..." to update what will be committed) + (use "git restore ..." to discard changes in working directory) + modified: third_party/opentelemetry-proto (new commits) +``` + +Add the upgraded submodule: + +```shell +git add third_party/opentelemetry-proto +``` + +#### file third_party_release + +Update the line pointing to the opentelemetry-proto tag. + +```text +opentelemetry-proto=v1.3.2 +``` + +Typical change: + +```shell +[malff@malff-desktop opentelemetry-cpp]$ git diff third_party_release +diff --git a/third_party_release b/third_party_release +index 0bbf67f3..7362473f 100644 +--- a/third_party_release ++++ b/third_party_release +@@ -19,7 +19,7 @@ benchmark=v1.8.3 + googletest=1.14.0 + ms-gsl=v3.1.0-67-g6f45293 + nlohmann-json=v3.11.3 +-opentelemetry-proto=v1.3.1 ++opentelemetry-proto=v1.3.2 + opentracing-cpp=v1.6.0 + prometheus-cpp=v1.2.4 + vcpkg=2024.02.14 +``` + +#### file bazel/repository.bzl + +Locate the entry for opentelemetry-proto: + +```text + # OTLP Protocol definition + maybe( + http_archive, + name = "com_github_opentelemetry_proto", + build_file = "@io_opentelemetry_cpp//bazel:opentelemetry_proto.BUILD", + sha256 = "bed250ceec8e4a83aa5604d7d5595a61945059dc662edd058a9da082283f7a00", + strip_prefix = "opentelemetry-proto-1.3.1", + urls = [ + "https://github.com/open-telemetry/opentelemetry-proto/archive/v1.3.1.tar.gz", + ], + ) +``` + +Update the URL to the new tag: + +```text + urls = [ + "https://github.com/open-telemetry/opentelemetry-proto/archive/v1.3.2.tar.gz", + ], +``` + +Update strip_prefix to the new tag: + +```text + strip_prefix = "opentelemetry-proto-1.3.2", +``` + +Download the new URL: + +```shell +wget https://github.com/open-telemetry/opentelemetry-proto/archive/v1.3.2.tar.gz +``` + +Run a checksum on the new file: + +```shell +sha256sum v1.3.2.tar.gz +``` + +```shell +c069c0d96137cf005d34411fa67dd3b6f1f8c64af1e7fb2fe0089a41c425acd7 v1.3.2.tar.gz +``` + +Update the checksum in file bazel/repository.bzl: + +```text + sha256 = "c069c0d96137cf005d34411fa67dd3b6f1f8c64af1e7fb2fe0089a41c425acd7", +``` + +Typical change: + +```shell +[malff@malff-desktop opentelemetry-cpp]$ git diff bazel/repository.bzl +diff --git a/bazel/repository.bzl b/bazel/repository.bzl +index bac1e45b..508b95a3 100644 +--- a/bazel/repository.bzl ++++ b/bazel/repository.bzl +@@ -88,10 +88,10 @@ def opentelemetry_cpp_deps(): + http_archive, + name = "com_github_opentelemetry_proto", + build_file = "@io_opentelemetry_cpp//bazel:opentelemetry_proto.BUILD", +- sha256 = "bed250ceec8e4a83aa5604d7d5595a61945059dc662edd058a9da082283f7a00", +- strip_prefix = "opentelemetry-proto-1.3.1", ++ sha256 = "c069c0d96137cf005d34411fa67dd3b6f1f8c64af1e7fb2fe0089a41c425acd7", ++ strip_prefix = "opentelemetry-proto-1.3.2", + urls = [ +- "https://github.com/open-telemetry/opentelemetry-proto/archive/v1.3.1.tar.gz", ++ "https://github.com/open-telemetry/opentelemetry-proto/archive/v1.3.2.tar.gz", + ], + ) +``` + +#### file cmake/opentelemetry-proto.cmake + +Update the tag in the CMake logic: + +```cmake + set(opentelemetry-proto "v1.3.2") +``` + +Typical change: + +```shell +[malff@malff-desktop opentelemetry-cpp]$ git diff cmake/opentelemetry-proto.cmake +diff --git a/cmake/opentelemetry-proto.cmake b/cmake/opentelemetry-proto.cmake +index 19516c3b..dd6213c1 100644 +--- a/cmake/opentelemetry-proto.cmake ++++ b/cmake/opentelemetry-proto.cmake +@@ -49,7 +49,7 @@ else() + "opentelemetry-proto=[ \\t]*([A-Za-z0-9_\\.\\-]+)") + set(opentelemetry-proto "${CMAKE_MATCH_1}") + else() +- set(opentelemetry-proto "v1.3.1") ++ set(opentelemetry-proto "v1.3.2") + endif() + unset(OTELCPP_THIRD_PARTY_RELEASE_CONTENT) + endif() +``` + +If opentelemetry-proto contains new files, +the makefile needs to be adjusted to build the new code. + +Depending on the actual changes in the opentelemetry-proto files, +the C++ code in opentelemetry-cpp may need adjustments. + +Typically, when opentelemetry-proto: + +* defines a new message (for example, for profiling) +* adds new optional fields to an existing message (for example, trace flags) + +the existing C++ code should work as is with the new opentelemetry-proto +format. + +In this case, it is better to: + +* upgrade the opentelemetry-proto version independently with one PR. +* upgrade the C++ code later (to use the new message, of provide new fields) + in a different PR. + +When the C++ code requires a newer minimum version of opentelemetry-proto, +make sure to document this, including in the release notes. + +#### file MODULE.bazel + +Make sure the new tag is available in bazel central: + +* [bazel-central](https://registry.bazel.build/modules/opentelemetry-proto) + +If missing, file a PR to add it, or contact the maintainer: + +* [repository](https://github.com/bazelbuild/bazel-central-registry/tree/main/modules/opentelemetry-proto) + +Update the opentelemetry-proto version to the new tag: + +```text +bazel_dep(name = "opentelemetry-proto", version = "1.3.2", repo_name = "com_github_opentelemetry_proto") +``` + +File `MODULE.bazel` is used in the github CI for repository +opentelemetry-cpp, so using a tag that does not exist (yet) in bazel central +will break the CI build. + +See the known issues section. + +Typical change: + +```shell +[malff@malff-desktop opentelemetry-cpp]$ git diff MODULE.bazel +diff --git a/MODULE.bazel b/MODULE.bazel +index 7b84c2b7..3161ffb1 100644 +--- a/MODULE.bazel ++++ b/MODULE.bazel +@@ -13,7 +13,7 @@ bazel_dep(name = "bazel_skylib", version = "1.5.0") + bazel_dep(name = "curl", version = "8.4.0") + bazel_dep(name = "grpc", version = "1.62.1", repo_name = "com_github_grpc_grpc") + bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "github_nlohmann_json") +-bazel_dep(name = "opentelemetry-proto", version = "1.3.1", repo_name = "com_github_opentelemetry_proto") ++bazel_dep(name = "opentelemetry-proto", version = "1.3.2", repo_name = "com_github_opentelemetry_proto") + bazel_dep(name = "opentracing-cpp", version = "1.6.0", repo_name = "com_github_opentracing") + bazel_dep(name = "platforms", version = "0.0.8") + bazel_dep(name = "prometheus-cpp", version = "1.2.4", repo_name = "com_github_jupp0r_prometheus_cpp") +``` + +### Known issues + +For bazel, two different methods to build exists. + +First, the code can build using file `bazel/repository.bzl`. +This option does not depend on bazel central. + +Secondly, there is also a build using modules, with file `MODULE.bazel`. +This option does depend on bazel central, and CI depends on it. diff --git a/third_party/opentelemetry-proto b/third_party/opentelemetry-proto index b3060d2104..40b3c1b746 160000 --- a/third_party/opentelemetry-proto +++ b/third_party/opentelemetry-proto @@ -1 +1 @@ -Subproject commit b3060d2104df364136d75a35779e6bd48bac449a +Subproject commit 40b3c1b746767cbc13c2e39da3eaf1a23e54ffdd diff --git a/third_party_release b/third_party_release index 0bbf67f3af..7362473f60 100644 --- a/third_party_release +++ b/third_party_release @@ -19,7 +19,7 @@ benchmark=v1.8.3 googletest=1.14.0 ms-gsl=v3.1.0-67-g6f45293 nlohmann-json=v3.11.3 -opentelemetry-proto=v1.3.1 +opentelemetry-proto=v1.3.2 opentracing-cpp=v1.6.0 prometheus-cpp=v1.2.4 vcpkg=2024.02.14 From 611906eeafdbfe4a92fd1f81989692a222da1a78 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Thu, 18 Jul 2024 01:27:46 +0200 Subject: [PATCH 08/89] [REMOVAL] Remove build option `WITH_DEPRECATED_SDK_FACTORY` (#2717) --- .github/workflows/iwyu.yml | 1 - CHANGELOG.md | 38 ++++++++ CMakeLists.txt | 19 ---- DEPRECATED.md | 80 +---------------- api/CMakeLists.txt | 5 -- ci/do_ci.ps1 | 2 - ci/do_ci.sh | 4 - examples/logs_simple/main.cc | 10 --- examples/metrics_simple/metrics_ostream.cc | 9 -- examples/otlp/file_log_main.cc | 13 --- examples/otlp/file_main.cc | 8 -- examples/otlp/grpc_log_main.cc | 13 --- examples/otlp/grpc_main.cc | 8 -- examples/otlp/http_log_main.cc | 16 ---- examples/otlp/http_main.cc | 8 -- examples/simple/main.cc | 5 -- .../otlp_grpc_log_record_exporter_test.cc | 7 -- .../sdk/logs/event_logger_provider_factory.h | 9 -- .../sdk/logs/logger_provider_factory.h | 32 ------- .../sdk/metrics/meter_provider_factory.h | 26 ------ .../sdk/trace/tracer_provider_factory.h | 64 -------------- sdk/src/logs/event_logger_provider_factory.cc | 11 --- sdk/src/logs/logger_provider_factory.cc | 46 ---------- sdk/src/metrics/meter_provider_factory.cc | 36 -------- sdk/src/trace/tracer_provider_factory.cc | 86 ------------------- 25 files changed, 39 insertions(+), 517 deletions(-) diff --git a/.github/workflows/iwyu.yml b/.github/workflows/iwyu.yml index 598f57e97e..2c84b84cdc 100644 --- a/.github/workflows/iwyu.yml +++ b/.github/workflows/iwyu.yml @@ -40,7 +40,6 @@ jobs: -DWITH_STL=CXX14 \ -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE="include-what-you-use;-w;-Xiwyu;--mapping_file=${TOPDIR}/.iwyu.imp;" \ -DBUILD_TESTING=OFF \ - -DWITH_DEPRECATED_SDK_FACTORY=OFF \ -DBUILD_W3CTRACECONTEXT_TEST=OFF \ -DWITH_OTLP_GRPC=OFF \ -DWITH_OTLP_HTTP=ON \ diff --git a/CHANGELOG.md b/CHANGELOG.md index e7e13ec3d6..bce84c84df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,44 @@ Increment the: * [CI] Add a clang-tidy build [#3001](https://github.com/open-telemetry/opentelemetry-cpp/pull/3001) +* [REMOVAL] Remove build option `WITH_DEPRECATED_SDK_FACTORY` + [#2717](https://github.com/open-telemetry/opentelemetry-cpp/pull/2717) + +Breaking changes: + +* [REMOVAL] Remove build option `WITH_DEPRECATED_SDK_FACTORY` + [#2717](https://github.com/open-telemetry/opentelemetry-cpp/pull/2717) + + * As announced in opentelemetry-cpp previous release 1.16.0, + CMake option `WITH_DEPRECATED_SDK_FACTORY` was temporary, + and to be removed by the next release. + * This option is now removed. + * Code configuring the SDK must be adjusted, as previously described: + + * [API/SDK] Provider cleanup + [#2664](https://github.com/open-telemetry/opentelemetry-cpp/pull/2664) + + * Before this fix: + * SDK factory methods such as: + * opentelemetry::sdk::trace::TracerProviderFactory::Create() + * opentelemetry::sdk::metrics::MeterProviderFactory::Create() + * opentelemetry::sdk::logs::LoggerProviderFactory::Create() + * opentelemetry::sdk::logs::EventLoggerProviderFactory::Create() + + returned an API object (opentelemetry::trace::TracerProvider) + to the caller. + + * After this fix, these methods return an SDK level object + (opentelemetry::sdk::trace::TracerProvider) to the caller. + * Returning an SDK object is necessary for the application to + cleanup and invoke SDK level methods, such as ForceFlush(), + on a provider. + * The application code that configures the SDK, by calling + the various provider factories, may need adjustment. + * All the examples have been updated, and in particular no + longer perform static_cast do convert an API object to an SDK object. + Please refer to examples for guidance on how to adjust. + ## [1.16.1 2024-07-17] * [BUILD] Add bazel missing BUILD file diff --git a/CMakeLists.txt b/CMakeLists.txt index 44ddd05e1c..d10e831297 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -159,14 +159,6 @@ message(STATUS "OPENTELEMETRY_VERSION=${OPENTELEMETRY_VERSION}") option(WITH_NO_DEPRECATED_CODE "Do not include deprecated code" OFF) -# This option is temporary, and will be removed. Set -# WITH_DEPRECATED_SDK_FACTORY=OFF to migrate to the new SDK code. -option(WITH_DEPRECATED_SDK_FACTORY "Use deprecated SDK provider factory" ON) - -if(WITH_DEPRECATED_SDK_FACTORY) - message(WARNING "WITH_DEPRECATED_SDK_FACTORY=ON is temporary and deprecated") -endif() - set(WITH_STL "OFF" CACHE STRING "Which version of the Standard Library for C++ to use") @@ -204,13 +196,6 @@ if(NOT WITH_STL STREQUAL "OFF") endif() endif() -if(DEFINED WITH_OTLP) - message( - FATAL_ERROR - "WITH_OTLP is deprecated. Please set either WITH_OTLP_GRPC=ON, WITH_OTLP_HTTP=ON, or both to ON." - ) -endif() - option(WITH_OTLP_GRPC_SSL_MTLS_PREVIEW "Whether to enable mTLS support fro gRPC" OFF) @@ -294,10 +279,6 @@ option( option(WITH_FUNC_TESTS "Whether to build functional tests" ON) -if(DEFINED WITH_LOGS_PREVIEW) - message(WARNING "WITH_LOGS_PREVIEW is removed because logs signal is stable") -endif() - option(WITH_ASYNC_EXPORT_PREVIEW "Whether to enable async export" OFF) # Exemplar specs status is experimental, so behind feature flag by default diff --git a/DEPRECATED.md b/DEPRECATED.md index 7db5ba9d93..0632f50503 100644 --- a/DEPRECATED.md +++ b/DEPRECATED.md @@ -88,85 +88,7 @@ No date set yet for the Jaeger Propagator. ## [opentelemetry-cpp SDK] -### SDK ProviderFactory cleanup - -#### Announcement (SDK ProviderFactory cleanup) - -* Version: 1.15.0 -* Date: 2024-06-03 -* PR: [API/SDK] Provider cleanup - [#2664](https://github.com/open-telemetry/opentelemetry-cpp/pull/2664) - -This PR introduces changes to SDK ProviderFactory methods. - -#### Motivation (SDK ProviderFactory cleanup) - -SDK Factory methods for signal providers, such as: - -* opentelemetry::sdk::trace::TracerProviderFactory -* opentelemetry::sdk::metrics::MeterProviderFactory -* opentelemetry::sdk::logs::LoggerProviderFactory -* opentelemetry::sdk::logs::EventLoggerProviderFactory - -currently returns a unique pointer on a API class. - -This is incorrect, the proper return type should be -a unique pointer on a SDK class instead. - -#### Scope (SDK ProviderFactory cleanup) - -All the current Create methods in: - -* class opentelemetry::sdk::trace::TracerProviderFactory -* class opentelemetry::sdk::metrics::MeterProviderFactory -* class opentelemetry::sdk::logs::LoggerProviderFactory -* class opentelemetry::sdk::logs::EventLoggerProviderFactory - -are marked as deprecated, as they return an API object. - -Instead, another set of Create methods is provided, -with a different return type, an SDK object. - -Both sets can not be exposed at the same time, -as this would cause build breaks, -so a compilation flag is defined to select which methods to use. - -When OPENTELEMETRY_DEPRECATED_SDK_FACTORY is defined, -the old, deprecated, methods are available. - -When OPENTELEMETRY_DEPRECATED_SDK_FACTORY is not defined, -the new methods are available. - -The scope of this deprecation and removal, -is to remove the flag OPENTELEMETRY_DEPRECATED_SDK_FACTORY itself, -which implies that only the new set of Create() methods, -returning an SDK object, are supported. - -#### Mitigation (SDK ProviderFactory cleanup) - -Build without defining flag OPENTELEMETRY_DEPRECATED_SDK_FACTORY. - -Existing code, such as: - -```cpp - std::shared_ptr tracer_provider; - tracer_provider = opentelemetry::sdk::trace::TracerProviderFactory::Create(...); -``` - -should be adjusted to: - -```cpp - std::shared_ptr tracer_provider; - tracer_provider = opentelemetry::sdk::trace::TracerProviderFactory::Create(...); -``` - -#### Planned removal (SDK ProviderFactory cleanup) - -Flag OPENTELEMETRY_DEPRECATED_SDK_FACTORY is introduced in release 1.16.0, -to provide a migration path. - -This flag is meant to be temporary, and short lived. -Expect removal by release 1.17.0 +N/A ## [opentelemetry-cpp Exporter] diff --git a/api/CMakeLists.txt b/api/CMakeLists.txt index e07275efed..78e97ad029 100644 --- a/api/CMakeLists.txt +++ b/api/CMakeLists.txt @@ -35,11 +35,6 @@ if(WITH_NO_DEPRECATED_CODE) INTERFACE OPENTELEMETRY_NO_DEPRECATED_CODE) endif() -if(WITH_DEPRECATED_SDK_FACTORY) - target_compile_definitions(opentelemetry_api - INTERFACE OPENTELEMETRY_DEPRECATED_SDK_FACTORY) -endif() - if(WITH_ABSEIL) target_compile_definitions(opentelemetry_api INTERFACE HAVE_ABSEIL) target_link_libraries( diff --git a/ci/do_ci.ps1 b/ci/do_ci.ps1 index bcae6359bb..e9c1f64646 100644 --- a/ci/do_ci.ps1 +++ b/ci/do_ci.ps1 @@ -135,7 +135,6 @@ switch ($action) { cmake $SRC_DIR ` -DOTELCPP_MAINTAINER_MODE=ON ` -DWITH_NO_DEPRECATED_CODE=ON ` - -DWITH_DEPRECATED_SDK_FACTORY=OFF ` -DVCPKG_TARGET_TRIPLET=x64-windows ` "-DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR/scripts/buildsystems/vcpkg.cmake" $exit = $LASTEXITCODE @@ -160,7 +159,6 @@ switch ($action) { -DCMAKE_CXX_STANDARD=20 ` -DOTELCPP_MAINTAINER_MODE=ON ` -DWITH_NO_DEPRECATED_CODE=ON ` - -DWITH_DEPRECATED_SDK_FACTORY=OFF ` -DVCPKG_TARGET_TRIPLET=x64-windows ` "-DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR/scripts/buildsystems/vcpkg.cmake" $exit = $LASTEXITCODE diff --git a/ci/do_ci.sh b/ci/do_ci.sh index efdac9e87e..6d339c8d4e 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -130,7 +130,6 @@ elif [[ "$1" == "cmake.maintainer.sync.test" ]]; then -DWITH_ASYNC_EXPORT_PREVIEW=OFF \ -DOTELCPP_MAINTAINER_MODE=ON \ -DWITH_NO_DEPRECATED_CODE=ON \ - -DWITH_DEPRECATED_SDK_FACTORY=OFF \ -DWITH_OTLP_HTTP_COMPRESSION=ON \ ${IWYU} \ "${SRC_DIR}" @@ -153,7 +152,6 @@ elif [[ "$1" == "cmake.maintainer.async.test" ]]; then -DWITH_ASYNC_EXPORT_PREVIEW=ON \ -DOTELCPP_MAINTAINER_MODE=ON \ -DWITH_NO_DEPRECATED_CODE=ON \ - -DWITH_DEPRECATED_SDK_FACTORY=OFF \ -DWITH_OTLP_HTTP_COMPRESSION=ON \ ${IWYU} \ "${SRC_DIR}" @@ -177,7 +175,6 @@ elif [[ "$1" == "cmake.maintainer.cpp11.async.test" ]]; then -DWITH_ASYNC_EXPORT_PREVIEW=ON \ -DOTELCPP_MAINTAINER_MODE=ON \ -DWITH_NO_DEPRECATED_CODE=ON \ - -DWITH_DEPRECATED_SDK_FACTORY=OFF \ -DWITH_OTLP_HTTP_COMPRESSION=ON \ "${SRC_DIR}" make -k -j $(nproc) @@ -199,7 +196,6 @@ elif [[ "$1" == "cmake.maintainer.abiv2.test" ]]; then -DWITH_ASYNC_EXPORT_PREVIEW=OFF \ -DOTELCPP_MAINTAINER_MODE=ON \ -DWITH_NO_DEPRECATED_CODE=ON \ - -DWITH_DEPRECATED_SDK_FACTORY=OFF \ -DWITH_ABI_VERSION_1=OFF \ -DWITH_ABI_VERSION_2=ON \ -DWITH_OTLP_HTTP_COMPRESSION=ON \ diff --git a/examples/logs_simple/main.cc b/examples/logs_simple/main.cc index 444775dc59..3d7dfb8831 100644 --- a/examples/logs_simple/main.cc +++ b/examples/logs_simple/main.cc @@ -44,13 +44,8 @@ void InitTracer() auto exporter = trace_exporter::OStreamSpanExporterFactory::Create(); auto processor = trace_sdk::SimpleSpanProcessorFactory::Create(std::move(exporter)); -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - std::shared_ptr provider = - opentelemetry::sdk::trace::TracerProviderFactory::Create(std::move(processor)); -#else std::shared_ptr provider = opentelemetry::sdk::trace::TracerProviderFactory::Create(std::move(processor)); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ // Set the global trace provider const std::shared_ptr &api_provider = provider; @@ -70,13 +65,8 @@ void InitLogger() std::unique_ptr(new logs_exporter::OStreamLogRecordExporter); auto processor = logs_sdk::SimpleLogRecordProcessorFactory::Create(std::move(exporter)); -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - std::shared_ptr provider( - opentelemetry::sdk::logs::LoggerProviderFactory::Create(std::move(processor))); -#else std::shared_ptr provider( opentelemetry::sdk::logs::LoggerProviderFactory::Create(std::move(processor))); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ // Set the global logger provider const std::shared_ptr &api_provider = provider; diff --git a/examples/metrics_simple/metrics_ostream.cc b/examples/metrics_simple/metrics_ostream.cc index 5871b5e6a3..5bdc7339eb 100644 --- a/examples/metrics_simple/metrics_ostream.cc +++ b/examples/metrics_simple/metrics_ostream.cc @@ -57,12 +57,7 @@ void InitMetrics(const std::string &name) auto reader = metrics_sdk::PeriodicExportingMetricReaderFactory::Create(std::move(exporter), options); -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - auto u_provider = opentelemetry::sdk::metrics::MeterProviderFactory::Create(); - auto *provider = static_cast(u_provider.get()); -#else auto provider = opentelemetry::sdk::metrics::MeterProviderFactory::Create(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ provider->AddMetricReader(std::move(reader)); @@ -118,11 +113,7 @@ void InitMetrics(const std::string &name) provider->AddView(std::move(histogram_instrument_selector), std::move(histogram_meter_selector), std::move(histogram_view)); -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - std::shared_ptr api_provider(std::move(u_provider)); -#else std::shared_ptr api_provider(std::move(provider)); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ metrics_api::Provider::SetMeterProvider(api_provider); } diff --git a/examples/otlp/file_log_main.cc b/examples/otlp/file_log_main.cc index 30eb71cc2b..3cd59f7240 100644 --- a/examples/otlp/file_log_main.cc +++ b/examples/otlp/file_log_main.cc @@ -46,13 +46,8 @@ namespace opentelemetry::exporter::otlp::OtlpFileExporterOptions opts; opentelemetry::exporter::otlp::OtlpFileLogRecordExporterOptions log_opts; -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY -std::shared_ptr tracer_provider; -std::shared_ptr logger_provider; -#else std::shared_ptr tracer_provider; std::shared_ptr logger_provider; -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ void InitTracer() { @@ -71,11 +66,7 @@ void CleanupTracer() // We call ForceFlush to prevent to cancel running exportings, It's optional. if (tracer_provider) { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - static_cast(tracer_provider.get())->ForceFlush(); -#else tracer_provider->ForceFlush(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } tracer_provider.reset(); @@ -99,11 +90,7 @@ void CleanupLogger() // We call ForceFlush to prevent to cancel running exportings, It's optional. if (logger_provider) { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - static_cast(logger_provider.get())->ForceFlush(); -#else logger_provider->ForceFlush(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } logger_provider.reset(); diff --git a/examples/otlp/file_main.cc b/examples/otlp/file_main.cc index 243ad44428..377662aee4 100644 --- a/examples/otlp/file_main.cc +++ b/examples/otlp/file_main.cc @@ -31,11 +31,7 @@ namespace { opentelemetry::exporter::otlp::OtlpFileExporterOptions opts; -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY -std::shared_ptr provider; -#else std::shared_ptr provider; -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ void InitTracer() { @@ -54,11 +50,7 @@ void CleanupTracer() // We call ForceFlush to prevent to cancel running exportings, It's optional. if (provider) { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - static_cast(provider.get())->ForceFlush(); -#else provider->ForceFlush(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } provider.reset(); diff --git a/examples/otlp/grpc_log_main.cc b/examples/otlp/grpc_log_main.cc index 24037f6190..c7aca2ea31 100644 --- a/examples/otlp/grpc_log_main.cc +++ b/examples/otlp/grpc_log_main.cc @@ -38,13 +38,8 @@ namespace opentelemetry::exporter::otlp::OtlpGrpcExporterOptions opts; opentelemetry::exporter::otlp::OtlpGrpcLogRecordExporterOptions log_opts; -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY -std::shared_ptr tracer_provider; -std::shared_ptr logger_provider; -#else std::shared_ptr tracer_provider; std::shared_ptr logger_provider; -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ void InitTracer() { @@ -63,11 +58,7 @@ void CleanupTracer() // We call ForceFlush to prevent to cancel running exportings, It's optional. if (tracer_provider) { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - static_cast(tracer_provider.get())->ForceFlush(); -#else tracer_provider->ForceFlush(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } tracer_provider.reset(); @@ -92,11 +83,7 @@ void CleanupLogger() // We call ForceFlush to prevent to cancel running exportings, It's optional. if (logger_provider) { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - static_cast(logger_provider.get())->ForceFlush(); -#else logger_provider->ForceFlush(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } logger_provider.reset(); diff --git a/examples/otlp/grpc_main.cc b/examples/otlp/grpc_main.cc index 15499985af..9b29e16edd 100644 --- a/examples/otlp/grpc_main.cc +++ b/examples/otlp/grpc_main.cc @@ -24,11 +24,7 @@ namespace { opentelemetry::exporter::otlp::OtlpGrpcExporterOptions opts; -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY -std::shared_ptr provider; -#else std::shared_ptr provider; -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ void InitTracer() { @@ -47,11 +43,7 @@ void CleanupTracer() // We call ForceFlush to prevent to cancel running exportings, It's optional. if (provider) { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - static_cast(provider.get())->ForceFlush(); -#else provider->ForceFlush(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } provider.reset(); diff --git a/examples/otlp/http_log_main.cc b/examples/otlp/http_log_main.cc index 37bace2b0f..4f42b61ce9 100644 --- a/examples/otlp/http_log_main.cc +++ b/examples/otlp/http_log_main.cc @@ -48,11 +48,7 @@ namespace opentelemetry::exporter::otlp::OtlpHttpExporterOptions trace_opts; -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY -std::shared_ptr tracer_provider; -#else std::shared_ptr tracer_provider; -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ void InitTracer() { @@ -88,11 +84,7 @@ void CleanupTracer() // We call ForceFlush to prevent to cancel running exportings, It's optional. if (tracer_provider) { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - static_cast(tracer_provider.get())->ForceFlush(); -#else tracer_provider->ForceFlush(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } tracer_provider.reset(); @@ -102,11 +94,7 @@ void CleanupTracer() opentelemetry::exporter::otlp::OtlpHttpLogRecordExporterOptions logger_opts; -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY -std::shared_ptr logger_provider; -#else std::shared_ptr logger_provider; -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ void InitLogger() { @@ -126,11 +114,7 @@ void CleanupLogger() // We call ForceFlush to prevent to cancel running exportings, It's optional. if (logger_provider) { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - static_cast(logger_provider.get())->ForceFlush(); -#else logger_provider->ForceFlush(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } logger_provider.reset(); diff --git a/examples/otlp/http_main.cc b/examples/otlp/http_main.cc index 6217bdcb34..ce88e46fca 100644 --- a/examples/otlp/http_main.cc +++ b/examples/otlp/http_main.cc @@ -35,11 +35,7 @@ namespace { opentelemetry::exporter::otlp::OtlpHttpExporterOptions opts; -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY -std::shared_ptr provider; -#else std::shared_ptr provider; -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ void InitTracer() { @@ -57,11 +53,7 @@ void CleanupTracer() // We call ForceFlush to prevent to cancel running exportings, It's optional. if (provider) { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - static_cast(provider.get())->ForceFlush(); -#else provider->ForceFlush(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } provider.reset(); diff --git a/examples/simple/main.cc b/examples/simple/main.cc index 349aec500a..245786688c 100644 --- a/examples/simple/main.cc +++ b/examples/simple/main.cc @@ -31,13 +31,8 @@ void InitTracer() auto exporter = trace_exporter::OStreamSpanExporterFactory::Create(); auto processor = trace_sdk::SimpleSpanProcessorFactory::Create(std::move(exporter)); -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - std::shared_ptr provider = - opentelemetry::sdk::trace::TracerProviderFactory::Create(std::move(processor)); -#else std::shared_ptr provider = opentelemetry::sdk::trace::TracerProviderFactory::Create(std::move(processor)); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ // Set the global trace provider const std::shared_ptr &api_provider = provider; diff --git a/exporters/otlp/test/otlp_grpc_log_record_exporter_test.cc b/exporters/otlp/test/otlp_grpc_log_record_exporter_test.cc index 4c7a9fd7f1..90827f576f 100644 --- a/exporters/otlp/test/otlp_grpc_log_record_exporter_test.cc +++ b/exporters/otlp/test/otlp_grpc_log_record_exporter_test.cc @@ -288,17 +288,10 @@ TEST_F(OtlpGrpcLogRecordExporterTestPeer, ExportIntegrationTest) std::unique_ptr trace_stub_interface( trace_mock_stub); -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - auto trace_provider = opentelemetry::nostd::shared_ptr( - opentelemetry::sdk::trace::TracerProviderFactory::Create( - opentelemetry::sdk::trace::SimpleSpanProcessorFactory::Create( - GetExporter(trace_stub_interface)))); -#else auto trace_provider = opentelemetry::nostd::shared_ptr( opentelemetry::sdk::trace::TracerProviderFactory::Create( opentelemetry::sdk::trace::SimpleSpanProcessorFactory::Create( GetExporter(trace_stub_interface)))); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ // Trace and Logs should both receive datas when links static gRPC on ELF ABI. EXPECT_CALL(*trace_mock_stub, Export(_, _, _)) diff --git a/sdk/include/opentelemetry/sdk/logs/event_logger_provider_factory.h b/sdk/include/opentelemetry/sdk/logs/event_logger_provider_factory.h index 621cbea6c8..5559605171 100644 --- a/sdk/include/opentelemetry/sdk/logs/event_logger_provider_factory.h +++ b/sdk/include/opentelemetry/sdk/logs/event_logger_provider_factory.h @@ -24,16 +24,7 @@ class EventLoggerProviderFactory * Create a EventLoggerProvider. */ -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - -# ifndef OPENTELEMETRY_NO_DEPRECATED_CODE - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create(); -# endif /* OPENTELEMETRY_NO_DEPRECATED_CODE */ - -#else static std::unique_ptr Create(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ }; } // namespace logs diff --git a/sdk/include/opentelemetry/sdk/logs/logger_provider_factory.h b/sdk/include/opentelemetry/sdk/logs/logger_provider_factory.h index 7b8f636e68..490393209c 100644 --- a/sdk/include/opentelemetry/sdk/logs/logger_provider_factory.h +++ b/sdk/include/opentelemetry/sdk/logs/logger_provider_factory.h @@ -24,36 +24,6 @@ namespace logs class OPENTELEMETRY_EXPORT LoggerProviderFactory { public: -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - -# ifndef OPENTELEMETRY_NO_DEPRECATED_CODE - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr &&processor); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr &&processor, - const opentelemetry::sdk::resource::Resource &resource); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::vector> &&processors); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr context); - -# endif /* OPENTELEMETRY_NO_DEPRECATED_CODE */ - -#else - /** * Create a LoggerProvider. */ @@ -85,8 +55,6 @@ class OPENTELEMETRY_EXPORT LoggerProviderFactory */ static std::unique_ptr Create( std::unique_ptr context); - -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ }; } // namespace logs diff --git a/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h b/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h index cb9106ddc8..499c87ae6a 100644 --- a/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h @@ -21,30 +21,6 @@ namespace metrics class OPENTELEMETRY_EXPORT MeterProviderFactory { public: -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - -# ifndef OPENTELEMETRY_NO_DEPRECATED_CODE - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create(); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr views); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr views, - const opentelemetry::sdk::resource::Resource &resource); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr context); - -# endif /* OPENTELEMETRY_NO_DEPRECATED_CODE */ - -#else - static std::unique_ptr Create(); static std::unique_ptr Create( @@ -56,8 +32,6 @@ class OPENTELEMETRY_EXPORT MeterProviderFactory static std::unique_ptr Create( std::unique_ptr context); - -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ }; } // namespace metrics diff --git a/sdk/include/opentelemetry/sdk/trace/tracer_provider_factory.h b/sdk/include/opentelemetry/sdk/trace/tracer_provider_factory.h index 7c4b6903de..ed451a8c99 100644 --- a/sdk/include/opentelemetry/sdk/trace/tracer_provider_factory.h +++ b/sdk/include/opentelemetry/sdk/trace/tracer_provider_factory.h @@ -28,68 +28,6 @@ namespace trace class OPENTELEMETRY_EXPORT TracerProviderFactory { public: -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - -# ifndef OPENTELEMETRY_NO_DEPRECATED_CODE - - /* Serie of builders with a single processor. */ - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr processor); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr processor, - const opentelemetry::sdk::resource::Resource &resource); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr processor, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr processor, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler, - std::unique_ptr id_generator); - - /* Serie of builders with a vector of processor. */ - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::vector> &&processors); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler, - std::unique_ptr id_generator); - - /* Create with a tracer context. */ - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr context); - -# endif /* OPENTELEMETRY_NO_DEPRECATED_CODE */ - -#else - /* Serie of builders with a single processor. */ static std::unique_ptr Create( @@ -134,8 +72,6 @@ class OPENTELEMETRY_EXPORT TracerProviderFactory static std::unique_ptr Create( std::unique_ptr context); - -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ }; } // namespace trace diff --git a/sdk/src/logs/event_logger_provider_factory.cc b/sdk/src/logs/event_logger_provider_factory.cc index 7f5c8cadf1..daff8a8590 100644 --- a/sdk/src/logs/event_logger_provider_factory.cc +++ b/sdk/src/logs/event_logger_provider_factory.cc @@ -11,22 +11,11 @@ namespace sdk namespace logs { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - -std::unique_ptr EventLoggerProviderFactory::Create() -{ - return std::unique_ptr(new EventLoggerProvider()); -} - -#else - std::unique_ptr EventLoggerProviderFactory::Create() { return std::unique_ptr(new EventLoggerProvider()); } -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ - } // namespace logs } // namespace sdk OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/src/logs/logger_provider_factory.cc b/sdk/src/logs/logger_provider_factory.cc index 08567c65d9..530d1c2db4 100644 --- a/sdk/src/logs/logger_provider_factory.cc +++ b/sdk/src/logs/logger_provider_factory.cc @@ -18,50 +18,6 @@ namespace sdk namespace logs { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - -std::unique_ptr LoggerProviderFactory::Create( - std::unique_ptr &&processor) -{ - auto resource = opentelemetry::sdk::resource::Resource::Create({}); - return Create(std::move(processor), resource); -} - -std::unique_ptr LoggerProviderFactory::Create( - std::unique_ptr &&processor, - const opentelemetry::sdk::resource::Resource &resource) -{ - std::unique_ptr provider( - new LoggerProvider(std::move(processor), resource)); - return provider; -} - -std::unique_ptr LoggerProviderFactory::Create( - std::vector> &&processors) -{ - auto resource = opentelemetry::sdk::resource::Resource::Create({}); - return Create(std::move(processors), resource); -} - -std::unique_ptr LoggerProviderFactory::Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource) -{ - std::unique_ptr provider( - new LoggerProvider(std::move(processors), resource)); - return provider; -} - -std::unique_ptr LoggerProviderFactory::Create( - std::unique_ptr context) -{ - std::unique_ptr provider( - new LoggerProvider(std::move(context))); - return provider; -} - -#else - std::unique_ptr LoggerProviderFactory::Create( std::unique_ptr &&processor) { @@ -102,8 +58,6 @@ std::unique_ptr LoggerProviderFactory: return provider; } -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ - } // namespace logs } // namespace sdk OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/src/metrics/meter_provider_factory.cc b/sdk/src/metrics/meter_provider_factory.cc index 7749a13124..c5e368aca6 100644 --- a/sdk/src/metrics/meter_provider_factory.cc +++ b/sdk/src/metrics/meter_provider_factory.cc @@ -18,40 +18,6 @@ namespace sdk namespace metrics { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - -std::unique_ptr MeterProviderFactory::Create() -{ - auto views = ViewRegistryFactory::Create(); - return Create(std::move(views)); -} - -std::unique_ptr MeterProviderFactory::Create( - std::unique_ptr views) -{ - auto resource = opentelemetry::sdk::resource::Resource::Create({}); - return Create(std::move(views), resource); -} - -std::unique_ptr MeterProviderFactory::Create( - std::unique_ptr views, - const opentelemetry::sdk::resource::Resource &resource) -{ - std::unique_ptr provider( - new opentelemetry::sdk::metrics::MeterProvider(std::move(views), resource)); - return provider; -} - -std::unique_ptr MeterProviderFactory::Create( - std::unique_ptr context) -{ - std::unique_ptr provider( - new opentelemetry::sdk::metrics::MeterProvider(std::move(context))); - return provider; -} - -#else - std::unique_ptr MeterProviderFactory::Create() { auto views = ViewRegistryFactory::Create(); @@ -82,8 +48,6 @@ std::unique_ptr MeterProviderFactory return provider; } -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ - } // namespace metrics } // namespace sdk OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/src/trace/tracer_provider_factory.cc b/sdk/src/trace/tracer_provider_factory.cc index eeb18a1e59..eaeb669b91 100644 --- a/sdk/src/trace/tracer_provider_factory.cc +++ b/sdk/src/trace/tracer_provider_factory.cc @@ -22,90 +22,6 @@ namespace sdk namespace trace { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - -std::unique_ptr TracerProviderFactory::Create( - std::unique_ptr processor) -{ - auto resource = opentelemetry::sdk::resource::Resource::Create({}); - return Create(std::move(processor), resource); -} - -std::unique_ptr TracerProviderFactory::Create( - std::unique_ptr processor, - const opentelemetry::sdk::resource::Resource &resource) -{ - auto sampler = AlwaysOnSamplerFactory::Create(); - return Create(std::move(processor), resource, std::move(sampler)); -} - -std::unique_ptr TracerProviderFactory::Create( - std::unique_ptr processor, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler) -{ - auto id_generator = RandomIdGeneratorFactory::Create(); - return Create(std::move(processor), resource, std::move(sampler), std::move(id_generator)); -} - -std::unique_ptr TracerProviderFactory::Create( - std::unique_ptr processor, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler, - std::unique_ptr id_generator) -{ - std::unique_ptr provider( - new opentelemetry::sdk::trace::TracerProvider(std::move(processor), resource, - std::move(sampler), std::move(id_generator))); - return provider; -} - -std::unique_ptr TracerProviderFactory::Create( - std::vector> &&processors) -{ - auto resource = opentelemetry::sdk::resource::Resource::Create({}); - return Create(std::move(processors), resource); -} - -std::unique_ptr TracerProviderFactory::Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource) -{ - auto sampler = AlwaysOnSamplerFactory::Create(); - return Create(std::move(processors), resource, std::move(sampler)); -} - -std::unique_ptr TracerProviderFactory::Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler) -{ - auto id_generator = RandomIdGeneratorFactory::Create(); - return Create(std::move(processors), resource, std::move(sampler), std::move(id_generator)); -} - -std::unique_ptr TracerProviderFactory::Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler, - std::unique_ptr id_generator) -{ - std::unique_ptr provider( - new opentelemetry::sdk::trace::TracerProvider(std::move(processors), resource, - std::move(sampler), std::move(id_generator))); - return provider; -} - -std::unique_ptr TracerProviderFactory::Create( - std::unique_ptr context) -{ - std::unique_ptr provider( - new opentelemetry::sdk::trace::TracerProvider(std::move(context))); - return provider; -} - -#else - std::unique_ptr TracerProviderFactory::Create( std::unique_ptr processor) { @@ -186,8 +102,6 @@ std::unique_ptr TracerProviderFactory return provider; } -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ - } // namespace trace } // namespace sdk OPENTELEMETRY_END_NAMESPACE From f195b9e3da9c7987c377fafe8a7a6873b0d34549 Mon Sep 17 00:00:00 2001 From: WenTao Ou Date: Fri, 19 Jul 2024 17:34:40 +0800 Subject: [PATCH 09/89] [EXPORTER] ForceFlush before canceling the running requests on shutdown. (#2727) --- .../exporters/otlp/otlp_http_client.h | 5 ++- exporters/otlp/src/otlp_grpc_client.cc | 9 ++++- exporters/otlp/src/otlp_http_client.cc | 38 ++++++++++++++----- 3 files changed, 39 insertions(+), 13 deletions(-) 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 6806f1cdf9..3753704bb3 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_client.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_client.h @@ -3,6 +3,7 @@ #pragma once +#include #include #include #include @@ -275,7 +276,7 @@ class OtlpHttpClient std::shared_ptr http_client); // Stores if this HTTP client had its Shutdown() method called - bool is_shutdown_; + std::atomic is_shutdown_; // The configuration options associated with this HTTP client. const OtlpHttpClientOptions options_; @@ -296,6 +297,8 @@ class OtlpHttpClient // Condition variable and mutex to control the concurrency count of running sessions std::mutex session_waker_lock_; std::condition_variable session_waker_; + std::atomic start_session_counter_; + std::atomic finished_session_counter_; }; } // namespace otlp } // namespace exporter diff --git a/exporters/otlp/src/otlp_grpc_client.cc b/exporters/otlp/src/otlp_grpc_client.cc index a5760bdd81..d3d59bce6e 100644 --- a/exporters/otlp/src/otlp_grpc_client.cc +++ b/exporters/otlp/src/otlp_grpc_client.cc @@ -567,14 +567,19 @@ bool OtlpGrpcClient::Shutdown(std::chrono::microseconds timeout) noexcept return true; } + bool force_flush_result; if (false == is_shutdown_.exchange(true, std::memory_order_acq_rel)) { - is_shutdown_ = true; + force_flush_result = ForceFlush(timeout); async_data_->cq.Shutdown(); } + else + { + force_flush_result = ForceFlush(timeout); + } - return ForceFlush(timeout); + return force_flush_result; } #endif diff --git a/exporters/otlp/src/otlp_http_client.cc b/exporters/otlp/src/otlp_http_client.cc index 94f02a9967..07b9108a3a 100644 --- a/exporters/otlp/src/otlp_http_client.cc +++ b/exporters/otlp/src/otlp_http_client.cc @@ -41,9 +41,11 @@ // clang-format off #include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep -#include +// clang-format on #include +#include #include +// clang-format off #include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep // clang-format on @@ -661,7 +663,11 @@ void ConvertListFieldToJson(nlohmann::json &value, } // namespace OtlpHttpClient::OtlpHttpClient(OtlpHttpClientOptions &&options) - : is_shutdown_(false), options_(options), http_client_(http_client::HttpClientFactory::Create()) + : is_shutdown_(false), + options_(options), + http_client_(http_client::HttpClientFactory::Create()), + start_session_counter_(0), + finished_session_counter_(0) { http_client_->SetMaxSessionsPerConnection(options_.max_requests_per_connection); } @@ -700,7 +706,11 @@ OtlpHttpClient::~OtlpHttpClient() OtlpHttpClient::OtlpHttpClient(OtlpHttpClientOptions &&options, std::shared_ptr http_client) - : is_shutdown_(false), options_(options), http_client_(std::move(http_client)) + : is_shutdown_(false), + options_(options), + http_client_(std::move(http_client)), + start_session_counter_(0), + finished_session_counter_(0) { http_client_->SetMaxSessionsPerConnection(options_.max_requests_per_connection); } @@ -799,6 +809,8 @@ bool OtlpHttpClient::ForceFlush(std::chrono::microseconds timeout) noexcept timeout_steady = (std::chrono::steady_clock::duration::max)(); } + size_t wait_counter = start_session_counter_.load(std::memory_order_acquire); + while (timeout_steady > std::chrono::steady_clock::duration::zero()) { { @@ -816,7 +828,7 @@ bool OtlpHttpClient::ForceFlush(std::chrono::microseconds timeout) noexcept { cleanupGCSessions(); } - else + else if (finished_session_counter_.load(std::memory_order_acquire) >= wait_counter) { break; } @@ -829,20 +841,24 @@ bool OtlpHttpClient::ForceFlush(std::chrono::microseconds timeout) noexcept bool OtlpHttpClient::Shutdown(std::chrono::microseconds timeout) noexcept { + is_shutdown_.store(true, std::memory_order_release); + + bool force_flush_result = ForceFlush(timeout); + { std::lock_guard guard{session_manager_lock_}; - is_shutdown_ = true; // Shutdown the session manager http_client_->CancelAllSessions(); http_client_->FinishAllSessions(); } - ForceFlush(timeout); - + // Wait util all sessions are canceled. while (cleanupGCSessions()) - ; - return true; + { + ForceFlush(std::chrono::milliseconds{1}); + } + return force_flush_result; } void OtlpHttpClient::ReleaseSession( @@ -859,6 +875,7 @@ void OtlpHttpClient::ReleaseSession( gc_sessions_.emplace_back(std::move(session_iter->second)); running_sessions_.erase(session_iter); + finished_session_counter_.fetch_add(1, std::memory_order_release); has_session = true; } @@ -1003,6 +1020,7 @@ void OtlpHttpClient::addSession(HttpSessionData &&session_data) noexcept store_session_data = std::move(session_data); } + start_session_counter_.fetch_add(1, std::memory_order_release); // Send request after the session is added session->SendRequest(handle); } @@ -1027,7 +1045,7 @@ bool OtlpHttpClient::cleanupGCSessions() noexcept bool OtlpHttpClient::IsShutdown() const noexcept { - return is_shutdown_; + return is_shutdown_.load(std::memory_order_acquire); } } // namespace otlp From 4520aa598b7c100eefbb4ce9a9f73cb50bb69514 Mon Sep 17 00:00:00 2001 From: WenTao Ou Date: Fri, 19 Jul 2024 18:12:48 +0800 Subject: [PATCH 10/89] [SDK] Fix crash in `PeriodicExportingMetricReader`. (#2983) --- api/include/opentelemetry/common/macros.h | 31 ++++++++ examples/plugin/plugin/tracer.cc | 1 + exporters/otlp/src/otlp_file_client.cc | 22 +++--- .../periodic_exporting_metric_reader.cc | 77 ++++++++++++++----- .../periodic_exporting_metric_reader_test.cc | 38 +++++++-- 5 files changed, 133 insertions(+), 36 deletions(-) diff --git a/api/include/opentelemetry/common/macros.h b/api/include/opentelemetry/common/macros.h index b4a270084d..b74c1048fc 100644 --- a/api/include/opentelemetry/common/macros.h +++ b/api/include/opentelemetry/common/macros.h @@ -387,6 +387,37 @@ point. #endif +// OPENTELEMETRY_HAVE_EXCEPTIONS +// +// Checks whether the compiler both supports and enables exceptions. Many +// compilers support a "no exceptions" mode that disables exceptions. +// +// Generally, when OPENTELEMETRY_HAVE_EXCEPTIONS is not defined: +// +// * Code using `throw` and `try` may not compile. +// * The `noexcept` specifier will still compile and behave as normal. +// * The `noexcept` operator may still return `false`. +// +// For further details, consult the compiler's documentation. +#ifndef OPENTELEMETRY_HAVE_EXCEPTIONS +# if defined(__clang__) && ((__clang_major__ * 100) + __clang_minor__) < 306 +// Clang < 3.6 +// http://releases.llvm.org/3.6.0/tools/clang/docs/ReleaseNotes.html#the-exceptions-macro +# if defined(__EXCEPTIONS) && OPENTELEMETRY_HAVE_FEATURE(cxx_exceptions) +# define OPENTELEMETRY_HAVE_EXCEPTIONS 1 +# endif // defined(__EXCEPTIONS) && OPENTELEMETRY_HAVE_FEATURE(cxx_exceptions) +# elif OPENTELEMETRY_HAVE_FEATURE(cxx_exceptions) +# define OPENTELEMETRY_HAVE_EXCEPTIONS 1 +// Handle remaining special cases and default to exceptions being supported. +# elif !(defined(__GNUC__) && !defined(__EXCEPTIONS) && !defined(__cpp_exceptions)) && \ + !(defined(_MSC_VER) && !defined(_CPPUNWIND)) +# define OPENTELEMETRY_HAVE_EXCEPTIONS 1 +# endif +#endif +#ifndef OPENTELEMETRY_HAVE_EXCEPTIONS +# define OPENTELEMETRY_HAVE_EXCEPTIONS 0 +#endif + /* OPENTELEMETRY_ATTRIBUTE_LIFETIME_BOUND indicates that a resource owned by a function parameter or implicit object parameter is retained by the return value of the diff --git a/examples/plugin/plugin/tracer.cc b/examples/plugin/plugin/tracer.cc index 5361197584..05ff971fb1 100644 --- a/examples/plugin/plugin/tracer.cc +++ b/examples/plugin/plugin/tracer.cc @@ -9,6 +9,7 @@ #include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/timestamp.h" #include "opentelemetry/context/context_value.h" +#include "opentelemetry/nostd/utility.h" #include "opentelemetry/trace/span_context.h" #include "opentelemetry/trace/span_metadata.h" #include "tracer.h" diff --git a/exporters/otlp/src/otlp_file_client.cc b/exporters/otlp/src/otlp_file_client.cc index 62552bdeff..8efa5c15b5 100644 --- a/exporters/otlp/src/otlp_file_client.cc +++ b/exporters/otlp/src/otlp_file_client.cc @@ -14,8 +14,6 @@ // clang-format on #include "google/protobuf/message.h" -#include "google/protobuf/reflection.h" -#include "google/protobuf/stubs/common.h" #include "nlohmann/json.hpp" // clang-format off @@ -28,15 +26,26 @@ #include "opentelemetry/sdk/common/global_log_handler.h" #include "opentelemetry/version.h" +#ifdef _MSC_VER +# include +# define strcasecmp _stricmp +#else +# include +#endif + +#include #include #include +#include #include -#include #include +#include #include +#include #include #include #include +#include #include #if !defined(__CYGWIN__) && defined(_WIN32) @@ -64,11 +73,8 @@ #else -# include -# include # include # include -# include # include # define FS_ACCESS(x) access(x, F_OK) @@ -89,10 +95,6 @@ # undef GetMessage #endif -#ifdef _MSC_VER -# define strcasecmp _stricmp -#endif - #if (defined(_MSC_VER) && _MSC_VER >= 1600) || \ (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || defined(__STDC_LIB_EXT1__) # ifdef _MSC_VER diff --git a/sdk/src/metrics/export/periodic_exporting_metric_reader.cc b/sdk/src/metrics/export/periodic_exporting_metric_reader.cc index f6ae47977d..7ca2747337 100644 --- a/sdk/src/metrics/export/periodic_exporting_metric_reader.cc +++ b/sdk/src/metrics/export/periodic_exporting_metric_reader.cc @@ -13,6 +13,7 @@ #include #include +#include "opentelemetry/common/macros.h" #include "opentelemetry/common/timestamp.h" #include "opentelemetry/sdk/common/global_log_handler.h" #include "opentelemetry/sdk/metrics/export/metric_producer.h" @@ -29,6 +30,10 @@ # include #endif +#if OPENTELEMETRY_HAVE_EXCEPTIONS +# include +#endif + OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk { @@ -90,31 +95,61 @@ void PeriodicExportingMetricReader::DoBackgroundWork() bool PeriodicExportingMetricReader::CollectAndExportOnce() { std::atomic cancel_export_for_timeout{false}; - auto future_receive = std::async(std::launch::async, [this, &cancel_export_for_timeout] { - Collect([this, &cancel_export_for_timeout](ResourceMetrics &metric_data) { - if (cancel_export_for_timeout) - { - OTEL_INTERNAL_LOG_ERROR( - "[Periodic Exporting Metric Reader] Collect took longer configured time: " - << export_timeout_millis_.count() << " ms, and timed out"); - return false; - } - this->exporter_->Export(metric_data); - return true; - }); - }); - std::future_status status; std::uint64_t notify_force_flush = force_flush_pending_sequence_.load(std::memory_order_acquire); - do + std::unique_ptr task_thread; + +#if OPENTELEMETRY_HAVE_EXCEPTIONS + try { - status = future_receive.wait_for(std::chrono::milliseconds(export_timeout_millis_)); - if (status == std::future_status::timeout) +#endif + std::promise sender; + auto receiver = sender.get_future(); + + task_thread.reset(new std::thread([this, &cancel_export_for_timeout] { + this->Collect([this, &cancel_export_for_timeout](ResourceMetrics &metric_data) { + if (cancel_export_for_timeout.load(std::memory_order_acquire)) + { + OTEL_INTERNAL_LOG_ERROR( + "[Periodic Exporting Metric Reader] Collect took longer configured time: " + << this->export_timeout_millis_.count() << " ms, and timed out"); + return false; + } + this->exporter_->Export(metric_data); + return true; + }); + })); + + std::future_status status; + do { - cancel_export_for_timeout = true; - break; - } - } while (status != std::future_status::ready); + status = receiver.wait_for(std::chrono::milliseconds(export_timeout_millis_)); + if (status == std::future_status::timeout) + { + cancel_export_for_timeout.store(true, std::memory_order_release); + break; + } + } while (status != std::future_status::ready); +#if OPENTELEMETRY_HAVE_EXCEPTIONS + } + catch (std::exception &e) + { + OTEL_INTERNAL_LOG_ERROR("[Periodic Exporting Metric Reader] Collect failed with exception " + << e.what()); + return false; + } + catch (...) + { + OTEL_INTERNAL_LOG_ERROR( + "[Periodic Exporting Metric Reader] Collect failed with unknown exception"); + return false; + } +#endif + + if (task_thread && task_thread->joinable()) + { + task_thread->join(); + } std::uint64_t notified_sequence = force_flush_notified_sequence_.load(std::memory_order_acquire); while (notify_force_flush > notified_sequence) diff --git a/sdk/test/metrics/periodic_exporting_metric_reader_test.cc b/sdk/test/metrics/periodic_exporting_metric_reader_test.cc index e115f79f75..f65c10ca05 100644 --- a/sdk/test/metrics/periodic_exporting_metric_reader_test.cc +++ b/sdk/test/metrics/periodic_exporting_metric_reader_test.cc @@ -7,6 +7,10 @@ #include +#include +#include +#include + using namespace opentelemetry; using namespace opentelemetry::sdk::instrumentationscope; using namespace opentelemetry::sdk::metrics; @@ -14,8 +18,14 @@ using namespace opentelemetry::sdk::metrics; class MockPushMetricExporter : public PushMetricExporter { public: + MockPushMetricExporter(std::chrono::milliseconds wait) : wait_(wait) {} + opentelemetry::sdk::common::ExportResult Export(const ResourceMetrics &record) noexcept override { + if (wait_ > std::chrono::milliseconds::zero()) + { + std::this_thread::sleep_for(wait_); + } records_.push_back(record); return opentelemetry::sdk::common::ExportResult::kSuccess; } @@ -34,6 +44,7 @@ class MockPushMetricExporter : public PushMetricExporter private: std::vector records_; + std::chrono::milliseconds wait_; }; class MockMetricProducer : public MetricProducer @@ -61,17 +72,34 @@ class MockMetricProducer : public MetricProducer TEST(PeriodicExporingMetricReader, BasicTests) { - std::unique_ptr exporter(new MockPushMetricExporter()); + std::unique_ptr exporter( + new MockPushMetricExporter(std::chrono::milliseconds{0})); PeriodicExportingMetricReaderOptions options; options.export_timeout_millis = std::chrono::milliseconds(200); options.export_interval_millis = std::chrono::milliseconds(500); auto exporter_ptr = exporter.get(); - PeriodicExportingMetricReader reader(std::move(exporter), options); + std::shared_ptr reader = + std::make_shared(std::move(exporter), options); MockMetricProducer producer; - reader.SetMetricProducer(&producer); + reader->SetMetricProducer(&producer); std::this_thread::sleep_for(std::chrono::milliseconds(2000)); - EXPECT_NO_THROW(reader.ForceFlush()); - reader.Shutdown(); + EXPECT_NO_THROW(reader->ForceFlush()); + reader->Shutdown(); EXPECT_EQ(static_cast(exporter_ptr)->GetDataCount(), static_cast(&producer)->GetDataCount()); } + +TEST(PeriodicExporingMetricReader, Timeout) +{ + std::unique_ptr exporter( + new MockPushMetricExporter(std::chrono::milliseconds{2000})); + PeriodicExportingMetricReaderOptions options; + options.export_timeout_millis = std::chrono::milliseconds(200); + options.export_interval_millis = std::chrono::milliseconds(500); + std::shared_ptr reader = + std::make_shared(std::move(exporter), options); + MockMetricProducer producer; + reader->SetMetricProducer(&producer); + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + reader->Shutdown(); +} From deed1e3a0c3d67afd9db522b69daad567cdb0592 Mon Sep 17 00:00:00 2001 From: Weipeng Hong <961365124@qq.com> Date: Sat, 20 Jul 2024 02:13:04 +0800 Subject: [PATCH 11/89] [SDK] Fix memory leak in TlsRandomNumberGenerator() constructor (#2661) --- sdk/src/common/random.cc | 9 ++++++++- sdk/test/common/random_test.cc | 27 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/sdk/src/common/random.cc b/sdk/src/common/random.cc index 77b88cfa2a..9b696dea65 100644 --- a/sdk/src/common/random.cc +++ b/sdk/src/common/random.cc @@ -5,6 +5,7 @@ #include "src/common/random.h" #include "src/common/platform/fork.h" +#include #include #include @@ -26,12 +27,17 @@ class TlsRandomNumberGenerator TlsRandomNumberGenerator() noexcept { Seed(); - platform::AtFork(nullptr, nullptr, OnFork); + if (!flag.test_and_set()) + { + platform::AtFork(nullptr, nullptr, OnFork); + } } static FastRandomNumberGenerator &engine() noexcept { return engine_; } private: + static std::atomic_flag flag; + static thread_local FastRandomNumberGenerator engine_; static void OnFork() noexcept { Seed(); } @@ -44,6 +50,7 @@ class TlsRandomNumberGenerator } }; +std::atomic_flag TlsRandomNumberGenerator::flag; thread_local FastRandomNumberGenerator TlsRandomNumberGenerator::engine_{}; } // namespace diff --git a/sdk/test/common/random_test.cc b/sdk/test/common/random_test.cc index 8132b2d5a4..243a998041 100644 --- a/sdk/test/common/random_test.cc +++ b/sdk/test/common/random_test.cc @@ -4,7 +4,10 @@ #include "src/common/random.h" #include +#include #include +#include +#include #include using opentelemetry::sdk::common::Random; @@ -34,3 +37,27 @@ TEST(RandomTest, GenerateRandomBuffer) std::equal(std::begin(buf1_vector), std::end(buf1_vector), std::begin(buf2_vector))); } } + +void doSomethingOnce(std::atomic_uint *count) +{ + static std::atomic_flag flag; + if (!flag.test_and_set()) + { + (*count)++; + } +} + +TEST(RandomTest, AtomicFlagMultiThreadTest) +{ + std::vector threads; + std::atomic_uint count(0); + for (int i = 0; i < 10; ++i) + { + threads.push_back(std::thread(doSomethingOnce, &count)); + } + for (auto &t : threads) + { + t.join(); + } + EXPECT_EQ(1, count.load()); +} From 84368cd76151bfad525739d675061bd071477f81 Mon Sep 17 00:00:00 2001 From: WenTao Ou Date: Mon, 29 Jul 2024 23:25:44 +0800 Subject: [PATCH 12/89] [EXPORTER] Ignore exception when create thread in OTLP file exporter. (#3012) --- exporters/otlp/src/otlp_file_client.cc | 122 +++++++++++++++---------- 1 file changed, 72 insertions(+), 50 deletions(-) diff --git a/exporters/otlp/src/otlp_file_client.cc b/exporters/otlp/src/otlp_file_client.cc index 8efa5c15b5..cc6e074bfd 100644 --- a/exporters/otlp/src/otlp_file_client.cc +++ b/exporters/otlp/src/otlp_file_client.cc @@ -47,6 +47,9 @@ #include #include #include +#if OPENTELEMETRY_HAVE_EXCEPTIONS +# include +#endif #if !defined(__CYGWIN__) && defined(_WIN32) # ifndef WIN32_LEAN_AND_MEAN @@ -1424,71 +1427,90 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileSystemBackend : public OtlpFileAppender return; } - std::lock_guard lock_guard_caller{file_->background_thread_lock}; - if (file_->background_flush_thread) +#if OPENTELEMETRY_HAVE_EXCEPTIONS + try { - return; - } - - std::shared_ptr concurrency_file = file_; - std::chrono::microseconds flush_interval = options_.flush_interval; - file_->background_flush_thread.reset(new std::thread([concurrency_file, flush_interval]() { - std::chrono::system_clock::time_point last_free_job_timepoint = - std::chrono::system_clock::now(); - std::size_t last_record_count = 0; +#endif - while (true) + std::lock_guard lock_guard_caller{file_->background_thread_lock}; + if (file_->background_flush_thread) { - std::chrono::system_clock::time_point now = std::chrono::system_clock::now(); - // Exit flush thread if there is not data to flush more than one minute. - if (now - last_free_job_timepoint > std::chrono::minutes{1}) - { - break; - } + return; + } - if (concurrency_file->is_shutdown.load(std::memory_order_acquire)) - { - break; - } + std::shared_ptr concurrency_file = file_; + std::chrono::microseconds flush_interval = options_.flush_interval; + file_->background_flush_thread.reset(new std::thread([concurrency_file, flush_interval]() { + std::chrono::system_clock::time_point last_free_job_timepoint = + std::chrono::system_clock::now(); + std::size_t last_record_count = 0; + while (true) { - std::unique_lock lk(concurrency_file->background_thread_waker_lock); - concurrency_file->background_thread_waker_cv.wait_for(lk, flush_interval); - } + std::chrono::system_clock::time_point now = std::chrono::system_clock::now(); + // Exit flush thread if there is not data to flush more than one minute. + if (now - last_free_job_timepoint > std::chrono::minutes{1}) + { + break; + } - { - std::size_t current_record_count = - concurrency_file->record_count.load(std::memory_order_acquire); - std::lock_guard lock_guard{concurrency_file->file_lock}; - if (current_record_count != last_record_count) + if (concurrency_file->is_shutdown.load(std::memory_order_acquire)) { - last_record_count = current_record_count; - last_free_job_timepoint = std::chrono::system_clock::now(); + break; } - if (concurrency_file->current_file) { - fflush(concurrency_file->current_file.get()); + std::unique_lock lk(concurrency_file->background_thread_waker_lock); + concurrency_file->background_thread_waker_cv.wait_for(lk, flush_interval); } - concurrency_file->flushed_record_count.store(current_record_count, - std::memory_order_release); - } + { + std::size_t current_record_count = + concurrency_file->record_count.load(std::memory_order_acquire); + std::lock_guard lock_guard{concurrency_file->file_lock}; + if (current_record_count != last_record_count) + { + last_record_count = current_record_count; + last_free_job_timepoint = std::chrono::system_clock::now(); + } - concurrency_file->background_thread_waiter_cv.notify_all(); - } + if (concurrency_file->current_file) + { + fflush(concurrency_file->current_file.get()); + } - // Detach running thread because it will exit soon - std::unique_ptr background_flush_thread; - { - std::lock_guard lock_guard_inner{concurrency_file->background_thread_lock}; - background_flush_thread.swap(concurrency_file->background_flush_thread); - } - if (background_flush_thread && background_flush_thread->joinable()) - { - background_flush_thread->detach(); - } - })); + concurrency_file->flushed_record_count.store(current_record_count, + std::memory_order_release); + } + + concurrency_file->background_thread_waiter_cv.notify_all(); + } + + // Detach running thread because it will exit soon + std::unique_ptr background_flush_thread; + { + std::lock_guard lock_guard_inner{concurrency_file->background_thread_lock}; + background_flush_thread.swap(concurrency_file->background_flush_thread); + } + if (background_flush_thread && background_flush_thread->joinable()) + { + background_flush_thread->detach(); + } + })); +#if OPENTELEMETRY_HAVE_EXCEPTIONS + } + catch (std::exception &e) + { + OTEL_INTERNAL_LOG_WARN("[OTLP FILE Client] Try to spawn background but got a exception: " + << e.what() << ".Data writing may experience some delays."); + } + catch (...) + { + OTEL_INTERNAL_LOG_WARN( + "[OTLP FILE Client] Try to spawn background but got a unknown exception.Data writing may " + "experience some delays."); + } +#endif } private: From eda6e93f47bd8c2fbc1619098d9334e4d1937ec2 Mon Sep 17 00:00:00 2001 From: Carbo Kuo Date: Fri, 2 Aug 2024 15:30:41 -0400 Subject: [PATCH 13/89] [BUILD] Update MODULE.bazel (#3015) --- MODULE.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MODULE.bazel b/MODULE.bazel index 311d4cbc16..13175f2c21 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -3,7 +3,7 @@ module( name = "opentelemetry-cpp", - version = "0", + version = "1.16.1", compatibility_level = 0, repo_name = "io_opentelemetry_cpp", ) From 34ca855055ebb9804756ff220fd64cb45d0c6de5 Mon Sep 17 00:00:00 2001 From: Manuel Bergler Date: Sat, 3 Aug 2024 00:54:26 +0200 Subject: [PATCH 14/89] [BUILD] Fix build without vcpkg on Windows when gRPC is disabled (#3016) --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d10e831297..b247f47fc9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -385,7 +385,8 @@ if(WITH_OTLP_GRPC if(WITH_OTLP_GRPC) find_package(gRPC) endif() - if((NOT Protobuf_FOUND AND NOT PROTOBUF_FOUND) OR (NOT gRPC_FOUND)) + if((NOT Protobuf_FOUND AND NOT PROTOBUF_FOUND) OR (WITH_OTLP_GRPC + AND NOT gRPC_FOUND)) if(WIN32 AND (NOT DEFINED CMAKE_TOOLCHAIN_FILE)) install_windows_deps() endif() From 7c6b9dbcaf43af9a281029121392aef31445b770 Mon Sep 17 00:00:00 2001 From: Carbo Kuo Date: Tue, 6 Aug 2024 13:43:02 -0400 Subject: [PATCH 15/89] [BUILD] Add abi_version_no bazel flag. (#3020) --- api/BUILD | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/api/BUILD b/api/BUILD index fdfe3ca146..dfc7d3c645 100644 --- a/api/BUILD +++ b/api/BUILD @@ -1,7 +1,7 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 -load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag") +load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "int_flag", "string_flag") package(default_visibility = ["//visibility:public"]) @@ -35,6 +35,9 @@ cc_library( ":set_cxx_stdlib_2020": ["OPENTELEMETRY_STL_VERSION=2020"], ":set_cxx_stdlib_2023": ["OPENTELEMETRY_STL_VERSION=2023"], "//conditions:default": [], + }) + select({ + ":abi_version_no_1": ["OPENTELEMETRY_ABI_VERSION_NO=1"], + ":abi_version_no_2": ["OPENTELEMETRY_ABI_VERSION_NO=2"], }), strip_include_prefix = "include", tags = ["api"], @@ -61,3 +64,18 @@ bool_flag( build_setting_default = False, deprecation = "The value of this flag is ignored. Bazel builds always depend on Abseil for its pre-adopted `std::` types. You should remove this flag from your build command.", ) + +int_flag( + name = "abi_version_no", + build_setting_default = 1, +) + +config_setting( + name = "abi_version_no_1", + flag_values = {":abi_version_no": "1"}, +) + +config_setting( + name = "abi_version_no_2", + flag_values = {":abi_version_no": "2"}, +) From cc60934199c39506b69e80263eaa1503a03bf7f3 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Thu, 8 Aug 2024 21:13:54 +0200 Subject: [PATCH 16/89] [Code health] Expand iwyu coverage to include unit tests. (#3022) --- .github/workflows/iwyu.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/iwyu.yml b/.github/workflows/iwyu.yml index 2c84b84cdc..c675193cdb 100644 --- a/.github/workflows/iwyu.yml +++ b/.github/workflows/iwyu.yml @@ -39,8 +39,8 @@ jobs: -DCMAKE_CXX_STANDARD=14 \ -DWITH_STL=CXX14 \ -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE="include-what-you-use;-w;-Xiwyu;--mapping_file=${TOPDIR}/.iwyu.imp;" \ - -DBUILD_TESTING=OFF \ - -DBUILD_W3CTRACECONTEXT_TEST=OFF \ + -DBUILD_TESTING=ON \ + -DBUILD_W3CTRACECONTEXT_TEST=ON \ -DWITH_OTLP_GRPC=OFF \ -DWITH_OTLP_HTTP=ON \ -DWITH_OTLP_FILE=ON \ From 41538b0525963031747d61c7775e1246231c7049 Mon Sep 17 00:00:00 2001 From: Troels Hoffmeyer Date: Fri, 9 Aug 2024 13:38:17 +0200 Subject: [PATCH 17/89] [BUILD] Version opentelemetry_proto/proto_grpc shared libraries (#2992) --- cmake/opentelemetry-proto.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmake/opentelemetry-proto.cmake b/cmake/opentelemetry-proto.cmake index 498a7e5681..fa6e185c13 100644 --- a/cmake/opentelemetry-proto.cmake +++ b/cmake/opentelemetry-proto.cmake @@ -325,6 +325,7 @@ add_library( ${TRACE_SERVICE_PB_CPP_FILE} ${LOGS_SERVICE_PB_CPP_FILE} ${METRICS_SERVICE_PB_CPP_FILE}) +set_target_version(opentelemetry_proto) # Disable include-what-you-use on generated code. set_target_properties( @@ -341,6 +342,7 @@ if(WITH_OTLP_GRPC) opentelemetry_proto_grpc ${OTELCPP_PROTO_TARGET_OPTIONS} ${TRACE_SERVICE_GRPC_PB_CPP_FILE} ${LOGS_SERVICE_GRPC_PB_CPP_FILE} ${METRICS_SERVICE_GRPC_PB_CPP_FILE}) + set_target_version(opentelemetry_proto_grpc) list(APPEND OPENTELEMETRY_PROTO_TARGETS opentelemetry_proto_grpc) target_link_libraries(opentelemetry_proto_grpc PUBLIC opentelemetry_proto) From 9e062b5bdd0920e1d6f5e7ffadc468e0b7ec945b Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Tue, 13 Aug 2024 10:51:39 +0200 Subject: [PATCH 18/89] [SEMANTIC CONVENTIONS] Upgrade semantic conventions to 1.27.0 (#3023) --- RELEASING.md | 2 +- .../trace/semantic_conventions.h | 1092 +++++++++++++---- buildscripts/semantic-convention/generate.sh | 6 +- docs/maintaining-dependencies.md | 131 +- docs/semantic-conventions.md | 76 -- .../sdk/resource/semantic_conventions.h | 1092 +++++++++++++---- 6 files changed, 1811 insertions(+), 588 deletions(-) delete mode 100644 docs/semantic-conventions.md diff --git a/RELEASING.md b/RELEASING.md index 8246e8fe44..852332e820 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -2,7 +2,7 @@ ## Pre Release -1: Upgrade to latest [semantic-conventions](docs/semantic-conventions.md) +1: Upgrade to latest [dependencies](docs/maintaining-dependencies.md) if required. 2: Make sure all relevant changes for this release are included under diff --git a/api/include/opentelemetry/trace/semantic_conventions.h b/api/include/opentelemetry/trace/semantic_conventions.h index a9290bff44..fb26385fbc 100644 --- a/api/include/opentelemetry/trace/semantic_conventions.h +++ b/api/include/opentelemetry/trace/semantic_conventions.h @@ -22,7 +22,7 @@ namespace SemanticConventions /** * The URL of the OpenTelemetry schema for these keys and values. */ -static constexpr const char *kSchemaUrl = "https://opentelemetry.io/schemas/1.26.0"; +static constexpr const char *kSchemaUrl = "https://opentelemetry.io/schemas/1.27.0"; /** * Uniquely identifies the framework API revision offered by a version ({@code os.version}) of the @@ -31,6 +31,69 @@ static constexpr const char *kSchemaUrl = "https://opentelemetry.io/schemas/1.26 */ static constexpr const char *kAndroidOsApiLevel = "android.os.api_level"; +/** + * The provenance filename of the built attestation which directly relates to the build artifact + * filename. This filename SHOULD accompany the artifact at publish time. See the SLSA + * Relationship specification for more information. + */ +static constexpr const char *kArtifactAttestationFilename = "artifact.attestation.filename"; + +/** + * The full hash value (see + * glossary), of the built attestation. Some envelopes in the software attestation space also + * refer to this as the digest. + */ +static constexpr const char *kArtifactAttestationHash = "artifact.attestation.hash"; + +/** + * The id of the build software attestation. + */ +static constexpr const char *kArtifactAttestationId = "artifact.attestation.id"; + +/** + * The human readable file name of the artifact, typically generated during build and release +processes. Often includes the package name and version in the file name. + * + *

Notes: +

  • This file name can also act as the Package Name in cases where the +package ecosystem maps accordingly. Additionally, the artifact can be published for others, +but that is not a guarantee.
+ */ +static constexpr const char *kArtifactFilename = "artifact.filename"; + +/** + * The full hash value (see +glossary), often found in checksum.txt on a release of the artifact and used to verify package +integrity. + * + *

Notes: +

  • The specific algorithm used to create the cryptographic hash value is +not defined. In situations where an artifact has multiple +cryptographic hashes, it is up to the implementer to choose which +hash value to set here; this should be the most secure hash algorithm +that is suitable for the situation and consistent with the +corresponding attestation. The implementer can then provide the other +hash values through an additional set of attribute extensions as they +deem necessary.
+ */ +static constexpr const char *kArtifactHash = "artifact.hash"; + +/** + * The Package URL of the package artifact provides a + * standard way to identify and locate the packaged artifact. + */ +static constexpr const char *kArtifactPurl = "artifact.purl"; + +/** + * The version of the artifact. + */ +static constexpr const char *kArtifactVersion = "artifact.version"; + /** * Rate-limiting result, shows whether the lease was acquired or contains a rejection reason */ @@ -397,6 +460,12 @@ href="https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part-copy.ht */ static constexpr const char *kAwsS3UploadId = "aws.s3.upload_id"; +/** + * The unique identifier of the service request. It's generated by the Azure service and returned + * with the response. + */ +static constexpr const char *kAzServiceRequestId = "az.service_request_id"; + /** * Array of brand name and version separated by a space * @@ -443,6 +512,39 @@ provides. */ static constexpr const char *kBrowserPlatform = "browser.platform"; +/** + * The human readable name of the pipeline within a CI/CD system. + */ +static constexpr const char *kCicdPipelineName = "cicd.pipeline.name"; + +/** + * The unique identifier of a pipeline run within a CI/CD system. + */ +static constexpr const char *kCicdPipelineRunId = "cicd.pipeline.run.id"; + +/** + * The human readable name of a task within a pipeline. Task here most closely aligns with a computing process in a pipeline. + * Other terms for tasks include commands, steps, and procedures. + */ +static constexpr const char *kCicdPipelineTaskName = "cicd.pipeline.task.name"; + +/** + * The unique identifier of a task run within a pipeline. + */ +static constexpr const char *kCicdPipelineTaskRunId = "cicd.pipeline.task.run.id"; + +/** + * The URL of the pipeline run providing the + * complete address in order to locate and identify the pipeline run. + */ +static constexpr const char *kCicdPipelineTaskRunUrlFull = "cicd.pipeline.task.run.url.full"; + +/** + * The type of the task within a pipeline. + */ +static constexpr const char *kCicdPipelineTaskType = "cicd.pipeline.task.type"; + /** * Client address - domain name if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name. @@ -523,7 +625,7 @@ Lambda: The function ARN. Take care not to use the "invoked ARN" directly but replace any alias suffix with -the resolved function version, as the same runtime instance may be invokable with multiple different +the resolved function version, as the same runtime instance may be invocable with multiple different aliases.
  • GCP: The URI of the resource
  • Azure: The identify Docker @@ -688,26 +785,36 @@ static constexpr const char *kContainerName = "container.name"; */ static constexpr const char *kContainerRuntime = "container.runtime"; +/** + * The mode of the CPU + */ +static constexpr const char *kCpuMode = "cpu.mode"; + /** * The name of the connection pool; unique within the instrumented application. In case the - * connection pool implementation doesn't provide a name, instrumentation should use a combination - * of {@code server.address} and {@code server.port} attributes formatted as {@code - * server.address:server.port}. + * connection pool implementation doesn't provide a name, instrumentation SHOULD use a combination + * of parameters that would make the name unique, for example, combining attributes {@code + * server.address}, {@code server.port}, and {@code db.namespace}, formatted as {@code + * server.address:server.port/db.namespace}. Instrumentations that generate connection pool name + * following different patterns SHOULD document it. */ -static constexpr const char *kDbClientConnectionsPoolName = "db.client.connections.pool.name"; +static constexpr const char *kDbClientConnectionPoolName = "db.client.connection.pool.name"; /** * The state of a connection in the pool */ -static constexpr const char *kDbClientConnectionsState = "db.client.connections.state"; +static constexpr const char *kDbClientConnectionState = "db.client.connection.state"; /** * The name of a collection (table, container) within the database. * *

    Notes: -

    • If the collection name is parsed from the query, it SHOULD match the value provided in -the query and may be qualified with the schema and database name. It is RECOMMENDED to capture the -value as provided by the application without attempting to do any case normalization.
    +
    • It is RECOMMENDED to capture the value as provided by the application without attempting +to do any case normalization. If the collection name is parsed from the query text, it SHOULD be the +first collection name found in the query and it SHOULD match the value provided in the query text +including any schema and database name prefix. For batch operations, if the individual operations +are known to have the same collection name then that collection name SHOULD be used, otherwise +{@code db.collection.name} SHOULD NOT be captured.
    */ static constexpr const char *kDbCollectionName = "db.collection.name"; @@ -725,17 +832,42 @@ provided by the application without attempting to do any case normalization.
  • batch operation. + * + *

    Notes: +

    • Operations are only considered batches when they contain two or more operations, and so + {@code db.operation.batch.size} SHOULD never be {@code 1}.
    + */ +static constexpr const char *kDbOperationBatchSize = "db.operation.batch.size"; + /** * The name of the operation or command being executed. * *

    Notes:

    • It is RECOMMENDED to capture the value as provided by the application without attempting - to do any case normalization.
    +to do any case normalization. If the operation name is parsed from the query text, it SHOULD be the +first operation name found in the query. For batch operations, if the individual operations are +known to have the same operation name then that operation name SHOULD be used prepended by {@code +BATCH}, otherwise {@code db.operation.name} SHOULD be {@code BATCH} or some other database system +specific term if more applicable. */ static constexpr const char *kDbOperationName = "db.operation.name"; /** * The database query being executed. + * + *

    Notes: +

    • For sanitization see Sanitization of {@code +db.query.text}. For batch operations, if the individual operations are known to have the same +query text then that query text SHOULD be used, otherwise all of the individual query texts SHOULD +be concatenated with separator {@code ;} or some other database system specific separator if more +applicable. Even though parameterized query text can potentially have sensitive data, by using a +parameterized query the user is giving a strong signal that any sensitive data will be passed as +parameter values, and the benefit to observability of capturing the static part of the query text by +default outweighs the risk.
    */ static constexpr const char *kDbQueryText = "db.query.text"; @@ -817,11 +949,6 @@ static constexpr const char *kDbCosmosdbStatusCode = "db.cosmosdb.status_code"; */ static constexpr const char *kDbCosmosdbSubStatusCode = "db.cosmosdb.sub_status_code"; -/** - * Represents the identifier of an Elasticsearch cluster. - */ -static constexpr const char *kDbElasticsearchClusterName = "db.elasticsearch.cluster.name"; - /** * Represents the human-readable identifier of the node/instance to which a request was routed. */ @@ -832,15 +959,30 @@ static constexpr const char *kDbElasticsearchNodeName = "db.elasticsearch.node.n environment (aka deployment tier). * *

    Notes: -

    • {@code deployment.environment} does not affect the uniqueness constraints defined through -the {@code service.namespace}, {@code service.name} and {@code service.instance.id} resource +
      • {@code deployment.environment.name} does not affect the uniqueness constraints defined +through the {@code service.namespace}, {@code service.name} and {@code service.instance.id} resource attributes. This implies that resources carrying the following attribute combinations MUST be considered to be identifying the same service:
      • {@code service.name=frontend}, {@code -deployment.environment=production}
      • {@code service.name=frontend}, {@code -deployment.environment=staging}.
      • +deployment.environment.name=production}
      • {@code service.name=frontend}, {@code +deployment.environment.name=staging}.
      */ -static constexpr const char *kDeploymentEnvironment = "deployment.environment"; +static constexpr const char *kDeploymentEnvironmentName = "deployment.environment.name"; + +/** + * The id of the deployment. + */ +static constexpr const char *kDeploymentId = "deployment.id"; + +/** + * The name of the deployment. + */ +static constexpr const char *kDeploymentName = "deployment.name"; + +/** + * The status of the deployment. + */ +static constexpr const char *kDeploymentStatus = "deployment.status"; /** * Deprecated use the {@code device.app.lifecycle} event definition including {@code android.state} @@ -853,6 +995,14 @@ static constexpr const char *kDeploymentEnvironment = "deployment.environment"; */ static constexpr const char *kAndroidState = "android.state"; +/** + * Deprecated, use {@code cpu.mode} instead. + * + * @deprecated Deprecated, use `cpu.mode` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kContainerCpuState = "container.cpu.state"; + /** * Deprecated, use {@code db.collection.name} instead. * @@ -877,6 +1027,14 @@ static constexpr const char *kDbConnectionString = "db.connection_string"; OPENTELEMETRY_DEPRECATED static constexpr const char *kDbCosmosdbContainer = "db.cosmosdb.container"; +/** + * Deprecated, use {@code db.namespace} instead. + * + * @deprecated Deprecated, use `db.namespace` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbElasticsearchClusterName = "db.elasticsearch.cluster.name"; + /** * Deprecated, no general replacement at this time. For Elasticsearch, use {@code * db.elasticsearch.node.name} instead. @@ -961,21 +1119,85 @@ OPENTELEMETRY_DEPRECATED static constexpr const char *kDbUser = "db.user"; /** - * Deprecated, use {@code db.client.connections.pool.name} instead. + * Deprecated, use {@code db.client.connection.pool.name} instead. + * + * @deprecated Deprecated, use `db.client.connection.pool.name` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbClientConnectionsPoolName = "db.client.connections.pool.name"; + +/** + * Deprecated, use {@code db.client.connection.state} instead. + * + * @deprecated Deprecated, use `db.client.connection.state` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbClientConnectionsState = "db.client.connections.state"; + +/** + * Deprecated, use {@code db.client.connection.pool.name} instead. * - * @deprecated Deprecated, use `db.client.connections.pool.name` instead. + * @deprecated Deprecated, use `db.client.connection.pool.name` instead. */ OPENTELEMETRY_DEPRECATED static constexpr const char *kPoolName = "pool.name"; /** - * Deprecated, use {@code db.client.connections.state} instead. + * Deprecated, use {@code db.client.connection.state} instead. * - * @deprecated Deprecated, use `db.client.connections.state` instead. + * @deprecated Deprecated, use `db.client.connection.state` instead. */ OPENTELEMETRY_DEPRECATED static constexpr const char *kState = "state"; +/** + * 'Deprecated, use {@code deployment.environment.name} instead.' + * + * @deprecated 'Deprecated, use `deployment.environment.name` instead.'. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDeploymentEnvironment = "deployment.environment"; + +/** + * Deprecated, use {@code user.id} instead. + * + * @deprecated Deprecated, use `user.id` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kEnduserId = "enduser.id"; + +/** + * Deprecated, use {@code user.roles} instead. + * + * @deprecated Deprecated, use `user.roles` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kEnduserRole = "enduser.role"; + +/** + * Deprecated, no replacement at this time. + * + * @deprecated Deprecated, no replacement at this time. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kEnduserScope = "enduser.scope"; + +/** + * Deprecated, use {@code gen_ai.usage.output_tokens} instead. + * + * @deprecated Deprecated, use `gen_ai.usage.output_tokens` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kGenAiUsageCompletionTokens = "gen_ai.usage.completion_tokens"; + +/** + * Deprecated, use {@code gen_ai.usage.input_tokens} instead. + * + * @deprecated Deprecated, use `gen_ai.usage.input_tokens` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kGenAiUsagePromptTokens = "gen_ai.usage.prompt_tokens"; + /** * Deprecated, use {@code client.address} instead. * @@ -1107,6 +1329,41 @@ static constexpr const char *kHttpUserAgent = "http.user_agent"; OPENTELEMETRY_DEPRECATED static constexpr const char *kIosState = "ios.state"; +/** + * Deprecated, no replacement at this time. + * + * @deprecated Deprecated, no replacement at this time. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingDestinationPublishAnonymous = + "messaging.destination_publish.anonymous"; + +/** + * Deprecated, no replacement at this time. + * + * @deprecated Deprecated, no replacement at this time. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingDestinationPublishName = + "messaging.destination_publish.name"; + +/** + * Deprecated, use {@code messaging.consumer.group.name} instead. + * + * @deprecated Deprecated, use `messaging.consumer.group.name` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingEventhubsConsumerGroup = + "messaging.eventhubs.consumer.group"; + +/** + * Deprecated, use {@code messaging.consumer.group.name} instead. + * + * @deprecated Deprecated, use `messaging.consumer.group.name` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingKafkaConsumerGroup = "messaging.kafka.consumer.group"; + /** * Deprecated, use {@code messaging.destination.partition.id} instead. * @@ -1116,6 +1373,14 @@ OPENTELEMETRY_DEPRECATED static constexpr const char *kMessagingKafkaDestinationPartition = "messaging.kafka.destination.partition"; +/** + * Deprecated, use {@code messaging.kafka.offset} instead. + * + * @deprecated Deprecated, use `messaging.kafka.offset` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingKafkaMessageOffset = "messaging.kafka.message.offset"; + /** * Deprecated, use {@code messaging.operation.type} instead. * @@ -1124,6 +1389,23 @@ static constexpr const char *kMessagingKafkaDestinationPartition = OPENTELEMETRY_DEPRECATED static constexpr const char *kMessagingOperation = "messaging.operation"; +/** + * Deprecated, use {@code messaging.consumer.group.name} instead. + * + * @deprecated Deprecated, use `messaging.consumer.group.name` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingRocketmqClientGroup = "messaging.rocketmq.client_group"; + +/** + * Deprecated, use {@code messaging.servicebus.destination.subscription_name} instead. + * + * @deprecated Deprecated, use `messaging.servicebus.destination.subscription_name` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingServicebusDestinationSubscriptionName = + "messaging.servicebus.destination.subscription_name"; + /** * Deprecated, use {@code network.local.address}. * @@ -1247,21 +1529,29 @@ OPENTELEMETRY_DEPRECATED static constexpr const char *kNetTransport = "net.transport"; /** - * None * - * @deprecated None. + * + * @deprecated . */ OPENTELEMETRY_DEPRECATED static constexpr const char *kOtelLibraryName = "otel.library.name"; /** - * None * - * @deprecated None. + * + * @deprecated . */ OPENTELEMETRY_DEPRECATED static constexpr const char *kOtelLibraryVersion = "otel.library.version"; +/** + * Deprecated, use {@code cpu.mode} instead. + * + * @deprecated Deprecated, use `cpu.mode` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kProcessCpuState = "process.cpu.state"; + /** * Deprecated, use {@code rpc.message.compressed_size} instead. * @@ -1294,6 +1584,14 @@ static constexpr const char *kMessageType = "message.type"; OPENTELEMETRY_DEPRECATED static constexpr const char *kMessageUncompressedSize = "message.uncompressed_size"; +/** + * Deprecated, use {@code cpu.mode} instead. + * + * @deprecated Deprecated, use `cpu.mode` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kSystemCpuState = "system.cpu.state"; + /** * Deprecated, use {@code system.process.status} instead. * @@ -1302,6 +1600,14 @@ static constexpr const char *kMessageUncompressedSize = "message.uncompressed_si OPENTELEMETRY_DEPRECATED static constexpr const char *kSystemProcessesStatus = "system.processes.status"; +/** + * Deprecated, use {@code server.address} instead. + * + * @deprecated Deprecated, use `server.address` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kTlsClientServerName = "tls.client.server_name"; + /** * Destination address - domain name if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name. @@ -1380,29 +1686,6 @@ static constexpr const char *kDiskIoDirection = "disk.io.direction"; */ static constexpr const char *kDnsQuestionName = "dns.question.name"; -/** - * Username or client_id extracted from the access token or Authorization header in the inbound - * request from outside the system. - */ -static constexpr const char *kEnduserId = "enduser.id"; - -/** - * Actual/assumed role the client is making the request under extracted from token or application - * security context. - */ -static constexpr const char *kEnduserRole = "enduser.role"; - -/** - * Scopes or granted authorities the client currently possesses extracted from token or application - * security context. The value would come from the scope associated with an OAuth 2.0 Access Token or an attribute - * value in a SAML 2.0 - * Assertion. - */ -static constexpr const char *kEnduserScope = "enduser.scope"; - /** * Describes a class of error the operation ended with. * @@ -1428,9 +1711,9 @@ static constexpr const char *kErrorType = "error.type"; * *

      Notes:

      • Event names are subject to the same rules as attribute - names. Notably, event names are namespaced to avoid collisions and provide a clean separation - of semantics for events in separate domains like browser, mobile, and kubernetes.
      + href="/docs/general/attribute-naming.md">attribute names. Notably, event names are namespaced + to avoid collisions and provide a clean separation of semantics for events in separate domains like + browser, mobile, and kubernetes.
    */ static constexpr const char *kEventName = "event.name"; @@ -1665,6 +1948,16 @@ static constexpr const char *kFilePath = "file.path"; */ static constexpr const char *kFileSize = "file.size"; +/** + * Identifies the Google Cloud service for which the official client library is intended. + * + *

    Notes: +

    • Intended to be a stable identifier for Google Cloud client libraries that is uniform + across implementation languages. The value should be derived from the canonical service domain for + the service; for example, 'foo.googleapis.com' should result in a value of 'foo'.
    + */ +static constexpr const char *kGcpClientService = "gcp.client.service"; + /** * The name of the Cloud Run execution being run for the @@ -1697,7 +1990,7 @@ static constexpr const char *kGcpGceInstanceHostname = "gcp.gce.instance.hostnam static constexpr const char *kGcpGceInstanceName = "gcp.gce.instance.name"; /** - * The full response received from the LLM. + * The full response received from the GenAI model. * *

    Notes:

    */ static constexpr const char *kDbOperationName = "db.operation.name"; /** * The database query being executed. + * + *

    Notes: +

    • For sanitization see Sanitization of {@code +db.query.text}. For batch operations, if the individual operations are known to have the same +query text then that query text SHOULD be used, otherwise all of the individual query texts SHOULD +be concatenated with separator {@code ;} or some other database system specific separator if more +applicable. Even though parameterized query text can potentially have sensitive data, by using a +parameterized query the user is giving a strong signal that any sensitive data will be passed as +parameter values, and the benefit to observability of capturing the static part of the query text by +default outweighs the risk.
    */ static constexpr const char *kDbQueryText = "db.query.text"; @@ -819,11 +951,6 @@ static constexpr const char *kDbCosmosdbStatusCode = "db.cosmosdb.status_code"; */ static constexpr const char *kDbCosmosdbSubStatusCode = "db.cosmosdb.sub_status_code"; -/** - * Represents the identifier of an Elasticsearch cluster. - */ -static constexpr const char *kDbElasticsearchClusterName = "db.elasticsearch.cluster.name"; - /** * Represents the human-readable identifier of the node/instance to which a request was routed. */ @@ -834,15 +961,30 @@ static constexpr const char *kDbElasticsearchNodeName = "db.elasticsearch.node.n environment (aka deployment tier). * *

    Notes: -

    • {@code deployment.environment} does not affect the uniqueness constraints defined through -the {@code service.namespace}, {@code service.name} and {@code service.instance.id} resource +
      • {@code deployment.environment.name} does not affect the uniqueness constraints defined +through the {@code service.namespace}, {@code service.name} and {@code service.instance.id} resource attributes. This implies that resources carrying the following attribute combinations MUST be considered to be identifying the same service:
      • {@code service.name=frontend}, {@code -deployment.environment=production}
      • {@code service.name=frontend}, {@code -deployment.environment=staging}.
      • +deployment.environment.name=production}
      • {@code service.name=frontend}, {@code +deployment.environment.name=staging}.
      */ -static constexpr const char *kDeploymentEnvironment = "deployment.environment"; +static constexpr const char *kDeploymentEnvironmentName = "deployment.environment.name"; + +/** + * The id of the deployment. + */ +static constexpr const char *kDeploymentId = "deployment.id"; + +/** + * The name of the deployment. + */ +static constexpr const char *kDeploymentName = "deployment.name"; + +/** + * The status of the deployment. + */ +static constexpr const char *kDeploymentStatus = "deployment.status"; /** * Deprecated use the {@code device.app.lifecycle} event definition including {@code android.state} @@ -855,6 +997,14 @@ static constexpr const char *kDeploymentEnvironment = "deployment.environment"; */ static constexpr const char *kAndroidState = "android.state"; +/** + * Deprecated, use {@code cpu.mode} instead. + * + * @deprecated Deprecated, use `cpu.mode` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kContainerCpuState = "container.cpu.state"; + /** * Deprecated, use {@code db.collection.name} instead. * @@ -879,6 +1029,14 @@ static constexpr const char *kDbConnectionString = "db.connection_string"; OPENTELEMETRY_DEPRECATED static constexpr const char *kDbCosmosdbContainer = "db.cosmosdb.container"; +/** + * Deprecated, use {@code db.namespace} instead. + * + * @deprecated Deprecated, use `db.namespace` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbElasticsearchClusterName = "db.elasticsearch.cluster.name"; + /** * Deprecated, no general replacement at this time. For Elasticsearch, use {@code * db.elasticsearch.node.name} instead. @@ -963,21 +1121,85 @@ OPENTELEMETRY_DEPRECATED static constexpr const char *kDbUser = "db.user"; /** - * Deprecated, use {@code db.client.connections.pool.name} instead. + * Deprecated, use {@code db.client.connection.pool.name} instead. + * + * @deprecated Deprecated, use `db.client.connection.pool.name` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbClientConnectionsPoolName = "db.client.connections.pool.name"; + +/** + * Deprecated, use {@code db.client.connection.state} instead. + * + * @deprecated Deprecated, use `db.client.connection.state` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbClientConnectionsState = "db.client.connections.state"; + +/** + * Deprecated, use {@code db.client.connection.pool.name} instead. * - * @deprecated Deprecated, use `db.client.connections.pool.name` instead. + * @deprecated Deprecated, use `db.client.connection.pool.name` instead. */ OPENTELEMETRY_DEPRECATED static constexpr const char *kPoolName = "pool.name"; /** - * Deprecated, use {@code db.client.connections.state} instead. + * Deprecated, use {@code db.client.connection.state} instead. * - * @deprecated Deprecated, use `db.client.connections.state` instead. + * @deprecated Deprecated, use `db.client.connection.state` instead. */ OPENTELEMETRY_DEPRECATED static constexpr const char *kState = "state"; +/** + * 'Deprecated, use {@code deployment.environment.name} instead.' + * + * @deprecated 'Deprecated, use `deployment.environment.name` instead.'. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDeploymentEnvironment = "deployment.environment"; + +/** + * Deprecated, use {@code user.id} instead. + * + * @deprecated Deprecated, use `user.id` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kEnduserId = "enduser.id"; + +/** + * Deprecated, use {@code user.roles} instead. + * + * @deprecated Deprecated, use `user.roles` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kEnduserRole = "enduser.role"; + +/** + * Deprecated, no replacement at this time. + * + * @deprecated Deprecated, no replacement at this time. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kEnduserScope = "enduser.scope"; + +/** + * Deprecated, use {@code gen_ai.usage.output_tokens} instead. + * + * @deprecated Deprecated, use `gen_ai.usage.output_tokens` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kGenAiUsageCompletionTokens = "gen_ai.usage.completion_tokens"; + +/** + * Deprecated, use {@code gen_ai.usage.input_tokens} instead. + * + * @deprecated Deprecated, use `gen_ai.usage.input_tokens` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kGenAiUsagePromptTokens = "gen_ai.usage.prompt_tokens"; + /** * Deprecated, use {@code client.address} instead. * @@ -1109,6 +1331,41 @@ static constexpr const char *kHttpUserAgent = "http.user_agent"; OPENTELEMETRY_DEPRECATED static constexpr const char *kIosState = "ios.state"; +/** + * Deprecated, no replacement at this time. + * + * @deprecated Deprecated, no replacement at this time. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingDestinationPublishAnonymous = + "messaging.destination_publish.anonymous"; + +/** + * Deprecated, no replacement at this time. + * + * @deprecated Deprecated, no replacement at this time. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingDestinationPublishName = + "messaging.destination_publish.name"; + +/** + * Deprecated, use {@code messaging.consumer.group.name} instead. + * + * @deprecated Deprecated, use `messaging.consumer.group.name` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingEventhubsConsumerGroup = + "messaging.eventhubs.consumer.group"; + +/** + * Deprecated, use {@code messaging.consumer.group.name} instead. + * + * @deprecated Deprecated, use `messaging.consumer.group.name` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingKafkaConsumerGroup = "messaging.kafka.consumer.group"; + /** * Deprecated, use {@code messaging.destination.partition.id} instead. * @@ -1118,6 +1375,14 @@ OPENTELEMETRY_DEPRECATED static constexpr const char *kMessagingKafkaDestinationPartition = "messaging.kafka.destination.partition"; +/** + * Deprecated, use {@code messaging.kafka.offset} instead. + * + * @deprecated Deprecated, use `messaging.kafka.offset` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingKafkaMessageOffset = "messaging.kafka.message.offset"; + /** * Deprecated, use {@code messaging.operation.type} instead. * @@ -1126,6 +1391,23 @@ static constexpr const char *kMessagingKafkaDestinationPartition = OPENTELEMETRY_DEPRECATED static constexpr const char *kMessagingOperation = "messaging.operation"; +/** + * Deprecated, use {@code messaging.consumer.group.name} instead. + * + * @deprecated Deprecated, use `messaging.consumer.group.name` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingRocketmqClientGroup = "messaging.rocketmq.client_group"; + +/** + * Deprecated, use {@code messaging.servicebus.destination.subscription_name} instead. + * + * @deprecated Deprecated, use `messaging.servicebus.destination.subscription_name` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingServicebusDestinationSubscriptionName = + "messaging.servicebus.destination.subscription_name"; + /** * Deprecated, use {@code network.local.address}. * @@ -1249,21 +1531,29 @@ OPENTELEMETRY_DEPRECATED static constexpr const char *kNetTransport = "net.transport"; /** - * None * - * @deprecated None. + * + * @deprecated . */ OPENTELEMETRY_DEPRECATED static constexpr const char *kOtelLibraryName = "otel.library.name"; /** - * None * - * @deprecated None. + * + * @deprecated . */ OPENTELEMETRY_DEPRECATED static constexpr const char *kOtelLibraryVersion = "otel.library.version"; +/** + * Deprecated, use {@code cpu.mode} instead. + * + * @deprecated Deprecated, use `cpu.mode` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kProcessCpuState = "process.cpu.state"; + /** * Deprecated, use {@code rpc.message.compressed_size} instead. * @@ -1296,6 +1586,14 @@ static constexpr const char *kMessageType = "message.type"; OPENTELEMETRY_DEPRECATED static constexpr const char *kMessageUncompressedSize = "message.uncompressed_size"; +/** + * Deprecated, use {@code cpu.mode} instead. + * + * @deprecated Deprecated, use `cpu.mode` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kSystemCpuState = "system.cpu.state"; + /** * Deprecated, use {@code system.process.status} instead. * @@ -1304,6 +1602,14 @@ static constexpr const char *kMessageUncompressedSize = "message.uncompressed_si OPENTELEMETRY_DEPRECATED static constexpr const char *kSystemProcessesStatus = "system.processes.status"; +/** + * Deprecated, use {@code server.address} instead. + * + * @deprecated Deprecated, use `server.address` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kTlsClientServerName = "tls.client.server_name"; + /** * Destination address - domain name if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name. @@ -1382,29 +1688,6 @@ static constexpr const char *kDiskIoDirection = "disk.io.direction"; */ static constexpr const char *kDnsQuestionName = "dns.question.name"; -/** - * Username or client_id extracted from the access token or Authorization header in the inbound - * request from outside the system. - */ -static constexpr const char *kEnduserId = "enduser.id"; - -/** - * Actual/assumed role the client is making the request under extracted from token or application - * security context. - */ -static constexpr const char *kEnduserRole = "enduser.role"; - -/** - * Scopes or granted authorities the client currently possesses extracted from token or application - * security context. The value would come from the scope associated with an OAuth 2.0 Access Token or an attribute - * value in a SAML 2.0 - * Assertion. - */ -static constexpr const char *kEnduserScope = "enduser.scope"; - /** * Describes a class of error the operation ended with. * @@ -1430,9 +1713,9 @@ static constexpr const char *kErrorType = "error.type"; * *

      Notes:

      • Event names are subject to the same rules as attribute - names. Notably, event names are namespaced to avoid collisions and provide a clean separation - of semantics for events in separate domains like browser, mobile, and kubernetes.
      + href="/docs/general/attribute-naming.md">attribute names. Notably, event names are namespaced + to avoid collisions and provide a clean separation of semantics for events in separate domains like + browser, mobile, and kubernetes.
    */ static constexpr const char *kEventName = "event.name"; @@ -1667,6 +1950,16 @@ static constexpr const char *kFilePath = "file.path"; */ static constexpr const char *kFileSize = "file.size"; +/** + * Identifies the Google Cloud service for which the official client library is intended. + * + *

    Notes: +

    • Intended to be a stable identifier for Google Cloud client libraries that is uniform + across implementation languages. The value should be derived from the canonical service domain for + the service; for example, 'foo.googleapis.com' should result in a value of 'foo'.
    + */ +static constexpr const char *kGcpClientService = "gcp.client.service"; + /** * The name of the Cloud Run execution being run for the @@ -1699,7 +1992,7 @@ static constexpr const char *kGcpGceInstanceHostname = "gcp.gce.instance.hostnam static constexpr const char *kGcpGceInstanceName = "gcp.gce.instance.name"; /** - * The full response received from the LLM. + * The full response received from the GenAI model. * *

    Notes:

    • It's RECOMMENDED to format completions as JSON string matching Notes: +
      • If one of the predefined values applies, but specific system uses a different name it's + RECOMMENDED to document it in the semantic conventions for specific GenAI system and use + system-specific name in the instrumentation. If a different name is not documented, instrumentation + libraries SHOULD use applicable predefined value.
      + */ +static constexpr const char *kGenAiOperationName = "gen_ai.operation.name"; + +/** + * The full prompt sent to the GenAI model. * *

      Notes:

      • It's RECOMMENDED to format prompts as JSON string matching Notes: -
        • The actual GenAI product may differ from the one identified by the client. For example, - when using OpenAI client libraries to communicate with Mistral, the {@code gen_ai.system} is set to - {@code openai} based on the instrumentation's best knowledge.
        +
        • The {@code gen_ai.system} describes a family of GenAI models with specific model +identified by {@code gen_ai.request.model} and {@code gen_ai.response.model} attributes.
        • The +actual GenAI product may differ from the one identified by the client. For example, when using +OpenAI client libraries to communicate with Mistral, the {@code gen_ai.system} is set to {@code +openai} based on the instrumentation's best knowledge.
        • For custom model, a custom friendly +name SHOULD be used. If none of these options apply, the {@code gen_ai.system} SHOULD be set to +{@code _OTHER}.
        */ static constexpr const char *kGenAiSystem = "gen_ai.system"; /** - * The number of tokens used in the LLM response (completion). + * The type of token being counted. */ -static constexpr const char *kGenAiUsageCompletionTokens = "gen_ai.usage.completion_tokens"; +static constexpr const char *kGenAiTokenType = "gen_ai.token.type"; /** - * The number of tokens used in the LLM prompt. + * The number of tokens used in the GenAI input (prompt). */ -static constexpr const char *kGenAiUsagePromptTokens = "gen_ai.usage.prompt_tokens"; +static constexpr const char *kGenAiUsageInputTokens = "gen_ai.usage.input_tokens"; + +/** + * The number of tokens used in the GenAI response (completion). + */ +static constexpr const char *kGenAiUsageOutputTokens = "gen_ai.usage.output_tokens"; + +/** + * The type of memory. + */ +static constexpr const char *kGoMemoryType = "go.memory.type"; /** * The GraphQL document being executed. @@ -2178,6 +2516,11 @@ static constexpr const char *kK8sStatefulsetName = "k8s.statefulset.name"; */ static constexpr const char *kK8sStatefulsetUid = "k8s.statefulset.uid"; +/** + * The Linux Slab memory state + */ +static constexpr const char *kLinuxMemorySlabState = "linux.memory.slab.state"; + /** * The stream associated with the log. See below for a list of well-known values. */ @@ -2203,6 +2546,16 @@ static constexpr const char *kLogFilePath = "log.file.path"; */ static constexpr const char *kLogFilePathResolved = "log.file.path_resolved"; +/** + * The complete orignal Log Record. + * + *

        Notes: +

        • This value MAY be added when processing a Log Record which was originally transmitted as + a string or equivalent data type AND the Body field of the Log Record does not contain the same + value. (e.g. a syslog or a log record read from a file.)
        + */ +static constexpr const char *kLogRecordOriginal = "log.record.original"; + /** * A unique identifier for the Log Record. * @@ -2231,6 +2584,16 @@ static constexpr const char *kMessagingBatchMessageCount = "messaging.batch.mess */ static constexpr const char *kMessagingClientId = "messaging.client.id"; +/** + * The name of the consumer group with which a consumer is associated. + * + *

        Notes: +

        • Semantic conventions for individual messaging systems SHOULD document whether {@code + messaging.consumer.group.name} is applicable and what it means in the context of that system.
        • +
        + */ +static constexpr const char *kMessagingConsumerGroupName = "messaging.consumer.group.name"; + /** * A boolean that is true if the message destination is anonymous (could be unnamed or have * auto-generated name). @@ -2254,6 +2617,17 @@ static constexpr const char *kMessagingDestinationName = "messaging.destination. static constexpr const char *kMessagingDestinationPartitionId = "messaging.destination.partition.id"; +/** + * The name of the destination subscription from which a message is consumed. + * + *

        Notes: +

        • Semantic conventions for individual messaging systems SHOULD document whether {@code + messaging.destination.subscription.name} is applicable and what it means in the context of that + system.
        + */ +static constexpr const char *kMessagingDestinationSubscriptionName = + "messaging.destination.subscription.name"; + /** * Low cardinality representation of the messaging destination name * @@ -2271,24 +2645,6 @@ static constexpr const char *kMessagingDestinationTemplate = "messaging.destinat */ static constexpr const char *kMessagingDestinationTemporary = "messaging.destination.temporary"; -/** - * A boolean that is true if the publish message destination is anonymous (could be unnamed or have - * auto-generated name). - */ -static constexpr const char *kMessagingDestinationPublishAnonymous = - "messaging.destination_publish.anonymous"; - -/** - * The name of the original destination the message was published to - * - *

        Notes: -

        • The name SHOULD uniquely identify a specific queue, topic, or other entity within the -broker. If the broker doesn't have such notion, the original destination name SHOULD uniquely -identify the broker.
        - */ -static constexpr const char *kMessagingDestinationPublishName = - "messaging.destination_publish.name"; - /** * The size of the message body in bytes. * @@ -2341,12 +2697,6 @@ static constexpr const char *kMessagingOperationType = "messaging.operation.type */ static constexpr const char *kMessagingSystem = "messaging.system"; -/** - * Name of the Kafka Consumer Group that is handling the message. Only applies to consumers, not - * producers. - */ -static constexpr const char *kMessagingKafkaConsumerGroup = "messaging.kafka.consumer.group"; - /** * Message keys in Kafka are used for grouping alike messages to ensure they're processed on the same partition. They differ from {@code messaging.message.id} in that they're not unique. If the @@ -2360,14 +2710,14 @@ static constexpr const char *kMessagingKafkaConsumerGroup = "messaging.kafka.con static constexpr const char *kMessagingKafkaMessageKey = "messaging.kafka.message.key"; /** - * The offset of a record in the corresponding Kafka partition. + * A boolean that is true if the message is a tombstone. */ -static constexpr const char *kMessagingKafkaMessageOffset = "messaging.kafka.message.offset"; +static constexpr const char *kMessagingKafkaMessageTombstone = "messaging.kafka.message.tombstone"; /** - * A boolean that is true if the message is a tombstone. + * The offset of a record in the corresponding Kafka partition. */ -static constexpr const char *kMessagingKafkaMessageTombstone = "messaging.kafka.message.tombstone"; +static constexpr const char *kMessagingKafkaOffset = "messaging.kafka.offset"; /** * RabbitMQ message routing key. @@ -2381,12 +2731,6 @@ static constexpr const char *kMessagingRabbitmqDestinationRoutingKey = static constexpr const char *kMessagingRabbitmqMessageDeliveryTag = "messaging.rabbitmq.message.delivery_tag"; -/** - * Name of the RocketMQ producer/consumer group that is handling the message. The client type is - * identified by the SpanKind. - */ -static constexpr const char *kMessagingRocketmqClientGroup = "messaging.rocketmq.client_group"; - /** * Model of message consumption. This only applies to consumer spans. */ @@ -2456,12 +2800,6 @@ static constexpr const char *kMessagingGcpPubsubMessageDeliveryAttempt = static constexpr const char *kMessagingGcpPubsubMessageOrderingKey = "messaging.gcp_pubsub.message.ordering_key"; -/** - * The name of the subscription in the topic messages are received from. - */ -static constexpr const char *kMessagingServicebusDestinationSubscriptionName = - "messaging.servicebus.destination.subscription_name"; - /** * Describes the
        settlement @@ -2482,12 +2820,6 @@ static constexpr const char *kMessagingServicebusMessageDeliveryCount = static constexpr const char *kMessagingServicebusMessageEnqueuedTime = "messaging.servicebus.message.enqueued_time"; -/** - * The name of the consumer group the event consumer is associated with. - */ -static constexpr const char *kMessagingEventhubsConsumerGroup = - "messaging.eventhubs.consumer.group"; - /** * The UTC epoch seconds at which the message has been accepted and stored in the entity. */ @@ -2771,8 +3103,7 @@ static constexpr const char *kProcessRealUserName = "process.real_user.name"; static constexpr const char *kProcessRuntimeDescription = "process.runtime.description"; /** - * The name of the runtime of this process. For compiled native binaries, this SHOULD be the name of - * the compiler. + * The name of the runtime of this process. */ static constexpr const char *kProcessRuntimeName = "process.runtime.name"; @@ -2816,11 +3147,6 @@ static constexpr const char *kProcessUserName = "process.user.name"; */ static constexpr const char *kProcessVpid = "process.vpid"; -/** - * The CPU state of the process. - */ -static constexpr const char *kProcessCpuState = "process.cpu.state"; - /** * The error codes of the Connect * request. Error codes are always string values. @@ -3040,11 +3366,6 @@ static constexpr const char *kSystemDevice = "system.device"; */ static constexpr const char *kSystemCpuLogicalNumber = "system.cpu.logical_number"; -/** - * The state of the CPU - */ -static constexpr const char *kSystemCpuState = "system.cpu.state"; - /** * The memory state */ @@ -3136,6 +3457,27 @@ static constexpr const char *kTelemetryDistroName = "telemetry.distro.name"; */ static constexpr const char *kTelemetryDistroVersion = "telemetry.distro.version"; +/** + * The fully qualified human readable name of the test case. + */ +static constexpr const char *kTestCaseName = "test.case.name"; + +/** + * The status of the actual test case result from test execution. + */ +static constexpr const char *kTestCaseResultStatus = "test.case.result.status"; + +/** + * The human readable name of a test suite. + */ +static constexpr const char *kTestSuiteName = "test.suite.name"; + +/** + * The status of the test suite run. + */ +static constexpr const char *kTestSuiteRunStatus = "test.suite.run.status"; + /** * Current "managed" thread ID (as opposed to OS thread ID). */ @@ -3215,12 +3557,6 @@ static constexpr const char *kTlsClientNotAfter = "tls.client.not_after"; */ static constexpr const char *kTlsClientNotBefore = "tls.client.not_before"; -/** - * Also called an SNI, this tells the server which hostname to which the client is attempting to - * connect to. - */ -static constexpr const char *kTlsClientServerName = "tls.client.server_name"; - /** * Distinguished name of subject of the x.509 certificate presented by the client. */ @@ -3483,6 +3819,102 @@ static constexpr const char *kUserAgentOriginal = "user_agent.original"; */ static constexpr const char *kUserAgentVersion = "user_agent.version"; +/** + * User email address. + */ +static constexpr const char *kUserEmail = "user.email"; + +/** + * User's full name + */ +static constexpr const char *kUserFullName = "user.full_name"; + +/** + * Unique user hash to correlate information for a user in anonymized form. + * + *

        Notes: +

        • Useful if {@code user.id} or {@code user.name} contain confidential information and + cannot be used.
        + */ +static constexpr const char *kUserHash = "user.hash"; + +/** + * Unique identifier of the user. + */ +static constexpr const char *kUserId = "user.id"; + +/** + * Short name or login/username of the user. + */ +static constexpr const char *kUserName = "user.name"; + +/** + * Array of user roles at the time of the event. + */ +static constexpr const char *kUserRoles = "user.roles"; + +/** + * The type of garbage collection. + */ +static constexpr const char *kV8jsGcType = "v8js.gc.type"; + +/** + * The name of the space type of heap memory. + * + *

        Notes: +

        + */ +static constexpr const char *kV8jsHeapSpaceName = "v8js.heap.space.name"; + +/** + * The ID of the change (pull request/merge request) if applicable. This is usually a unique (within + * repository) identifier generated by the VCS system. + */ +static constexpr const char *kVcsRepositoryChangeId = "vcs.repository.change.id"; + +/** + * The human readable title of the change (pull request/merge request). This title is often a brief + * summary of the change and may get merged in to a ref as the commit summary. + */ +static constexpr const char *kVcsRepositoryChangeTitle = "vcs.repository.change.title"; + +/** + * The name of the reference such as + * branch or tag in the repository. + */ +static constexpr const char *kVcsRepositoryRefName = "vcs.repository.ref.name"; + +/** + * The revision, literally revised +version, The revision most often refers to a commit object in Git, or a revision number in SVN. + * + *

        Notes: +

        • The revision can be a full hash value (see glossary), of +the recorded change to a ref within a repository pointing to a commit commit object. It does not necessarily have to be a +hash; it can simply define a revision number which +is an integer that is monotonically increasing. In cases where it is identical to the {@code +ref.name}, it SHOULD still be included. It is up to the implementer to decide which value to set as +the revision based on the VCS system and situational context.
        + */ +static constexpr const char *kVcsRepositoryRefRevision = "vcs.repository.ref.revision"; + +/** + * The type of the reference in the + * repository. + */ +static constexpr const char *kVcsRepositoryRefType = "vcs.repository.ref.type"; + +/** + * The URL of the repository providing the complete + * address in order to locate and identify the repository. + */ +static constexpr const char *kVcsRepositoryUrlFull = "vcs.repository.url.full"; + /** * Additional description of the web engine (e.g. detailed version and edition information). */ @@ -3539,6 +3971,16 @@ static constexpr const char *kEc2 = "ec2"; static constexpr const char *kFargate = "fargate"; } // namespace AwsEcsLaunchtypeValues +namespace CicdPipelineTaskTypeValues +{ +/** build. */ +static constexpr const char *kBuild = "build"; +/** test. */ +static constexpr const char *kTest = "test"; +/** deploy. */ +static constexpr const char *kDeploy = "deploy"; +} // namespace CicdPipelineTaskTypeValues + namespace CloudPlatformValues { /** Alibaba Cloud Elastic Compute Service. */ @@ -3617,132 +4059,144 @@ static constexpr const char *kIbmCloud = "ibm_cloud"; static constexpr const char *kTencentCloud = "tencent_cloud"; } // namespace CloudProviderValues -namespace ContainerCpuStateValues +namespace CpuModeValues { -/** When tasks of the cgroup are in user mode (Linux). When all container processes are in user mode - * (Windows). */ +/** user. */ static constexpr const char *kUser = "user"; -/** When CPU is used by the system (host OS). */ +/** system. */ static constexpr const char *kSystem = "system"; -/** When tasks of the cgroup are in kernel mode (Linux). When all container processes are in kernel - * mode (Windows). */ +/** nice. */ +static constexpr const char *kNice = "nice"; +/** idle. */ +static constexpr const char *kIdle = "idle"; +/** iowait. */ +static constexpr const char *kIowait = "iowait"; +/** interrupt. */ +static constexpr const char *kInterrupt = "interrupt"; +/** steal. */ +static constexpr const char *kSteal = "steal"; +/** kernel. */ static constexpr const char *kKernel = "kernel"; -} // namespace ContainerCpuStateValues +} // namespace CpuModeValues -namespace DbClientConnectionsStateValues +namespace DbClientConnectionStateValues { /** idle. */ static constexpr const char *kIdle = "idle"; /** used. */ static constexpr const char *kUsed = "used"; -} // namespace DbClientConnectionsStateValues +} // namespace DbClientConnectionStateValues namespace DbSystemValues { /** Some other SQL database. Fallback only. See notes. */ static constexpr const char *kOtherSql = "other_sql"; -/** Microsoft SQL Server. */ -static constexpr const char *kMssql = "mssql"; -/** Microsoft SQL Server Compact. */ -static constexpr const char *kMssqlcompact = "mssqlcompact"; -/** MySQL. */ -static constexpr const char *kMysql = "mysql"; -/** Oracle Database. */ -static constexpr const char *kOracle = "oracle"; -/** IBM Db2. */ -static constexpr const char *kDb2 = "db2"; -/** PostgreSQL. */ -static constexpr const char *kPostgresql = "postgresql"; -/** Amazon Redshift. */ -static constexpr const char *kRedshift = "redshift"; -/** Apache Hive. */ -static constexpr const char *kHive = "hive"; -/** Cloudscape. */ -static constexpr const char *kCloudscape = "cloudscape"; -/** HyperSQL DataBase. */ -static constexpr const char *kHsqldb = "hsqldb"; -/** Progress Database. */ -static constexpr const char *kProgress = "progress"; -/** SAP MaxDB. */ -static constexpr const char *kMaxdb = "maxdb"; -/** SAP HANA. */ -static constexpr const char *kHanadb = "hanadb"; -/** Ingres. */ -static constexpr const char *kIngres = "ingres"; -/** FirstSQL. */ -static constexpr const char *kFirstsql = "firstsql"; -/** EnterpriseDB. */ -static constexpr const char *kEdb = "edb"; -/** InterSystems Caché. */ -static constexpr const char *kCache = "cache"; /** Adabas (Adaptable Database System). */ static constexpr const char *kAdabas = "adabas"; -/** Firebird. */ -static constexpr const char *kFirebird = "firebird"; +/** Deprecated, use `intersystems_cache` instead. */ +static constexpr const char *kCache = "cache"; +/** InterSystems Caché. */ +static constexpr const char *kIntersystemsCache = "intersystems_cache"; +/** Apache Cassandra. */ +static constexpr const char *kCassandra = "cassandra"; +/** ClickHouse. */ +static constexpr const char *kClickhouse = "clickhouse"; +/** Deprecated, use `other_sql` instead. */ +static constexpr const char *kCloudscape = "cloudscape"; +/** CockroachDB. */ +static constexpr const char *kCockroachdb = "cockroachdb"; +/** Deprecated, no replacement at this time. */ +static constexpr const char *kColdfusion = "coldfusion"; +/** Microsoft Azure Cosmos DB. */ +static constexpr const char *kCosmosdb = "cosmosdb"; +/** Couchbase. */ +static constexpr const char *kCouchbase = "couchbase"; +/** CouchDB. */ +static constexpr const char *kCouchdb = "couchdb"; +/** IBM Db2. */ +static constexpr const char *kDb2 = "db2"; /** Apache Derby. */ static constexpr const char *kDerby = "derby"; +/** Amazon DynamoDB. */ +static constexpr const char *kDynamodb = "dynamodb"; +/** EnterpriseDB. */ +static constexpr const char *kEdb = "edb"; +/** Elasticsearch. */ +static constexpr const char *kElasticsearch = "elasticsearch"; /** FileMaker. */ static constexpr const char *kFilemaker = "filemaker"; +/** Firebird. */ +static constexpr const char *kFirebird = "firebird"; +/** Deprecated, use `other_sql` instead. */ +static constexpr const char *kFirstsql = "firstsql"; +/** Apache Geode. */ +static constexpr const char *kGeode = "geode"; +/** H2. */ +static constexpr const char *kH2 = "h2"; +/** SAP HANA. */ +static constexpr const char *kHanadb = "hanadb"; +/** Apache HBase. */ +static constexpr const char *kHbase = "hbase"; +/** Apache Hive. */ +static constexpr const char *kHive = "hive"; +/** HyperSQL DataBase. */ +static constexpr const char *kHsqldb = "hsqldb"; +/** InfluxDB. */ +static constexpr const char *kInfluxdb = "influxdb"; /** Informix. */ static constexpr const char *kInformix = "informix"; +/** Ingres. */ +static constexpr const char *kIngres = "ingres"; /** InstantDB. */ static constexpr const char *kInstantdb = "instantdb"; /** InterBase. */ static constexpr const char *kInterbase = "interbase"; /** MariaDB. */ static constexpr const char *kMariadb = "mariadb"; +/** SAP MaxDB. */ +static constexpr const char *kMaxdb = "maxdb"; +/** Memcached. */ +static constexpr const char *kMemcached = "memcached"; +/** MongoDB. */ +static constexpr const char *kMongodb = "mongodb"; +/** Microsoft SQL Server. */ +static constexpr const char *kMssql = "mssql"; +/** Deprecated, Microsoft SQL Server Compact is discontinued. */ +static constexpr const char *kMssqlcompact = "mssqlcompact"; +/** MySQL. */ +static constexpr const char *kMysql = "mysql"; +/** Neo4j. */ +static constexpr const char *kNeo4j = "neo4j"; /** Netezza. */ static constexpr const char *kNetezza = "netezza"; +/** OpenSearch. */ +static constexpr const char *kOpensearch = "opensearch"; +/** Oracle Database. */ +static constexpr const char *kOracle = "oracle"; /** Pervasive PSQL. */ static constexpr const char *kPervasive = "pervasive"; /** PointBase. */ static constexpr const char *kPointbase = "pointbase"; +/** PostgreSQL. */ +static constexpr const char *kPostgresql = "postgresql"; +/** Progress Database. */ +static constexpr const char *kProgress = "progress"; +/** Redis. */ +static constexpr const char *kRedis = "redis"; +/** Amazon Redshift. */ +static constexpr const char *kRedshift = "redshift"; +/** Cloud Spanner. */ +static constexpr const char *kSpanner = "spanner"; /** SQLite. */ static constexpr const char *kSqlite = "sqlite"; /** Sybase. */ static constexpr const char *kSybase = "sybase"; /** Teradata. */ static constexpr const char *kTeradata = "teradata"; -/** Vertica. */ -static constexpr const char *kVertica = "vertica"; -/** H2. */ -static constexpr const char *kH2 = "h2"; -/** ColdFusion IMQ. */ -static constexpr const char *kColdfusion = "coldfusion"; -/** Apache Cassandra. */ -static constexpr const char *kCassandra = "cassandra"; -/** Apache HBase. */ -static constexpr const char *kHbase = "hbase"; -/** MongoDB. */ -static constexpr const char *kMongodb = "mongodb"; -/** Redis. */ -static constexpr const char *kRedis = "redis"; -/** Couchbase. */ -static constexpr const char *kCouchbase = "couchbase"; -/** CouchDB. */ -static constexpr const char *kCouchdb = "couchdb"; -/** Microsoft Azure Cosmos DB. */ -static constexpr const char *kCosmosdb = "cosmosdb"; -/** Amazon DynamoDB. */ -static constexpr const char *kDynamodb = "dynamodb"; -/** Neo4j. */ -static constexpr const char *kNeo4j = "neo4j"; -/** Apache Geode. */ -static constexpr const char *kGeode = "geode"; -/** Elasticsearch. */ -static constexpr const char *kElasticsearch = "elasticsearch"; -/** Memcached. */ -static constexpr const char *kMemcached = "memcached"; -/** CockroachDB. */ -static constexpr const char *kCockroachdb = "cockroachdb"; -/** OpenSearch. */ -static constexpr const char *kOpensearch = "opensearch"; -/** ClickHouse. */ -static constexpr const char *kClickhouse = "clickhouse"; -/** Cloud Spanner. */ -static constexpr const char *kSpanner = "spanner"; /** Trino. */ static constexpr const char *kTrino = "trino"; +/** Vertica. */ +static constexpr const char *kVertica = "vertica"; } // namespace DbSystemValues namespace DbCassandraConsistencyLevelValues @@ -3813,6 +4267,14 @@ static constexpr const char *kQueryPlan = "QueryPlan"; static constexpr const char *kExecuteJavascript = "ExecuteJavaScript"; } // namespace DbCosmosdbOperationTypeValues +namespace DeploymentStatusValues +{ +/** failed. */ +static constexpr const char *kFailed = "failed"; +/** succeeded. */ +static constexpr const char *kSucceeded = "succeeded"; +} // namespace DeploymentStatusValues + namespace AndroidStateValues { /** Any time before Activity.onResume() or, if the app has no Activity, Context.startService() has @@ -3826,6 +4288,26 @@ static constexpr const char *kBackground = "background"; static constexpr const char *kForeground = "foreground"; } // namespace AndroidStateValues +namespace ContainerCpuStateValues +{ +/** When tasks of the cgroup are in user mode (Linux). When all container processes are in user mode + * (Windows). */ +static constexpr const char *kUser = "user"; +/** When CPU is used by the system (host OS). */ +static constexpr const char *kSystem = "system"; +/** When tasks of the cgroup are in kernel mode (Linux). When all container processes are in kernel + * mode (Windows). */ +static constexpr const char *kKernel = "kernel"; +} // namespace ContainerCpuStateValues + +namespace DbClientConnectionsStateValues +{ +/** idle. */ +static constexpr const char *kIdle = "idle"; +/** used. */ +static constexpr const char *kUsed = "used"; +} // namespace DbClientConnectionsStateValues + namespace StateValues { /** idle. */ @@ -3890,6 +4372,16 @@ static constexpr const char *kInproc = "inproc"; static constexpr const char *kOther = "other"; } // namespace NetTransportValues +namespace ProcessCpuStateValues +{ +/** system. */ +static constexpr const char *kSystem = "system"; +/** user. */ +static constexpr const char *kUser = "user"; +/** wait. */ +static constexpr const char *kWait = "wait"; +} // namespace ProcessCpuStateValues + namespace MessageTypeValues { /** sent. */ @@ -3898,6 +4390,24 @@ static constexpr const char *kSent = "SENT"; static constexpr const char *kReceived = "RECEIVED"; } // namespace MessageTypeValues +namespace SystemCpuStateValues +{ +/** user. */ +static constexpr const char *kUser = "user"; +/** system. */ +static constexpr const char *kSystem = "system"; +/** nice. */ +static constexpr const char *kNice = "nice"; +/** idle. */ +static constexpr const char *kIdle = "idle"; +/** iowait. */ +static constexpr const char *kIowait = "iowait"; +/** interrupt. */ +static constexpr const char *kInterrupt = "interrupt"; +/** steal. */ +static constexpr const char *kSteal = "steal"; +} // namespace SystemCpuStateValues + namespace SystemProcessesStatusValues { /** running. */ @@ -3962,12 +4472,46 @@ static constexpr const char *kTimer = "timer"; static constexpr const char *kOther = "other"; } // namespace FaasTriggerValues +namespace GenAiOperationNameValues +{ +/** Chat completion operation such as [OpenAI Chat + * API](https://platform.openai.com/docs/api-reference/chat). */ +static constexpr const char *kChat = "chat"; +/** Text completions operation such as [OpenAI Completions API + * (Legacy)](https://platform.openai.com/docs/api-reference/completions). */ +static constexpr const char *kTextCompletion = "text_completion"; +} // namespace GenAiOperationNameValues + namespace GenAiSystemValues { /** OpenAI. */ static constexpr const char *kOpenai = "openai"; +/** Vertex AI. */ +static constexpr const char *kVertexAi = "vertex_ai"; +/** Anthropic. */ +static constexpr const char *kAnthropic = "anthropic"; +/** Cohere. */ +static constexpr const char *kCohere = "cohere"; } // namespace GenAiSystemValues +namespace GenAiTokenTypeValues +{ +/** Input tokens (prompt, input, etc.). */ +static constexpr const char *kInput = "input"; +/** Output tokens (completion, response, etc.). */ +static constexpr const char *kCompletion = "output"; +} // namespace GenAiTokenTypeValues + +namespace GoMemoryTypeValues +{ +/** Memory allocated from the heap that is reserved for stack space, whether or not it is currently + * in-use. */ +static constexpr const char *kStack = "stack"; +/** Memory used by the Go runtime, excluding other categories of memory usage described in this + * enumeration. */ +static constexpr const char *kOther = "other"; +} // namespace GoMemoryTypeValues + namespace GraphqlOperationTypeValues { /** GraphQL query. */ @@ -4056,6 +4600,14 @@ static constexpr const char *kTimedWaiting = "timed_waiting"; static constexpr const char *kTerminated = "terminated"; } // namespace JvmThreadStateValues +namespace LinuxMemorySlabStateValues +{ +/** reclaimable. */ +static constexpr const char *kReclaimable = "reclaimable"; +/** unreclaimable. */ +static constexpr const char *kUnreclaimable = "unreclaimable"; +} // namespace LinuxMemorySlabStateValues + namespace LogIostreamValues { /** Logs from stdout stream. */ @@ -4076,10 +4628,12 @@ static constexpr const char *kCreate = "create"; /** One or more messages are requested by a consumer. This operation refers to pull-based scenarios, * where consumers explicitly call methods of messaging SDKs to receive messages. */ static constexpr const char *kReceive = "receive"; -/** One or more messages are delivered to or processed by a consumer. */ -static constexpr const char *kDeliver = "process"; +/** One or more messages are processed by a consumer. */ +static constexpr const char *kProcess = "process"; /** One or more messages are settled. */ static constexpr const char *kSettle = "settle"; +/** Deprecated. Use `process` instead. */ +static constexpr const char *kDeliver = "deliver"; } // namespace MessagingOperationTypeValues namespace MessagingSystemValues @@ -4104,6 +4658,8 @@ static constexpr const char *kKafka = "kafka"; static constexpr const char *kRabbitmq = "rabbitmq"; /** Apache RocketMQ. */ static constexpr const char *kRocketmq = "rocketmq"; +/** Apache Pulsar. */ +static constexpr const char *kPulsar = "pulsar"; } // namespace MessagingSystemValues namespace MessagingRocketmqConsumptionModelValues @@ -4216,6 +4772,8 @@ static constexpr const char *kUdp = "udp"; static constexpr const char *kPipe = "pipe"; /** Unix domain socket. */ static constexpr const char *kUnix = "unix"; +/** QUIC. */ +static constexpr const char *kQuic = "quic"; } // namespace NetworkTransportValues namespace NetworkTypeValues @@ -4285,16 +4843,6 @@ static constexpr const char *kMajor = "major"; static constexpr const char *kMinor = "minor"; } // namespace ProcessPagingFaultTypeValues -namespace ProcessCpuStateValues -{ -/** system. */ -static constexpr const char *kSystem = "system"; -/** user. */ -static constexpr const char *kUser = "user"; -/** wait. */ -static constexpr const char *kWait = "wait"; -} // namespace ProcessCpuStateValues - namespace RpcConnectRpcErrorCodeValues { /** cancelled. */ @@ -4411,24 +4959,6 @@ static constexpr const char *kLongPolling = "long_polling"; static constexpr const char *kWebSockets = "web_sockets"; } // namespace SignalrTransportValues -namespace SystemCpuStateValues -{ -/** user. */ -static constexpr const char *kUser = "user"; -/** system. */ -static constexpr const char *kSystem = "system"; -/** nice. */ -static constexpr const char *kNice = "nice"; -/** idle. */ -static constexpr const char *kIdle = "idle"; -/** iowait. */ -static constexpr const char *kIowait = "iowait"; -/** interrupt. */ -static constexpr const char *kInterrupt = "interrupt"; -/** steal. */ -static constexpr const char *kSteal = "steal"; -} // namespace SystemCpuStateValues - namespace SystemMemoryStateValues { /** used. */ @@ -4561,6 +5091,30 @@ static constexpr const char *kSwift = "swift"; static constexpr const char *kWebjs = "webjs"; } // namespace TelemetrySdkLanguageValues +namespace TestCaseResultStatusValues +{ +/** pass. */ +static constexpr const char *kPass = "pass"; +/** fail. */ +static constexpr const char *kFail = "fail"; +} // namespace TestCaseResultStatusValues + +namespace TestSuiteRunStatusValues +{ +/** success. */ +static constexpr const char *kSuccess = "success"; +/** failure. */ +static constexpr const char *kFailure = "failure"; +/** skipped. */ +static constexpr const char *kSkipped = "skipped"; +/** aborted. */ +static constexpr const char *kAborted = "aborted"; +/** timed_out. */ +static constexpr const char *kTimedOut = "timed_out"; +/** in_progress. */ +static constexpr const char *kInProgress = "in_progress"; +} // namespace TestSuiteRunStatusValues + namespace TlsProtocolNameValues { /** ssl. */ @@ -4569,6 +5123,40 @@ static constexpr const char *kSsl = "ssl"; static constexpr const char *kTls = "tls"; } // namespace TlsProtocolNameValues +namespace V8jsGcTypeValues +{ +/** Major (Mark Sweep Compact). */ +static constexpr const char *kMajor = "major"; +/** Minor (Scavenge). */ +static constexpr const char *kMinor = "minor"; +/** Incremental (Incremental Marking). */ +static constexpr const char *kIncremental = "incremental"; +/** Weak Callbacks (Process Weak Callbacks). */ +static constexpr const char *kWeakcb = "weakcb"; +} // namespace V8jsGcTypeValues + +namespace V8jsHeapSpaceNameValues +{ +/** New memory space. */ +static constexpr const char *kNewSpace = "new_space"; +/** Old memory space. */ +static constexpr const char *kOldSpace = "old_space"; +/** Code memory space. */ +static constexpr const char *kCodeSpace = "code_space"; +/** Map memory space. */ +static constexpr const char *kMapSpace = "map_space"; +/** Large object memory space. */ +static constexpr const char *kLargeObjectSpace = "large_object_space"; +} // namespace V8jsHeapSpaceNameValues + +namespace VcsRepositoryRefTypeValues +{ +/** [branch](https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefbranchabranch). */ +static constexpr const char *kBranch = "branch"; +/** [tag](https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddeftagatag). */ +static constexpr const char *kTag = "tag"; +} // namespace VcsRepositoryRefTypeValues + } // namespace SemanticConventions } // namespace resource } // namespace sdk From 1203bcf2647cfb8d10a217a0a04d43c6295bd12a Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Wed, 14 Aug 2024 10:47:59 -0700 Subject: [PATCH 19/89] [SDK] Support empty histogram buckets (#3027) * support empty buckets * Update histogram_test.cc * Update histogram_test.cc * test for negative values * fix count --- .../aggregation/histogram_aggregation.cc | 4 +- sdk/test/metrics/histogram_test.cc | 120 ++++++++++++++++++ 2 files changed, 122 insertions(+), 2 deletions(-) diff --git a/sdk/src/metrics/aggregation/histogram_aggregation.cc b/sdk/src/metrics/aggregation/histogram_aggregation.cc index da725cf09c..d6b4c90a0b 100644 --- a/sdk/src/metrics/aggregation/histogram_aggregation.cc +++ b/sdk/src/metrics/aggregation/histogram_aggregation.cc @@ -28,7 +28,7 @@ namespace metrics LongHistogramAggregation::LongHistogramAggregation(const AggregationConfig *aggregation_config) { auto ac = static_cast(aggregation_config); - if (ac && ac->boundaries_.size()) + if (ac) { point_data_.boundaries_ = ac->boundaries_; } @@ -109,7 +109,7 @@ PointType LongHistogramAggregation::ToPoint() const noexcept DoubleHistogramAggregation::DoubleHistogramAggregation(const AggregationConfig *aggregation_config) { auto ac = static_cast(aggregation_config); - if (ac && ac->boundaries_.size()) + if (ac) { point_data_.boundaries_ = ac->boundaries_; } diff --git a/sdk/test/metrics/histogram_test.cc b/sdk/test/metrics/histogram_test.cc index 4daceb685b..57f7790ba1 100644 --- a/sdk/test/metrics/histogram_test.cc +++ b/sdk/test/metrics/histogram_test.cc @@ -134,6 +134,66 @@ TEST(Histogram, DoubleCustomBuckets) ASSERT_EQ(std::vector({10, 20, 30, 40}), actual.boundaries_); ASSERT_EQ(std::vector({2, 2, 2, 2, 2}), actual.counts_); } + +TEST(Histogram, DoubleEmptyBuckets) +{ + MeterProvider mp; + auto m = mp.GetMeter("meter1", "version1", "schema1"); + std::string instrument_unit = "ms"; + std::string instrument_name = "historgram1"; + std::string instrument_desc = "histogram metrics"; + + std::unique_ptr exporter(new MockMetricExporter()); + std::shared_ptr reader{new MockMetricReader(std::move(exporter))}; + mp.AddMetricReader(reader); + + std::shared_ptr config(new HistogramAggregationConfig()); + config->boundaries_ = {}; + std::unique_ptr view{ + new View("view1", "view1_description", instrument_unit, AggregationType::kHistogram, config)}; + std::unique_ptr instrument_selector{ + new InstrumentSelector(InstrumentType::kHistogram, instrument_name, instrument_unit)}; + std::unique_ptr meter_selector{new MeterSelector("meter1", "version1", "schema1")}; + mp.AddView(std::move(instrument_selector), std::move(meter_selector), std::move(view)); + + auto h = m->CreateDoubleHistogram(instrument_name, instrument_desc, instrument_unit); + + h->Record(-5, {}); + h->Record(10, {}); + h->Record(15, {}); + h->Record(20, {}); + h->Record(25, {}); + h->Record(30, {}); + h->Record(35, {}); + h->Record(40, {}); + h->Record(45, {}); + h->Record(50, {}); + + std::vector actuals; + reader->Collect([&](ResourceMetrics &rm) { + for (const ScopeMetrics &smd : rm.scope_metric_data_) + { + for (const MetricData &md : smd.metric_data_) + { + for (const PointDataAttributes &dp : md.point_data_attr_) + { + actuals.push_back(opentelemetry::nostd::get(dp.point_data)); + } + } + } + return true; + }); + + ASSERT_EQ(1, actuals.size()); + + const auto &actual = actuals.at(0); + ASSERT_EQ(270.0, opentelemetry::nostd::get(actual.sum_)); + ASSERT_EQ(9, actual.count_); + ASSERT_EQ(10.0, opentelemetry::nostd::get(actual.min_)); + ASSERT_EQ(50.0, opentelemetry::nostd::get(actual.max_)); + ASSERT_EQ(std::vector({}), actual.boundaries_); + ASSERT_EQ(std::vector({9}), actual.counts_); +} #endif TEST(Histogram, UInt64) @@ -249,4 +309,64 @@ TEST(Histogram, UInt64CustomBuckets) ASSERT_EQ(std::vector({10, 20, 30, 40}), actual.boundaries_); ASSERT_EQ(std::vector({2, 2, 2, 2, 2}), actual.counts_); } + +TEST(Histogram, UInt64EmptyBuckets) +{ + MeterProvider mp; + auto m = mp.GetMeter("meter1", "version1", "schema1"); + std::string instrument_name = "historgram1"; + std::string instrument_desc = "histogram metrics"; + std::string instrument_unit = "ms"; + + std::unique_ptr exporter(new MockMetricExporter()); + std::shared_ptr reader{new MockMetricReader(std::move(exporter))}; + mp.AddMetricReader(reader); + + std::shared_ptr config(new HistogramAggregationConfig()); + config->boundaries_ = {}; + std::unique_ptr view{ + new View("view1", "view1_description", "ms", AggregationType::kHistogram, config)}; + std::unique_ptr instrument_selector{ + new InstrumentSelector(InstrumentType::kHistogram, instrument_name, instrument_unit)}; + std::unique_ptr meter_selector{new MeterSelector("meter1", "version1", "schema1")}; + mp.AddView(std::move(instrument_selector), std::move(meter_selector), std::move(view)); + + auto h = m->CreateUInt64Histogram(instrument_name, instrument_desc, instrument_unit); + + h->Record(5, {}); + h->Record(10, {}); + h->Record(15, {}); + h->Record(20, {}); + h->Record(25, {}); + h->Record(30, {}); + h->Record(35, {}); + h->Record(40, {}); + h->Record(45, {}); + h->Record(50, {}); + + std::vector actuals; + reader->Collect([&](ResourceMetrics &rm) { + for (const ScopeMetrics &smd : rm.scope_metric_data_) + { + for (const MetricData &md : smd.metric_data_) + { + for (const PointDataAttributes &dp : md.point_data_attr_) + { + actuals.push_back(opentelemetry::nostd::get(dp.point_data)); + } + } + } + return true; + }); + + ASSERT_EQ(1, actuals.size()); + + const auto &actual = actuals.at(0); + ASSERT_EQ(275, opentelemetry::nostd::get(actual.sum_)); + ASSERT_EQ(10, actual.count_); + ASSERT_EQ(5, opentelemetry::nostd::get(actual.min_)); + ASSERT_EQ(50, opentelemetry::nostd::get(actual.max_)); + ASSERT_EQ(std::vector({}), actual.boundaries_); + ASSERT_EQ(std::vector({10}), actual.counts_); +} #endif From b8909692c64dfbbeae6d10ce8f887a6250ac04a4 Mon Sep 17 00:00:00 2001 From: WenTao Ou Date: Fri, 16 Aug 2024 21:30:29 +0800 Subject: [PATCH 20/89] [TEST] Fix sync problems in OTLP File exporter tests. (#3031) --- .../otlp/test/otlp_file_exporter_test.cc | 24 ++++++++++++++----- .../otlp_file_log_record_exporter_test.cc | 6 ++++- .../test/otlp_file_metric_exporter_test.cc | 18 +++++++++++--- 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/exporters/otlp/test/otlp_file_exporter_test.cc b/exporters/otlp/test/otlp_file_exporter_test.cc index 16a1306f88..81e1baab44 100644 --- a/exporters/otlp/test/otlp_file_exporter_test.cc +++ b/exporters/otlp/test/otlp_file_exporter_test.cc @@ -25,6 +25,7 @@ #include "nlohmann/json.hpp" #include +#include #include using namespace testing; @@ -112,13 +113,24 @@ class OtlpFileExporterTestPeer : public ::testing::Test provider->ForceFlush(); + output.flush(); + output.sync(); + auto check_json_text = output.str(); + if (!check_json_text.empty()) { - auto check_json = nlohmann::json::parse(output.str(), nullptr, false); - auto resource_span = *check_json["resourceSpans"].begin(); - auto scope_span = *resource_span["scopeSpans"].begin(); - auto span = *scope_span["spans"].begin(); - auto received_trace_id = span["traceId"].get(); - EXPECT_EQ(received_trace_id, report_trace_id); + auto check_json = nlohmann::json::parse(check_json_text, nullptr, false); + if (!check_json.is_discarded()) + { + auto resource_span = *check_json["resourceSpans"].begin(); + auto scope_span = *resource_span["scopeSpans"].begin(); + auto span = *scope_span["spans"].begin(); + auto received_trace_id = span["traceId"].get(); + EXPECT_EQ(received_trace_id, report_trace_id); + } + else + { + FAIL() << "Failed to parse json:" << check_json_text; + } } } }; diff --git a/exporters/otlp/test/otlp_file_log_record_exporter_test.cc b/exporters/otlp/test/otlp_file_log_record_exporter_test.cc index 9f04bcece4..5bc1e4a473 100644 --- a/exporters/otlp/test/otlp_file_log_record_exporter_test.cc +++ b/exporters/otlp/test/otlp_file_log_record_exporter_test.cc @@ -122,8 +122,12 @@ class OtlpFileLogRecordExporterTestPeer : public ::testing::Test provider->ForceFlush(); + output.flush(); + output.sync(); + auto check_json_text = output.str(); + if (!check_json_text.empty()) { - auto check_json = nlohmann::json::parse(output.str(), nullptr, false); + auto check_json = nlohmann::json::parse(check_json_text, nullptr, false); auto resource_logs = *check_json["resourceLogs"].begin(); auto scope_logs = *resource_logs["scopeLogs"].begin(); auto scope = scope_logs["scope"]; diff --git a/exporters/otlp/test/otlp_file_metric_exporter_test.cc b/exporters/otlp/test/otlp_file_metric_exporter_test.cc index f08c8854ba..50f60e15b7 100644 --- a/exporters/otlp/test/otlp_file_metric_exporter_test.cc +++ b/exporters/otlp/test/otlp_file_metric_exporter_test.cc @@ -106,8 +106,12 @@ class OtlpFileMetricExporterTestPeer : public ::testing::Test exporter->ForceFlush(); + output.flush(); + output.sync(); + auto check_json_text = output.str(); + if (!check_json_text.empty()) { - auto check_json = nlohmann::json::parse(output.str(), nullptr, false); + auto check_json = nlohmann::json::parse(check_json_text, nullptr, false); auto resource_metrics = *check_json["resourceMetrics"].begin(); auto scope_metrics = *resource_metrics["scopeMetrics"].begin(); @@ -167,8 +171,12 @@ class OtlpFileMetricExporterTestPeer : public ::testing::Test exporter->ForceFlush(); + output.flush(); + output.sync(); + auto check_json_text = output.str(); + if (!check_json_text.empty()) { - auto check_json = nlohmann::json::parse(output.str(), nullptr, false); + auto check_json = nlohmann::json::parse(check_json_text, nullptr, false); auto resource_metrics = *check_json["resourceMetrics"].begin(); auto scope_metrics = *resource_metrics["scopeMetrics"].begin(); @@ -233,8 +241,12 @@ class OtlpFileMetricExporterTestPeer : public ::testing::Test exporter->ForceFlush(); + output.flush(); + output.sync(); + auto check_json_text = output.str(); + if (!check_json_text.empty()) { - auto check_json = nlohmann::json::parse(output.str(), nullptr, false); + auto check_json = nlohmann::json::parse(check_json_text, nullptr, false); auto resource_metrics = *check_json["resourceMetrics"].begin(); auto scope_metrics = *resource_metrics["scopeMetrics"].begin(); From 242d52ac67a8c20484cddabd2b3feeebeb4399b0 Mon Sep 17 00:00:00 2001 From: WenTao Ou Date: Thu, 22 Aug 2024 06:36:53 +0800 Subject: [PATCH 21/89] [SDK] PeriodicExportingMetricReader: future is never set, blocks until timeout (#3030) --- .../periodic_exporting_metric_reader.cc | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/sdk/src/metrics/export/periodic_exporting_metric_reader.cc b/sdk/src/metrics/export/periodic_exporting_metric_reader.cc index 7ca2747337..1ebfc2a1b6 100644 --- a/sdk/src/metrics/export/periodic_exporting_metric_reader.cc +++ b/sdk/src/metrics/export/periodic_exporting_metric_reader.cc @@ -106,19 +106,22 @@ bool PeriodicExportingMetricReader::CollectAndExportOnce() std::promise sender; auto receiver = sender.get_future(); - task_thread.reset(new std::thread([this, &cancel_export_for_timeout] { - this->Collect([this, &cancel_export_for_timeout](ResourceMetrics &metric_data) { - if (cancel_export_for_timeout.load(std::memory_order_acquire)) - { - OTEL_INTERNAL_LOG_ERROR( - "[Periodic Exporting Metric Reader] Collect took longer configured time: " - << this->export_timeout_millis_.count() << " ms, and timed out"); - return false; - } - this->exporter_->Export(metric_data); - return true; - }); - })); + task_thread.reset( + new std::thread([this, &cancel_export_for_timeout, sender = std::move(sender)] { + this->Collect([this, &cancel_export_for_timeout](ResourceMetrics &metric_data) { + if (cancel_export_for_timeout.load(std::memory_order_acquire)) + { + OTEL_INTERNAL_LOG_ERROR( + "[Periodic Exporting Metric Reader] Collect took longer configured time: " + << this->export_timeout_millis_.count() << " ms, and timed out"); + return false; + } + this->exporter_->Export(metric_data); + return true; + }); + + const_cast &>(sender).set_value(); + })); std::future_status status; do From a71642fe678f90ba6d379d699e533ce441394bdf Mon Sep 17 00:00:00 2001 From: Siddhartha Malladi Date: Sun, 25 Aug 2024 23:28:32 +0530 Subject: [PATCH 22/89] [Code Health] Clang Tidy cleanup, Part 2 (#3038) --- .clang-tidy | 3 ++ .github/workflows/clang-tidy.yaml | 2 +- .../propagation/baggage_propagator_test.cc | 4 +-- .../propagation/composite_propagator_test.cc | 6 ++-- api/test/logs/logger_benchmark.cc | 8 ++--- api/test/nostd/shared_ptr_test.cc | 2 +- .../trace/propagation/b3_propagation_test.cc | 4 +-- .../propagation/http_text_format_test.cc | 4 +-- .../propagation/jaeger_propagation_test.cc | 4 +-- examples/http/server.cc | 4 +-- exporters/otlp/src/otlp_file_client.cc | 6 ++-- .../src/otlp_file_metric_exporter_options.cc | 3 +- .../src/otlp_grpc_metric_exporter_options.cc | 3 +- exporters/otlp/src/otlp_http_client.cc | 2 +- .../otlp/src/otlp_http_exporter_options.cc | 29 ++++++++--------- .../otlp_http_log_record_exporter_options.cc | 29 ++++++++--------- .../src/otlp_http_metric_exporter_options.cc | 31 ++++++++++--------- .../otlp/src/otlp_populate_attribute_utils.cc | 15 ++++++--- exporters/prometheus/src/exporter_utils.cc | 10 +++--- exporters/prometheus/test/collector_test.cc | 4 +-- exporters/zipkin/src/zipkin_exporter.cc | 6 ++-- ext/src/http/client/curl/http_client_curl.cc | 7 ++--- ext/test/http/curl_http_test.cc | 13 ++++---- ext/test/w3c_tracecontext_test/main.cc | 4 +-- .../sdk/common/circular_buffer.h | 1 - sdk/src/common/base64.cc | 7 +---- sdk/src/logs/logger_provider.cc | 4 +-- .../aggregation/lastvalue_aggregation.cc | 22 ++++++------- .../metrics/aggregation/sum_aggregation.cc | 4 +-- sdk/src/metrics/state/sync_metric_storage.cc | 2 +- sdk/src/trace/batch_span_processor.cc | 2 +- sdk/src/trace/samplers/parent_factory.cc | 2 +- sdk/test/common/random_test.cc | 1 + .../periodic_exporting_metric_reader_test.cc | 4 +-- 34 files changed, 127 insertions(+), 125 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 9a30fbef54..db61b810c9 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -31,9 +31,12 @@ Checks: > -misc-unused-alias-decls, -misc-use-anonymous-namespace, cppcoreguidelines-*, + -cppcoreguidelines-owning-memory, + -cppcoreguidelines-avoid-do-while, -cppcoreguidelines-avoid-c-arrays, -cppcoreguidelines-avoid-magic-numbers, -cppcoreguidelines-init-variables, -cppcoreguidelines-macro-usage, -cppcoreguidelines-non-private-member-variables-in-classes, + -cppcoreguidelines-avoid-non-const-global-variables, -cppcoreguidelines-pro-* \ No newline at end of file diff --git a/.github/workflows/clang-tidy.yaml b/.github/workflows/clang-tidy.yaml index 9e5f6c26db..612ff05270 100644 --- a/.github/workflows/clang-tidy.yaml +++ b/.github/workflows/clang-tidy.yaml @@ -68,7 +68,7 @@ jobs: - name: Run clang-tidy run: | cd build - make -j$(nproc) 2>&1 | tee -a clang-tidy.log || exit 1 + make 2>&1 | tee -a clang-tidy.log || exit 1 - uses: actions/upload-artifact@v4 with: diff --git a/api/test/baggage/propagation/baggage_propagator_test.cc b/api/test/baggage/propagation/baggage_propagator_test.cc index 83de75757b..c966fe7603 100644 --- a/api/test/baggage/propagation/baggage_propagator_test.cc +++ b/api/test/baggage/propagation/baggage_propagator_test.cc @@ -15,7 +15,7 @@ class BaggageCarrierTest : public context::propagation::TextMapCarrier { public: BaggageCarrierTest() = default; - virtual nostd::string_view Get(nostd::string_view key) const noexcept override + nostd::string_view Get(nostd::string_view key) const noexcept override { auto it = headers_.find(std::string(key)); if (it != headers_.end()) @@ -24,7 +24,7 @@ class BaggageCarrierTest : public context::propagation::TextMapCarrier } return ""; } - virtual void Set(nostd::string_view key, nostd::string_view value) noexcept override + void Set(nostd::string_view key, nostd::string_view value) noexcept override { headers_[std::string(key)] = std::string(value); } diff --git a/api/test/context/propagation/composite_propagator_test.cc b/api/test/context/propagation/composite_propagator_test.cc index 5bf18710ed..075841080f 100644 --- a/api/test/context/propagation/composite_propagator_test.cc +++ b/api/test/context/propagation/composite_propagator_test.cc @@ -31,7 +31,7 @@ static std::string Hex(const T &id_item) class TextMapCarrierTest : public context::propagation::TextMapCarrier { public: - virtual nostd::string_view Get(nostd::string_view key) const noexcept override + nostd::string_view Get(nostd::string_view key) const noexcept override { auto it = headers_.find(std::string(key)); if (it != headers_.end()) @@ -40,7 +40,7 @@ class TextMapCarrierTest : public context::propagation::TextMapCarrier } return ""; } - virtual void Set(nostd::string_view key, nostd::string_view value) noexcept override + void Set(nostd::string_view key, nostd::string_view value) noexcept override { headers_[std::string(key)] = std::string(value); } @@ -66,7 +66,7 @@ class CompositePropagatorTest : public ::testing::Test new context::propagation::CompositePropagator(std::move(propogator_list)); } - ~CompositePropagatorTest() { delete composite_propagator_; } + ~CompositePropagatorTest() override { delete composite_propagator_; } protected: context::propagation::CompositePropagator *composite_propagator_; diff --git a/api/test/logs/logger_benchmark.cc b/api/test/logs/logger_benchmark.cc index db225d496a..7e8913a3f7 100644 --- a/api/test/logs/logger_benchmark.cc +++ b/api/test/logs/logger_benchmark.cc @@ -32,7 +32,7 @@ constexpr int64_t kMaxIterations = 1000000000; class Barrier { public: - explicit Barrier(std::size_t iCount) : mThreshold(iCount), mCount(iCount), mGeneration(0) {} + explicit Barrier(std::size_t iCount) : mThreshold(iCount), mCount(iCount) {} void Wait() { @@ -55,7 +55,7 @@ class Barrier std::condition_variable mCond; std::size_t mThreshold; std::size_t mCount; - std::size_t mGeneration; + std::size_t mGeneration{0}; }; static void ThreadRoutine(Barrier &barrier, @@ -84,14 +84,14 @@ static void ThreadRoutine(Barrier &barrier, void MultiThreadRunner(benchmark::State &state, const std::function &func) { - int num_threads = std::thread::hardware_concurrency(); + uint32_t num_threads = std::thread::hardware_concurrency(); Barrier barrier(num_threads); std::vector threads; threads.reserve(num_threads); - for (int i = 0; i < num_threads; i++) + for (uint32_t i = 0; i < num_threads; i++) { threads.emplace_back(ThreadRoutine, std::ref(barrier), std::ref(state), i, func); } diff --git a/api/test/nostd/shared_ptr_test.cc b/api/test/nostd/shared_ptr_test.cc index 5c290c6284..2ebba82628 100644 --- a/api/test/nostd/shared_ptr_test.cc +++ b/api/test/nostd/shared_ptr_test.cc @@ -35,7 +35,7 @@ class C class D : public C { public: - virtual ~D() {} + ~D() override {} }; TEST(SharedPtrTest, DefaultConstruction) diff --git a/api/test/trace/propagation/b3_propagation_test.cc b/api/test/trace/propagation/b3_propagation_test.cc index 5546916abc..732db1bd34 100644 --- a/api/test/trace/propagation/b3_propagation_test.cc +++ b/api/test/trace/propagation/b3_propagation_test.cc @@ -15,7 +15,7 @@ using namespace opentelemetry; class TextMapCarrierTest : public context::propagation::TextMapCarrier { public: - virtual nostd::string_view Get(nostd::string_view key) const noexcept override + nostd::string_view Get(nostd::string_view key) const noexcept override { auto it = headers_.find(std::string(key)); if (it != headers_.end()) @@ -24,7 +24,7 @@ class TextMapCarrierTest : public context::propagation::TextMapCarrier } return ""; } - virtual void Set(nostd::string_view key, nostd::string_view value) noexcept override + void Set(nostd::string_view key, nostd::string_view value) noexcept override { headers_[std::string(key)] = std::string(value); } diff --git a/api/test/trace/propagation/http_text_format_test.cc b/api/test/trace/propagation/http_text_format_test.cc index e41e0fe65c..99f7117928 100644 --- a/api/test/trace/propagation/http_text_format_test.cc +++ b/api/test/trace/propagation/http_text_format_test.cc @@ -18,7 +18,7 @@ using namespace opentelemetry; class TextMapCarrierTest : public context::propagation::TextMapCarrier { public: - virtual nostd::string_view Get(nostd::string_view key) const noexcept override + nostd::string_view Get(nostd::string_view key) const noexcept override { auto it = headers_.find(std::string(key)); if (it != headers_.end()) @@ -27,7 +27,7 @@ class TextMapCarrierTest : public context::propagation::TextMapCarrier } return ""; } - virtual void Set(nostd::string_view key, nostd::string_view value) noexcept override + void Set(nostd::string_view key, nostd::string_view value) noexcept override { headers_[std::string(key)] = std::string(value); } diff --git a/api/test/trace/propagation/jaeger_propagation_test.cc b/api/test/trace/propagation/jaeger_propagation_test.cc index add38eac6c..f0fdaf734d 100644 --- a/api/test/trace/propagation/jaeger_propagation_test.cc +++ b/api/test/trace/propagation/jaeger_propagation_test.cc @@ -14,7 +14,7 @@ using namespace opentelemetry; class TextMapCarrierTest : public context::propagation::TextMapCarrier { public: - virtual nostd::string_view Get(nostd::string_view key) const noexcept override + nostd::string_view Get(nostd::string_view key) const noexcept override { auto it = headers_.find(std::string(key)); if (it != headers_.end()) @@ -23,7 +23,7 @@ class TextMapCarrierTest : public context::propagation::TextMapCarrier } return ""; } - virtual void Set(nostd::string_view key, nostd::string_view value) noexcept override + void Set(nostd::string_view key, nostd::string_view value) noexcept override { headers_[std::string(key)] = std::string(value); } diff --git a/examples/http/server.cc b/examples/http/server.cc index 3dbdae8512..85cccc234d 100644 --- a/examples/http/server.cc +++ b/examples/http/server.cc @@ -21,8 +21,8 @@ constexpr const char *server_name = "localhost"; class RequestHandler : public HTTP_SERVER_NS::HttpRequestCallback { public: - virtual int onHttpRequest(HTTP_SERVER_NS::HttpRequest const &request, - HTTP_SERVER_NS::HttpResponse &response) override + int onHttpRequest(HTTP_SERVER_NS::HttpRequest const &request, + HTTP_SERVER_NS::HttpResponse &response) override { StartSpanOptions options; options.kind = SpanKind::kServer; // server diff --git a/exporters/otlp/src/otlp_file_client.cc b/exporters/otlp/src/otlp_file_client.cc index cc6e074bfd..bdd6eac27d 100644 --- a/exporters/otlp/src/otlp_file_client.cc +++ b/exporters/otlp/src/otlp_file_client.cc @@ -966,7 +966,7 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileSystemBackend : public OtlpFileAppender { public: explicit OtlpFileSystemBackend(const OtlpFileClientFileSystemOptions &options) - : options_(options), is_initialized_{false}, check_file_path_interval_{0} + : options_(options), is_initialized_{false} { file_ = std::make_shared(); file_->is_shutdown.store(false); @@ -1539,7 +1539,7 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileSystemBackend : public OtlpFileAppender std::shared_ptr file_; std::atomic is_initialized_; - std::time_t check_file_path_interval_; + std::time_t check_file_path_interval_{0}; }; class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileOstreamBackend : public OtlpFileAppender @@ -1568,7 +1568,7 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileOstreamBackend : public OtlpFileAppende }; OtlpFileClient::OtlpFileClient(OtlpFileClientOptions &&options) - : is_shutdown_(false), options_(options) + : is_shutdown_(false), options_(std::move(options)) { if (nostd::holds_alternative(options_.backend_options)) { diff --git a/exporters/otlp/src/otlp_file_metric_exporter_options.cc b/exporters/otlp/src/otlp_file_metric_exporter_options.cc index 3ad8eaa457..e1b1f5ca7a 100644 --- a/exporters/otlp/src/otlp_file_metric_exporter_options.cc +++ b/exporters/otlp/src/otlp_file_metric_exporter_options.cc @@ -13,6 +13,7 @@ namespace otlp { OtlpFileMetricExporterOptions::OtlpFileMetricExporterOptions() + : aggregation_temporality(PreferredAggregationTemporality::kCumulative) { console_debug = false; @@ -25,8 +26,6 @@ OtlpFileMetricExporterOptions::OtlpFileMetricExporterOptions() fs_options.rotate_size = 10; backend_options = fs_options; - - aggregation_temporality = PreferredAggregationTemporality::kCumulative; } OtlpFileMetricExporterOptions::~OtlpFileMetricExporterOptions() {} diff --git a/exporters/otlp/src/otlp_grpc_metric_exporter_options.cc b/exporters/otlp/src/otlp_grpc_metric_exporter_options.cc index 983561424f..0d84ec276f 100644 --- a/exporters/otlp/src/otlp_grpc_metric_exporter_options.cc +++ b/exporters/otlp/src/otlp_grpc_metric_exporter_options.cc @@ -11,6 +11,7 @@ namespace otlp { OtlpGrpcMetricExporterOptions::OtlpGrpcMetricExporterOptions() + : aggregation_temporality(PreferredAggregationTemporality::kCumulative) { endpoint = GetOtlpDefaultGrpcMetricsEndpoint(); use_ssl_credentials = !GetOtlpDefaultGrpcMetricsIsInsecure(); /* negation intended. */ @@ -28,8 +29,6 @@ OtlpGrpcMetricExporterOptions::OtlpGrpcMetricExporterOptions() metadata = GetOtlpDefaultMetricsHeaders(); user_agent = GetOtlpDefaultUserAgent(); - aggregation_temporality = PreferredAggregationTemporality::kCumulative; - max_threads = 0; compression = GetOtlpDefaultMetricsCompression(); diff --git a/exporters/otlp/src/otlp_http_client.cc b/exporters/otlp/src/otlp_http_client.cc index 07b9108a3a..876719fa1e 100644 --- a/exporters/otlp/src/otlp_http_client.cc +++ b/exporters/otlp/src/otlp_http_client.cc @@ -707,7 +707,7 @@ OtlpHttpClient::~OtlpHttpClient() OtlpHttpClient::OtlpHttpClient(OtlpHttpClientOptions &&options, std::shared_ptr http_client) : is_shutdown_(false), - options_(options), + options_(std::move(options)), http_client_(std::move(http_client)), start_session_counter_(0), finished_session_counter_(0) diff --git a/exporters/otlp/src/otlp_http_exporter_options.cc b/exporters/otlp/src/otlp_http_exporter_options.cc index 753efcb481..0b00fc9708 100644 --- a/exporters/otlp/src/otlp_http_exporter_options.cc +++ b/exporters/otlp/src/otlp_http_exporter_options.cc @@ -16,27 +16,28 @@ namespace otlp { OtlpHttpExporterOptions::OtlpHttpExporterOptions() + : json_bytes_mapping(JsonBytesMappingKind::kHexId), + use_json_name(false), + console_debug(false), + ssl_insecure_skip_verify(false) { - url = GetOtlpDefaultHttpTracesEndpoint(); - content_type = GetOtlpHttpProtocolFromString(GetOtlpDefaultHttpTracesProtocol()); - json_bytes_mapping = JsonBytesMappingKind::kHexId; - use_json_name = false; - console_debug = false; - timeout = GetOtlpDefaultTracesTimeout(); - http_headers = GetOtlpDefaultTracesHeaders(); + url = GetOtlpDefaultHttpTracesEndpoint(); + content_type = GetOtlpHttpProtocolFromString(GetOtlpDefaultHttpTracesProtocol()); + + timeout = GetOtlpDefaultTracesTimeout(); + http_headers = GetOtlpDefaultTracesHeaders(); #ifdef ENABLE_ASYNC_EXPORT max_concurrent_requests = 64; max_requests_per_connection = 8; #endif /* ENABLE_ASYNC_EXPORT */ - ssl_insecure_skip_verify = false; - ssl_ca_cert_path = GetOtlpDefaultTracesSslCertificatePath(); - ssl_ca_cert_string = GetOtlpDefaultTracesSslCertificateString(); - ssl_client_key_path = GetOtlpDefaultTracesSslClientKeyPath(); - ssl_client_key_string = GetOtlpDefaultTracesSslClientKeyString(); - ssl_client_cert_path = GetOtlpDefaultTracesSslClientCertificatePath(); - ssl_client_cert_string = GetOtlpDefaultTracesSslClientCertificateString(); + ssl_ca_cert_path = GetOtlpDefaultTracesSslCertificatePath(); + ssl_ca_cert_string = GetOtlpDefaultTracesSslCertificateString(); + ssl_client_key_path = GetOtlpDefaultTracesSslClientKeyPath(); + ssl_client_key_string = GetOtlpDefaultTracesSslClientKeyString(); + ssl_client_cert_path = GetOtlpDefaultTracesSslClientCertificatePath(); + ssl_client_cert_string = GetOtlpDefaultTracesSslClientCertificateString(); ssl_min_tls = GetOtlpDefaultTracesSslTlsMinVersion(); ssl_max_tls = GetOtlpDefaultTracesSslTlsMaxVersion(); diff --git a/exporters/otlp/src/otlp_http_log_record_exporter_options.cc b/exporters/otlp/src/otlp_http_log_record_exporter_options.cc index 08a04cfa80..f193ea10df 100644 --- a/exporters/otlp/src/otlp_http_log_record_exporter_options.cc +++ b/exporters/otlp/src/otlp_http_log_record_exporter_options.cc @@ -16,27 +16,28 @@ namespace otlp { OtlpHttpLogRecordExporterOptions::OtlpHttpLogRecordExporterOptions() + : json_bytes_mapping(JsonBytesMappingKind::kHexId), + use_json_name(false), + console_debug(false), + ssl_insecure_skip_verify(false) { - url = GetOtlpDefaultHttpLogsEndpoint(); - content_type = GetOtlpHttpProtocolFromString(GetOtlpDefaultHttpLogsProtocol()); - json_bytes_mapping = JsonBytesMappingKind::kHexId; - use_json_name = false; - console_debug = false; - timeout = GetOtlpDefaultLogsTimeout(); - http_headers = GetOtlpDefaultLogsHeaders(); + url = GetOtlpDefaultHttpLogsEndpoint(); + content_type = GetOtlpHttpProtocolFromString(GetOtlpDefaultHttpLogsProtocol()); + + timeout = GetOtlpDefaultLogsTimeout(); + http_headers = GetOtlpDefaultLogsHeaders(); #ifdef ENABLE_ASYNC_EXPORT max_concurrent_requests = 64; max_requests_per_connection = 8; #endif - ssl_insecure_skip_verify = false; - ssl_ca_cert_path = GetOtlpDefaultLogsSslCertificatePath(); - ssl_ca_cert_string = GetOtlpDefaultLogsSslCertificateString(); - ssl_client_key_path = GetOtlpDefaultLogsSslClientKeyPath(); - ssl_client_key_string = GetOtlpDefaultLogsSslClientKeyString(); - ssl_client_cert_path = GetOtlpDefaultLogsSslClientCertificatePath(); - ssl_client_cert_string = GetOtlpDefaultLogsSslClientCertificateString(); + ssl_ca_cert_path = GetOtlpDefaultLogsSslCertificatePath(); + ssl_ca_cert_string = GetOtlpDefaultLogsSslCertificateString(); + ssl_client_key_path = GetOtlpDefaultLogsSslClientKeyPath(); + ssl_client_key_string = GetOtlpDefaultLogsSslClientKeyString(); + ssl_client_cert_path = GetOtlpDefaultLogsSslClientCertificatePath(); + ssl_client_cert_string = GetOtlpDefaultLogsSslClientCertificateString(); ssl_min_tls = GetOtlpDefaultLogsSslTlsMinVersion(); ssl_max_tls = GetOtlpDefaultLogsSslTlsMaxVersion(); diff --git a/exporters/otlp/src/otlp_http_metric_exporter_options.cc b/exporters/otlp/src/otlp_http_metric_exporter_options.cc index 66d65fa54b..95a8dd885c 100644 --- a/exporters/otlp/src/otlp_http_metric_exporter_options.cc +++ b/exporters/otlp/src/otlp_http_metric_exporter_options.cc @@ -17,28 +17,29 @@ namespace otlp { OtlpHttpMetricExporterOptions::OtlpHttpMetricExporterOptions() + : json_bytes_mapping(JsonBytesMappingKind::kHexId), + use_json_name(false), + console_debug(false), + aggregation_temporality(PreferredAggregationTemporality::kCumulative), + ssl_insecure_skip_verify(false) { - url = GetOtlpDefaultMetricsEndpoint(); - content_type = GetOtlpHttpProtocolFromString(GetOtlpDefaultHttpMetricsProtocol()); - json_bytes_mapping = JsonBytesMappingKind::kHexId; - use_json_name = false; - console_debug = false; - timeout = GetOtlpDefaultMetricsTimeout(); - http_headers = GetOtlpDefaultMetricsHeaders(); - aggregation_temporality = PreferredAggregationTemporality::kCumulative; + url = GetOtlpDefaultMetricsEndpoint(); + content_type = GetOtlpHttpProtocolFromString(GetOtlpDefaultHttpMetricsProtocol()); + + timeout = GetOtlpDefaultMetricsTimeout(); + http_headers = GetOtlpDefaultMetricsHeaders(); #ifdef ENABLE_ASYNC_EXPORT max_concurrent_requests = 64; max_requests_per_connection = 8; #endif - ssl_insecure_skip_verify = false; - ssl_ca_cert_path = GetOtlpDefaultMetricsSslCertificatePath(); - ssl_ca_cert_string = GetOtlpDefaultMetricsSslCertificateString(); - ssl_client_key_path = GetOtlpDefaultMetricsSslClientKeyPath(); - ssl_client_key_string = GetOtlpDefaultMetricsSslClientKeyString(); - ssl_client_cert_path = GetOtlpDefaultMetricsSslClientCertificatePath(); - ssl_client_cert_string = GetOtlpDefaultMetricsSslClientCertificateString(); + ssl_ca_cert_path = GetOtlpDefaultMetricsSslCertificatePath(); + ssl_ca_cert_string = GetOtlpDefaultMetricsSslCertificateString(); + ssl_client_key_path = GetOtlpDefaultMetricsSslClientKeyPath(); + ssl_client_key_string = GetOtlpDefaultMetricsSslClientKeyString(); + ssl_client_cert_path = GetOtlpDefaultMetricsSslClientCertificatePath(); + ssl_client_cert_string = GetOtlpDefaultMetricsSslClientCertificateString(); ssl_min_tls = GetOtlpDefaultMetricsSslTlsMinVersion(); ssl_max_tls = GetOtlpDefaultMetricsSslTlsMaxVersion(); diff --git a/exporters/otlp/src/otlp_populate_attribute_utils.cc b/exporters/otlp/src/otlp_populate_attribute_utils.cc index a2ef2edafa..490e4c771b 100644 --- a/exporters/otlp/src/otlp_populate_attribute_utils.cc +++ b/exporters/otlp/src/otlp_populate_attribute_utils.cc @@ -72,7 +72,8 @@ void OtlpPopulateAttributeUtils::PopulateAnyValue( } else if (nostd::holds_alternative(value)) { - proto_value->set_int_value(nostd::get(value)); + proto_value->set_int_value( + nostd::get(value)); // NOLINT(cppcoreguidelines-narrowing-conversions) } else if (nostd::holds_alternative(value)) { @@ -132,7 +133,8 @@ void OtlpPopulateAttributeUtils::PopulateAnyValue( auto array_value = proto_value->mutable_array_value(); for (const auto &val : nostd::get>(value)) { - array_value->add_values()->set_int_value(val); + array_value->add_values()->set_int_value( + val); // NOLINT(cppcoreguidelines-narrowing-conversions) } } else if (nostd::holds_alternative>(value)) @@ -186,7 +188,8 @@ void OtlpPopulateAttributeUtils::PopulateAnyValue( } else if (nostd::holds_alternative(value)) { - proto_value->set_int_value(nostd::get(value)); + proto_value->set_int_value( + nostd::get(value)); // NOLINT(cppcoreguidelines-narrowing-conversions) } else if (nostd::holds_alternative(value)) { @@ -217,7 +220,8 @@ void OtlpPopulateAttributeUtils::PopulateAnyValue( auto array_value = proto_value->mutable_array_value(); for (const auto &val : nostd::get>(value)) { - array_value->add_values()->set_int_value(val); + array_value->add_values()->set_int_value( + val); // NOLINT(cppcoreguidelines-narrowing-conversions) } } else if (nostd::holds_alternative>(value)) @@ -233,7 +237,8 @@ void OtlpPopulateAttributeUtils::PopulateAnyValue( auto array_value = proto_value->mutable_array_value(); for (const auto &val : nostd::get>(value)) { - array_value->add_values()->set_int_value(val); + array_value->add_values()->set_int_value( + val); // NOLINT(cppcoreguidelines-narrowing-conversions) } } else if (nostd::holds_alternative>(value)) diff --git a/exporters/prometheus/src/exporter_utils.cc b/exporters/prometheus/src/exporter_utils.cc index 35ee748273..77fcd56ad2 100644 --- a/exporters/prometheus/src/exporter_utils.cc +++ b/exporters/prometheus/src/exporter_utils.cc @@ -284,11 +284,11 @@ std::string PrometheusExporterUtils::SanitizeNames(std::string name) } #if OPENTELEMETRY_HAVE_WORKING_REGEX -std::regex INVALID_CHARACTERS_PATTERN("[^a-zA-Z0-9]"); -std::regex CHARACTERS_BETWEEN_BRACES_PATTERN("\\{(.*?)\\}"); -std::regex SANITIZE_LEADING_UNDERSCORES("^_+"); -std::regex SANITIZE_TRAILING_UNDERSCORES("_+$"); -std::regex SANITIZE_CONSECUTIVE_UNDERSCORES("[_]{2,}"); +const std::regex INVALID_CHARACTERS_PATTERN("[^a-zA-Z0-9]"); +const std::regex CHARACTERS_BETWEEN_BRACES_PATTERN("\\{(.*?)\\}"); +const std::regex SANITIZE_LEADING_UNDERSCORES("^_+"); +const std::regex SANITIZE_TRAILING_UNDERSCORES("_+$"); +const std::regex SANITIZE_CONSECUTIVE_UNDERSCORES("[_]{2,}"); #endif std::string PrometheusExporterUtils::GetEquivalentPrometheusUnit( diff --git a/exporters/prometheus/test/collector_test.cc b/exporters/prometheus/test/collector_test.cc index 63f840bc9a..a70fd317b3 100644 --- a/exporters/prometheus/test/collector_test.cc +++ b/exporters/prometheus/test/collector_test.cc @@ -23,7 +23,7 @@ class MockMetricProducer : public opentelemetry::sdk::metrics::MetricProducer public: MockMetricProducer(std::chrono::microseconds sleep_ms = std::chrono::microseconds::zero()) - : sleep_ms_{sleep_ms}, data_sent_size_(0) + : sleep_ms_{sleep_ms} {} bool Collect(nostd::function_ref callback) noexcept override @@ -39,7 +39,7 @@ class MockMetricProducer : public opentelemetry::sdk::metrics::MetricProducer private: std::chrono::microseconds sleep_ms_; - size_t data_sent_size_; + size_t data_sent_size_{0}; }; class MockMetricReader : public opentelemetry::sdk::metrics::MetricReader diff --git a/exporters/zipkin/src/zipkin_exporter.cc b/exporters/zipkin/src/zipkin_exporter.cc index a554cbf4cc..4c5723c674 100644 --- a/exporters/zipkin/src/zipkin_exporter.cc +++ b/exporters/zipkin/src/zipkin_exporter.cc @@ -50,9 +50,11 @@ ZipkinExporter::ZipkinExporter() : options_(ZipkinExporterOptions()), url_parser ZipkinExporter::ZipkinExporter( std::shared_ptr http_client) - : options_(ZipkinExporterOptions()), url_parser_(options_.endpoint) + : options_(ZipkinExporterOptions()), + http_client_(std::move(http_client)), + url_parser_(options_.endpoint) { - http_client_ = http_client; + InitializeLocalEndpoint(); } diff --git a/ext/src/http/client/curl/http_client_curl.cc b/ext/src/http/client/curl/http_client_curl.cc index 67b0b93a54..22f20fb0e0 100644 --- a/ext/src/http/client/curl/http_client_curl.cc +++ b/ext/src/http/client/curl/http_client_curl.cc @@ -185,13 +185,12 @@ void Session::FinishOperation() } HttpClient::HttpClient() - : next_session_id_{0}, + : multi_handle_(curl_multi_init()), + next_session_id_{0}, max_sessions_per_connection_{8}, scheduled_delay_milliseconds_{std::chrono::milliseconds(256)}, curl_global_initializer_(HttpCurlGlobalInitializer::GetInstance()) -{ - multi_handle_ = curl_multi_init(); -} +{} HttpClient::~HttpClient() { diff --git a/ext/test/http/curl_http_test.cc b/ext/test/http/curl_http_test.cc index 0dc6e5d5e8..d5351d2314 100644 --- a/ext/test/http/curl_http_test.cc +++ b/ext/test/http/curl_http_test.cc @@ -26,12 +26,11 @@ namespace nostd = opentelemetry::nostd; class CustomEventHandler : public http_client::EventHandler { public: - virtual void OnResponse(http_client::Response & /* response */) noexcept override + void OnResponse(http_client::Response & /* response */) noexcept override { got_response_ = true; } - virtual void OnEvent(http_client::SessionState state, - nostd::string_view /* reason */) noexcept override + void OnEvent(http_client::SessionState state, nostd::string_view /* reason */) noexcept override { switch (state) { @@ -113,7 +112,7 @@ class BasicCurlHttpTests : public ::testing::Test, public HTTP_SERVER_NS::HttpRe public: BasicCurlHttpTests() : is_setup_(false), is_running_(false) {} - virtual void SetUp() override + void SetUp() override { if (is_setup_.exchange(true)) { @@ -132,7 +131,7 @@ class BasicCurlHttpTests : public ::testing::Test, public HTTP_SERVER_NS::HttpRe is_running_ = true; } - virtual void TearDown() override + void TearDown() override { if (!is_setup_.exchange(false)) return; @@ -140,8 +139,8 @@ class BasicCurlHttpTests : public ::testing::Test, public HTTP_SERVER_NS::HttpRe is_running_ = false; } - virtual int onHttpRequest(HTTP_SERVER_NS::HttpRequest const &request, - HTTP_SERVER_NS::HttpResponse &response) override + int onHttpRequest(HTTP_SERVER_NS::HttpRequest const &request, + HTTP_SERVER_NS::HttpResponse &response) override { int response_status = 404; if (request.uri == "/get/") diff --git a/ext/test/w3c_tracecontext_test/main.cc b/ext/test/w3c_tracecontext_test/main.cc index d9819cde0d..4e9fb36796 100644 --- a/ext/test/w3c_tracecontext_test/main.cc +++ b/ext/test/w3c_tracecontext_test/main.cc @@ -30,7 +30,7 @@ class TextMapCarrierTest : public context::propagation::TextMapCarrier { public: TextMapCarrierTest(std::map &headers) : headers_(headers) {} - virtual nostd::string_view Get(nostd::string_view key) const noexcept override + nostd::string_view Get(nostd::string_view key) const noexcept override { auto it = headers_.find(std::string(key)); if (it != headers_.end()) @@ -39,7 +39,7 @@ class TextMapCarrierTest : public context::propagation::TextMapCarrier } return ""; } - virtual void Set(nostd::string_view key, nostd::string_view value) noexcept override + void Set(nostd::string_view key, nostd::string_view value) noexcept override { headers_[std::string(key)] = std::string(value); } diff --git a/sdk/include/opentelemetry/sdk/common/circular_buffer.h b/sdk/include/opentelemetry/sdk/common/circular_buffer.h index c2548012b1..6541612158 100644 --- a/sdk/include/opentelemetry/sdk/common/circular_buffer.h +++ b/sdk/include/opentelemetry/sdk/common/circular_buffer.h @@ -113,7 +113,6 @@ class CircularBuffer data_[head_index].Swap(ptr); } } - return true; } bool Add(std::unique_ptr &&ptr) noexcept diff --git a/sdk/src/common/base64.cc b/sdk/src/common/base64.cc index 3c572fe344..a78b88ad68 100644 --- a/sdk/src/common/base64.cc +++ b/sdk/src/common/base64.cc @@ -200,15 +200,10 @@ static int Base64UnescapeInternal(unsigned char *dst, ++line_len; if (src[i] == padding_char) { - if (++j > 2) + if (++j > 2 || (valid_slen & 3) == 1 || (valid_slen & 3) == 2) { return -2; } - else if ((valid_slen & 3) == 1 || (valid_slen & 3) == 2) - { - // First and second char of every group can not be padding char - return -2; - } } else { diff --git a/sdk/src/logs/logger_provider.cc b/sdk/src/logs/logger_provider.cc index fdea3eb51a..46bf1ade33 100644 --- a/sdk/src/logs/logger_provider.cc +++ b/sdk/src/logs/logger_provider.cc @@ -31,13 +31,13 @@ LoggerProvider::LoggerProvider(std::unique_ptr &&processor, { std::vector> processors; processors.emplace_back(std::move(processor)); - context_ = std::make_shared(std::move(processors), std::move(resource)); + context_ = std::make_shared(std::move(processors), resource); OTEL_INTERNAL_LOG_DEBUG("[LoggerProvider] LoggerProvider created."); } LoggerProvider::LoggerProvider(std::vector> &&processors, const opentelemetry::sdk::resource::Resource &resource) noexcept - : context_{std::make_shared(std::move(processors), std::move(resource))} + : context_{std::make_shared(std::move(processors), resource)} {} LoggerProvider::LoggerProvider() noexcept diff --git a/sdk/src/metrics/aggregation/lastvalue_aggregation.cc b/sdk/src/metrics/aggregation/lastvalue_aggregation.cc index 0380015234..2bc0eddb0e 100644 --- a/sdk/src/metrics/aggregation/lastvalue_aggregation.cc +++ b/sdk/src/metrics/aggregation/lastvalue_aggregation.cc @@ -28,9 +28,7 @@ LongLastValueAggregation::LongLastValueAggregation() point_data_.value_ = static_cast(0); } -LongLastValueAggregation::LongLastValueAggregation(LastValuePointData &&data) - : point_data_{std::move(data)} -{} +LongLastValueAggregation::LongLastValueAggregation(LastValuePointData &&data) : point_data_{data} {} LongLastValueAggregation::LongLastValueAggregation(const LastValuePointData &data) : point_data_{data} @@ -51,12 +49,12 @@ std::unique_ptr LongLastValueAggregation::Merge( if (nostd::get(ToPoint()).sample_ts_.time_since_epoch() > nostd::get(delta.ToPoint()).sample_ts_.time_since_epoch()) { - LastValuePointData merge_data = std::move(nostd::get(ToPoint())); + LastValuePointData merge_data = nostd::get(ToPoint()); return std::unique_ptr(new LongLastValueAggregation(std::move(merge_data))); } else { - LastValuePointData merge_data = std::move(nostd::get(delta.ToPoint())); + LastValuePointData merge_data = nostd::get(delta.ToPoint()); return std::unique_ptr(new LongLastValueAggregation(std::move(merge_data))); } } @@ -66,12 +64,12 @@ std::unique_ptr LongLastValueAggregation::Diff(const Aggregation &n if (nostd::get(ToPoint()).sample_ts_.time_since_epoch() > nostd::get(next.ToPoint()).sample_ts_.time_since_epoch()) { - LastValuePointData diff_data = std::move(nostd::get(ToPoint())); + LastValuePointData diff_data = nostd::get(ToPoint()); return std::unique_ptr(new LongLastValueAggregation(std::move(diff_data))); } else { - LastValuePointData diff_data = std::move(nostd::get(next.ToPoint())); + LastValuePointData diff_data = nostd::get(next.ToPoint()); return std::unique_ptr(new LongLastValueAggregation(std::move(diff_data))); } } @@ -89,7 +87,7 @@ DoubleLastValueAggregation::DoubleLastValueAggregation() } DoubleLastValueAggregation::DoubleLastValueAggregation(LastValuePointData &&data) - : point_data_{std::move(data)} + : point_data_{data} {} DoubleLastValueAggregation::DoubleLastValueAggregation(const LastValuePointData &data) @@ -111,12 +109,12 @@ std::unique_ptr DoubleLastValueAggregation::Merge( if (nostd::get(ToPoint()).sample_ts_.time_since_epoch() > nostd::get(delta.ToPoint()).sample_ts_.time_since_epoch()) { - LastValuePointData merge_data = std::move(nostd::get(ToPoint())); + LastValuePointData merge_data = nostd::get(ToPoint()); return std::unique_ptr(new DoubleLastValueAggregation(std::move(merge_data))); } else { - LastValuePointData merge_data = std::move(nostd::get(delta.ToPoint())); + LastValuePointData merge_data = nostd::get(delta.ToPoint()); return std::unique_ptr(new DoubleLastValueAggregation(std::move(merge_data))); } } @@ -127,12 +125,12 @@ std::unique_ptr DoubleLastValueAggregation::Diff( if (nostd::get(ToPoint()).sample_ts_.time_since_epoch() > nostd::get(next.ToPoint()).sample_ts_.time_since_epoch()) { - LastValuePointData diff_data = std::move(nostd::get(ToPoint())); + LastValuePointData diff_data = nostd::get(ToPoint()); return std::unique_ptr(new DoubleLastValueAggregation(std::move(diff_data))); } else { - LastValuePointData diff_data = std::move(nostd::get(next.ToPoint())); + LastValuePointData diff_data = nostd::get(next.ToPoint()); return std::unique_ptr(new DoubleLastValueAggregation(std::move(diff_data))); } } diff --git a/sdk/src/metrics/aggregation/sum_aggregation.cc b/sdk/src/metrics/aggregation/sum_aggregation.cc index 1e0442e92c..ce0d4c5de5 100644 --- a/sdk/src/metrics/aggregation/sum_aggregation.cc +++ b/sdk/src/metrics/aggregation/sum_aggregation.cc @@ -27,7 +27,7 @@ LongSumAggregation::LongSumAggregation(bool is_monotonic) point_data_.is_monotonic_ = is_monotonic; } -LongSumAggregation::LongSumAggregation(SumPointData &&data) : point_data_{std::move(data)} {} +LongSumAggregation::LongSumAggregation(SumPointData &&data) : point_data_{data} {} LongSumAggregation::LongSumAggregation(const SumPointData &data) : point_data_{data} {} @@ -81,7 +81,7 @@ DoubleSumAggregation::DoubleSumAggregation(bool is_monotonic) point_data_.is_monotonic_ = is_monotonic; } -DoubleSumAggregation::DoubleSumAggregation(SumPointData &&data) : point_data_(std::move(data)) {} +DoubleSumAggregation::DoubleSumAggregation(SumPointData &&data) : point_data_(data) {} DoubleSumAggregation::DoubleSumAggregation(const SumPointData &data) : point_data_(data) {} diff --git a/sdk/src/metrics/state/sync_metric_storage.cc b/sdk/src/metrics/state/sync_metric_storage.cc index fe736e64f3..ad6ea27821 100644 --- a/sdk/src/metrics/state/sync_metric_storage.cc +++ b/sdk/src/metrics/state/sync_metric_storage.cc @@ -39,7 +39,7 @@ bool SyncMetricStorage::Collect(CollectorHandle *collector, } return temporal_metric_storage_.buildMetrics(collector, collectors, sdk_start_ts, collection_ts, - std::move(delta_metrics), callback); + delta_metrics, callback); } } // namespace metrics diff --git a/sdk/src/trace/batch_span_processor.cc b/sdk/src/trace/batch_span_processor.cc index 6aa6a49949..f0f55d20e8 100644 --- a/sdk/src/trace/batch_span_processor.cc +++ b/sdk/src/trace/batch_span_processor.cc @@ -66,7 +66,7 @@ void BatchSpanProcessor::OnEnd(std::unique_ptr &&span) noexcept return; } - if (buffer_.Add(span) == false) + if (buffer_.Add(std::move(span)) == false) { OTEL_INTERNAL_LOG_WARN("BatchSpanProcessor queue is full - dropping span."); return; diff --git a/sdk/src/trace/samplers/parent_factory.cc b/sdk/src/trace/samplers/parent_factory.cc index 7f1bc088d6..63a7eff1c4 100644 --- a/sdk/src/trace/samplers/parent_factory.cc +++ b/sdk/src/trace/samplers/parent_factory.cc @@ -16,7 +16,7 @@ namespace trace std::unique_ptr ParentBasedSamplerFactory::Create( const std::shared_ptr &delegate_sampler) { - std::unique_ptr sampler(new ParentBasedSampler(std::move(delegate_sampler))); + std::unique_ptr sampler(new ParentBasedSampler(delegate_sampler)); return sampler; } diff --git a/sdk/test/common/random_test.cc b/sdk/test/common/random_test.cc index 243a998041..e22e0508fc 100644 --- a/sdk/test/common/random_test.cc +++ b/sdk/test/common/random_test.cc @@ -51,6 +51,7 @@ TEST(RandomTest, AtomicFlagMultiThreadTest) { std::vector threads; std::atomic_uint count(0); + threads.reserve(10); for (int i = 0; i < 10; ++i) { threads.push_back(std::thread(doSomethingOnce, &count)); diff --git a/sdk/test/metrics/periodic_exporting_metric_reader_test.cc b/sdk/test/metrics/periodic_exporting_metric_reader_test.cc index f65c10ca05..277a20582f 100644 --- a/sdk/test/metrics/periodic_exporting_metric_reader_test.cc +++ b/sdk/test/metrics/periodic_exporting_metric_reader_test.cc @@ -51,7 +51,7 @@ class MockMetricProducer : public MetricProducer { public: MockMetricProducer(std::chrono::microseconds sleep_ms = std::chrono::microseconds::zero()) - : sleep_ms_{sleep_ms}, data_sent_size_(0) + : sleep_ms_{sleep_ms} {} bool Collect(nostd::function_ref callback) noexcept override @@ -67,7 +67,7 @@ class MockMetricProducer : public MetricProducer private: std::chrono::microseconds sleep_ms_; - size_t data_sent_size_; + size_t data_sent_size_{0}; }; TEST(PeriodicExporingMetricReader, BasicTests) From a9208987c5ac1b2b9136e00ecfbf18890f80aa95 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Mon, 26 Aug 2024 21:59:17 +0200 Subject: [PATCH 23/89] [Code Health] include-what-you-use cleanup, part 3 (#3004) --- .iwyu.imp | 3 ++ .../baggage/propagation/baggage_propagator.h | 6 +++ .../common/key_value_iterable_view.h | 5 +++ api/include/opentelemetry/context/context.h | 3 ++ .../opentelemetry/context/runtime_context.h | 4 ++ .../opentelemetry/nostd/function_ref.h | 6 ++- api/include/opentelemetry/nostd/string_view.h | 5 ++- api/include/opentelemetry/nostd/variant.h | 2 +- .../opentelemetry/plugin/dynamic_load.h | 6 +-- api/include/opentelemetry/trace/noop.h | 10 ++++- api/include/opentelemetry/trace/provider.h | 4 +- api/include/opentelemetry/trace/scope.h | 4 +- .../opentelemetry/trace/span_context.h | 2 + api/include/opentelemetry/trace/trace_state.h | 5 ++- api/test/baggage/baggage_benchmark.cc | 9 ++-- api/test/baggage/baggage_test.cc | 41 ++++++++++--------- .../propagation/baggage_propagator_test.cc | 11 ++++- api/test/common/kv_properties_test.cc | 7 +++- api/test/common/spinlock_benchmark.cc | 17 ++++++-- api/test/common/string_util_test.cc | 6 +-- api/test/context/context_test.cc | 11 +++-- .../propagation/composite_propagator_test.cc | 30 +++++++++----- api/test/context/runtime_context_test.cc | 17 ++++++-- api/test/core/timestamp_test.cc | 6 ++- api/test/core/version_test.cc | 6 ++- api/test/logs/logger_benchmark.cc | 25 +++++------ api/test/logs/logger_test.cc | 18 +++++++- api/test/logs/provider_test.cc | 9 +++- api/test/metrics/meter_provider_test.cc | 2 + api/test/metrics/noop_sync_instrument_test.cc | 7 ++++ api/test/nostd/shared_ptr_test.cc | 8 ++-- api/test/nostd/span_test.cc | 8 ++-- api/test/nostd/string_view_test.cc | 7 +++- api/test/nostd/unique_ptr_test.cc | 6 ++- api/test/nostd/utility_test.cc | 6 +-- api/test/plugin/dynamic_load_test.cc | 6 +-- api/test/singleton/component_a.cc | 5 ++- api/test/singleton/component_b.cc | 5 ++- api/test/singleton/component_c.cc | 5 ++- api/test/singleton/component_d.cc | 5 ++- api/test/singleton/component_e.cc | 5 ++- api/test/singleton/component_f.cc | 5 ++- api/test/singleton/component_g.cc | 5 ++- api/test/singleton/component_h.cc | 5 ++- api/test/singleton/singleton_test.cc | 10 ++++- .../trace/key_value_iterable_view_test.cc | 11 ++++- api/test/trace/noop_test.cc | 23 ++++++++--- .../trace/propagation/b3_propagation_test.cc | 26 +++++++++--- api/test/trace/propagation/detail/hex_test.cc | 9 ++-- .../propagation/http_text_format_test.cc | 30 +++++++++++--- .../propagation/jaeger_propagation_test.cc | 30 +++++++++++--- api/test/trace/provider_test.cc | 8 ++-- api/test/trace/scope_test.cc | 12 ++++-- api/test/trace/span_benchmark.cc | 17 ++++++-- api/test/trace/span_id_benchmark.cc | 5 ++- api/test/trace/trace_flags_test.cc | 7 ++-- api/test/trace/trace_state_test.cc | 7 +++- api/test/trace/tracer_test.cc | 9 ++-- .../otlp/otlp_grpc_metric_exporter_factory.h | 2 + .../ext/http/client/http_client.h | 2 + functional/otlp/func_http_main.cc | 1 + 61 files changed, 415 insertions(+), 162 deletions(-) diff --git a/.iwyu.imp b/.iwyu.imp index 53fddd24aa..7ebbeae511 100644 --- a/.iwyu.imp +++ b/.iwyu.imp @@ -9,5 +9,8 @@ # Local opentelemetry-cpp + { "include": ["", "private", "", "public"] }, + { "include": ["", "private", "", "public"] }, + { "include": ["", "private", "", "public"] }, ] diff --git a/api/include/opentelemetry/baggage/propagation/baggage_propagator.h b/api/include/opentelemetry/baggage/propagation/baggage_propagator.h index 6de32882c0..d75409ed60 100644 --- a/api/include/opentelemetry/baggage/propagation/baggage_propagator.h +++ b/api/include/opentelemetry/baggage/propagation/baggage_propagator.h @@ -3,9 +3,15 @@ #pragma once +#include +#include + #include "opentelemetry/baggage/baggage.h" #include "opentelemetry/baggage/baggage_context.h" +#include "opentelemetry/context/context.h" #include "opentelemetry/context/propagation/text_map_propagator.h" +#include "opentelemetry/nostd/function_ref.h" +#include "opentelemetry/nostd/string_view.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/api/include/opentelemetry/common/key_value_iterable_view.h b/api/include/opentelemetry/common/key_value_iterable_view.h index fb1a6ea019..e22fb6f06f 100644 --- a/api/include/opentelemetry/common/key_value_iterable_view.h +++ b/api/include/opentelemetry/common/key_value_iterable_view.h @@ -3,9 +3,14 @@ #pragma once +#include +#include #include +#include #include +#include +#include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/nostd/function_ref.h" #include "opentelemetry/nostd/span.h" diff --git a/api/include/opentelemetry/context/context.h b/api/include/opentelemetry/context/context.h index cf5c9cd319..620ca51c8b 100644 --- a/api/include/opentelemetry/context/context.h +++ b/api/include/opentelemetry/context/context.h @@ -4,9 +4,12 @@ #pragma once #include +#include + #include "opentelemetry/context/context_value.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/variant.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/api/include/opentelemetry/context/runtime_context.h b/api/include/opentelemetry/context/runtime_context.h index cccc71e32f..73d4dcd908 100644 --- a/api/include/opentelemetry/context/runtime_context.h +++ b/api/include/opentelemetry/context/runtime_context.h @@ -3,8 +3,12 @@ #pragma once +#include +#include + #include "opentelemetry/common/macros.h" #include "opentelemetry/context/context.h" +#include "opentelemetry/context/context_value.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/unique_ptr.h" diff --git a/api/include/opentelemetry/nostd/function_ref.h b/api/include/opentelemetry/nostd/function_ref.h index 1064c966d7..6f0c2dd330 100644 --- a/api/include/opentelemetry/nostd/function_ref.h +++ b/api/include/opentelemetry/nostd/function_ref.h @@ -3,8 +3,10 @@ #pragma once -#include +#include +#include // IWYU pragma: keep #include +#include #include "opentelemetry/version.h" @@ -12,7 +14,7 @@ OPENTELEMETRY_BEGIN_NAMESPACE namespace nostd { template -class function_ref; +class function_ref; // IWYU pragma: keep /** * Non-owning function reference that can be used as a more performant diff --git a/api/include/opentelemetry/nostd/string_view.h b/api/include/opentelemetry/nostd/string_view.h index 5ee86dce23..f0e5bd9e2a 100644 --- a/api/include/opentelemetry/nostd/string_view.h +++ b/api/include/opentelemetry/nostd/string_view.h @@ -12,13 +12,14 @@ #if !defined(OPENTELEMETRY_HAVE_STD_STRING_VIEW) # include -# include # include +# include # include # include # include +# include +# include -# include "opentelemetry/common/macros.h" # include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/api/include/opentelemetry/nostd/variant.h b/api/include/opentelemetry/nostd/variant.h index d0b2d96001..6f3837c588 100644 --- a/api/include/opentelemetry/nostd/variant.h +++ b/api/include/opentelemetry/nostd/variant.h @@ -54,7 +54,7 @@ OPENTELEMETRY_END_NAMESPACE # ifdef HAVE_ABSEIL # include "absl/types/variant.h" # else -# include "./internal/absl/types/variant.h" +# include "opentelemetry/nostd/internal/absl/types/variant.h" # endif # ifdef _MSC_VER diff --git a/api/include/opentelemetry/plugin/dynamic_load.h b/api/include/opentelemetry/plugin/dynamic_load.h index 10b4a34af4..2da2713555 100644 --- a/api/include/opentelemetry/plugin/dynamic_load.h +++ b/api/include/opentelemetry/plugin/dynamic_load.h @@ -6,19 +6,19 @@ #include #include +#include "opentelemetry/plugin/factory.h" +#include "opentelemetry/version.h" + #ifdef _WIN32 # include "opentelemetry/plugin/detail/dynamic_load_windows.h" // IWYU pragma: export #else # include "opentelemetry/plugin/detail/dynamic_load_unix.h" // IWYU pragma: export #endif -#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace plugin { -class Factory; - /** * Load an OpenTelemetry implementation as a plugin. * @param plugin the path to the plugin to load diff --git a/api/include/opentelemetry/trace/noop.h b/api/include/opentelemetry/trace/noop.h index 345c4ba0c9..fa0c7957df 100644 --- a/api/include/opentelemetry/trace/noop.h +++ b/api/include/opentelemetry/trace/noop.h @@ -7,15 +7,21 @@ // This file is part of the internal implementation of OpenTelemetry. Nothing in this file should be // used directly. Please refer to span.h and tracer.h for documentation on these interfaces. -#include +#include +#include -#include "opentelemetry/context/runtime_context.h" +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/key_value_iterable.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/context/context_value.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/trace/span.h" #include "opentelemetry/trace/span_context.h" #include "opentelemetry/trace/span_context_kv_iterable.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/span_startoptions.h" #include "opentelemetry/trace/tracer.h" #include "opentelemetry/trace/tracer_provider.h" #include "opentelemetry/version.h" diff --git a/api/include/opentelemetry/trace/provider.h b/api/include/opentelemetry/trace/provider.h index d5a52a02f6..1439b579be 100644 --- a/api/include/opentelemetry/trace/provider.h +++ b/api/include/opentelemetry/trace/provider.h @@ -5,18 +5,16 @@ #include -#include "opentelemetry/common/macros.h" #include "opentelemetry/common/spin_lock_mutex.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/trace/noop.h" +#include "opentelemetry/trace/tracer_provider.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace trace { -class TracerProvider; - /** * Stores the singleton global TracerProvider. */ diff --git a/api/include/opentelemetry/trace/scope.h b/api/include/opentelemetry/trace/scope.h index 11ded4ab6c..20c415cc72 100644 --- a/api/include/opentelemetry/trace/scope.h +++ b/api/include/opentelemetry/trace/scope.h @@ -3,9 +3,11 @@ #pragma once +#include "opentelemetry/context/context.h" #include "opentelemetry/context/runtime_context.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/unique_ptr.h" +#include "opentelemetry/trace/span.h" #include "opentelemetry/trace/span_metadata.h" #include "opentelemetry/version.h" @@ -13,8 +15,6 @@ OPENTELEMETRY_BEGIN_NAMESPACE namespace trace { -class Span; - /** * Controls how long a span is active. * diff --git a/api/include/opentelemetry/trace/span_context.h b/api/include/opentelemetry/trace/span_context.h index 5fcab6e7ed..9403a74fb6 100644 --- a/api/include/opentelemetry/trace/span_context.h +++ b/api/include/opentelemetry/trace/span_context.h @@ -3,6 +3,8 @@ #pragma once +#include + #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/trace/span_id.h" #include "opentelemetry/trace/trace_flags.h" diff --git a/api/include/opentelemetry/trace/trace_state.h b/api/include/opentelemetry/trace/trace_state.h index f51410025a..753f48c99e 100644 --- a/api/include/opentelemetry/trace/trace_state.h +++ b/api/include/opentelemetry/trace/trace_state.h @@ -3,13 +3,14 @@ #pragma once -#include +#include +#include #include +#include #include "opentelemetry/common/kv_properties.h" #include "opentelemetry/nostd/function_ref.h" #include "opentelemetry/nostd/shared_ptr.h" -#include "opentelemetry/nostd/span.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/version.h" diff --git a/api/test/baggage/baggage_benchmark.cc b/api/test/baggage/baggage_benchmark.cc index 4ced142327..0786537cc0 100644 --- a/api/test/baggage/baggage_benchmark.cc +++ b/api/test/baggage/baggage_benchmark.cc @@ -1,11 +1,14 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include + #include "opentelemetry/baggage/baggage.h" #include "opentelemetry/nostd/string_view.h" - -#include -#include +#include "opentelemetry/nostd/utility.h" using namespace opentelemetry::baggage; namespace nostd = opentelemetry::nostd; diff --git a/api/test/baggage/baggage_test.cc b/api/test/baggage/baggage_test.cc index f29615c983..6f0347eef9 100644 --- a/api/test/baggage/baggage_test.cc +++ b/api/test/baggage/baggage_test.cc @@ -1,15 +1,17 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/nostd/string_view.h" - +#include #include +#include #include #include #include "opentelemetry/baggage/baggage.h" +#include "opentelemetry/common/kv_properties.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/string_view.h" -using namespace opentelemetry; using namespace opentelemetry::baggage; std::string header_with_custom_entries(size_t num_entries) @@ -82,7 +84,8 @@ TEST(BaggageTest, ValidateExtractHeader) { auto baggage = Baggage::FromHeader(testcase.input); size_t index = 0; - baggage->GetAllEntries([&testcase, &index](nostd::string_view key, nostd::string_view value) { + baggage->GetAllEntries([&testcase, &index](opentelemetry::nostd::string_view key, + opentelemetry::nostd::string_view value) { EXPECT_EQ(key, testcase.keys[index]); EXPECT_EQ(value, testcase.values[index]); index++; @@ -97,7 +100,7 @@ TEST(BaggageTest, ValidateExtractHeader) // Entries beyond threshold are dropped auto baggage = Baggage::FromHeader(header_with_custom_entries(Baggage::kMaxKeyValuePairs + 1)); auto header = baggage->ToHeader(); - common::KeyValueStringTokenizer kv_str_tokenizer(header); + opentelemetry::common::KeyValueStringTokenizer kv_str_tokenizer(header); int expected_tokens = Baggage::kMaxKeyValuePairs; EXPECT_EQ(kv_str_tokenizer.NumTokens(), expected_tokens); @@ -126,7 +129,7 @@ TEST(BaggageTest, ValidateInjectHeader) for (auto &testcase : testcases) { - nostd::shared_ptr baggage(new Baggage{}); + opentelemetry::nostd::shared_ptr baggage(new Baggage{}); for (size_t i = 0; i < testcase.keys.size(); i++) { baggage = baggage->Set(testcase.keys[i], testcase.values[i]); @@ -202,17 +205,17 @@ TEST(BaggageTest, BaggageRemove) TEST(BaggageTest, BaggageGetAll) { - std::string baggage_header = "k1=v1,k2=v2,k3=v3"; - auto baggage = Baggage::FromHeader(baggage_header); - const int kNumPairs = 3; - nostd::string_view keys[kNumPairs] = {"k1", "k2", "k3"}; - nostd::string_view values[kNumPairs] = {"v1", "v2", "v3"}; - size_t index = 0; - baggage->GetAllEntries( - [&keys, &values, &index](nostd::string_view key, nostd::string_view value) { - EXPECT_EQ(key, keys[index]); - EXPECT_EQ(value, values[index]); - index++; - return true; - }); + std::string baggage_header = "k1=v1,k2=v2,k3=v3"; + auto baggage = Baggage::FromHeader(baggage_header); + const int kNumPairs = 3; + opentelemetry::nostd::string_view keys[kNumPairs] = {"k1", "k2", "k3"}; + opentelemetry::nostd::string_view values[kNumPairs] = {"v1", "v2", "v3"}; + size_t index = 0; + baggage->GetAllEntries([&keys, &values, &index](opentelemetry::nostd::string_view key, + opentelemetry::nostd::string_view value) { + EXPECT_EQ(key, keys[index]); + EXPECT_EQ(value, values[index]); + index++; + return true; + }); } diff --git a/api/test/baggage/propagation/baggage_propagator_test.cc b/api/test/baggage/propagation/baggage_propagator_test.cc index c966fe7603..0efe1fac19 100644 --- a/api/test/baggage/propagation/baggage_propagator_test.cc +++ b/api/test/baggage/propagation/baggage_propagator_test.cc @@ -2,11 +2,20 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/baggage/propagation/baggage_propagator.h" #include #include +#include #include +#include +#include + +#include "opentelemetry/baggage/baggage.h" #include "opentelemetry/baggage/baggage_context.h" +#include "opentelemetry/baggage/propagation/baggage_propagator.h" +#include "opentelemetry/context/context.h" +#include "opentelemetry/context/propagation/text_map_propagator.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/utility.h" using namespace opentelemetry; using namespace opentelemetry::baggage::propagation; diff --git a/api/test/common/kv_properties_test.cc b/api/test/common/kv_properties_test.cc index f616664265..e81ee6979c 100644 --- a/api/test/common/kv_properties_test.cc +++ b/api/test/common/kv_properties_test.cc @@ -3,12 +3,15 @@ // SPDX-License-Identifier: Apache-2.0 #include -#include - +#include #include #include #include +#include +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/utility.h" + // ------------------------- Entry class tests --------------------------------- using namespace opentelemetry; diff --git a/api/test/common/spinlock_benchmark.cc b/api/test/common/spinlock_benchmark.cc index d0fef2c41b..b5e98a2108 100644 --- a/api/test/common/spinlock_benchmark.cc +++ b/api/test/common/spinlock_benchmark.cc @@ -1,10 +1,21 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/common/spin_lock_mutex.h" - #include -#include +#include +#include +#include +#include +#include + +#if defined(__i386__) || defined(__x86_64__) +# if defined(__clang__) || defined(__INTEL_COMPILER) +# include // for _mm_pause +# endif +#endif + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/common/spin_lock_mutex.h" namespace { diff --git a/api/test/common/string_util_test.cc b/api/test/common/string_util_test.cc index da2e635119..f074d4fbe3 100644 --- a/api/test/common/string_util_test.cc +++ b/api/test/common/string_util_test.cc @@ -2,11 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 #include -#include +#include -#include -#include -#include +#include // ------------------------- StringUtil class tests --------------------------------- diff --git a/api/test/context/context_test.cc b/api/test/context/context_test.cc index 294f1cd180..0798d7a130 100644 --- a/api/test/context/context_test.cc +++ b/api/test/context/context_test.cc @@ -1,11 +1,16 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/context/context.h" - +#include +#include #include +#include -#include +#include "opentelemetry/context/context.h" +#include "opentelemetry/context/context_value.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/variant.h" using namespace opentelemetry; diff --git a/api/test/context/propagation/composite_propagator_test.cc b/api/test/context/propagation/composite_propagator_test.cc index 075841080f..e905f64e1a 100644 --- a/api/test/context/propagation/composite_propagator_test.cc +++ b/api/test/context/propagation/composite_propagator_test.cc @@ -1,22 +1,32 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/trace/scope.h" -#include "opentelemetry/trace/span.h" -#include "opentelemetry/trace/span_context.h" +#include +#include +#include +#include +#include +#include +#include +#include "opentelemetry/context/context.h" #include "opentelemetry/context/propagation/composite_propagator.h" #include "opentelemetry/context/propagation/text_map_propagator.h" +#include "opentelemetry/context/runtime_context.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/variant.h" #include "opentelemetry/trace/default_span.h" #include "opentelemetry/trace/propagation/b3_propagator.h" #include "opentelemetry/trace/propagation/http_trace_context.h" - -#include -#include -#include - -#include +#include "opentelemetry/trace/scope.h" +#include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_flags.h" +#include "opentelemetry/trace/trace_id.h" using namespace opentelemetry; diff --git a/api/test/context/runtime_context_test.cc b/api/test/context/runtime_context_test.cc index cd551c599c..f8407b0ca8 100644 --- a/api/test/context/runtime_context_test.cc +++ b/api/test/context/runtime_context_test.cc @@ -1,13 +1,22 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/context/runtime_context.h" -#include "opentelemetry/context/context.h" - +#include +#include +#include #include #include +#include +#include +#include -#include +#include "opentelemetry/context/context.h" +#include "opentelemetry/context/context_value.h" +#include "opentelemetry/context/runtime_context.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/unique_ptr.h" +#include "opentelemetry/nostd/variant.h" using namespace opentelemetry; diff --git a/api/test/core/timestamp_test.cc b/api/test/core/timestamp_test.cc index 8efc0215be..ba3c70e4e5 100644 --- a/api/test/core/timestamp_test.cc +++ b/api/test/core/timestamp_test.cc @@ -1,9 +1,11 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/common/timestamp.h" - #include +#include +#include + +#include "opentelemetry/common/timestamp.h" using opentelemetry::common::SteadyTimestamp; using opentelemetry::common::SystemTimestamp; diff --git a/api/test/core/version_test.cc b/api/test/core/version_test.cc index 2e360ffdad..1ceb68602b 100644 --- a/api/test/core/version_test.cc +++ b/api/test/core/version_test.cc @@ -1,9 +1,11 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/version.h" - #include +#include +#include + +#include "opentelemetry/version.h" TEST(VersionTest, Consistency) { diff --git a/api/test/logs/logger_benchmark.cc b/api/test/logs/logger_benchmark.cc index 7e8913a3f7..29808fa003 100644 --- a/api/test/logs/logger_benchmark.cc +++ b/api/test/logs/logger_benchmark.cc @@ -1,29 +1,30 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/common/timestamp.h" -#include "opentelemetry/logs/logger.h" -#include "opentelemetry/logs/provider.h" -#include "opentelemetry/nostd/shared_ptr.h" - -#include +#include +#include +#include #include +#include #include #include #include #include -#include +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/logs/event_id.h" +#include "opentelemetry/logs/logger.h" +#include "opentelemetry/logs/logger_provider.h" +#include "opentelemetry/logs/provider.h" +#include "opentelemetry/logs/severity.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" using opentelemetry::logs::EventId; using opentelemetry::logs::Provider; using opentelemetry::logs::Severity; -namespace common = opentelemetry::common; -namespace nostd = opentelemetry::nostd; -namespace trace = opentelemetry::trace; -namespace log_api = opentelemetry::logs; - namespace { diff --git a/api/test/logs/logger_test.cc b/api/test/logs/logger_test.cc index 848f053453..351e079dd4 100644 --- a/api/test/logs/logger_test.cc +++ b/api/test/logs/logger_test.cc @@ -2,13 +2,27 @@ // SPDX-License-Identifier: Apache-2.0 #include -#include +#include +#include +#include #include -#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/key_value_iterable.h" +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/logs/event_id.h" +#include "opentelemetry/logs/event_logger.h" +#include "opentelemetry/logs/event_logger_provider.h" +#include "opentelemetry/logs/log_record.h" #include "opentelemetry/logs/logger.h" +#include "opentelemetry/logs/logger_provider.h" #include "opentelemetry/logs/provider.h" +#include "opentelemetry/logs/severity.h" #include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/unique_ptr.h" +#include "opentelemetry/nostd/utility.h" using opentelemetry::logs::EventId; using opentelemetry::logs::Logger; diff --git a/api/test/logs/provider_test.cc b/api/test/logs/provider_test.cc index 92c589ef7e..298289ceab 100644 --- a/api/test/logs/provider_test.cc +++ b/api/test/logs/provider_test.cc @@ -2,10 +2,17 @@ // SPDX-License-Identifier: Apache-2.0 #include -#include +#include +#include "opentelemetry/common/key_value_iterable.h" +#include "opentelemetry/logs/event_logger.h" +#include "opentelemetry/logs/event_logger_provider.h" +#include "opentelemetry/logs/logger.h" +#include "opentelemetry/logs/logger_provider.h" #include "opentelemetry/logs/provider.h" #include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/utility.h" using opentelemetry::logs::EventLogger; using opentelemetry::logs::EventLoggerProvider; diff --git a/api/test/metrics/meter_provider_test.cc b/api/test/metrics/meter_provider_test.cc index b8fb083799..639f0e8f49 100644 --- a/api/test/metrics/meter_provider_test.cc +++ b/api/test/metrics/meter_provider_test.cc @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 #include + +#include "opentelemetry/metrics/meter_provider.h" #include "opentelemetry/metrics/noop.h" #include "opentelemetry/metrics/provider.h" #include "opentelemetry/nostd/shared_ptr.h" diff --git a/api/test/metrics/noop_sync_instrument_test.cc b/api/test/metrics/noop_sync_instrument_test.cc index 6411e0e820..4218f2b4ff 100644 --- a/api/test/metrics/noop_sync_instrument_test.cc +++ b/api/test/metrics/noop_sync_instrument_test.cc @@ -2,8 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 #include +#include #include +#include +#include + +#include "opentelemetry/context/context.h" #include "opentelemetry/metrics/noop.h" +#include "opentelemetry/metrics/sync_instruments.h" +#include "opentelemetry/nostd/string_view.h" TEST(Counter, Add) { diff --git a/api/test/nostd/shared_ptr_test.cc b/api/test/nostd/shared_ptr_test.cc index 2ebba82628..e5f77709b1 100644 --- a/api/test/nostd/shared_ptr_test.cc +++ b/api/test/nostd/shared_ptr_test.cc @@ -1,11 +1,13 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/nostd/shared_ptr.h" - #include - +#include #include +#include +#include + +#include "opentelemetry/nostd/shared_ptr.h" using opentelemetry::nostd::shared_ptr; diff --git a/api/test/nostd/span_test.cc b/api/test/nostd/span_test.cc index 17427a249a..b54883d67a 100644 --- a/api/test/nostd/span_test.cc +++ b/api/test/nostd/span_test.cc @@ -1,10 +1,8 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/nostd/span.h" - -#include - +#include +#include #include #include #include @@ -12,7 +10,7 @@ #include #include -#include +#include "opentelemetry/nostd/span.h" using opentelemetry::nostd::span; diff --git a/api/test/nostd/string_view_test.cc b/api/test/nostd/string_view_test.cc index bbd5cb0648..f32da62b42 100644 --- a/api/test/nostd/string_view_test.cc +++ b/api/test/nostd/string_view_test.cc @@ -1,11 +1,14 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/nostd/string_view.h" - #include #include #include +#include +#include +#include + +#include "opentelemetry/nostd/string_view.h" using opentelemetry::nostd::string_view; diff --git a/api/test/nostd/unique_ptr_test.cc b/api/test/nostd/unique_ptr_test.cc index 893525c266..9fbe058822 100644 --- a/api/test/nostd/unique_ptr_test.cc +++ b/api/test/nostd/unique_ptr_test.cc @@ -1,9 +1,11 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/nostd/unique_ptr.h" - #include +#include +#include + +#include "opentelemetry/nostd/unique_ptr.h" using opentelemetry::nostd::unique_ptr; diff --git a/api/test/nostd/utility_test.cc b/api/test/nostd/utility_test.cc index 821b2a70a4..5c62df0c88 100644 --- a/api/test/nostd/utility_test.cc +++ b/api/test/nostd/utility_test.cc @@ -1,13 +1,13 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/nostd/utility.h" - +#include +#include #include #include #include -#include +#include "opentelemetry/nostd/utility.h" namespace nostd = opentelemetry::nostd; diff --git a/api/test/plugin/dynamic_load_test.cc b/api/test/plugin/dynamic_load_test.cc index 8e8b14800c..68a27b5a8f 100644 --- a/api/test/plugin/dynamic_load_test.cc +++ b/api/test/plugin/dynamic_load_test.cc @@ -1,10 +1,10 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/plugin/dynamic_load.h" -#include "opentelemetry/plugin/factory.h" - #include +#include + +#include "opentelemetry/plugin/dynamic_load.h" TEST(LoadFactoryTest, FailureTest) { diff --git a/api/test/singleton/component_a.cc b/api/test/singleton/component_a.cc index bdf03cb699..1660f85685 100644 --- a/api/test/singleton/component_a.cc +++ b/api/test/singleton/component_a.cc @@ -1,9 +1,12 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include "opentelemetry/context/context_value.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/trace/provider.h" -#include "opentelemetry/version.h" +#include "opentelemetry/trace/scope.h" +#include "opentelemetry/trace/tracer.h" +#include "opentelemetry/trace/tracer_provider.h" #include "component_a.h" diff --git a/api/test/singleton/component_b.cc b/api/test/singleton/component_b.cc index 966d9c461a..ea53f39b6e 100644 --- a/api/test/singleton/component_b.cc +++ b/api/test/singleton/component_b.cc @@ -1,9 +1,12 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include "opentelemetry/context/context_value.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/trace/provider.h" -#include "opentelemetry/version.h" +#include "opentelemetry/trace/scope.h" +#include "opentelemetry/trace/tracer.h" +#include "opentelemetry/trace/tracer_provider.h" #include "component_b.h" diff --git a/api/test/singleton/component_c.cc b/api/test/singleton/component_c.cc index cd87ceb727..9fae8b41db 100644 --- a/api/test/singleton/component_c.cc +++ b/api/test/singleton/component_c.cc @@ -1,9 +1,12 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include "opentelemetry/context/context_value.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/trace/provider.h" -#include "opentelemetry/version.h" +#include "opentelemetry/trace/scope.h" +#include "opentelemetry/trace/tracer.h" +#include "opentelemetry/trace/tracer_provider.h" #define BUILD_COMPONENT_C diff --git a/api/test/singleton/component_d.cc b/api/test/singleton/component_d.cc index 313fd1d23a..57f3252826 100644 --- a/api/test/singleton/component_d.cc +++ b/api/test/singleton/component_d.cc @@ -1,9 +1,12 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include "opentelemetry/context/context_value.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/trace/provider.h" -#include "opentelemetry/version.h" +#include "opentelemetry/trace/scope.h" +#include "opentelemetry/trace/tracer.h" +#include "opentelemetry/trace/tracer_provider.h" #define BUILD_COMPONENT_D diff --git a/api/test/singleton/component_e.cc b/api/test/singleton/component_e.cc index 9c88d27732..94eec808ab 100644 --- a/api/test/singleton/component_e.cc +++ b/api/test/singleton/component_e.cc @@ -1,9 +1,12 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include "opentelemetry/context/context_value.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/trace/provider.h" -#include "opentelemetry/version.h" +#include "opentelemetry/trace/scope.h" +#include "opentelemetry/trace/tracer.h" +#include "opentelemetry/trace/tracer_provider.h" #define BUILD_COMPONENT_E diff --git a/api/test/singleton/component_f.cc b/api/test/singleton/component_f.cc index 33b0af2fbd..9083e2bced 100644 --- a/api/test/singleton/component_f.cc +++ b/api/test/singleton/component_f.cc @@ -1,9 +1,12 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include "opentelemetry/context/context_value.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/trace/provider.h" -#include "opentelemetry/version.h" +#include "opentelemetry/trace/scope.h" +#include "opentelemetry/trace/tracer.h" +#include "opentelemetry/trace/tracer_provider.h" #define BUILD_COMPONENT_F diff --git a/api/test/singleton/component_g.cc b/api/test/singleton/component_g.cc index 50de03ee98..0529ca7c27 100644 --- a/api/test/singleton/component_g.cc +++ b/api/test/singleton/component_g.cc @@ -1,9 +1,12 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include "opentelemetry/context/context_value.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/trace/provider.h" -#include "opentelemetry/version.h" +#include "opentelemetry/trace/scope.h" +#include "opentelemetry/trace/tracer.h" +#include "opentelemetry/trace/tracer_provider.h" namespace trace = opentelemetry::trace; namespace nostd = opentelemetry::nostd; diff --git a/api/test/singleton/component_h.cc b/api/test/singleton/component_h.cc index 3ff6e0cc5a..a66ab96858 100644 --- a/api/test/singleton/component_h.cc +++ b/api/test/singleton/component_h.cc @@ -1,9 +1,12 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include "opentelemetry/context/context_value.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/trace/provider.h" -#include "opentelemetry/version.h" +#include "opentelemetry/trace/scope.h" +#include "opentelemetry/trace/tracer.h" +#include "opentelemetry/trace/tracer_provider.h" namespace trace = opentelemetry::trace; namespace nostd = opentelemetry::nostd; diff --git a/api/test/singleton/singleton_test.cc b/api/test/singleton/singleton_test.cc index fb4551cfe9..d212221118 100644 --- a/api/test/singleton/singleton_test.cc +++ b/api/test/singleton/singleton_test.cc @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 #include +#include /* TODO: @@ -12,8 +13,6 @@ # include #endif -#include - #include "component_a.h" #include "component_b.h" #include "component_c.h" @@ -21,11 +20,18 @@ #include "component_e.h" #include "component_f.h" +#include "opentelemetry/common/key_value_iterable.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/utility.h" #include "opentelemetry/trace/default_span.h" +#include "opentelemetry/trace/noop.h" #include "opentelemetry/trace/provider.h" #include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/span_context.h" #include "opentelemetry/trace/span_context_kv_iterable.h" #include "opentelemetry/trace/span_startoptions.h" +#include "opentelemetry/trace/tracer.h" #include "opentelemetry/trace/tracer_provider.h" using namespace opentelemetry; diff --git a/api/test/trace/key_value_iterable_view_test.cc b/api/test/trace/key_value_iterable_view_test.cc index e0f43c4afb..b2334b8f98 100644 --- a/api/test/trace/key_value_iterable_view_test.cc +++ b/api/test/trace/key_value_iterable_view_test.cc @@ -1,11 +1,18 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/common/key_value_iterable_view.h" - #include #include +#include +#include +#include + +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/key_value_iterable.h" +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/type_traits.h" +#include "opentelemetry/nostd/utility.h" using namespace opentelemetry; diff --git a/api/test/trace/noop_test.cc b/api/test/trace/noop_test.cc index b47700d442..26663c738f 100644 --- a/api/test/trace/noop_test.cc +++ b/api/test/trace/noop_test.cc @@ -1,14 +1,27 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/trace/noop.h" -#include "opentelemetry/common/timestamp.h" - +#include +#include +#include #include -#include #include +#include +#include -#include +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/context/context_value.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/unique_ptr.h" +#include "opentelemetry/trace/noop.h" +#include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_flags.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/trace/tracer.h" namespace trace_api = opentelemetry::trace; namespace nonstd = opentelemetry::nostd; diff --git a/api/test/trace/propagation/b3_propagation_test.cc b/api/test/trace/propagation/b3_propagation_test.cc index 732db1bd34..a2a0581ad1 100644 --- a/api/test/trace/propagation/b3_propagation_test.cc +++ b/api/test/trace/propagation/b3_propagation_test.cc @@ -1,14 +1,30 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include "util.h" + +#include "opentelemetry/context/context.h" +#include "opentelemetry/context/context_value.h" +#include "opentelemetry/context/propagation/text_map_propagator.h" #include "opentelemetry/context/runtime_context.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/trace/default_span.h" #include "opentelemetry/trace/propagation/b3_propagator.h" #include "opentelemetry/trace/scope.h" -#include "util.h" - -#include - -#include +#include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_flags.h" +#include "opentelemetry/trace/trace_id.h" using namespace opentelemetry; diff --git a/api/test/trace/propagation/detail/hex_test.cc b/api/test/trace/propagation/detail/hex_test.cc index f4bd765f48..88cf5b46b0 100644 --- a/api/test/trace/propagation/detail/hex_test.cc +++ b/api/test/trace/propagation/detail/hex_test.cc @@ -1,11 +1,12 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/trace/propagation/detail/hex.h" - -#include - #include +#include +#include + +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/trace/propagation/detail/hex.h" using namespace opentelemetry; diff --git a/api/test/trace/propagation/http_text_format_test.cc b/api/test/trace/propagation/http_text_format_test.cc index 99f7117928..54f041a9cc 100644 --- a/api/test/trace/propagation/http_text_format_test.cc +++ b/api/test/trace/propagation/http_text_format_test.cc @@ -1,17 +1,35 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include +#include "util.h" + +#include "opentelemetry/context/context.h" +#include "opentelemetry/context/context_value.h" #include "opentelemetry/context/propagation/global_propagator.h" +#include "opentelemetry/context/propagation/text_map_propagator.h" #include "opentelemetry/context/runtime_context.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/variant.h" #include "opentelemetry/trace/context.h" +#include "opentelemetry/trace/default_span.h" #include "opentelemetry/trace/propagation/http_trace_context.h" #include "opentelemetry/trace/scope.h" -#include "util.h" - -#include -#include - -#include +#include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_flags.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/trace/trace_state.h" using namespace opentelemetry; diff --git a/api/test/trace/propagation/jaeger_propagation_test.cc b/api/test/trace/propagation/jaeger_propagation_test.cc index f0fdaf734d..637d2206b8 100644 --- a/api/test/trace/propagation/jaeger_propagation_test.cc +++ b/api/test/trace/propagation/jaeger_propagation_test.cc @@ -1,13 +1,33 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/trace/propagation/jaeger.h" -#include "opentelemetry/trace/scope.h" -#include "util.h" - +#include +#include +#include #include +#include +#include +#include +#include "util.h" -#include +#include "opentelemetry/context/context.h" +#include "opentelemetry/context/context_value.h" +#include "opentelemetry/context/propagation/text_map_propagator.h" +#include "opentelemetry/context/runtime_context.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/trace/context.h" +#include "opentelemetry/trace/default_span.h" +#include "opentelemetry/trace/propagation/jaeger.h" +#include "opentelemetry/trace/scope.h" +#include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_flags.h" +#include "opentelemetry/trace/trace_id.h" using namespace opentelemetry; diff --git a/api/test/trace/provider_test.cc b/api/test/trace/provider_test.cc index be2ca2842c..6b59d91245 100644 --- a/api/test/trace/provider_test.cc +++ b/api/test/trace/provider_test.cc @@ -1,12 +1,14 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/trace/provider.h" +#include + #include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/trace/provider.h" +#include "opentelemetry/trace/tracer.h" #include "opentelemetry/trace/tracer_provider.h" -#include - using opentelemetry::trace::Provider; using opentelemetry::trace::Tracer; using opentelemetry::trace::TracerProvider; diff --git a/api/test/trace/scope_test.cc b/api/test/trace/scope_test.cc index b74905b167..1383122bbc 100644 --- a/api/test/trace/scope_test.cc +++ b/api/test/trace/scope_test.cc @@ -1,12 +1,16 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/trace/scope.h" -#include "opentelemetry/context/context.h" +#include + +#include "opentelemetry/context/context_value.h" +#include "opentelemetry/context/runtime_context.h" #include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/variant.h" #include "opentelemetry/trace/noop.h" - -#include +#include "opentelemetry/trace/scope.h" +#include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/span_metadata.h" using opentelemetry::trace::kSpanKey; using opentelemetry::trace::NoopSpan; diff --git a/api/test/trace/span_benchmark.cc b/api/test/trace/span_benchmark.cc index 3120eb0e5a..8770ec14a0 100644 --- a/api/test/trace/span_benchmark.cc +++ b/api/test/trace/span_benchmark.cc @@ -1,15 +1,24 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include + +#include "opentelemetry/context/context_value.h" +#include "opentelemetry/context/runtime_context.h" #include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/variant.h" #include "opentelemetry/trace/context.h" +#include "opentelemetry/trace/default_span.h" #include "opentelemetry/trace/noop.h" +#include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/span_context.h" #include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/span_startoptions.h" +#include "opentelemetry/trace/trace_flags.h" #include "opentelemetry/trace/trace_id.h" - -#include - -#include +#include "opentelemetry/trace/tracer.h" using opentelemetry::trace::SpanContext; namespace trace_api = opentelemetry::trace; diff --git a/api/test/trace/span_id_benchmark.cc b/api/test/trace/span_id_benchmark.cc index 42d4aeb465..236fa3ac76 100644 --- a/api/test/trace/span_id_benchmark.cc +++ b/api/test/trace/span_id_benchmark.cc @@ -1,11 +1,12 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/trace/span_id.h" - #include #include +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/trace/span_id.h" + namespace { using opentelemetry::trace::SpanId; diff --git a/api/test/trace/trace_flags_test.cc b/api/test/trace/trace_flags_test.cc index 783b56d839..d900c6f7d5 100644 --- a/api/test/trace/trace_flags_test.cc +++ b/api/test/trace/trace_flags_test.cc @@ -1,12 +1,11 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/trace/trace_flags.h" - -#include +#include +#include #include -#include +#include "opentelemetry/trace/trace_flags.h" namespace { diff --git a/api/test/trace/trace_state_test.cc b/api/test/trace/trace_state_test.cc index e6ed73c1f4..d136bddb00 100644 --- a/api/test/trace/trace_state_test.cc +++ b/api/test/trace/trace_state_test.cc @@ -1,10 +1,13 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/trace/trace_state.h" - #include +#include +#include +#include + #include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/trace/trace_state.h" namespace { diff --git a/api/test/trace/tracer_test.cc b/api/test/trace/tracer_test.cc index 8e16f15e25..77396a24d2 100644 --- a/api/test/trace/tracer_test.cc +++ b/api/test/trace/tracer_test.cc @@ -1,11 +1,14 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include + +#include "opentelemetry/context/context_value.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/trace/noop.h" -#include "opentelemetry/trace/scope.h" - -#include +#include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/tracer.h" namespace trace_api = opentelemetry::trace; namespace nostd = opentelemetry::nostd; diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h index f8b3ee1fc3..11b185a384 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h @@ -3,6 +3,8 @@ #pragma once +#include + #include "opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_options.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" diff --git a/ext/include/opentelemetry/ext/http/client/http_client.h b/ext/include/opentelemetry/ext/http/client/http_client.h index 1089402e28..d17215da9b 100644 --- a/ext/include/opentelemetry/ext/http/client/http_client.h +++ b/ext/include/opentelemetry/ext/http/client/http_client.h @@ -6,8 +6,10 @@ #include #include #include +#include #include #include + #include "opentelemetry/nostd/function_ref.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/version.h" diff --git a/functional/otlp/func_http_main.cc b/functional/otlp/func_http_main.cc index ece1588425..99fec8443e 100644 --- a/functional/otlp/func_http_main.cc +++ b/functional/otlp/func_http_main.cc @@ -1,6 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include #include #include #include From f02d70bdb82985bea713b283bdd3da9937cb2172 Mon Sep 17 00:00:00 2001 From: Punya Biswal Date: Tue, 3 Sep 2024 09:19:57 -0400 Subject: [PATCH 24/89] Fix overflow in timeout logic (#3046) --- .../periodic_exporting_metric_reader.cc | 2 +- sdk/src/metrics/meter_context.cc | 34 +++++++------------ 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/sdk/src/metrics/export/periodic_exporting_metric_reader.cc b/sdk/src/metrics/export/periodic_exporting_metric_reader.cc index 1ebfc2a1b6..42fd6003ae 100644 --- a/sdk/src/metrics/export/periodic_exporting_metric_reader.cc +++ b/sdk/src/metrics/export/periodic_exporting_metric_reader.cc @@ -218,7 +218,7 @@ bool PeriodicExportingMetricReader::OnForceFlush(std::chrono::microseconds timeo // - If original `timeout` is `zero`, use that in exporter::forceflush // - Else if remaining `timeout_steady` more than zero, use that in exporter::forceflush // - Else don't invoke exporter::forceflush ( as remaining time is zero or less) - if (timeout <= std::chrono::steady_clock::duration::zero()) + if (timeout <= std::chrono::milliseconds::duration::zero()) { result = exporter_->ForceFlush(std::chrono::duration_cast(timeout)); diff --git a/sdk/src/metrics/meter_context.cc b/sdk/src/metrics/meter_context.cc index 40b9da42b2..42efce76fb 100644 --- a/sdk/src/metrics/meter_context.cc +++ b/sdk/src/metrics/meter_context.cc @@ -168,46 +168,36 @@ bool MeterContext::ForceFlush(std::chrono::microseconds timeout) noexcept bool result = true; // Simultaneous flush not allowed. const std::lock_guard locked(forceflush_lock_); - // Convert to nanos to prevent overflow - auto timeout_ns = (std::chrono::nanoseconds::max)(); - if (std::chrono::duration_cast(timeout_ns) > timeout) - { - timeout_ns = std::chrono::duration_cast(timeout); - } - - auto current_time = std::chrono::system_clock::now(); - std::chrono::system_clock::time_point expire_time; - auto overflow_checker = (std::chrono::system_clock::time_point::max)(); - // check if the expected expire time doesn't overflow. - if (overflow_checker - current_time > timeout_ns) + auto time_remaining = (std::chrono::steady_clock::duration::max)(); + if (std::chrono::duration_cast(time_remaining) > timeout) { - expire_time = - current_time + std::chrono::duration_cast(timeout_ns); + time_remaining = timeout; } - else + + auto current_time = std::chrono::steady_clock::now(); + auto expire_time = (std::chrono::steady_clock::time_point::max)(); + if (expire_time - current_time > time_remaining) { - // overflow happens, reset expire time to max. - expire_time = overflow_checker; + expire_time = current_time + time_remaining; } for (auto &collector : collectors_) { if (!std::static_pointer_cast(collector)->ForceFlush( - std::chrono::duration_cast(timeout_ns))) + std::chrono::duration_cast(time_remaining))) { result = false; } - current_time = std::chrono::system_clock::now(); - + current_time = std::chrono::steady_clock::now(); if (expire_time >= current_time) { - timeout_ns = std::chrono::duration_cast(expire_time - current_time); + time_remaining = expire_time - current_time; } else { - timeout_ns = std::chrono::nanoseconds::zero(); + time_remaining = std::chrono::steady_clock::duration::zero(); } } if (!result) From 7f785b5d5c1c3b6125eca9685a9eb6d7f443038a Mon Sep 17 00:00:00 2001 From: Punya Biswal Date: Tue, 3 Sep 2024 15:08:37 -0400 Subject: [PATCH 25/89] [TEST] Add missing tests to Bazel build (#3045) * Fix overflow in timeout logic Also use steady clock consistently. Prior to this change, the test would fail under ASAN: bazel test --config=asan --test_output=errors //sdk/test/metrics:meter_provider_sdk_test INFO: Analyzed target //sdk/test/metrics:meter_provider_sdk_test (0 packages loaded, 0 targets configured). FAIL: //sdk/test/metrics:meter_provider_sdk_test (see /private/var/tmp/_bazel_punya/e3bd968ba61238cdeb1a5537fc3dbf7d/execroot/_main/bazel-out/darwin_arm64-fastbuild-asan/testlogs/sdk/test/metrics/meter_provider_sdk_test/test.log) INFO: From Testing //sdk/test/metrics:meter_provider_sdk_test: ==================== Test output for //sdk/test/metrics:meter_provider_sdk_test: Running main() from gmock_main.cc [==========] Running 1 test from 1 test suite. [----------] Global test environment set-up. [----------] 1 test from MeterProvider [ RUN ] MeterProvider.GetMeter [Warning] File: sdk/src/metrics/meter_provider.cc:65 [MeterProvider::GetMeter] Library name is empty. [Warning] File: sdk/src/metrics/meter_provider.cc:65 [MeterProvider::GetMeter] Library name is empty. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__chrono/duration.h:102:59: runtime error: signed integer overflow: 9221646818050376183 * 1000 cannot be represented in type '_Ct' (aka 'long long') SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__chrono/duration.h:102:59 in ================================================================================ INFO: Found 1 test target... Target //sdk/test/metrics:meter_provider_sdk_test up-to-date: bazel-bin/sdk/test/metrics/meter_provider_sdk_test INFO: Elapsed time: 2.251s, Critical Path: 2.13s INFO: 5 processes: 5 darwin-sandbox. INFO: Build completed, 1 test FAILED, 5 total actions //sdk/test/metrics:meter_provider_sdk_test FAILED in 0.6s /private/var/tmp/_bazel_punya/e3bd968ba61238cdeb1a5537fc3dbf7d/execroot/_main/bazel-out/darwin_arm64-fastbuild-asan/testlogs/sdk/test/metrics/meter_provider_sdk_test/test.log Executed 1 out of 1 test: 1 fails locally. Fix overflow in periodic_exporting_metric_reader * Add missing tests to Bazel build by globbing test files Previously, we were missing * instrument_metadata_validator_test * observable_registry_test * cardinality_limit_test * periodic_exporting_metric_reader_test And there were no checks in place to prevent things from getting worse. Remove unnecessary exception checks in attributes_hashmap_test, which simplifies the build and CI script. Resolve symbol collision using anonymous namespaces. --------- Co-authored-by: Lalit Kumar Bhasin --- ci/do_ci.sh | 4 +- sdk/test/metrics/BUILD | 303 +----------------- sdk/test/metrics/async_instruments_test.cc | 3 + sdk/test/metrics/attributes_hashmap_test.cc | 10 +- sdk/test/metrics/meter_test.cc | 2 +- .../periodic_exporting_metric_reader_test.cc | 2 +- 6 files changed, 14 insertions(+), 310 deletions(-) diff --git a/ci/do_ci.sh b/ci/do_ci.sh index 6d339c8d4e..4cd97a7f43 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -484,8 +484,8 @@ elif [[ "$1" == "bazel.noexcept" ]]; then # there are some exceptions and error handling code from the Prometheus Client # as well as Opentracing shim (due to some third party code in its Opentracing dependency) # that make this test always fail. Ignore these packages in the noexcept test here. - bazel $BAZEL_STARTUP_OPTIONS build --copt=-fno-exceptions $BAZEL_OPTIONS_ASYNC -- //... -//exporters/prometheus/... -//examples/prometheus/... -//sdk/test/metrics:attributes_hashmap_test -//opentracing-shim/... - bazel $BAZEL_STARTUP_OPTIONS test --copt=-fno-exceptions $BAZEL_TEST_OPTIONS_ASYNC -- //... -//exporters/prometheus/... -//examples/prometheus/... -//sdk/test/metrics:attributes_hashmap_test -//opentracing-shim/... + bazel $BAZEL_STARTUP_OPTIONS build --copt=-fno-exceptions $BAZEL_OPTIONS_ASYNC -- //... -//exporters/prometheus/... -//examples/prometheus/... -//opentracing-shim/... + bazel $BAZEL_STARTUP_OPTIONS test --copt=-fno-exceptions $BAZEL_TEST_OPTIONS_ASYNC -- //... -//exporters/prometheus/... -//examples/prometheus/... -//opentracing-shim/... exit 0 elif [[ "$1" == "bazel.nortti" ]]; then # there are some exceptions and error handling code from the Prometheus Client diff --git a/sdk/test/metrics/BUILD b/sdk/test/metrics/BUILD index 3cf379494d..70d0cc063a 100644 --- a/sdk/test/metrics/BUILD +++ b/sdk/test/metrics/BUILD @@ -19,307 +19,8 @@ cc_library( ) cc_test( - name = "meter_test", - srcs = [ - "meter_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "meter_provider_sdk_test", - srcs = [ - "meter_provider_sdk_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "metric_reader_test", - srcs = [ - "metric_reader_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "histogram_test", - srcs = [ - "histogram_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "view_registry_test", - srcs = [ - "view_registry_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "aggregation_test", - srcs = [ - "aggregation_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "sync_metric_storage_counter_test", - srcs = [ - "sync_metric_storage_counter_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "sync_metric_storage_up_down_counter_test", - srcs = [ - "sync_metric_storage_up_down_counter_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "sync_metric_storage_histogram_test", - srcs = [ - "sync_metric_storage_histogram_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "sync_instruments_test", - srcs = [ - "sync_instruments_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "async_instruments_test", - srcs = [ - "async_instruments_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "async_metric_storage_test", - srcs = [ - "async_metric_storage_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "observer_result_test", - srcs = [ - "observer_result_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "multi_metric_storage_test", - srcs = [ - "multi_metric_storage_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "attributes_processor_test", - srcs = [ - "attributes_processor_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "attributes_hashmap_test", - srcs = [ - "attributes_hashmap_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "circular_buffer_counter_test", - srcs = [ - "circular_buffer_counter_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "//sdk/src/metrics", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "base2_exponential_histogram_indexer_test", - srcs = [ - "base2_exponential_histogram_indexer_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "histogram_aggregation_test", - srcs = [ - "histogram_aggregation_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "sum_aggregation_test", - srcs = [ - "sum_aggregation_test.cc", - ], + name = "all_tests", + srcs = glob(["*_test.cc"]), tags = [ "metrics", "test", diff --git a/sdk/test/metrics/async_instruments_test.cc b/sdk/test/metrics/async_instruments_test.cc index b7ad885bbd..01a421e046 100644 --- a/sdk/test/metrics/async_instruments_test.cc +++ b/sdk/test/metrics/async_instruments_test.cc @@ -12,10 +12,13 @@ using namespace opentelemetry::sdk::metrics; using M = std::map; +namespace +{ // NOLINTNEXTLINE void asyc_generate_measurements(opentelemetry::metrics::ObserverResult /* observer */, void * /* state */) {} +} // namespace TEST(AsyncInstruments, ObservableInstrument) { diff --git a/sdk/test/metrics/attributes_hashmap_test.cc b/sdk/test/metrics/attributes_hashmap_test.cc index 9ae8f5cfd5..7d77e6166a 100644 --- a/sdk/test/metrics/attributes_hashmap_test.cc +++ b/sdk/test/metrics/attributes_hashmap_test.cc @@ -26,14 +26,14 @@ TEST(AttributesHashMap, BasicTests) std::unique_ptr aggregation1( new DropAggregation()); // = std::unique_ptr(new DropAggregation); hash_map.Set(m1, std::move(aggregation1), hash); - EXPECT_NO_THROW(hash_map.Get(hash)->Aggregate(static_cast(1))); + hash_map.Get(hash)->Aggregate(static_cast(1)); EXPECT_EQ(hash_map.Size(), 1); EXPECT_EQ(hash_map.Has(hash), true); // Set same key again auto aggregation2 = std::unique_ptr(new DropAggregation()); hash_map.Set(m1, std::move(aggregation2), hash); - EXPECT_NO_THROW(hash_map.Get(hash)->Aggregate(static_cast(1))); + hash_map.Get(hash)->Aggregate(static_cast(1)); EXPECT_EQ(hash_map.Size(), 1); EXPECT_EQ(hash_map.Has(hash), true); @@ -44,7 +44,7 @@ TEST(AttributesHashMap, BasicTests) hash_map.Set(m3, std::move(aggregation3), hash3); EXPECT_EQ(hash_map.Has(hash), true); EXPECT_EQ(hash_map.Has(hash3), true); - EXPECT_NO_THROW(hash_map.Get(hash3)->Aggregate(static_cast(1))); + hash_map.Get(hash3)->Aggregate(static_cast(1)); EXPECT_EQ(hash_map.Size(), 2); // GetOrSetDefault @@ -54,8 +54,8 @@ TEST(AttributesHashMap, BasicTests) }; MetricAttributes m4 = {{"k1", "v1"}, {"k2", "v2"}, {"k3", "v3"}}; auto hash4 = opentelemetry::sdk::common::GetHashForAttributeMap(m4); - EXPECT_NO_THROW(hash_map.GetOrSetDefault(m4, create_default_aggregation, hash4) - ->Aggregate(static_cast(1))); + hash_map.GetOrSetDefault(m4, create_default_aggregation, hash4) + ->Aggregate(static_cast(1)); EXPECT_EQ(hash_map.Size(), 3); // Set attributes with different order - shouldn't create a new entry. diff --git a/sdk/test/metrics/meter_test.cc b/sdk/test/metrics/meter_test.cc index b5ed86f55a..cd66737465 100644 --- a/sdk/test/metrics/meter_test.cc +++ b/sdk/test/metrics/meter_test.cc @@ -28,7 +28,6 @@ nostd::shared_ptr InitMeter(MetricReader **metricReaderPtr, auto meter = provider->GetMeter(meter_name); return meter; } -} // namespace void asyc_generate_measurements(opentelemetry::metrics::ObserverResult observer, void * /* state */) { @@ -36,6 +35,7 @@ void asyc_generate_measurements(opentelemetry::metrics::ObserverResult observer, nostd::get>>(observer); observer_long->Observe(10); } +} // namespace TEST(MeterTest, BasicAsyncTests) { diff --git a/sdk/test/metrics/periodic_exporting_metric_reader_test.cc b/sdk/test/metrics/periodic_exporting_metric_reader_test.cc index 277a20582f..2eec5e8c61 100644 --- a/sdk/test/metrics/periodic_exporting_metric_reader_test.cc +++ b/sdk/test/metrics/periodic_exporting_metric_reader_test.cc @@ -83,7 +83,7 @@ TEST(PeriodicExporingMetricReader, BasicTests) MockMetricProducer producer; reader->SetMetricProducer(&producer); std::this_thread::sleep_for(std::chrono::milliseconds(2000)); - EXPECT_NO_THROW(reader->ForceFlush()); + reader->ForceFlush(); reader->Shutdown(); EXPECT_EQ(static_cast(exporter_ptr)->GetDataCount(), static_cast(&producer)->GetDataCount()); From 080356950e121630f0ba518b963f00fce25a589b Mon Sep 17 00:00:00 2001 From: Alex Boten <223565+codeboten@users.noreply.github.com> Date: Wed, 4 Sep 2024 12:45:12 -0700 Subject: [PATCH 26/89] [TEST] update collector example with debug exporter (#3050) The logging exporter was renamed debug in 2023, the logging exporter will be removed in the near future, updating the example accordingly. --- functional/otlp/otel-config-http.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functional/otlp/otel-config-http.yaml b/functional/otlp/otel-config-http.yaml index da68e6f96c..858b3b7fe5 100644 --- a/functional/otlp/otel-config-http.yaml +++ b/functional/otlp/otel-config-http.yaml @@ -22,12 +22,12 @@ processors: check_interval: 5s exporters: - logging: - loglevel: debug + debug: + verbosity: debug service: pipelines: traces: receivers: [otlp] processors: [memory_limiter, batch] - exporters: [logging] + exporters: [debug] From 0d5a387b00f4d5fa25839883929e37365324b3de Mon Sep 17 00:00:00 2001 From: Alex Boten <223565+codeboten@users.noreply.github.com> Date: Wed, 4 Sep 2024 14:58:53 -0700 Subject: [PATCH 27/89] [EXAMPLE] update collector example with debug exporter (#3049) The logging exporter was renamed debug in 2023, the logging exporter will be removed in the near future, updating the example accordingly. Co-authored-by: Marc Alff --- .../opentelemetry-collector-config/config.dev.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/otlp/opentelemetry-collector-config/config.dev.yaml b/examples/otlp/opentelemetry-collector-config/config.dev.yaml index 267b7250d6..8fbe3634ea 100644 --- a/examples/otlp/opentelemetry-collector-config/config.dev.yaml +++ b/examples/otlp/opentelemetry-collector-config/config.dev.yaml @@ -2,8 +2,8 @@ # SPDX-License-Identifier: Apache-2.0 exporters: - logging: - loglevel: DEBUG + debug: + verbosity: debug receivers: otlp: protocols: @@ -17,14 +17,14 @@ service: receivers: - otlp exporters: - - logging + - debug logs: receivers: - otlp exporters: - - logging + - debug metrics: receivers: - otlp exporters: - - logging + - debug From 261a15182964faf5115b4209adefa7054f07abf1 Mon Sep 17 00:00:00 2001 From: Alex Boten <223565+codeboten@users.noreply.github.com> Date: Thu, 5 Sep 2024 12:34:20 -0700 Subject: [PATCH 28/89] [TEST] update references to logging exporter (#3053) This exporter has been replaced by the debug exporter and will be removed soon Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com> --- .../otlp/opentelemetry-collector-config/config.dev.yaml | 2 +- functional/otlp/otel-config-http.yaml | 2 +- functional/otlp/otel-config-https.yaml | 6 +++--- functional/otlp/otel-docker-config-http.yaml | 6 +++--- functional/otlp/otel-docker-config-https.yaml | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/otlp/opentelemetry-collector-config/config.dev.yaml b/examples/otlp/opentelemetry-collector-config/config.dev.yaml index 8fbe3634ea..b98e384917 100644 --- a/examples/otlp/opentelemetry-collector-config/config.dev.yaml +++ b/examples/otlp/opentelemetry-collector-config/config.dev.yaml @@ -3,7 +3,7 @@ exporters: debug: - verbosity: debug + verbosity: detailed receivers: otlp: protocols: diff --git a/functional/otlp/otel-config-http.yaml b/functional/otlp/otel-config-http.yaml index 858b3b7fe5..8e5fcb6aee 100644 --- a/functional/otlp/otel-config-http.yaml +++ b/functional/otlp/otel-config-http.yaml @@ -23,7 +23,7 @@ processors: exporters: debug: - verbosity: debug + verbosity: detailed service: pipelines: diff --git a/functional/otlp/otel-config-https.yaml b/functional/otlp/otel-config-https.yaml index f106baf8b6..63ae36f211 100644 --- a/functional/otlp/otel-config-https.yaml +++ b/functional/otlp/otel-config-https.yaml @@ -29,12 +29,12 @@ processors: check_interval: 5s exporters: - logging: - loglevel: debug + debug: + verbosity: detailed service: pipelines: traces: receivers: [otlp] processors: [memory_limiter, batch] - exporters: [logging] + exporters: [debug] diff --git a/functional/otlp/otel-docker-config-http.yaml b/functional/otlp/otel-docker-config-http.yaml index c18f0e54a4..beadb85130 100644 --- a/functional/otlp/otel-docker-config-http.yaml +++ b/functional/otlp/otel-docker-config-http.yaml @@ -21,12 +21,12 @@ processors: check_interval: 5s exporters: - logging: - loglevel: debug + debug: + verbosity: detailed service: pipelines: traces: receivers: [otlp] processors: [memory_limiter, batch] - exporters: [logging] + exporters: [debug] diff --git a/functional/otlp/otel-docker-config-https.yaml b/functional/otlp/otel-docker-config-https.yaml index db8f2b3756..ef15696e70 100644 --- a/functional/otlp/otel-docker-config-https.yaml +++ b/functional/otlp/otel-docker-config-https.yaml @@ -28,12 +28,12 @@ processors: check_interval: 5s exporters: - logging: - loglevel: debug + debug: + verbosity: detailed service: pipelines: traces: receivers: [otlp] processors: [memory_limiter, batch] - exporters: [logging] + exporters: [debug] From d623bc57f6d41aea2b8508886e7f831208876964 Mon Sep 17 00:00:00 2001 From: Tom Tan Date: Thu, 5 Sep 2024 13:40:26 -0700 Subject: [PATCH 29/89] [EXAMPLE] Clean the tracer initialization in OStream example (#3051) --- examples/logs_simple/main.cc | 20 ++++++++++---------- examples/simple/main.cc | 10 +++++----- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/examples/logs_simple/main.cc b/examples/logs_simple/main.cc index 3d7dfb8831..b1304f9a63 100644 --- a/examples/logs_simple/main.cc +++ b/examples/logs_simple/main.cc @@ -44,18 +44,18 @@ void InitTracer() auto exporter = trace_exporter::OStreamSpanExporterFactory::Create(); auto processor = trace_sdk::SimpleSpanProcessorFactory::Create(std::move(exporter)); - std::shared_ptr provider = - opentelemetry::sdk::trace::TracerProviderFactory::Create(std::move(processor)); + std::shared_ptr sdk_provider = + trace_sdk::TracerProviderFactory::Create(std::move(processor)); // Set the global trace provider - const std::shared_ptr &api_provider = provider; + const std::shared_ptr &api_provider = sdk_provider; trace_api::Provider::SetTracerProvider(api_provider); } void CleanupTracer() { - std::shared_ptr none; - trace_api::Provider::SetTracerProvider(none); + std::shared_ptr noop; + trace_api::Provider::SetTracerProvider(noop); } void InitLogger() @@ -65,18 +65,18 @@ void InitLogger() std::unique_ptr(new logs_exporter::OStreamLogRecordExporter); auto processor = logs_sdk::SimpleLogRecordProcessorFactory::Create(std::move(exporter)); - std::shared_ptr provider( - opentelemetry::sdk::logs::LoggerProviderFactory::Create(std::move(processor))); + std::shared_ptr sdk_provider( + logs_sdk::LoggerProviderFactory::Create(std::move(processor))); // Set the global logger provider - const std::shared_ptr &api_provider = provider; + const std::shared_ptr &api_provider = sdk_provider; logs_api::Provider::SetLoggerProvider(api_provider); } void CleanupLogger() { - std::shared_ptr none; - logs_api::Provider::SetLoggerProvider(none); + std::shared_ptr noop; + logs_api::Provider::SetLoggerProvider(noop); } } // namespace diff --git a/examples/simple/main.cc b/examples/simple/main.cc index 245786688c..d8cf4009ad 100644 --- a/examples/simple/main.cc +++ b/examples/simple/main.cc @@ -31,18 +31,18 @@ void InitTracer() auto exporter = trace_exporter::OStreamSpanExporterFactory::Create(); auto processor = trace_sdk::SimpleSpanProcessorFactory::Create(std::move(exporter)); - std::shared_ptr provider = - opentelemetry::sdk::trace::TracerProviderFactory::Create(std::move(processor)); + std::shared_ptr sdk_provider = + trace_sdk::TracerProviderFactory::Create(std::move(processor)); // Set the global trace provider - const std::shared_ptr &api_provider = provider; + const std::shared_ptr &api_provider = sdk_provider; trace_api::Provider::SetTracerProvider(api_provider); } void CleanupTracer() { - std::shared_ptr none; - trace_api::Provider::SetTracerProvider(none); + std::shared_ptr noop; + trace_api::Provider::SetTracerProvider(noop); } } // namespace From 4eb78a6a04994b48a6d81318539d826801d148c1 Mon Sep 17 00:00:00 2001 From: Tom Tan Date: Sun, 8 Sep 2024 00:22:15 -0700 Subject: [PATCH 30/89] [EXPORTER] Fix the format of SpanLink for ETW (#3054) --- .../opentelemetry/exporters/etw/etw_fields.h | 5 ++- .../opentelemetry/exporters/etw/etw_tracer.h | 34 +++++++++++++++---- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/exporters/etw/include/opentelemetry/exporters/etw/etw_fields.h b/exporters/etw/include/opentelemetry/exporters/etw/etw_fields.h index 041929d1c0..ea4354426d 100644 --- a/exporters/etw/include/opentelemetry/exporters/etw/etw_fields.h +++ b/exporters/etw/include/opentelemetry/exporters/etw/etw_fields.h @@ -113,6 +113,9 @@ # define ETW_FIELD_SPAN_KIND "Kind" /* Span Kind */ # define ETW_FIELD_SPAN_LINKS "Links" /* Span Links array */ +# define ETW_FIELD_SPAN_LINKS_TO_SPAN_ID "toSpanId" /* Span Links toSpanId */ +# define ETW_FIELD_SPAN_LINKS_TO_TRACE_ID "toTraceId" /* Span Links toTraceId */ + # define ETW_FIELD_PAYLOAD_NAME "Name" /* ETW Payload["Name"] */ /* Span option constants */ @@ -136,7 +139,7 @@ /* Log specific */ # define ETW_FIELD_LOG_BODY "body" /* Log body */ # define ETW_FIELD_LOG_SEVERITY_TEXT "severityText" /* Sev text */ -# define ETW_FIELD_LOG_SEVERITY_NUM "severityNumber" /* Sev num */ +# define ETW_FIELD_LOG_SEVERITY_NUM "severityNumber" /* Sev num */ #endif diff --git a/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h b/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h index 9071fd47d4..272558cead 100644 --- a/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h +++ b/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h @@ -212,19 +212,41 @@ class Tracer : public opentelemetry::trace::Tracer, // Add `SpanLinks` attribute if the list is not empty if (links.size()) { - size_t idx = 0; + bool first = true; std::string linksValue; + + // reserve space for all the SpanLinks. + // A single SpanLink will be outptut as: + // [{"toSpanId":"9a43c801557f26b7","toTraceId":"ac6cd70ac4bb168a99cb7651b048d965"}] + // The second and above link output to string are 1 byte less than the first SpanLink. + const size_t kSingleSpanLinkSizeInBytes = 80; + linksValue.reserve(kSingleSpanLinkSizeInBytes + + (links.size() - 1) * (kSingleSpanLinkSizeInBytes - 1)); + linksValue += "["; + links.ForEachKeyValue([&](opentelemetry::trace::SpanContext ctx, const opentelemetry::common::KeyValueIterable &) { - if (!linksValue.empty()) + if (first) + { + first = false; + linksValue += "{\"" ETW_FIELD_SPAN_LINKS_TO_SPAN_ID "\":\""; + } + else { - linksValue += ','; - linksValue += ToLowerBase16(ctx.span_id()); + linksValue += ",{\"" ETW_FIELD_SPAN_LINKS_TO_SPAN_ID "\":\""; } - idx++; + + linksValue += ToLowerBase16(ctx.span_id()); + linksValue += "\",\"" ETW_FIELD_SPAN_LINKS_TO_TRACE_ID "\":\""; + linksValue += ToLowerBase16(ctx.trace_id()); + linksValue += "\"}"; + return true; }); - attributes[ETW_FIELD_SPAN_LINKS] = linksValue; + + linksValue += "]"; + + attributes[ETW_FIELD_SPAN_LINKS] = std::move(linksValue); } } From c37df2318dd2a9fde6f256a9a861f4b281938a45 Mon Sep 17 00:00:00 2001 From: Punya Biswal Date: Tue, 10 Sep 2024 10:27:48 -0400 Subject: [PATCH 31/89] Implement in-memory metric exporter (#3043) Fixes #1405 --- CHANGELOG.md | 3 + exporters/memory/BUILD | 78 +++++++++++++++- exporters/memory/CMakeLists.txt | 38 ++++++++ .../exporters/memory/in_memory_metric_data.h | 72 ++++++++++++++ .../in_memory_metric_exporter_factory.h | 44 +++++++++ exporters/memory/src/in_memory_metric_data.cc | 54 +++++++++++ .../src/in_memory_metric_exporter_factory.cc | 93 +++++++++++++++++++ .../memory/test/in_memory_metric_data_test.cc | 55 +++++++++++ .../test/in_memory_metric_exporter_test.cc | 60 ++++++++++++ 9 files changed, 496 insertions(+), 1 deletion(-) create mode 100644 exporters/memory/include/opentelemetry/exporters/memory/in_memory_metric_data.h create mode 100644 exporters/memory/include/opentelemetry/exporters/memory/in_memory_metric_exporter_factory.h create mode 100644 exporters/memory/src/in_memory_metric_data.cc create mode 100644 exporters/memory/src/in_memory_metric_exporter_factory.cc create mode 100644 exporters/memory/test/in_memory_metric_data_test.cc create mode 100644 exporters/memory/test/in_memory_metric_exporter_test.cc diff --git a/CHANGELOG.md b/CHANGELOG.md index bce84c84df..66d60f3513 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,9 @@ Increment the: * [REMOVAL] Remove build option `WITH_DEPRECATED_SDK_FACTORY` [#2717](https://github.com/open-telemetry/opentelemetry-cpp/pull/2717) +* [EXPORTER] Add in-memory metric exporter + [#3043](https://github.com/open-telemetry/opentelemetry-cpp/pull/3043) + Breaking changes: * [REMOVAL] Remove build option `WITH_DEPRECATED_SDK_FACTORY` diff --git a/exporters/memory/BUILD b/exporters/memory/BUILD index a65066480c..033c85d369 100644 --- a/exporters/memory/BUILD +++ b/exporters/memory/BUILD @@ -4,14 +4,90 @@ package(default_visibility = ["//visibility:public"]) cc_library( - name = "in_memory_span_data", + name = "in_memory_metric_data", + srcs = [ + "src/in_memory_metric_data.cc", + ], + hdrs = [ + "include/opentelemetry/exporters/memory/in_memory_metric_data.h", + ], + strip_include_prefix = "include", + tags = [ + "memory", + "test", + ], + deps = [ + ":in_memory_data", + "//sdk/src/metrics", + ], +) + +cc_test( + name = "in_memory_metric_data_test", + srcs = ["test/in_memory_metric_data_test.cc"], + tags = [ + "memory", + "test", + ], + deps = [ + ":in_memory_metric_data", + "@com_google_googletest//:gtest_main", + ], +) + +cc_library( + name = "in_memory_metric_exporter_factory", + srcs = [ + "src/in_memory_metric_exporter_factory.cc", + ], + hdrs = [ + "include/opentelemetry/exporters/memory/in_memory_metric_exporter_factory.h", + ], + strip_include_prefix = "include", + tags = [ + "memory", + "test", + ], + deps = [ + ":in_memory_metric_data", + "//sdk/src/metrics", + ], +) + +cc_test( + name = "in_memory_metric_exporter_test", + srcs = ["test/in_memory_metric_exporter_test.cc"], + tags = [ + "memory", + "test", + ], + deps = [ + ":in_memory_metric_exporter_factory", + "@com_google_googletest//:gtest_main", + ], +) + +cc_library( + name = "in_memory_data", hdrs = [ "include/opentelemetry/exporters/memory/in_memory_data.h", + ], + strip_include_prefix = "include", + tags = ["memory"], + deps = [ + "//sdk:headers", + ], +) + +cc_library( + name = "in_memory_span_data", + hdrs = [ "include/opentelemetry/exporters/memory/in_memory_span_data.h", ], strip_include_prefix = "include", tags = ["memory"], deps = [ + ":in_memory_data", "//api", "//sdk/src/resource", "//sdk/src/trace", diff --git a/exporters/memory/CMakeLists.txt b/exporters/memory/CMakeLists.txt index 3dff044018..0738759a96 100644 --- a/exporters/memory/CMakeLists.txt +++ b/exporters/memory/CMakeLists.txt @@ -16,9 +16,26 @@ set_target_version(opentelemetry_exporter_in_memory) target_link_libraries(opentelemetry_exporter_in_memory PUBLIC opentelemetry_trace) +add_library( + opentelemetry_exporter_in_memory_metric + src/in_memory_metric_exporter_factory.cc src/in_memory_metric_data.cc) + +target_include_directories( + opentelemetry_exporter_in_memory_metric + PUBLIC "$" + "$") + +set_target_properties(opentelemetry_exporter_in_memory_metric + PROPERTIES EXPORT_NAME in_memory_metric_exporter) +set_target_version(opentelemetry_exporter_in_memory_metric) + +target_link_libraries(opentelemetry_exporter_in_memory_metric + PUBLIC opentelemetry_metrics) + if(OPENTELEMETRY_INSTALL) install( TARGETS opentelemetry_exporter_in_memory + opentelemetry_exporter_in_memory_metric EXPORT "${PROJECT_NAME}-target" RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -35,16 +52,29 @@ if(BUILD_TESTING) add_executable(in_memory_span_data_test test/in_memory_span_data_test.cc) add_executable(in_memory_span_exporter_test test/in_memory_span_exporter_test.cc) + add_executable(in_memory_metric_data_test test/in_memory_metric_data_test.cc) + add_executable(in_memory_metric_exporter_test + test/in_memory_metric_exporter_test.cc) target_link_libraries( in_memory_span_data_test ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} opentelemetry_exporter_in_memory opentelemetry_resources) + target_link_libraries( + in_memory_metric_data_test ${GTEST_BOTH_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} opentelemetry_exporter_in_memory_metric + opentelemetry_resources) + target_link_libraries( in_memory_span_exporter_test ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} opentelemetry_exporter_in_memory opentelemetry_resources) + target_link_libraries( + in_memory_metric_exporter_test ${GTEST_BOTH_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} opentelemetry_exporter_in_memory_metric + opentelemetry_resources) + gtest_add_tests( TARGET in_memory_span_data_test TEST_PREFIX exporter. @@ -53,4 +83,12 @@ if(BUILD_TESTING) TARGET in_memory_span_exporter_test TEST_PREFIX exporter. TEST_LIST in_memory_span_exporter_test) + gtest_add_tests( + TARGET in_memory_metric_data_test + TEST_PREFIX exporter. + TEST_LIST in_memory_metric_data_test) + gtest_add_tests( + TARGET in_memory_metric_exporter_test + TEST_PREFIX exporter. + TEST_LIST in_memory_metric_exporter_test) endif() diff --git a/exporters/memory/include/opentelemetry/exporters/memory/in_memory_metric_data.h b/exporters/memory/include/opentelemetry/exporters/memory/in_memory_metric_data.h new file mode 100644 index 0000000000..8d24c586b2 --- /dev/null +++ b/exporters/memory/include/opentelemetry/exporters/memory/in_memory_metric_data.h @@ -0,0 +1,72 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include +#include +#include +#include + +#include "opentelemetry/exporters/memory/in_memory_data.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace metrics +{ +struct ResourceMetrics; +} +} // namespace sdk +namespace exporter +{ +namespace memory +{ + +/// The abstract base class for types used to store in-memory data backing an +/// InMemoryMetricExporter. +class InMemoryMetricData +{ +public: + InMemoryMetricData() = default; + virtual ~InMemoryMetricData() = default; + + InMemoryMetricData(const InMemoryMetricData &) = delete; + InMemoryMetricData(InMemoryMetricData &&) = delete; + InMemoryMetricData &operator=(const InMemoryMetricData &) = delete; + InMemoryMetricData &operator=(InMemoryMetricData &&) = delete; + + virtual void Add(std::unique_ptr resource_metrics) = 0; +}; + +/// An implementation of InMemoryMetricData that stores full-fidelity data points in a circular +/// buffer. This allows tests to inspect every aspect of exported data, in exchange for a somewhat +/// cumbersome API. +class CircularBufferInMemoryMetricData final : public InMemoryMetricData, + public InMemoryData +{ +public: + explicit CircularBufferInMemoryMetricData(size_t buffer_size); + void Add(std::unique_ptr resource_metrics) override; +}; + +/// An implementation of InMemoryMetricData that stores only the most recent data point in each time +/// series, and allows convenient lookups of time series. This makes simple tests easier to write. +class SimpleAggregateInMemoryMetricData final : public InMemoryMetricData +{ +public: + using AttributeToPoint = std::map; + + void Add(std::unique_ptr resource_metrics) override; + const AttributeToPoint &Get(const std::string &scope, const std::string &metric); + void Clear(); + +private: + std::map, AttributeToPoint> data_; +}; + +} // namespace memory +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/memory/include/opentelemetry/exporters/memory/in_memory_metric_exporter_factory.h b/exporters/memory/include/opentelemetry/exporters/memory/in_memory_metric_exporter_factory.h new file mode 100644 index 0000000000..f6934df727 --- /dev/null +++ b/exporters/memory/include/opentelemetry/exporters/memory/in_memory_metric_exporter_factory.h @@ -0,0 +1,44 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace metrics +{ +class PushMetricExporter; +} // namespace metrics +} // namespace sdk +namespace exporter +{ +namespace memory +{ +class InMemoryMetricData; + +/// A factory for InMemoryMetricExporter +class InMemoryMetricExporterFactory +{ +public: + /// Create a InMemoryMetricExporter with a default buffer size and aggregation + /// temporality selector. + /// @param [out] data the InMemoryMetricData the exporter will write to, + /// for the caller to inspect + /// @param [in] buffer_size number of entries to save in the circular buffer + /// @param [in] temporality output temporality as a function of instrument kind + static std::unique_ptr Create( + const std::shared_ptr &data, + const sdk::metrics::AggregationTemporalitySelector &temporality); + + static std::unique_ptr Create( + const std::shared_ptr &data); +}; +} // namespace memory +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/memory/src/in_memory_metric_data.cc b/exporters/memory/src/in_memory_metric_data.cc new file mode 100644 index 0000000000..2a77e0b5a3 --- /dev/null +++ b/exporters/memory/src/in_memory_metric_data.cc @@ -0,0 +1,54 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include "opentelemetry/exporters/memory/in_memory_metric_data.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace memory +{ +using sdk::metrics::ResourceMetrics; + +CircularBufferInMemoryMetricData::CircularBufferInMemoryMetricData(size_t buffer_size) + : InMemoryData(buffer_size) +{} + +void CircularBufferInMemoryMetricData::Add(std::unique_ptr resource_metrics) +{ + InMemoryData::Add(std::move(resource_metrics)); +} + +void SimpleAggregateInMemoryMetricData::Add(std::unique_ptr resource_metrics) +{ + for (const auto &sm : resource_metrics->scope_metric_data_) + { + const auto &scope = sm.scope_->GetName(); + for (const auto &m : sm.metric_data_) + { + const auto &metric = m.instrument_descriptor.name_; + for (const auto &pda : m.point_data_attr_) + { + data_[{scope, metric}].insert({pda.attributes, pda.point_data}); + } + } + } +} + +const SimpleAggregateInMemoryMetricData::AttributeToPoint &SimpleAggregateInMemoryMetricData::Get( + const std::string &scope, + const std::string &metric) +{ + return data_[{scope, metric}]; +} + +void SimpleAggregateInMemoryMetricData::Clear() +{ + data_.clear(); +} + +} // namespace memory +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/memory/src/in_memory_metric_exporter_factory.cc b/exporters/memory/src/in_memory_metric_exporter_factory.cc new file mode 100644 index 0000000000..f2577c4e9b --- /dev/null +++ b/exporters/memory/src/in_memory_metric_exporter_factory.cc @@ -0,0 +1,93 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include "opentelemetry/exporters/memory/in_memory_metric_exporter_factory.h" +#include "opentelemetry/exporters/memory/in_memory_metric_data.h" +#include "opentelemetry/sdk/common/global_log_handler.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace memory +{ + +using opentelemetry::sdk::metrics::PushMetricExporter; +using sdk::common::ExportResult; +using sdk::metrics::AggregationTemporality; +using sdk::metrics::AggregationTemporalitySelector; +using sdk::metrics::InstrumentType; +using sdk::metrics::ResourceMetrics; + +namespace +{ + +/// A Push Metric Exporter which accumulates metrics data in memory and allows it to be inspected. +/// It is not thread-safe. +class InMemoryMetricExporter final : public sdk::metrics::PushMetricExporter +{ +public: + /// @param buffer_size a required value that sets the size of the CircularBuffer + /// @param temporality Output temporality as a function of instrument kind. + InMemoryMetricExporter(const std::shared_ptr &data, + const sdk::metrics::AggregationTemporalitySelector &temporality) + : data_(data), temporality_(temporality) + {} + + ~InMemoryMetricExporter() override = default; + + InMemoryMetricExporter(const InMemoryMetricExporter &) = delete; + InMemoryMetricExporter(const InMemoryMetricExporter &&) = delete; + void operator=(const InMemoryMetricExporter &) = delete; + void operator=(const InMemoryMetricExporter &&) = delete; + + ExportResult Export(const ResourceMetrics &data) noexcept override + { + if (is_shutdown_) + { + OTEL_INTERNAL_LOG_ERROR("[In Memory Metric Exporter] Exporting failed, exporter is shutdown"); + return ExportResult::kFailure; + } + data_->Add(std::make_unique(data)); + return ExportResult::kSuccess; + } + + AggregationTemporality GetAggregationTemporality( + InstrumentType instrument_type) const noexcept override + { + return temporality_(instrument_type); + } + + bool ForceFlush(std::chrono::microseconds /* timeout */) noexcept override { return true; } + + bool Shutdown(std::chrono::microseconds /* timeout */) noexcept override + { + is_shutdown_ = true; + return true; + } + +private: + std::shared_ptr data_; + std::atomic is_shutdown_{false}; + sdk::metrics::AggregationTemporalitySelector temporality_; +}; + +} // namespace + +std::unique_ptr InMemoryMetricExporterFactory::Create( + const std::shared_ptr &data) +{ + return Create(data, [](auto) { return AggregationTemporality::kCumulative; }); +} + +std::unique_ptr InMemoryMetricExporterFactory::Create( + const std::shared_ptr &data, + const AggregationTemporalitySelector &temporality) +{ + return std::make_unique(data, temporality); +} + +} // namespace memory +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/memory/test/in_memory_metric_data_test.cc b/exporters/memory/test/in_memory_metric_data_test.cc new file mode 100644 index 0000000000..ffaba2cfb9 --- /dev/null +++ b/exporters/memory/test/in_memory_metric_data_test.cc @@ -0,0 +1,55 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include "opentelemetry/exporters/memory/in_memory_metric_data.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/resource/resource.h" + +#include + +#include + +using opentelemetry::exporter::memory::CircularBufferInMemoryMetricData; +using opentelemetry::exporter::memory::SimpleAggregateInMemoryMetricData; +using opentelemetry::sdk::metrics::MetricData; +using opentelemetry::sdk::metrics::PointDataAttributes; +using opentelemetry::sdk::metrics::ResourceMetrics; +using opentelemetry::sdk::metrics::ScopeMetrics; +using opentelemetry::sdk::metrics::SumPointData; +using opentelemetry::sdk::resource::Resource; + +TEST(InMemoryMetricDataTest, CircularBuffer) +{ + CircularBufferInMemoryMetricData buf(10); + Resource resource = Resource::GetEmpty(); + buf.Add(std::make_unique( + &resource, std::vector{{nullptr, std::vector{}}})); + EXPECT_EQ((*buf.Get().begin())->resource_, &resource); +} + +TEST(InMemoryMetricDataTest, SimpleAggregate) +{ + SimpleAggregateInMemoryMetricData agg; + + Resource resource = Resource::GetEmpty(); + + auto scope = opentelemetry::sdk::instrumentationscope::InstrumentationScope::Create( + "my-scope", "1.0.0", "http://example.com"); + + SumPointData spd; + spd.value_ = 42.0; + PointDataAttributes pda{{{"hello", "world"}}, spd}; + + MetricData md; + md.instrument_descriptor.name_ = "my-metric"; + md.point_data_attr_.push_back(pda); + + agg.Add(std::make_unique( + &resource, std::vector{{scope.get(), std::vector{md}}})); + auto it = agg.Get("my-scope", "my-metric").begin(); + + auto saved_point = opentelemetry::nostd::get(it->second); + + EXPECT_EQ(opentelemetry::nostd::get(saved_point.value_), 42.0); +} diff --git a/exporters/memory/test/in_memory_metric_exporter_test.cc b/exporters/memory/test/in_memory_metric_exporter_test.cc new file mode 100644 index 0000000000..adaa322f71 --- /dev/null +++ b/exporters/memory/test/in_memory_metric_exporter_test.cc @@ -0,0 +1,60 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include "opentelemetry/exporters/memory/in_memory_metric_data.h" +#include "opentelemetry/exporters/memory/in_memory_metric_exporter_factory.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/sdk/resource/resource.h" + +#include + +using opentelemetry::exporter::memory::CircularBufferInMemoryMetricData; +using opentelemetry::exporter::memory::InMemoryMetricExporterFactory; +using opentelemetry::sdk::common::ExportResult; +using opentelemetry::sdk::metrics::AggregationTemporality; +using opentelemetry::sdk::metrics::InstrumentType; +using opentelemetry::sdk::metrics::PushMetricExporter; +using opentelemetry::sdk::metrics::ResourceMetrics; +using opentelemetry::sdk::metrics::ScopeMetrics; +using opentelemetry::sdk::resource::Resource; + +class InMemoryMetricExporterTest : public ::testing::Test +{ +protected: + InMemoryMetricExporterTest() { exporter_ = InMemoryMetricExporterFactory::Create(data_); } + + std::unique_ptr exporter_; + std::shared_ptr data_ = + std::make_shared(10); + + Resource resource_ = Resource::GetEmpty(); + ResourceMetrics resource_metrics_{&resource_, std::vector{}}; +}; + +TEST_F(InMemoryMetricExporterTest, Export) +{ + EXPECT_EQ(exporter_->Export(resource_metrics_), ExportResult::kSuccess); + + auto data = data_->Get(); + EXPECT_EQ(data.size(), 1); + EXPECT_EQ((*data.begin())->resource_, &resource_); +} + +TEST_F(InMemoryMetricExporterTest, ForceFlush) +{ + EXPECT_TRUE(exporter_->ForceFlush()); +} + +TEST_F(InMemoryMetricExporterTest, Shutdown) +{ + EXPECT_TRUE(exporter_->Shutdown()); + EXPECT_EQ(exporter_->Export(resource_metrics_), ExportResult::kFailure); +} + +TEST_F(InMemoryMetricExporterTest, TemporalitySelector) +{ + EXPECT_EQ(exporter_->GetAggregationTemporality(InstrumentType::kCounter), + AggregationTemporality::kCumulative); +} From c6d394547b012077998b6bd74665145488e85ffe Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Wed, 11 Sep 2024 21:05:32 +0200 Subject: [PATCH 32/89] [Code Health] include-what-you-use cleanup, part 4 (#3040) --- .iwyu.imp | 8 +++- .../exporters/memory/in_memory_span_data.h | 8 ++-- .../memory/in_memory_span_exporter.h | 11 ++++- exporters/zipkin/src/zipkin_exporter.cc | 1 + .../ext/http/common/url_parser.h | 5 +- ext/test/http/curl_http_test.cc | 21 +++++---- ext/test/http/url_parser_test.cc | 7 ++- ext/test/w3c_tracecontext_test/main.cc | 25 ++++++++-- .../sdk/common/attribute_utils.h | 8 +++- .../sdk/common/attributemap_hash.h | 7 +++ .../sdk/common/circular_buffer.h | 3 ++ .../sdk/common/circular_buffer_range.h | 3 +- .../sdk/metrics/observer_result.h | 2 + .../sdk/metrics/state/attributes_hashmap.h | 13 +++-- .../sdk/metrics/state/multi_metric_storage.h | 16 ++----- .../sdk/metrics/sync_instruments.h | 1 - .../sdk/metrics/view/attributes_processor.h | 4 +- .../sdk/metrics/view/view_registry.h | 6 ++- .../sdk/trace/simple_processor.h | 3 ++ .../opentelemetry/sdk/trace/span_data.h | 8 +++- sdk/include/opentelemetry/sdk/trace/tracer.h | 2 - .../opentelemetry/sdk/trace/tracer_provider.h | 1 - .../metrics/aggregation/sum_aggregation.cc | 1 - .../periodic_exporting_metric_reader.cc | 2 - sdk/src/metrics/meter_context.cc | 1 - sdk/src/trace/samplers/parent_factory.cc | 3 +- sdk/test/common/attribute_utils_test.cc | 10 ++-- .../common/attributemap_hash_benchmark.cc | 2 + sdk/test/common/circular_buffer_benchmark.cc | 10 +++- sdk/test/common/circular_buffer_range_test.cc | 6 +-- sdk/test/common/circular_buffer_test.cc | 16 +++++-- sdk/test/common/env_var_test.cc | 7 ++- .../fast_random_number_generator_test.cc | 8 ++-- sdk/test/common/global_log_handle_test.cc | 7 +-- sdk/test/common/random_benchmark.cc | 6 +-- sdk/test/common/random_fork_test.cc | 4 +- sdk/test/common/random_test.cc | 8 ++-- .../instrumentationscope_test.cc | 15 ++++-- .../logs/batch_log_record_processor_test.cc | 24 ++++++++-- sdk/test/logs/log_record_test.cc | 22 +++++++-- sdk/test/logs/logger_provider_sdk_test.cc | 24 ++++++++-- sdk/test/logs/logger_sdk_test.cc | 24 ++++++++-- .../logs/simple_log_record_processor_test.cc | 24 +++++++--- sdk/test/metrics/aggregation_test.cc | 10 ++-- sdk/test/metrics/async_instruments_test.cc | 13 ++++- sdk/test/metrics/async_metric_storage_test.cc | 39 ++++++++------- .../metrics/attributes_hashmap_benchmark.cc | 17 ++++--- sdk/test/metrics/attributes_hashmap_test.cc | 20 ++++++-- .../metrics/attributes_processor_benchmark.cc | 5 ++ sdk/test/metrics/attributes_processor_test.cc | 11 ++++- ...exponential_histogram_indexer_benchmark.cc | 5 +- ...ase2_exponential_histogram_indexer_test.cc | 6 ++- sdk/test/metrics/cardinality_limit_test.cc | 31 ++++++++++-- .../metrics/circular_buffer_counter_test.cc | 5 +- sdk/test/metrics/common.cc | 4 +- sdk/test/metrics/common.h | 9 ++-- .../histogram_aggregation_benchmark.cc | 21 +++++++-- .../metrics/histogram_aggregation_test.cc | 21 +++++++-- sdk/test/metrics/histogram_test.cc | 22 +++++++-- .../instrument_metadata_validator_test.cc | 6 ++- sdk/test/metrics/measurements_benchmark.cc | 29 +++++++++--- sdk/test/metrics/meter_provider_sdk_test.cc | 10 +++- sdk/test/metrics/meter_test.cc | 23 +++++++-- sdk/test/metrics/metric_reader_test.cc | 10 +++- sdk/test/metrics/multi_metric_storage_test.cc | 15 +++--- sdk/test/metrics/observable_registry_test.cc | 5 +- sdk/test/metrics/observer_result_test.cc | 12 ++++- .../periodic_exporting_metric_reader_test.cc | 19 ++++++-- sdk/test/metrics/sum_aggregation_benchmark.cc | 24 +++++++--- sdk/test/metrics/sum_aggregation_test.cc | 26 ++++++++-- sdk/test/metrics/sync_instruments_test.cc | 19 +++++--- .../sync_metric_storage_counter_test.cc | 28 +++++++---- .../sync_metric_storage_histogram_test.cc | 29 ++++++++---- ...ync_metric_storage_up_down_counter_test.cc | 29 ++++++++---- sdk/test/metrics/view_registry_test.cc | 15 ++++-- sdk/test/resource/resource_test.cc | 18 ++++--- sdk/test/trace/always_off_sampler_test.cc | 12 +++++ sdk/test/trace/always_on_sampler_test.cc | 18 +++++-- sdk/test/trace/batch_span_processor_test.cc | 28 ++++++----- sdk/test/trace/parent_sampler_test.cc | 18 ++++++- sdk/test/trace/sampler_benchmark.cc | 24 ++++++++-- sdk/test/trace/simple_processor_test.cc | 16 +++++-- sdk/test/trace/span_data_test.cc | 33 +++++++++---- sdk/test/trace/trace_id_ratio_sampler_test.cc | 20 ++++++-- sdk/test/trace/tracer_provider_test.cc | 23 ++++++--- sdk/test/trace/tracer_test.cc | 47 +++++++++++++++++-- .../http/client/http_client_test_factory.h | 4 ++ .../http/client/nosend/http_client_nosend.h | 20 ++++---- .../http/client/nosend/http_client_nosend.cc | 11 +++++ 89 files changed, 912 insertions(+), 305 deletions(-) diff --git a/.iwyu.imp b/.iwyu.imp index 7ebbeae511..6529a92458 100644 --- a/.iwyu.imp +++ b/.iwyu.imp @@ -7,10 +7,16 @@ # Work around for C++ STL { "include": ["", "private", "", "public"] }, - # Local opentelemetry-cpp + # Local opentelemetry-cpp style + # We prefer to include for simplicity { "include": ["", "private", "", "public"] }, { "include": ["", "private", "", "public"] }, + { "include": ["", "private", "", "public"] }, { "include": ["", "private", "", "public"] }, + + # We prefer to include for simplicity + { "include": ["", "private", "", "public"] }, + { "include": ["", "private", "", "public"] }, ] diff --git a/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_data.h b/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_data.h index 874b475690..6eaae0663c 100644 --- a/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_data.h +++ b/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_data.h @@ -3,11 +3,13 @@ #pragma once +#include +#include +#include + #include "opentelemetry/exporters/memory/in_memory_data.h" -#include "opentelemetry/sdk/trace/recordable.h" #include "opentelemetry/sdk/trace/span_data.h" - -#include +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_exporter.h b/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_exporter.h index 0c2a14a673..6be83113ce 100644 --- a/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_exporter.h +++ b/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_exporter.h @@ -3,13 +3,20 @@ #pragma once +#include #include -#include +#include +#include +#include +#include #include "opentelemetry/exporters/memory/in_memory_span_data.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/common/global_log_handler.h" #include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/sdk/trace/recordable.h" #include "opentelemetry/sdk/trace/span_data.h" -#include "opentelemetry/sdk_config.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/exporters/zipkin/src/zipkin_exporter.cc b/exporters/zipkin/src/zipkin_exporter.cc index 4c5723c674..5d5dd728a6 100644 --- a/exporters/zipkin/src/zipkin_exporter.cc +++ b/exporters/zipkin/src/zipkin_exporter.cc @@ -10,6 +10,7 @@ #include #include #include +#include #include "nlohmann/json.hpp" diff --git a/ext/include/opentelemetry/ext/http/common/url_parser.h b/ext/include/opentelemetry/ext/http/common/url_parser.h index 5e18d85bb6..386d4fcd2f 100644 --- a/ext/include/opentelemetry/ext/http/common/url_parser.h +++ b/ext/include/opentelemetry/ext/http/common/url_parser.h @@ -3,11 +3,12 @@ #pragma once +#include #include #include -#include -#include "opentelemetry/nostd/string_view.h" + #include "opentelemetry/version.h" + OPENTELEMETRY_BEGIN_NAMESPACE namespace ext { diff --git a/ext/test/http/curl_http_test.cc b/ext/test/http/curl_http_test.cc index d5351d2314..137c9b7f9b 100644 --- a/ext/test/http/curl_http_test.cc +++ b/ext/test/http/curl_http_test.cc @@ -1,23 +1,28 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/ext//http/client/curl/http_client_curl.h" -#include "opentelemetry/ext/http/client/http_client_factory.h" -#include "opentelemetry/ext/http/server/http_server.h" - -#include +#include +#include #include #include #include #include +#include #include -#include +#include +#include #include #include -#define HTTP_PORT 19000 +#include "opentelemetry/ext//http/client/curl/http_client_curl.h" +#include "opentelemetry/ext/http/client/curl/http_operation_curl.h" +#include "opentelemetry/ext/http/client/http_client.h" +#include "opentelemetry/ext/http/client/http_client_factory.h" +#include "opentelemetry/ext/http/server/http_server.h" +#include "opentelemetry/nostd/function_ref.h" +#include "opentelemetry/nostd/string_view.h" -#include +#define HTTP_PORT 19000 namespace curl = opentelemetry::ext::http::client::curl; namespace http_client = opentelemetry::ext::http::client; diff --git a/ext/test/http/url_parser_test.cc b/ext/test/http/url_parser_test.cc index 7b28d763e6..79a5e60a60 100644 --- a/ext/test/http/url_parser_test.cc +++ b/ext/test/http/url_parser_test.cc @@ -1,9 +1,12 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/ext/http/common/url_parser.h" - #include +#include +#include +#include + +#include "opentelemetry/ext/http/common/url_parser.h" namespace http_common = opentelemetry::ext::http::common; diff --git a/ext/test/w3c_tracecontext_test/main.cc b/ext/test/w3c_tracecontext_test/main.cc index 4e9fb36796..fed07a2398 100644 --- a/ext/test/w3c_tracecontext_test/main.cc +++ b/ext/test/w3c_tracecontext_test/main.cc @@ -1,19 +1,38 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/context/context_value.h" +#include "opentelemetry/context/propagation/text_map_propagator.h" #include "opentelemetry/context/runtime_context.h" #include "opentelemetry/exporters/ostream/span_exporter.h" #include "opentelemetry/ext/http/client/curl/http_client_curl.h" +#include "opentelemetry/ext/http/client/curl/http_operation_curl.h" +#include "opentelemetry/ext/http/client/http_client.h" #include "opentelemetry/ext/http/server/http_server.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/recordable.h" #include "opentelemetry/sdk/trace/simple_processor.h" #include "opentelemetry/sdk/trace/tracer_context.h" #include "opentelemetry/sdk/trace/tracer_provider.h" #include "opentelemetry/trace/propagation/http_trace_context.h" #include "opentelemetry/trace/provider.h" #include "opentelemetry/trace/scope.h" - -#include -#include "nlohmann/json.hpp" +#include "opentelemetry/trace/tracer.h" +#include "opentelemetry/trace/tracer_provider.h" namespace trace_api = opentelemetry::trace; namespace http_client = opentelemetry::ext::http::client; diff --git a/sdk/include/opentelemetry/sdk/common/attribute_utils.h b/sdk/include/opentelemetry/sdk/common/attribute_utils.h index e21649b695..86b507a66b 100644 --- a/sdk/include/opentelemetry/sdk/common/attribute_utils.h +++ b/sdk/include/opentelemetry/sdk/common/attribute_utils.h @@ -3,13 +3,19 @@ #pragma once +#include +#include #include #include #include +#include #include #include "opentelemetry/common/attribute_value.h" -#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/common/key_value_iterable.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/variant.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/sdk/include/opentelemetry/sdk/common/attributemap_hash.h b/sdk/include/opentelemetry/sdk/common/attributemap_hash.h index e09b03d08b..39df29b278 100644 --- a/sdk/include/opentelemetry/sdk/common/attributemap_hash.h +++ b/sdk/include/opentelemetry/sdk/common/attributemap_hash.h @@ -3,8 +3,15 @@ #pragma once +#include #include +#include +#include +#include +#include +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/nostd/function_ref.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/variant.h" diff --git a/sdk/include/opentelemetry/sdk/common/circular_buffer.h b/sdk/include/opentelemetry/sdk/common/circular_buffer.h index 6541612158..a35498ecea 100644 --- a/sdk/include/opentelemetry/sdk/common/circular_buffer.h +++ b/sdk/include/opentelemetry/sdk/common/circular_buffer.h @@ -5,9 +5,12 @@ #include #include +#include #include +#include #include +#include "opentelemetry/nostd/span.h" #include "opentelemetry/sdk/common/atomic_unique_ptr.h" #include "opentelemetry/sdk/common/circular_buffer_range.h" #include "opentelemetry/version.h" diff --git a/sdk/include/opentelemetry/sdk/common/circular_buffer_range.h b/sdk/include/opentelemetry/sdk/common/circular_buffer_range.h index e9b89f9d02..5e16c3d410 100644 --- a/sdk/include/opentelemetry/sdk/common/circular_buffer_range.h +++ b/sdk/include/opentelemetry/sdk/common/circular_buffer_range.h @@ -3,8 +3,9 @@ #pragma once +#include #include -#include +#include #include "opentelemetry/nostd/span.h" #include "opentelemetry/version.h" diff --git a/sdk/include/opentelemetry/sdk/metrics/observer_result.h b/sdk/include/opentelemetry/sdk/metrics/observer_result.h index 4ed3cd168d..cc60cf5f64 100644 --- a/sdk/include/opentelemetry/sdk/metrics/observer_result.h +++ b/sdk/include/opentelemetry/sdk/metrics/observer_result.h @@ -5,8 +5,10 @@ #include +#include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/metrics/observer_result.h" +#include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/metrics/state/attributes_hashmap.h" #include "opentelemetry/sdk/metrics/view/attributes_processor.h" #include "opentelemetry/version.h" diff --git a/sdk/include/opentelemetry/sdk/metrics/state/attributes_hashmap.h b/sdk/include/opentelemetry/sdk/metrics/state/attributes_hashmap.h index a509080318..ddf2a8b206 100644 --- a/sdk/include/opentelemetry/sdk/metrics/state/attributes_hashmap.h +++ b/sdk/include/opentelemetry/sdk/metrics/state/attributes_hashmap.h @@ -3,18 +3,21 @@ #pragma once +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/nostd/function_ref.h" #include "opentelemetry/sdk/common/attribute_utils.h" #include "opentelemetry/sdk/common/attributemap_hash.h" #include "opentelemetry/sdk/metrics/aggregation/aggregation.h" -#include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/view/attributes_processor.h" #include "opentelemetry/version.h" -#include -#include -#include - OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk { diff --git a/sdk/include/opentelemetry/sdk/metrics/state/multi_metric_storage.h b/sdk/include/opentelemetry/sdk/metrics/state/multi_metric_storage.h index 6202b0c7fb..2a77b2f856 100644 --- a/sdk/include/opentelemetry/sdk/metrics/state/multi_metric_storage.h +++ b/sdk/include/opentelemetry/sdk/metrics/state/multi_metric_storage.h @@ -3,26 +3,20 @@ #pragma once +#include #include #include #include +#include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/common/timestamp.h" -#include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/context/context.h" +#include "opentelemetry/sdk/metrics/state/attributes_hashmap.h" #include "opentelemetry/sdk/metrics/state/metric_storage.h" +#include "opentelemetry/sdk/metrics/view/attributes_processor.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE -namespace common -{ -class KeyValueIterable; -} // namespace common - -namespace context -{ -class Context; -} // namespace context - namespace sdk { namespace metrics diff --git a/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h b/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h index 1d5f8dbc55..039a37e748 100644 --- a/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h +++ b/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h @@ -12,7 +12,6 @@ #include "opentelemetry/metrics/sync_instruments.h" #include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/state/metric_storage.h" -#include "opentelemetry/sdk_config.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/sdk/include/opentelemetry/sdk/metrics/view/attributes_processor.h b/sdk/include/opentelemetry/sdk/metrics/view/attributes_processor.h index a71abb7a99..5d53959e1b 100644 --- a/sdk/include/opentelemetry/sdk/metrics/view/attributes_processor.h +++ b/sdk/include/opentelemetry/sdk/metrics/view/attributes_processor.h @@ -5,9 +5,11 @@ #include #include +#include + +#include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/state/filtered_ordered_attribute_map.h" #include "opentelemetry/version.h" diff --git a/sdk/include/opentelemetry/sdk/metrics/view/view_registry.h b/sdk/include/opentelemetry/sdk/metrics/view/view_registry.h index 40343c28de..fd1e4bee0c 100644 --- a/sdk/include/opentelemetry/sdk/metrics/view/view_registry.h +++ b/sdk/include/opentelemetry/sdk/metrics/view/view_registry.h @@ -3,14 +3,18 @@ #pragma once +#include #include -#include +#include +#include #include #include "opentelemetry/nostd/function_ref.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" +#include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/view/instrument_selector.h" #include "opentelemetry/sdk/metrics/view/meter_selector.h" +#include "opentelemetry/sdk/metrics/view/predicate.h" #include "opentelemetry/sdk/metrics/view/view.h" #include "opentelemetry/version.h" diff --git a/sdk/include/opentelemetry/sdk/trace/simple_processor.h b/sdk/include/opentelemetry/sdk/trace/simple_processor.h index dee8e80bb8..ce6d378b79 100644 --- a/sdk/include/opentelemetry/sdk/trace/simple_processor.h +++ b/sdk/include/opentelemetry/sdk/trace/simple_processor.h @@ -7,12 +7,15 @@ #include #include #include +#include #include "opentelemetry/common/spin_lock_mutex.h" #include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/common/exporter_utils.h" #include "opentelemetry/sdk/trace/exporter.h" #include "opentelemetry/sdk/trace/processor.h" #include "opentelemetry/sdk/trace/recordable.h" +#include "opentelemetry/trace/span_context.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/sdk/include/opentelemetry/sdk/trace/span_data.h b/sdk/include/opentelemetry/sdk/trace/span_data.h index 8e301c1a01..2bd8b2112b 100644 --- a/sdk/include/opentelemetry/sdk/trace/span_data.h +++ b/sdk/include/opentelemetry/sdk/trace/span_data.h @@ -11,14 +11,18 @@ #include #include "opentelemetry/common/attribute_value.h" -#include "opentelemetry/common/macros.h" +#include "opentelemetry/common/key_value_iterable.h" +#include "opentelemetry/common/key_value_iterable_view.h" #include "opentelemetry/common/timestamp.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/common/attribute_utils.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/sdk/trace/recordable.h" -#include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/span_context.h" #include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_flags.h" #include "opentelemetry/trace/trace_id.h" #include "opentelemetry/version.h" diff --git a/sdk/include/opentelemetry/sdk/trace/tracer.h b/sdk/include/opentelemetry/sdk/trace/tracer.h index fb8342c1d5..f738203b4f 100644 --- a/sdk/include/opentelemetry/sdk/trace/tracer.h +++ b/sdk/include/opentelemetry/sdk/trace/tracer.h @@ -4,12 +4,10 @@ #pragma once #include -#include #include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/sdk/trace/id_generator.h" diff --git a/sdk/include/opentelemetry/sdk/trace/tracer_provider.h b/sdk/include/opentelemetry/sdk/trace/tracer_provider.h index 13a65a2d87..44d5840558 100644 --- a/sdk/include/opentelemetry/sdk/trace/tracer_provider.h +++ b/sdk/include/opentelemetry/sdk/trace/tracer_provider.h @@ -4,7 +4,6 @@ #pragma once #include -#include #include #include diff --git a/sdk/src/metrics/aggregation/sum_aggregation.cc b/sdk/src/metrics/aggregation/sum_aggregation.cc index ce0d4c5de5..cd518e5460 100644 --- a/sdk/src/metrics/aggregation/sum_aggregation.cc +++ b/sdk/src/metrics/aggregation/sum_aggregation.cc @@ -4,7 +4,6 @@ #include #include #include -#include #include "opentelemetry/common/spin_lock_mutex.h" #include "opentelemetry/nostd/variant.h" diff --git a/sdk/src/metrics/export/periodic_exporting_metric_reader.cc b/sdk/src/metrics/export/periodic_exporting_metric_reader.cc index 42fd6003ae..682badf3a4 100644 --- a/sdk/src/metrics/export/periodic_exporting_metric_reader.cc +++ b/sdk/src/metrics/export/periodic_exporting_metric_reader.cc @@ -9,11 +9,9 @@ #include #include #include -#include #include #include -#include "opentelemetry/common/macros.h" #include "opentelemetry/common/timestamp.h" #include "opentelemetry/sdk/common/global_log_handler.h" #include "opentelemetry/sdk/metrics/export/metric_producer.h" diff --git a/sdk/src/metrics/meter_context.cc b/sdk/src/metrics/meter_context.cc index 42efce76fb..15e689706a 100644 --- a/sdk/src/metrics/meter_context.cc +++ b/sdk/src/metrics/meter_context.cc @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/sdk/src/trace/samplers/parent_factory.cc b/sdk/src/trace/samplers/parent_factory.cc index 63a7eff1c4..25a2e94f65 100644 --- a/sdk/src/trace/samplers/parent_factory.cc +++ b/sdk/src/trace/samplers/parent_factory.cc @@ -1,8 +1,9 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include +#include +#include "opentelemetry/sdk/trace/sampler.h" #include "opentelemetry/sdk/trace/samplers/parent.h" #include "opentelemetry/sdk/trace/samplers/parent_factory.h" #include "opentelemetry/version.h" diff --git a/sdk/test/common/attribute_utils_test.cc b/sdk/test/common/attribute_utils_test.cc index b7ef17244f..9b1f6bd56e 100644 --- a/sdk/test/common/attribute_utils_test.cc +++ b/sdk/test/common/attribute_utils_test.cc @@ -1,13 +1,17 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/common/attribute_utils.h" - #include +#include +#include +#include + +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/attribute_utils.h" TEST(AttributeMapTest, DefaultConstruction) { - opentelemetry::sdk::common::AttributeMap attribute_map; EXPECT_EQ(attribute_map.GetAttributes().size(), 0); } diff --git a/sdk/test/common/attributemap_hash_benchmark.cc b/sdk/test/common/attributemap_hash_benchmark.cc index 811ecb23dd..e0641fb961 100644 --- a/sdk/test/common/attributemap_hash_benchmark.cc +++ b/sdk/test/common/attributemap_hash_benchmark.cc @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 #include + +#include "opentelemetry/sdk/common/attribute_utils.h" #include "opentelemetry/sdk/common/attributemap_hash.h" using namespace opentelemetry::sdk::common; diff --git a/sdk/test/common/circular_buffer_benchmark.cc b/sdk/test/common/circular_buffer_benchmark.cc index 1f2b9b42cf..7ffc452135 100644 --- a/sdk/test/common/circular_buffer_benchmark.cc +++ b/sdk/test/common/circular_buffer_benchmark.cc @@ -1,18 +1,24 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "benchmark/benchmark.h" - +#include #include #include +#include +#include #include #include #include #include #include +#include "benchmark/benchmark.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/common/atomic_unique_ptr.h" #include "opentelemetry/sdk/common/circular_buffer.h" +#include "opentelemetry/sdk/common/circular_buffer_range.h" #include "test/common/baseline_circular_buffer.h" + using opentelemetry::sdk::common::AtomicUniquePtr; using opentelemetry::sdk::common::CircularBuffer; using opentelemetry::sdk::common::CircularBufferRange; diff --git a/sdk/test/common/circular_buffer_range_test.cc b/sdk/test/common/circular_buffer_range_test.cc index 5852704687..ed2f028978 100644 --- a/sdk/test/common/circular_buffer_range_test.cc +++ b/sdk/test/common/circular_buffer_range_test.cc @@ -1,11 +1,11 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/common/circular_buffer_range.h" +#include -#include +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/common/circular_buffer_range.h" -#include using opentelemetry::sdk::common::CircularBufferRange; TEST(CircularBufferRangeTest, ForEach) diff --git a/sdk/test/common/circular_buffer_test.cc b/sdk/test/common/circular_buffer_test.cc index a20c3e42aa..8a3292ca60 100644 --- a/sdk/test/common/circular_buffer_test.cc +++ b/sdk/test/common/circular_buffer_test.cc @@ -1,14 +1,24 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/common/circular_buffer.h" - +#include +#include #include +#include #include +#include +#include +#include +#include #include #include +#include + +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/common/atomic_unique_ptr.h" +#include "opentelemetry/sdk/common/circular_buffer.h" +#include "opentelemetry/sdk/common/circular_buffer_range.h" -#include using opentelemetry::sdk::common::AtomicUniquePtr; using opentelemetry::sdk::common::CircularBuffer; using opentelemetry::sdk::common::CircularBufferRange; diff --git a/sdk/test/common/env_var_test.cc b/sdk/test/common/env_var_test.cc index 23d3802361..8f64dc1f10 100644 --- a/sdk/test/common/env_var_test.cc +++ b/sdk/test/common/env_var_test.cc @@ -1,9 +1,12 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/common/env_variables.h" - #include +#include +#include +#include + +#include "opentelemetry/sdk/common/env_variables.h" #if defined(_MSC_VER) using opentelemetry::sdk::common::setenv; diff --git a/sdk/test/common/fast_random_number_generator_test.cc b/sdk/test/common/fast_random_number_generator_test.cc index e9209fdb6b..1f87ea13d7 100644 --- a/sdk/test/common/fast_random_number_generator_test.cc +++ b/sdk/test/common/fast_random_number_generator_test.cc @@ -1,11 +1,13 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "src/common/random.h" - +#include +#include #include +#include +#include -#include +#include "src/common/fast_random_number_generator.h" using opentelemetry::sdk::common::FastRandomNumberGenerator; diff --git a/sdk/test/common/global_log_handle_test.cc b/sdk/test/common/global_log_handle_test.cc index 28b111cc71..3c3fc3d7f3 100644 --- a/sdk/test/common/global_log_handle_test.cc +++ b/sdk/test/common/global_log_handle_test.cc @@ -1,12 +1,13 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/common/global_log_handler.h" - #include - #include +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/sdk/common/attribute_utils.h" +#include "opentelemetry/sdk/common/global_log_handler.h" + class CustomLogHandler : public opentelemetry::sdk::common::internal_log::LogHandler { public: diff --git a/sdk/test/common/random_benchmark.cc b/sdk/test/common/random_benchmark.cc index df2ebf95ec..46dadbe260 100644 --- a/sdk/test/common/random_benchmark.cc +++ b/sdk/test/common/random_benchmark.cc @@ -1,12 +1,10 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "src/common/random.h" - -#include +#include #include -#include +#include "src/common/random.h" namespace { diff --git a/sdk/test/common/random_fork_test.cc b/sdk/test/common/random_fork_test.cc index 2db8b9fcdf..15f7a43cf2 100644 --- a/sdk/test/common/random_fork_test.cc +++ b/sdk/test/common/random_fork_test.cc @@ -7,13 +7,13 @@ // See https://github.com/opentracing-contrib/nginx-opentracing/issues/52 # include "src/common/random.h" +# include # include -# include # include # include -# include # include # include + using opentelemetry::sdk::common::Random; static uint64_t *child_id; diff --git a/sdk/test/common/random_test.cc b/sdk/test/common/random_test.cc index e22e0508fc..85292babe4 100644 --- a/sdk/test/common/random_test.cc +++ b/sdk/test/common/random_test.cc @@ -1,15 +1,17 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "src/common/random.h" - +#include #include #include +#include +#include #include #include #include -#include +#include "src/common/random.h" + using opentelemetry::sdk::common::Random; TEST(RandomTest, GenerateRandom64) diff --git a/sdk/test/instrumentationscope/instrumentationscope_test.cc b/sdk/test/instrumentationscope/instrumentationscope_test.cc index 2f376d5d6b..da00ec8e93 100644 --- a/sdk/test/instrumentationscope/instrumentationscope_test.cc +++ b/sdk/test/instrumentationscope/instrumentationscope_test.cc @@ -1,15 +1,22 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/sdk/instrumentationlibrary/instrumentation_library.h" -#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" - #include +#include +#include #include #include +#include #include +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/utility.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/instrumentationlibrary/instrumentation_library.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" + using namespace opentelemetry; using namespace opentelemetry::sdk::instrumentationscope; diff --git a/sdk/test/logs/batch_log_record_processor_test.cc b/sdk/test/logs/batch_log_record_processor_test.cc index 3bdd849938..036146f4e6 100644 --- a/sdk/test/logs/batch_log_record_processor_test.cc +++ b/sdk/test/logs/batch_log_record_processor_test.cc @@ -1,15 +1,31 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/logs/batch_log_record_processor.h" -#include "opentelemetry/sdk/logs/exporter.h" -#include "opentelemetry/sdk/logs/recordable.h" - #include +#include +#include #include +#include #include +#include #include #include +#include + +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/logs/log_record.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/utility.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/atomic_unique_ptr.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/logs/batch_log_record_processor.h" +#include "opentelemetry/sdk/logs/batch_log_record_processor_options.h" +#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/sdk/logs/processor.h" +#include "opentelemetry/sdk/logs/recordable.h" using namespace opentelemetry::sdk::logs; using namespace opentelemetry::sdk::common; diff --git a/sdk/test/logs/log_record_test.cc b/sdk/test/logs/log_record_test.cc index bd9e462012..99ba9f296d 100644 --- a/sdk/test/logs/log_record_test.cc +++ b/sdk/test/logs/log_record_test.cc @@ -1,21 +1,33 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include #include -#include +#include +#include #include -#include +#include +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/key_value_iterable.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/logs/event_id.h" +#include "opentelemetry/logs/log_record.h" #include "opentelemetry/logs/logger.h" -#include "opentelemetry/logs/provider.h" +#include "opentelemetry/logs/logger_provider.h" +#include "opentelemetry/logs/severity.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/unique_ptr.h" +#include "opentelemetry/nostd/utility.h" #include "opentelemetry/nostd/variant.h" #include "opentelemetry/sdk/logs/read_write_log_record.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/trace_flags.h" #include "opentelemetry/trace/trace_id.h" -#include - using opentelemetry::sdk::logs::ReadWriteLogRecord; namespace trace_api = opentelemetry::trace; namespace logs_api = opentelemetry::logs; diff --git a/sdk/test/logs/logger_provider_sdk_test.cc b/sdk/test/logs/logger_provider_sdk_test.cc index ecb9ea6f9c..a5a3d3a68a 100644 --- a/sdk/test/logs/logger_provider_sdk_test.cc +++ b/sdk/test/logs/logger_provider_sdk_test.cc @@ -1,20 +1,38 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include +#include +#include +#include +#include #include +#include +#include +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/logs/log_record.h" +#include "opentelemetry/logs/logger_provider.h" #include "opentelemetry/logs/provider.h" +#include "opentelemetry/logs/severity.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/utility.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" +#include "opentelemetry/sdk/logs/event_logger_provider.h" #include "opentelemetry/sdk/logs/event_logger_provider_factory.h" #include "opentelemetry/sdk/logs/exporter.h" #include "opentelemetry/sdk/logs/logger.h" +#include "opentelemetry/sdk/logs/logger_context.h" #include "opentelemetry/sdk/logs/logger_provider.h" +#include "opentelemetry/sdk/logs/processor.h" #include "opentelemetry/sdk/logs/recordable.h" #include "opentelemetry/sdk/logs/simple_log_record_processor.h" - -#include +#include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/trace_flags.h" +#include "opentelemetry/trace/trace_id.h" using namespace opentelemetry::sdk::logs; namespace logs_api = opentelemetry::logs; diff --git a/sdk/test/logs/logger_sdk_test.cc b/sdk/test/logs/logger_sdk_test.cc index 9e63672d3c..4af0fb3745 100644 --- a/sdk/test/logs/logger_sdk_test.cc +++ b/sdk/test/logs/logger_sdk_test.cc @@ -1,26 +1,44 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include #include #include #include - +#include + +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/logs/event_logger.h" +#include "opentelemetry/logs/event_logger_provider.h" +#include "opentelemetry/logs/log_record.h" +#include "opentelemetry/logs/logger.h" #include "opentelemetry/logs/logger_provider.h" +#include "opentelemetry/logs/severity.h" +#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/utility.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/logs/event_logger.h" #include "opentelemetry/sdk/logs/event_logger_provider.h" #include "opentelemetry/sdk/logs/logger.h" #include "opentelemetry/sdk/logs/logger_provider.h" #include "opentelemetry/sdk/logs/processor.h" #include "opentelemetry/sdk/logs/recordable.h" +#include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/sdk/trace/processor.h" #include "opentelemetry/sdk/trace/tracer_provider.h" #include "opentelemetry/sdk/trace/tracer_provider_factory.h" #include "opentelemetry/trace/scope.h" +#include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/trace_flags.h" +#include "opentelemetry/trace/trace_id.h" #include "opentelemetry/trace/tracer.h" -#include - using namespace opentelemetry::sdk::logs; namespace logs_api = opentelemetry::logs; namespace nostd = opentelemetry::nostd; diff --git a/sdk/test/logs/simple_log_record_processor_test.cc b/sdk/test/logs/simple_log_record_processor_test.cc index 30e5771394..b8a9f03e0c 100644 --- a/sdk/test/logs/simple_log_record_processor_test.cc +++ b/sdk/test/logs/simple_log_record_processor_test.cc @@ -1,16 +1,26 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/logs/simple_log_record_processor.h" -#include "opentelemetry/nostd/span.h" -#include "opentelemetry/sdk/logs/exporter.h" -#include "opentelemetry/sdk/logs/recordable.h" - #include - +#include +#include #include -#include +#include +#include #include +#include + +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/logs/log_record.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/utility.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/sdk/logs/recordable.h" +#include "opentelemetry/sdk/logs/simple_log_record_processor.h" using namespace opentelemetry::sdk::logs; using namespace opentelemetry::sdk::common; diff --git a/sdk/test/metrics/aggregation_test.cc b/sdk/test/metrics/aggregation_test.cc index d52cc9e732..d56f33545a 100644 --- a/sdk/test/metrics/aggregation_test.cc +++ b/sdk/test/metrics/aggregation_test.cc @@ -2,13 +2,17 @@ // SPDX-License-Identifier: Apache-2.0 #include +#include +#include + +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/metrics/aggregation/aggregation.h" #include "opentelemetry/sdk/metrics/aggregation/aggregation_config.h" #include "opentelemetry/sdk/metrics/aggregation/histogram_aggregation.h" #include "opentelemetry/sdk/metrics/aggregation/lastvalue_aggregation.h" #include "opentelemetry/sdk/metrics/aggregation/sum_aggregation.h" - -#include "opentelemetry/nostd/shared_ptr.h" -#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" using namespace opentelemetry::sdk::metrics; namespace nostd = opentelemetry::nostd; diff --git a/sdk/test/metrics/async_instruments_test.cc b/sdk/test/metrics/async_instruments_test.cc index 01a421e046..cda08a1549 100644 --- a/sdk/test/metrics/async_instruments_test.cc +++ b/sdk/test/metrics/async_instruments_test.cc @@ -1,12 +1,21 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include + +#include "opentelemetry/metrics/observer_result.h" +#include "opentelemetry/nostd/utility.h" #include "opentelemetry/sdk/metrics/async_instruments.h" +#include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/state/filtered_ordered_attribute_map.h" +#include "opentelemetry/sdk/metrics/state/metric_storage.h" #include "opentelemetry/sdk/metrics/state/multi_metric_storage.h" #include "opentelemetry/sdk/metrics/state/observable_registry.h" -#include - using namespace opentelemetry; using namespace opentelemetry::sdk::metrics; diff --git a/sdk/test/metrics/async_metric_storage_test.cc b/sdk/test/metrics/async_metric_storage_test.cc index dcbe105418..912310415a 100644 --- a/sdk/test/metrics/async_metric_storage_test.cc +++ b/sdk/test/metrics/async_metric_storage_test.cc @@ -1,30 +1,37 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "common.h" -#include "opentelemetry/common/key_value_iterable_view.h" -#include "opentelemetry/sdk/metrics/async_instruments.h" +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/nostd/function_ref.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/state/async_metric_storage.h" +#include "opentelemetry/sdk/metrics/state/attributes_hashmap.h" +#include "opentelemetry/sdk/metrics/state/filtered_ordered_attribute_map.h" +#include "opentelemetry/sdk/metrics/state/metric_collector.h" +#include "opentelemetry/sdk/metrics/view/attributes_processor.h" #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW # include "opentelemetry/sdk/metrics/exemplar/filter_type.h" # include "opentelemetry/sdk/metrics/exemplar/reservoir.h" #endif -#include "opentelemetry/sdk/metrics/instruments.h" -#include "opentelemetry/sdk/metrics/meter_context.h" -#include "opentelemetry/sdk/metrics/metric_reader.h" -#include "opentelemetry/sdk/metrics/observer_result.h" -#include "opentelemetry/sdk/metrics/push_metric_exporter.h" -#include "opentelemetry/sdk/metrics/state/async_metric_storage.h" -#include "opentelemetry/sdk/metrics/state/metric_collector.h" -#include "opentelemetry/sdk/metrics/state/observable_registry.h" - -#include -#include -#include -#include - using namespace opentelemetry::sdk::metrics; using namespace opentelemetry::sdk::instrumentationscope; using namespace opentelemetry::sdk::resource; diff --git a/sdk/test/metrics/attributes_hashmap_benchmark.cc b/sdk/test/metrics/attributes_hashmap_benchmark.cc index 5dc02ca5be..ed080d911d 100644 --- a/sdk/test/metrics/attributes_hashmap_benchmark.cc +++ b/sdk/test/metrics/attributes_hashmap_benchmark.cc @@ -2,17 +2,22 @@ // SPDX-License-Identifier: Apache-2.0 #include -#include "opentelemetry/sdk/common/attributemap_hash.h" -#include "opentelemetry/sdk/metrics/aggregation/aggregation.h" -#include "opentelemetry/sdk/metrics/aggregation/drop_aggregation.h" -#include "opentelemetry/sdk/metrics/instruments.h" -#include "opentelemetry/sdk/metrics/state/attributes_hashmap.h" - +#include +#include +#include #include +#include #include #include #include +#include "opentelemetry/sdk/common/attributemap_hash.h" +#include "opentelemetry/sdk/metrics/aggregation/aggregation.h" +#include "opentelemetry/sdk/metrics/aggregation/drop_aggregation.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" +#include "opentelemetry/sdk/metrics/state/attributes_hashmap.h" +#include "opentelemetry/sdk/metrics/view/attributes_processor.h" + using namespace opentelemetry::sdk::metrics; constexpr size_t MAX_THREADS = 500; namespace diff --git a/sdk/test/metrics/attributes_hashmap_test.cc b/sdk/test/metrics/attributes_hashmap_test.cc index 7d77e6166a..c7f0f01ee5 100644 --- a/sdk/test/metrics/attributes_hashmap_test.cc +++ b/sdk/test/metrics/attributes_hashmap_test.cc @@ -1,12 +1,24 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/state/attributes_hashmap.h" #include -#include "opentelemetry/sdk/metrics/aggregation/drop_aggregation.h" -#include "opentelemetry/sdk/metrics/instruments.h" - +#include +#include #include +#include +#include +#include +#include + +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/utility.h" +#include "opentelemetry/sdk/common/attributemap_hash.h" +#include "opentelemetry/sdk/metrics/aggregation/aggregation.h" +#include "opentelemetry/sdk/metrics/aggregation/drop_aggregation.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" +#include "opentelemetry/sdk/metrics/state/attributes_hashmap.h" +#include "opentelemetry/sdk/metrics/view/attributes_processor.h" using namespace opentelemetry::sdk::metrics; namespace nostd = opentelemetry::nostd; diff --git a/sdk/test/metrics/attributes_processor_benchmark.cc b/sdk/test/metrics/attributes_processor_benchmark.cc index 28f1984b40..708549406b 100644 --- a/sdk/test/metrics/attributes_processor_benchmark.cc +++ b/sdk/test/metrics/attributes_processor_benchmark.cc @@ -3,7 +3,12 @@ #include #include +#include + +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/sdk/metrics/state/filtered_ordered_attribute_map.h" #include "opentelemetry/sdk/metrics/view/attributes_processor.h" + using namespace opentelemetry::sdk::metrics; namespace { diff --git a/sdk/test/metrics/attributes_processor_test.cc b/sdk/test/metrics/attributes_processor_test.cc index 62c0879ca9..5299af1358 100644 --- a/sdk/test/metrics/attributes_processor_test.cc +++ b/sdk/test/metrics/attributes_processor_test.cc @@ -1,8 +1,17 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/view/attributes_processor.h" #include +#include +#include +#include +#include + +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/sdk/common/attribute_utils.h" +#include "opentelemetry/sdk/metrics/state/filtered_ordered_attribute_map.h" +#include "opentelemetry/sdk/metrics/view/attributes_processor.h" using namespace opentelemetry::sdk::metrics; using namespace opentelemetry::common; diff --git a/sdk/test/metrics/base2_exponential_histogram_indexer_benchmark.cc b/sdk/test/metrics/base2_exponential_histogram_indexer_benchmark.cc index 9f1d0d864d..40ea14d575 100644 --- a/sdk/test/metrics/base2_exponential_histogram_indexer_benchmark.cc +++ b/sdk/test/metrics/base2_exponential_histogram_indexer_benchmark.cc @@ -1,12 +1,13 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/aggregation/base2_exponential_histogram_indexer.h" - #include +#include #include #include +#include "opentelemetry/sdk/metrics/aggregation/base2_exponential_histogram_indexer.h" + using namespace opentelemetry::sdk::metrics; namespace { diff --git a/sdk/test/metrics/base2_exponential_histogram_indexer_test.cc b/sdk/test/metrics/base2_exponential_histogram_indexer_test.cc index 85f6fe72e9..716985e7cf 100644 --- a/sdk/test/metrics/base2_exponential_histogram_indexer_test.cc +++ b/sdk/test/metrics/base2_exponential_histogram_indexer_test.cc @@ -1,9 +1,11 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/aggregation/base2_exponential_histogram_indexer.h" - #include +#include +#include + +#include "opentelemetry/sdk/metrics/aggregation/base2_exponential_histogram_indexer.h" using namespace opentelemetry::sdk::metrics; diff --git a/sdk/test/metrics/cardinality_limit_test.cc b/sdk/test/metrics/cardinality_limit_test.cc index cf94112f1a..926062709b 100644 --- a/sdk/test/metrics/cardinality_limit_test.cc +++ b/sdk/test/metrics/cardinality_limit_test.cc @@ -1,18 +1,39 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "common.h" + +#include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/context/context.h" +#include "opentelemetry/nostd/function_ref.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/attributemap_hash.h" +#include "opentelemetry/sdk/metrics/aggregation/aggregation.h" #include "opentelemetry/sdk/metrics/aggregation/sum_aggregation.h" -#ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW -# include "opentelemetry/sdk/metrics/exemplar/filter_type.h" -#endif +#include "opentelemetry/sdk/metrics/data/metric_data.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" #include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/state/attributes_hashmap.h" +#include "opentelemetry/sdk/metrics/state/filtered_ordered_attribute_map.h" +#include "opentelemetry/sdk/metrics/state/metric_collector.h" #include "opentelemetry/sdk/metrics/state/sync_metric_storage.h" +#include "opentelemetry/sdk/metrics/view/attributes_processor.h" -#include -#include +#ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW +# include "opentelemetry/sdk/metrics/exemplar/filter_type.h" +#endif using namespace opentelemetry::sdk::metrics; using namespace opentelemetry::common; diff --git a/sdk/test/metrics/circular_buffer_counter_test.cc b/sdk/test/metrics/circular_buffer_counter_test.cc index a8218d9e6b..38b6000d3e 100644 --- a/sdk/test/metrics/circular_buffer_counter_test.cc +++ b/sdk/test/metrics/circular_buffer_counter_test.cc @@ -1,11 +1,12 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/data/circular_buffer.h" - #include +#include #include +#include "opentelemetry/sdk/metrics/data/circular_buffer.h" + using namespace opentelemetry::sdk::metrics; class AdaptingIntegerArrayTest : public testing::TestWithParam diff --git a/sdk/test/metrics/common.cc b/sdk/test/metrics/common.cc index 87343f6186..8aff2f91fa 100644 --- a/sdk/test/metrics/common.cc +++ b/sdk/test/metrics/common.cc @@ -2,8 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 #include "common.h" +#include + +#include "opentelemetry/sdk/metrics/data/point_data.h" -using namespace opentelemetry; using namespace opentelemetry::sdk::instrumentationscope; using namespace opentelemetry::sdk::metrics; using namespace opentelemetry::sdk::common; diff --git a/sdk/test/metrics/common.h b/sdk/test/metrics/common.h index b3b73e15d6..ff2060e285 100644 --- a/sdk/test/metrics/common.h +++ b/sdk/test/metrics/common.h @@ -3,13 +3,16 @@ #pragma once -#include "opentelemetry/sdk/metrics/data/point_data.h" +#include +#include + +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/metric_reader.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" #include "opentelemetry/sdk/metrics/state/metric_collector.h" -#include - class MockMetricExporter : public opentelemetry::sdk::metrics::PushMetricExporter { public: diff --git a/sdk/test/metrics/histogram_aggregation_benchmark.cc b/sdk/test/metrics/histogram_aggregation_benchmark.cc index f85a4f4706..80ebb59069 100644 --- a/sdk/test/metrics/histogram_aggregation_benchmark.cc +++ b/sdk/test/metrics/histogram_aggregation_benchmark.cc @@ -1,18 +1,29 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "common.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/metrics/sync_instruments.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" #include "opentelemetry/sdk/metrics/data/point_data.h" -#include "opentelemetry/sdk/metrics/meter.h" -#include "opentelemetry/sdk/metrics/meter_context.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" #include "opentelemetry/sdk/metrics/meter_provider.h" #include "opentelemetry/sdk/metrics/metric_reader.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" -#include -#include - using namespace opentelemetry; using namespace opentelemetry::sdk::instrumentationscope; using namespace opentelemetry::sdk::metrics; diff --git a/sdk/test/metrics/histogram_aggregation_test.cc b/sdk/test/metrics/histogram_aggregation_test.cc index 6fd13c902c..264e223ccc 100644 --- a/sdk/test/metrics/histogram_aggregation_test.cc +++ b/sdk/test/metrics/histogram_aggregation_test.cc @@ -1,17 +1,30 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include #include "common.h" +#include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/metrics/sync_instruments.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" #include "opentelemetry/sdk/metrics/data/point_data.h" -#include "opentelemetry/sdk/metrics/meter.h" -#include "opentelemetry/sdk/metrics/meter_context.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/meter_provider.h" #include "opentelemetry/sdk/metrics/metric_reader.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" - -#include +#include "opentelemetry/sdk/metrics/view/instrument_selector.h" +#include "opentelemetry/sdk/metrics/view/meter_selector.h" +#include "opentelemetry/sdk/metrics/view/view.h" #if OPENTELEMETRY_HAVE_WORKING_REGEX diff --git a/sdk/test/metrics/histogram_test.cc b/sdk/test/metrics/histogram_test.cc index 57f7790ba1..8e0f3c1c1c 100644 --- a/sdk/test/metrics/histogram_test.cc +++ b/sdk/test/metrics/histogram_test.cc @@ -1,17 +1,31 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include #include "common.h" #include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/metrics/sync_instruments.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/metrics/aggregation/aggregation_config.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" #include "opentelemetry/sdk/metrics/data/point_data.h" -#include "opentelemetry/sdk/metrics/meter.h" -#include "opentelemetry/sdk/metrics/meter_context.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/meter_provider.h" #include "opentelemetry/sdk/metrics/metric_reader.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" - -#include +#include "opentelemetry/sdk/metrics/view/instrument_selector.h" +#include "opentelemetry/sdk/metrics/view/meter_selector.h" +#include "opentelemetry/sdk/metrics/view/view.h" #if OPENTELEMETRY_HAVE_WORKING_REGEX # include diff --git a/sdk/test/metrics/instrument_metadata_validator_test.cc b/sdk/test/metrics/instrument_metadata_validator_test.cc index 28c6d4a4fd..1ecdc17025 100644 --- a/sdk/test/metrics/instrument_metadata_validator_test.cc +++ b/sdk/test/metrics/instrument_metadata_validator_test.cc @@ -1,8 +1,12 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/instrument_metadata_validator.h" #include +#include +#include +#include + +#include "opentelemetry/sdk/metrics/instrument_metadata_validator.h" static std::string CreateVeryLargeString(size_t multiple) { diff --git a/sdk/test/metrics/measurements_benchmark.cc b/sdk/test/metrics/measurements_benchmark.cc index 06ac75a65a..15d96130b5 100644 --- a/sdk/test/metrics/measurements_benchmark.cc +++ b/sdk/test/metrics/measurements_benchmark.cc @@ -1,15 +1,30 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/meter.h" -#include "opentelemetry/sdk/metrics/meter_context.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/context/context.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/metrics/sync_instruments.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/utility.h" +#include "opentelemetry/sdk/common/attribute_utils.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/meter_provider.h" #include "opentelemetry/sdk/metrics/metric_reader.h" -#include "opentelemetry/sdk/metrics/push_metric_exporter.h" - -#include -#include -#include using namespace opentelemetry; using namespace opentelemetry::sdk::instrumentationscope; diff --git a/sdk/test/metrics/meter_provider_sdk_test.cc b/sdk/test/metrics/meter_provider_sdk_test.cc index 60ac7ab46f..36cb28c228 100644 --- a/sdk/test/metrics/meter_provider_sdk_test.cc +++ b/sdk/test/metrics/meter_provider_sdk_test.cc @@ -1,16 +1,22 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include #include "common.h" -#include -#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/common/macros.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" +#include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/meter.h" #include "opentelemetry/sdk/metrics/meter_provider.h" #include "opentelemetry/sdk/metrics/metric_reader.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" #include "opentelemetry/sdk/metrics/view/instrument_selector.h" #include "opentelemetry/sdk/metrics/view/meter_selector.h" +#include "opentelemetry/sdk/metrics/view/view.h" using namespace opentelemetry::sdk::metrics; diff --git a/sdk/test/metrics/meter_test.cc b/sdk/test/metrics/meter_test.cc index cd66737465..196be7b105 100644 --- a/sdk/test/metrics/meter_test.cc +++ b/sdk/test/metrics/meter_test.cc @@ -1,16 +1,31 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "common.h" +#include "opentelemetry/metrics/async_instruments.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/metrics/meter_provider.h" +#include "opentelemetry/metrics/observer_result.h" +#include "opentelemetry/metrics/sync_instruments.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/exporter_utils.h" #include "opentelemetry/sdk/metrics/data/point_data.h" -#include "opentelemetry/sdk/metrics/meter.h" -#include "opentelemetry/sdk/metrics/meter_context.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" #include "opentelemetry/sdk/metrics/meter_provider.h" #include "opentelemetry/sdk/metrics/metric_reader.h" -#include - using namespace opentelemetry; using namespace opentelemetry::sdk::instrumentationscope; using namespace opentelemetry::sdk::metrics; diff --git a/sdk/test/metrics/metric_reader_test.cc b/sdk/test/metrics/metric_reader_test.cc index 061d505a1d..fb0c5a9cf0 100644 --- a/sdk/test/metrics/metric_reader_test.cc +++ b/sdk/test/metrics/metric_reader_test.cc @@ -1,12 +1,18 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include #include "common.h" -#include +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/meter_context.h" #include "opentelemetry/sdk/metrics/metric_reader.h" -#include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/sdk/metrics/state/metric_collector.h" using namespace opentelemetry; using namespace opentelemetry::sdk::instrumentationscope; diff --git a/sdk/test/metrics/multi_metric_storage_test.cc b/sdk/test/metrics/multi_metric_storage_test.cc index 97c5a438ee..e2449db9d5 100644 --- a/sdk/test/metrics/multi_metric_storage_test.cc +++ b/sdk/test/metrics/multi_metric_storage_test.cc @@ -1,18 +1,21 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/state/multi_metric_storage.h" -#include "opentelemetry/common/key_value_iterable_view.h" +#include +#include +#include + +#include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/context/context.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" +#include "opentelemetry/sdk/metrics/state/metric_storage.h" +#include "opentelemetry/sdk/metrics/state/multi_metric_storage.h" #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW # include "opentelemetry/sdk/metrics/exemplar/no_exemplar_reservoir.h" #endif // ENABLE_METRICS_EXEMPLAR_PREVIEW -#include "opentelemetry/sdk/metrics/instruments.h" - -#include - using namespace opentelemetry; using namespace opentelemetry::sdk::metrics; diff --git a/sdk/test/metrics/observable_registry_test.cc b/sdk/test/metrics/observable_registry_test.cc index 6b6efb755a..23957b8275 100644 --- a/sdk/test/metrics/observable_registry_test.cc +++ b/sdk/test/metrics/observable_registry_test.cc @@ -1,11 +1,10 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/state/observable_registry.h" -#include "opentelemetry/metrics/observer_result.h" - #include +#include "opentelemetry/sdk/metrics/state/observable_registry.h" + using namespace opentelemetry::sdk::metrics; #if 0 diff --git a/sdk/test/metrics/observer_result_test.cc b/sdk/test/metrics/observer_result_test.cc index eea56738b9..73b7b86ec5 100644 --- a/sdk/test/metrics/observer_result_test.cc +++ b/sdk/test/metrics/observer_result_test.cc @@ -1,11 +1,19 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" #include "opentelemetry/sdk/metrics/observer_result.h" #include "opentelemetry/sdk/metrics/view/attributes_processor.h" -#include - using namespace opentelemetry::sdk::metrics; TEST(ObserverResult, BasicTests) { diff --git a/sdk/test/metrics/periodic_exporting_metric_reader_test.cc b/sdk/test/metrics/periodic_exporting_metric_reader_test.cc index 2eec5e8c61..50fe7f20d8 100644 --- a/sdk/test/metrics/periodic_exporting_metric_reader_test.cc +++ b/sdk/test/metrics/periodic_exporting_metric_reader_test.cc @@ -1,15 +1,24 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader.h" -#include "opentelemetry/sdk/metrics/export/metric_producer.h" -#include "opentelemetry/sdk/metrics/push_metric_exporter.h" - #include - +#include +#include #include #include +#include #include +#include +#include + +#include "opentelemetry/nostd/function_ref.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader.h" +#include "opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_options.h" +#include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" using namespace opentelemetry; using namespace opentelemetry::sdk::instrumentationscope; diff --git a/sdk/test/metrics/sum_aggregation_benchmark.cc b/sdk/test/metrics/sum_aggregation_benchmark.cc index 728b3542a1..b2e44b15e5 100644 --- a/sdk/test/metrics/sum_aggregation_benchmark.cc +++ b/sdk/test/metrics/sum_aggregation_benchmark.cc @@ -1,19 +1,31 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "common.h" +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/metrics/sync_instruments.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" #include "opentelemetry/sdk/metrics/data/point_data.h" -#include "opentelemetry/sdk/metrics/meter.h" -#include "opentelemetry/sdk/metrics/meter_context.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" #include "opentelemetry/sdk/metrics/meter_provider.h" #include "opentelemetry/sdk/metrics/metric_reader.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" -#include -#include -#include - using namespace opentelemetry; using namespace opentelemetry::sdk::instrumentationscope; using namespace opentelemetry::sdk::metrics; diff --git a/sdk/test/metrics/sum_aggregation_test.cc b/sdk/test/metrics/sum_aggregation_test.cc index 33a111974e..73caebbe7e 100644 --- a/sdk/test/metrics/sum_aggregation_test.cc +++ b/sdk/test/metrics/sum_aggregation_test.cc @@ -1,17 +1,35 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include #include "common.h" +#include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/macros.h" +#include "opentelemetry/context/context.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/metrics/sync_instruments.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/metrics/aggregation/aggregation_config.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" #include "opentelemetry/sdk/metrics/data/point_data.h" -#include "opentelemetry/sdk/metrics/meter.h" -#include "opentelemetry/sdk/metrics/meter_context.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/meter_provider.h" #include "opentelemetry/sdk/metrics/metric_reader.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" - -#include +#include "opentelemetry/sdk/metrics/view/attributes_processor.h" +#include "opentelemetry/sdk/metrics/view/instrument_selector.h" +#include "opentelemetry/sdk/metrics/view/meter_selector.h" +#include "opentelemetry/sdk/metrics/view/view.h" #if OPENTELEMETRY_HAVE_WORKING_REGEX diff --git a/sdk/test/metrics/sync_instruments_test.cc b/sdk/test/metrics/sync_instruments_test.cc index 723d29f20e..fb59e1d033 100644 --- a/sdk/test/metrics/sync_instruments_test.cc +++ b/sdk/test/metrics/sync_instruments_test.cc @@ -1,15 +1,22 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/sync_instruments.h" +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/key_value_iterable_view.h" #include "opentelemetry/context/context.h" +#include "opentelemetry/nostd/utility.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" -#include "opentelemetry/sdk/metrics/exemplar/no_exemplar_reservoir.h" +#include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/state/filtered_ordered_attribute_map.h" +#include "opentelemetry/sdk/metrics/state/metric_storage.h" #include "opentelemetry/sdk/metrics/state/multi_metric_storage.h" - -#include -#include -#include +#include "opentelemetry/sdk/metrics/sync_instruments.h" using namespace opentelemetry; using namespace opentelemetry::sdk::instrumentationscope; diff --git a/sdk/test/metrics/sync_metric_storage_counter_test.cc b/sdk/test/metrics/sync_metric_storage_counter_test.cc index 2593b69719..c67b9d499a 100644 --- a/sdk/test/metrics/sync_metric_storage_counter_test.cc +++ b/sdk/test/metrics/sync_metric_storage_counter_test.cc @@ -1,25 +1,35 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "common.h" -#include +#include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/key_value_iterable_view.h" #include "opentelemetry/context/context.h" -#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/function_ref.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" +#include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/state/metric_collector.h" +#include "opentelemetry/sdk/metrics/state/sync_metric_storage.h" +#include "opentelemetry/sdk/metrics/view/attributes_processor.h" #if ENABLE_METRICS_EXEMPLAR_PREVIEW # include "opentelemetry/sdk/metrics/exemplar/filter_type.h" # include "opentelemetry/sdk/metrics/exemplar/reservoir.h" #endif -#include "opentelemetry/sdk/metrics/instruments.h" -#include "opentelemetry/sdk/metrics/state/sync_metric_storage.h" -#include "opentelemetry/sdk/metrics/view/attributes_processor.h" - -#include -#include - using namespace opentelemetry::sdk::metrics; using namespace opentelemetry::common; using M = std::map; diff --git a/sdk/test/metrics/sync_metric_storage_histogram_test.cc b/sdk/test/metrics/sync_metric_storage_histogram_test.cc index 71a16b85c6..34145743d9 100644 --- a/sdk/test/metrics/sync_metric_storage_histogram_test.cc +++ b/sdk/test/metrics/sync_metric_storage_histogram_test.cc @@ -1,24 +1,35 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "common.h" +#include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/key_value_iterable_view.h" -#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/context/context.h" +#include "opentelemetry/nostd/function_ref.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" +#include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/state/metric_collector.h" +#include "opentelemetry/sdk/metrics/state/sync_metric_storage.h" +#include "opentelemetry/sdk/metrics/view/attributes_processor.h" #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW # include "opentelemetry/sdk/metrics/exemplar/filter_type.h" # include "opentelemetry/sdk/metrics/exemplar/reservoir.h" #endif -#include "opentelemetry/sdk/metrics/instruments.h" -#include "opentelemetry/sdk/metrics/state/sync_metric_storage.h" -#include "opentelemetry/sdk/metrics/view/attributes_processor.h" - -#include -#include -#include - using namespace opentelemetry::sdk::metrics; using namespace opentelemetry::common; using M = std::map; diff --git a/sdk/test/metrics/sync_metric_storage_up_down_counter_test.cc b/sdk/test/metrics/sync_metric_storage_up_down_counter_test.cc index 88ae56eb3f..4732e5b9f2 100644 --- a/sdk/test/metrics/sync_metric_storage_up_down_counter_test.cc +++ b/sdk/test/metrics/sync_metric_storage_up_down_counter_test.cc @@ -1,22 +1,33 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "common.h" +#include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/key_value_iterable_view.h" -#include "opentelemetry/nostd/shared_ptr.h" - -#ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW -# include "opentelemetry/sdk/metrics/exemplar/filter_type.h" -#endif - +#include "opentelemetry/context/context.h" +#include "opentelemetry/nostd/function_ref.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" #include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/state/metric_collector.h" #include "opentelemetry/sdk/metrics/state/sync_metric_storage.h" #include "opentelemetry/sdk/metrics/view/attributes_processor.h" -#include -#include -#include +#ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW +# include "opentelemetry/sdk/metrics/exemplar/filter_type.h" +#endif using namespace opentelemetry::sdk::metrics; using namespace opentelemetry::common; diff --git a/sdk/test/metrics/view_registry_test.cc b/sdk/test/metrics/view_registry_test.cc index fb188e7124..0135227e16 100644 --- a/sdk/test/metrics/view_registry_test.cc +++ b/sdk/test/metrics/view_registry_test.cc @@ -1,12 +1,19 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/view/view_registry.h" +#include +#include +#include +#include + +#include "opentelemetry/common/macros.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/metrics/instruments.h" -#include "opentelemetry/sdk/metrics/view/predicate.h" - -#include +#include "opentelemetry/sdk/metrics/state/filtered_ordered_attribute_map.h" +#include "opentelemetry/sdk/metrics/view/instrument_selector.h" +#include "opentelemetry/sdk/metrics/view/meter_selector.h" +#include "opentelemetry/sdk/metrics/view/view.h" +#include "opentelemetry/sdk/metrics/view/view_registry.h" #if OPENTELEMETRY_HAVE_WORKING_REGEX # include diff --git a/sdk/test/resource/resource_test.cc b/sdk/test/resource/resource_test.cc index 419264862c..c15087e9b7 100644 --- a/sdk/test/resource/resource_test.cc +++ b/sdk/test/resource/resource_test.cc @@ -1,17 +1,21 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/resource/resource.h" -#include "opentelemetry/sdk/common/attribute_utils.h" -#include "opentelemetry/sdk/resource/resource_detector.h" -#include "opentelemetry/sdk/resource/semantic_conventions.h" -#include "opentelemetry/sdk/version/version.h" - +#include +#include #include #include #include +#include +#include -#include +#include "opentelemetry/nostd/utility.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/attribute_utils.h" +#include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/sdk/resource/resource_detector.h" +#include "opentelemetry/sdk/resource/semantic_conventions.h" +#include "opentelemetry/sdk/version/version.h" #if defined(_MSC_VER) # include "opentelemetry/sdk/common/env_variables.h" diff --git a/sdk/test/trace/always_off_sampler_test.cc b/sdk/test/trace/always_off_sampler_test.cc index 1c32bd5a8f..5680e22c75 100644 --- a/sdk/test/trace/always_off_sampler_test.cc +++ b/sdk/test/trace/always_off_sampler_test.cc @@ -2,8 +2,20 @@ // SPDX-License-Identifier: Apache-2.0 #include +#include +#include +#include +#include + +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/sdk/trace/sampler.h" #include "opentelemetry/sdk/trace/samplers/always_off.h" +#include "opentelemetry/trace/span_context.h" #include "opentelemetry/trace/span_context_kv_iterable_view.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/trace/trace_state.h" using opentelemetry::sdk::trace::AlwaysOffSampler; using opentelemetry::sdk::trace::Decision; diff --git a/sdk/test/trace/always_on_sampler_test.cc b/sdk/test/trace/always_on_sampler_test.cc index c483f9b8be..04b7e60a2b 100644 --- a/sdk/test/trace/always_on_sampler_test.cc +++ b/sdk/test/trace/always_on_sampler_test.cc @@ -1,12 +1,24 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/utility.h" +#include "opentelemetry/sdk/trace/sampler.h" #include "opentelemetry/sdk/trace/samplers/always_on.h" +#include "opentelemetry/trace/span_context.h" #include "opentelemetry/trace/span_context_kv_iterable_view.h" - -#include -#include +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/trace/trace_state.h" using namespace opentelemetry::sdk::trace; using namespace opentelemetry::nostd; diff --git a/sdk/test/trace/batch_span_processor_test.cc b/sdk/test/trace/batch_span_processor_test.cc index 9bb09d6e55..293747350a 100644 --- a/sdk/test/trace/batch_span_processor_test.cc +++ b/sdk/test/trace/batch_span_processor_test.cc @@ -1,22 +1,28 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/trace/batch_span_processor.h" -#include "opentelemetry/sdk/common/exporter_utils.h" -#include "opentelemetry/sdk/common/global_log_handler.h" -#include "opentelemetry/sdk/trace/batch_span_processor_options.h" -#include "opentelemetry/sdk/trace/exporter.h" -#include "opentelemetry/sdk/trace/span_data.h" -#include "opentelemetry/sdk/trace/tracer.h" - #include - #include +#include #include -#include -#include +#include +#include #include #include +#include + +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/common/attribute_utils.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/common/global_log_handler.h" +#include "opentelemetry/sdk/trace/batch_span_processor.h" +#include "opentelemetry/sdk/trace/batch_span_processor_options.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/recordable.h" +#include "opentelemetry/sdk/trace/span_data.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/sdk/test/trace/parent_sampler_test.cc b/sdk/test/trace/parent_sampler_test.cc index 7d2ef7f107..a6ed8ff7f8 100644 --- a/sdk/test/trace/parent_sampler_test.cc +++ b/sdk/test/trace/parent_sampler_test.cc @@ -2,11 +2,27 @@ // SPDX-License-Identifier: Apache-2.0 #include -#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/context/context_value.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/trace/sampler.h" #include "opentelemetry/sdk/trace/samplers/always_off.h" #include "opentelemetry/sdk/trace/samplers/always_on.h" #include "opentelemetry/sdk/trace/samplers/parent.h" +#include "opentelemetry/trace/span_context.h" #include "opentelemetry/trace/span_context_kv_iterable_view.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_flags.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/trace/trace_state.h" using opentelemetry::sdk::trace::AlwaysOffSampler; using opentelemetry::sdk::trace::AlwaysOnSampler; diff --git a/sdk/test/trace/sampler_benchmark.cc b/sdk/test/trace/sampler_benchmark.cc index ec188b84a1..529143b53e 100644 --- a/sdk/test/trace/sampler_benchmark.cc +++ b/sdk/test/trace/sampler_benchmark.cc @@ -1,20 +1,34 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/key_value_iterable_view.h" #include "opentelemetry/exporters/memory/in_memory_span_exporter.h" #include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/recordable.h" #include "opentelemetry/sdk/trace/sampler.h" #include "opentelemetry/sdk/trace/samplers/always_off.h" #include "opentelemetry/sdk/trace/samplers/always_on.h" #include "opentelemetry/sdk/trace/samplers/parent.h" #include "opentelemetry/sdk/trace/samplers/trace_id_ratio.h" #include "opentelemetry/sdk/trace/simple_processor.h" -#include "opentelemetry/sdk/trace/span_data.h" #include "opentelemetry/sdk/trace/tracer.h" - -#include - -#include +#include "opentelemetry/sdk/trace/tracer_context.h" +#include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_context_kv_iterable_view.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/trace/tracer.h" using namespace opentelemetry::sdk::trace; using opentelemetry::exporter::memory::InMemorySpanExporter; diff --git a/sdk/test/trace/simple_processor_test.cc b/sdk/test/trace/simple_processor_test.cc index 7653bb2cfc..92fdf71d58 100644 --- a/sdk/test/trace/simple_processor_test.cc +++ b/sdk/test/trace/simple_processor_test.cc @@ -1,13 +1,23 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/trace/simple_processor.h" +#include +#include +#include +#include +#include + +#include "opentelemetry/exporters/memory/in_memory_span_data.h" #include "opentelemetry/exporters/memory/in_memory_span_exporter.h" #include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/common/atomic_unique_ptr.h" +#include "opentelemetry/sdk/common/exporter_utils.h" #include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/recordable.h" +#include "opentelemetry/sdk/trace/simple_processor.h" #include "opentelemetry/sdk/trace/span_data.h" - -#include +#include "opentelemetry/trace/span_context.h" using namespace opentelemetry::sdk::trace; using namespace opentelemetry::sdk::common; diff --git a/sdk/test/trace/span_data_test.cc b/sdk/test/trace/span_data_test.cc index 6dfc09bd12..054af65330 100644 --- a/sdk/test/trace/span_data_test.cc +++ b/sdk/test/trace/span_data_test.cc @@ -1,18 +1,32 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/trace/span_data.h" +#include +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/span.h" #include "opentelemetry/nostd/variant.h" -#include "opentelemetry/trace/span.h" +#include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/sdk/trace/span_data.h" +#include "opentelemetry/trace/span_context.h" #include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_flags.h" #include "opentelemetry/trace/trace_id.h" - -#include +#include "opentelemetry/trace/trace_state.h" using opentelemetry::sdk::trace::SpanData; namespace trace_api = opentelemetry::trace; namespace common = opentelemetry::common; -namespace nostd = opentelemetry::nostd; TEST(SpanData, DefaultValues) { @@ -70,7 +84,7 @@ TEST(SpanData, Set) ASSERT_EQ(data.GetDescription(), "description"); ASSERT_EQ(data.GetStartTime().time_since_epoch(), now.time_since_epoch()); ASSERT_EQ(data.GetDuration(), std::chrono::nanoseconds(1000000)); - ASSERT_EQ(nostd::get(data.GetAttributes().at("attr1")), 314159); + ASSERT_EQ(opentelemetry::nostd::get(data.GetAttributes().at("attr1")), 314159); ASSERT_EQ(data.GetEvents().at(0).GetName(), "event1"); ASSERT_EQ(data.GetEvents().at(0).GetTimestamp(), now); } @@ -89,7 +103,9 @@ TEST(SpanData, EventAttributes) for (int i = 0; i < kNumAttributes; i++) { - EXPECT_EQ(nostd::get(data.GetEvents().at(0).GetAttributes().at(keys[i])), values[i]); + EXPECT_EQ( + opentelemetry::nostd::get(data.GetEvents().at(0).GetAttributes().at(keys[i])), + values[i]); } } @@ -130,6 +146,7 @@ TEST(SpanData, Links) EXPECT_EQ(data.GetLinks().at(0).GetSpanContext(), span_context); for (int i = 0; i < kNumAttributes; i++) { - EXPECT_EQ(nostd::get(data.GetLinks().at(0).GetAttributes().at(keys[i])), values[i]); + EXPECT_EQ(opentelemetry::nostd::get(data.GetLinks().at(0).GetAttributes().at(keys[i])), + values[i]); } } diff --git a/sdk/test/trace/trace_id_ratio_sampler_test.cc b/sdk/test/trace/trace_id_ratio_sampler_test.cc index 1b0088f134..ac83a8dc6d 100644 --- a/sdk/test/trace/trace_id_ratio_sampler_test.cc +++ b/sdk/test/trace/trace_id_ratio_sampler_test.cc @@ -1,14 +1,26 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/trace/sampler.h" #include "opentelemetry/sdk/trace/samplers/trace_id_ratio.h" +#include "opentelemetry/trace/span_context.h" #include "opentelemetry/trace/span_context_kv_iterable_view.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_flags.h" +#include "opentelemetry/trace/trace_id.h" #include "src/common/random.h" -#include -#include -#include - using opentelemetry::sdk::common::Random; using opentelemetry::sdk::trace::Decision; using opentelemetry::sdk::trace::TraceIdRatioBasedSampler; diff --git a/sdk/test/trace/tracer_provider_test.cc b/sdk/test/trace/tracer_provider_test.cc index 9715a7e0b8..fa3afa2690 100644 --- a/sdk/test/trace/tracer_provider_test.cc +++ b/sdk/test/trace/tracer_provider_test.cc @@ -1,20 +1,31 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/trace/tracer_provider.h" +#include +#include +#include +#include + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/sdk/trace/id_generator.h" +#include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/random_id_generator.h" +#include "opentelemetry/sdk/trace/recordable.h" +#include "opentelemetry/sdk/trace/sampler.h" #include "opentelemetry/sdk/trace/samplers/always_off.h" -#include "opentelemetry/sdk/trace/samplers/always_on.h" #include "opentelemetry/sdk/trace/simple_processor.h" #include "opentelemetry/sdk/trace/tracer.h" - -#include +#include "opentelemetry/sdk/trace/tracer_context.h" +#include "opentelemetry/sdk/trace/tracer_provider.h" using namespace opentelemetry::sdk::trace; using namespace opentelemetry::sdk::resource; -#include - TEST(TracerProvider, GetTracer) { std::unique_ptr processor(new SimpleSpanProcessor(nullptr)); diff --git a/sdk/test/trace/tracer_test.cc b/sdk/test/trace/tracer_test.cc index c57b638e3d..2c4de8e83c 100644 --- a/sdk/test/trace/tracer_test.cc +++ b/sdk/test/trace/tracer_test.cc @@ -1,17 +1,58 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/trace/tracer.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/key_value_iterable.h" +#include "opentelemetry/common/macros.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/context/context.h" +#include "opentelemetry/context/context_value.h" +#include "opentelemetry/exporters/memory/in_memory_span_data.h" #include "opentelemetry/exporters/memory/in_memory_span_exporter.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/unique_ptr.h" +#include "opentelemetry/nostd/utility.h" +#include "opentelemetry/nostd/variant.h" #include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/sdk/trace/id_generator.h" +#include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/random_id_generator.h" +#include "opentelemetry/sdk/trace/recordable.h" +#include "opentelemetry/sdk/trace/sampler.h" #include "opentelemetry/sdk/trace/samplers/always_off.h" #include "opentelemetry/sdk/trace/samplers/always_on.h" #include "opentelemetry/sdk/trace/samplers/parent.h" #include "opentelemetry/sdk/trace/simple_processor.h" #include "opentelemetry/sdk/trace/span_data.h" +#include "opentelemetry/sdk/trace/tracer.h" +#include "opentelemetry/sdk/trace/tracer_context.h" #include "opentelemetry/trace/context.h" - -#include +#include "opentelemetry/trace/scope.h" +#include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_context_kv_iterable.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/span_startoptions.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/trace/trace_state.h" +#include "opentelemetry/trace/tracer.h" using namespace opentelemetry::sdk::trace; using namespace opentelemetry::sdk::resource; diff --git a/test_common/include/opentelemetry/test_common/ext/http/client/http_client_test_factory.h b/test_common/include/opentelemetry/test_common/ext/http/client/http_client_test_factory.h index 51f9502bb8..eb56b59806 100644 --- a/test_common/include/opentelemetry/test_common/ext/http/client/http_client_test_factory.h +++ b/test_common/include/opentelemetry/test_common/ext/http/client/http_client_test_factory.h @@ -2,7 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 #pragma once + +#include + #include "opentelemetry/ext/http/client/http_client.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace ext diff --git a/test_common/include/opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h b/test_common/include/opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h index 3207857743..a5f8c2f0e1 100644 --- a/test_common/include/opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h +++ b/test_common/include/opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h @@ -3,16 +3,18 @@ #pragma once -#include "opentelemetry/ext/http/client/http_client.h" -#include "opentelemetry/ext/http/common/url_parser.h" -#include "opentelemetry/version.h" - -#include +#include +#include +#include +#include +#include #include -#include +#include -#include -#include "gmock/gmock.h" +#include "opentelemetry/ext/http/client/http_client.h" +#include "opentelemetry/nostd/function_ref.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace ext @@ -116,7 +118,7 @@ class Response : public opentelemetry::ext::http::client::Response opentelemetry::ext::http::client::StatusCode status_code_; }; -class HttpClient; +class HttpClient; // IWYU pragma: keep class Session : public opentelemetry::ext::http::client::Session { diff --git a/test_common/src/http/client/nosend/http_client_nosend.cc b/test_common/src/http/client/nosend/http_client_nosend.cc index 98cae0476a..46784869c4 100644 --- a/test_common/src/http/client/nosend/http_client_nosend.cc +++ b/test_common/src/http/client/nosend/http_client_nosend.cc @@ -1,7 +1,18 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/ext/http/client/http_client.h" +#include "opentelemetry/nostd/function_ref.h" +#include "opentelemetry/nostd/string_view.h" #include "opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace ext From 2314e061a533808a1f4a693fac86e4cb0b8fa7e4 Mon Sep 17 00:00:00 2001 From: loong_hy <88186554+loong-hy@users.noreply.github.com> Date: Wed, 18 Sep 2024 12:03:42 +0800 Subject: [PATCH 33/89] [BUILD] add loongarch info (#3052) --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b247f47fc9..fd41fa7148 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,6 +77,8 @@ else() set(ARCH s390x) elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(sparc.*|SPARC.*)") set(ARCH sparc) + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(loongarch.*|LOONGARCH.*)") + set(ARCH loongarch) else() message( FATAL_ERROR From 23818a7105c2565ff0a07580a585d10ec3dc8db4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabr=C3=ADzio=20de=20Royes=20Mello?= Date: Fri, 20 Sep 2024 10:49:22 -0300 Subject: [PATCH 34/89] [CI] Update otel-collector version (#3067) Looks like otel-collector equal or higher than 0.86.0 has the "debug" exporter. So updated the README.md with the latest version of the otel-collector (v0.109.0) and also the CI script. --- ci/do_ci.sh | 2 +- examples/otlp/README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/do_ci.sh b/ci/do_ci.sh index 4cd97a7f43..c31d5e887a 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -20,7 +20,7 @@ function install_prometheus_cpp_client function run_benchmarks { docker run -d --rm -it -p 4317:4317 -p 4318:4318 -v \ - $(pwd)/examples/otlp:/cfg otel/opentelemetry-collector:0.38.0 \ + $(pwd)/examples/otlp:/cfg otel/opentelemetry-collector:0.109.0 \ --config=/cfg/opentelemetry-collector-config/config.dev.yaml [ -z "${BENCHMARK_DIR}" ] && export BENCHMARK_DIR=$HOME/benchmark diff --git a/examples/otlp/README.md b/examples/otlp/README.md index e845786346..d1846a88a2 100644 --- a/examples/otlp/README.md +++ b/examples/otlp/README.md @@ -50,13 +50,13 @@ OpenTelemetry Collector with an OTLP receiver by running: - On Unix based systems use: ```console -docker run --rm -it -p 4317:4317 -p 4318:4318 -v $(pwd)/examples/otlp:/cfg otel/opentelemetry-collector:0.59.0 --config=/cfg/opentelemetry-collector-config/config.dev.yaml +docker run --rm -it -p 4317:4317 -p 4318:4318 -v $(pwd)/examples/otlp:/cfg otel/opentelemetry-collector:0.109.0 --config=/cfg/opentelemetry-collector-config/config.dev.yaml ``` - On Windows use: ```console -docker run --rm -it -p 4317:4317 -p 4318:4318 -v "%cd%/examples/otlp":/cfg otel/opentelemetry-collector:0.59.0 --config=/cfg/opentelemetry-collector-config/config.dev.yaml +docker run --rm -it -p 4317:4317 -p 4318:4318 -v "%cd%/examples/otlp":/cfg otel/opentelemetry-collector:0.109.0 --config=/cfg/opentelemetry-collector-config/config.dev.yaml ``` Note that the OTLP gRPC and HTTP exporters connects to the Collector at `localhost:4317` and `localhost:4318/v1/traces` respectively. This can be changed with first argument from command-line, for example: From 7b824738c3cf6bd56fc833918fd034820a4c9735 Mon Sep 17 00:00:00 2001 From: Punya Biswal Date: Tue, 1 Oct 2024 16:29:22 -0400 Subject: [PATCH 35/89] [SDK] Update MetricProducer interface to match spec (#3044) Following https://github.com/open-telemetry/opentelemetry-specification/blob/v1.36.0/specification/metrics/sdk.md#metricproducer. Updates #1831 --- exporters/prometheus/test/collector_test.cc | 18 ++++----- .../sdk/metrics/export/metric_producer.h | 38 +++++++++++++------ .../sdk/metrics/state/metric_collector.h | 2 +- sdk/src/metrics/metric_reader.cc | 12 +++++- sdk/src/metrics/state/metric_collector.cc | 9 ++--- sdk/test/metrics/metric_reader_test.cc | 2 +- .../periodic_exporting_metric_reader_test.cc | 5 +-- 7 files changed, 53 insertions(+), 33 deletions(-) diff --git a/exporters/prometheus/test/collector_test.cc b/exporters/prometheus/test/collector_test.cc index a70fd317b3..a31d23ab72 100644 --- a/exporters/prometheus/test/collector_test.cc +++ b/exporters/prometheus/test/collector_test.cc @@ -12,12 +12,13 @@ #include using opentelemetry::exporter::metrics::PrometheusCollector; +using opentelemetry::sdk::metrics::MetricProducer; using opentelemetry::sdk::metrics::ResourceMetrics; namespace metric_api = opentelemetry::metrics; namespace metric_sdk = opentelemetry::sdk::metrics; namespace metric_exporter = opentelemetry::exporter::metrics; -class MockMetricProducer : public opentelemetry::sdk::metrics::MetricProducer +class MockMetricProducer : public MetricProducer { TestDataPoints test_data_points_; @@ -26,13 +27,12 @@ class MockMetricProducer : public opentelemetry::sdk::metrics::MetricProducer : sleep_ms_{sleep_ms} {} - bool Collect(nostd::function_ref callback) noexcept override + MetricProducer::Result Produce() noexcept override { std::this_thread::sleep_for(sleep_ms_); data_sent_size_++; ResourceMetrics data = test_data_points_.CreateSumPointData(); - callback(data); - return true; + return {data, MetricProducer::Status::kSuccess}; } size_t GetDataCount() { return data_sent_size_; } @@ -70,15 +70,13 @@ class MockMetricReader : public opentelemetry::sdk::metrics::MetricReader */ TEST(PrometheusCollector, BasicTests) { - MockMetricReader *reader = new MockMetricReader(); - MockMetricProducer *producer = new MockMetricProducer(); - reader->SetMetricProducer(producer); - PrometheusCollector collector(reader, true, false); + MockMetricReader reader; + MockMetricProducer producer; + reader.SetMetricProducer(&producer); + PrometheusCollector collector(&reader, true, false); auto data = collector.Collect(); // Collection size should be the same as the size // of the records collection produced by MetricProducer. ASSERT_EQ(data.size(), 2); - delete reader; - delete producer; } diff --git a/sdk/include/opentelemetry/sdk/metrics/export/metric_producer.h b/sdk/include/opentelemetry/sdk/metrics/export/metric_producer.h index 11eb113e1e..f6aa4ca2a4 100644 --- a/sdk/include/opentelemetry/sdk/metrics/export/metric_producer.h +++ b/sdk/include/opentelemetry/sdk/metrics/export/metric_producer.h @@ -7,6 +7,7 @@ #include #include "opentelemetry/nostd/function_ref.h" +#include "opentelemetry/nostd/variant.h" #include "opentelemetry/sdk/metrics/data/metric_data.h" #include "opentelemetry/version.h" @@ -70,27 +71,42 @@ struct ResourceMetrics }; /** - * MetricProducer is the interface that is used to make metric data available to the - * OpenTelemetry exporters. Implementations should be stateful, in that each call to - * `Collect` will return any metric generated since the last call was made. + * MetricProducer defines the interface which bridges to third-party metric sources MUST implement, + * so they can be plugged into an OpenTelemetry MetricReader as a source of aggregated metric data. * - *

        Implementations must be thread-safe. + * Implementations must be thread-safe, and should accept configuration for the + * AggregationTemporality of produced metrics. */ - class MetricProducer { public: MetricProducer() = default; virtual ~MetricProducer() = default; + MetricProducer(const MetricProducer &) = delete; + MetricProducer(const MetricProducer &&) = delete; + void operator=(const MetricProducer &) = delete; + void operator=(const MetricProducer &&) = delete; + + enum class Status + { + kSuccess, + kFailure, + kTimeout, + }; + + struct Result + { + ResourceMetrics points_; + Status status_; + }; + /** - * The callback to be called for each metric exporter. This will only be those - * metrics that have been produced since the last time this method was called. - * - * @return a status of completion of method. + * Produce returns a batch of Metric Points, with a single instrumentation scope that identifies + * the MetricProducer. Implementations may return successfully collected points even if there is a + * partial failure. */ - virtual bool Collect( - nostd::function_ref callback) noexcept = 0; + virtual Result Produce() noexcept = 0; }; } // namespace metrics diff --git a/sdk/include/opentelemetry/sdk/metrics/state/metric_collector.h b/sdk/include/opentelemetry/sdk/metrics/state/metric_collector.h index e652ba12a9..bfc3a06324 100644 --- a/sdk/include/opentelemetry/sdk/metrics/state/metric_collector.h +++ b/sdk/include/opentelemetry/sdk/metrics/state/metric_collector.h @@ -53,7 +53,7 @@ class MetricCollector : public MetricProducer, public CollectorHandle * * @return a status of completion of method. */ - bool Collect(nostd::function_ref callback) noexcept override; + Result Produce() noexcept override; bool ForceFlush(std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept; diff --git a/sdk/src/metrics/metric_reader.cc b/sdk/src/metrics/metric_reader.cc index e2f5bc1f1c..024f91fe0f 100644 --- a/sdk/src/metrics/metric_reader.cc +++ b/sdk/src/metrics/metric_reader.cc @@ -26,7 +26,7 @@ bool MetricReader::Collect( if (!metric_producer_) { OTEL_INTERNAL_LOG_WARN( - "MetricReader::Collect Cannot invoke Collect(). No MetricProducer registered for " + "MetricReader::Collect Cannot invoke Produce(). No MetricProducer registered for " "collection!") return false; } @@ -36,7 +36,15 @@ bool MetricReader::Collect( OTEL_INTERNAL_LOG_WARN("MetricReader::Collect invoked while Shutdown in progress!"); } - return metric_producer_->Collect(callback); + auto result = metric_producer_->Produce(); + + // According to the spec, + // When the Produce operation fails, the MetricProducer MAY return successfully collected + // results and a failed reasons list to the caller. + // So we invoke the callback with whatever points we get back, even if the overall operation may + // have failed. + auto success = callback(result.points_); + return (result.status_ == MetricProducer::Status::kSuccess) && success; } bool MetricReader::Shutdown(std::chrono::microseconds timeout) noexcept diff --git a/sdk/src/metrics/state/metric_collector.cc b/sdk/src/metrics/state/metric_collector.cc index a790a6b6a1..2a799b7fda 100644 --- a/sdk/src/metrics/state/metric_collector.cc +++ b/sdk/src/metrics/state/metric_collector.cc @@ -24,6 +24,7 @@ namespace sdk { namespace metrics { +using opentelemetry::sdk::resource::Resource; MetricCollector::MetricCollector(opentelemetry::sdk::metrics::MeterContext *context, std::shared_ptr metric_reader) @@ -38,14 +39,13 @@ AggregationTemporality MetricCollector::GetAggregationTemporality( return metric_reader_->GetAggregationTemporality(instrument_type); } -bool MetricCollector::Collect( - nostd::function_ref callback) noexcept +MetricProducer::Result MetricCollector::Produce() noexcept { if (!meter_context_) { OTEL_INTERNAL_LOG_ERROR("[MetricCollector::Collect] - Error during collecting." << "The metric context is invalid"); - return false; + return {{}, MetricProducer::Status::kFailure}; } ResourceMetrics resource_metrics; meter_context_->ForEachMeter([&](const std::shared_ptr &meter) noexcept { @@ -61,8 +61,7 @@ bool MetricCollector::Collect( return true; }); resource_metrics.resource_ = &meter_context_->GetResource(); - callback(resource_metrics); - return true; + return {resource_metrics, MetricProducer::Status::kSuccess}; } bool MetricCollector::ForceFlush(std::chrono::microseconds timeout) noexcept diff --git a/sdk/test/metrics/metric_reader_test.cc b/sdk/test/metrics/metric_reader_test.cc index fb0c5a9cf0..330bca7818 100644 --- a/sdk/test/metrics/metric_reader_test.cc +++ b/sdk/test/metrics/metric_reader_test.cc @@ -31,5 +31,5 @@ TEST(MetricReaderTest, BasicTests) std::shared_ptr meter_context2(new MeterContext()); std::shared_ptr metric_producer{ new MetricCollector(meter_context2.get(), std::move(metric_reader2))}; - metric_producer->Collect([](ResourceMetrics & /* metric_data */) { return true; }); + metric_producer->Produce(); } diff --git a/sdk/test/metrics/periodic_exporting_metric_reader_test.cc b/sdk/test/metrics/periodic_exporting_metric_reader_test.cc index 50fe7f20d8..4e92ecd683 100644 --- a/sdk/test/metrics/periodic_exporting_metric_reader_test.cc +++ b/sdk/test/metrics/periodic_exporting_metric_reader_test.cc @@ -63,13 +63,12 @@ class MockMetricProducer : public MetricProducer : sleep_ms_{sleep_ms} {} - bool Collect(nostd::function_ref callback) noexcept override + MetricProducer::Result Produce() noexcept override { std::this_thread::sleep_for(sleep_ms_); data_sent_size_++; ResourceMetrics data; - callback(data); - return true; + return {data, MetricProducer::Status::kSuccess}; } size_t GetDataCount() { return data_sent_size_; } From 3910b049c1469651b1d5dd585785880efae52f4a Mon Sep 17 00:00:00 2001 From: WenTao Ou Date: Mon, 7 Oct 2024 15:03:21 +0800 Subject: [PATCH 36/89] Fix URL in ES exporter, fix ipv6 supporting for http client. (#3081) --- .../src/es_log_record_exporter.cc | 2 +- .../ext/http/common/url_parser.h | 36 +++++++++++- ext/test/http/url_parser_test.cc | 57 ++++++++++++++++++- 3 files changed, 92 insertions(+), 3 deletions(-) diff --git a/exporters/elasticsearch/src/es_log_record_exporter.cc b/exporters/elasticsearch/src/es_log_record_exporter.cc index 3b3e8c4aeb..bfc1ad3d64 100644 --- a/exporters/elasticsearch/src/es_log_record_exporter.cc +++ b/exporters/elasticsearch/src/es_log_record_exporter.cc @@ -323,7 +323,7 @@ sdk::common::ExportResult ElasticsearchLogRecordExporter::Export( } // Create a connection to the ElasticSearch instance - auto session = http_client_->CreateSession(options_.host_ + std::to_string(options_.port_)); + auto session = http_client_->CreateSession(options_.host_ + ":" + std::to_string(options_.port_)); auto request = session->CreateRequest(); // Populate the request with headers and methods diff --git a/ext/include/opentelemetry/ext/http/common/url_parser.h b/ext/include/opentelemetry/ext/http/common/url_parser.h index 386d4fcd2f..75f53ce943 100644 --- a/ext/include/opentelemetry/ext/http/common/url_parser.h +++ b/ext/include/opentelemetry/ext/http/common/url_parser.h @@ -65,7 +65,7 @@ class UrlParser cpos = pos1 + 1; } } - pos = url_.find_first_of(":", cpos); + pos = FindPortPosition(url_, cpos); bool is_port = false; if (pos == std::string::npos) { @@ -130,6 +130,40 @@ class UrlParser query_ = std::string(url_.begin() + cpos, url_.begin() + url_.length()); } } + +private: + static std::string::size_type FindPortPosition(const std::string &url, + std::string::size_type offset) + { + // @see https://www.rfc-editor.org/rfc/rfc3986#page-18 + size_t sub_expression_counter = 0; + for (std::string::size_type i = offset; i < url.size(); ++i) + { + char c = url[i]; + if (0 == sub_expression_counter && c == ':') + { + return i; + } + + if (c == '[') + { + ++sub_expression_counter; + } + else if (c == ']') + { + if (sub_expression_counter > 0) + { + --sub_expression_counter; + } + } + else if (0 == sub_expression_counter && c == '/') + { + break; + } + } + + return std::string::npos; + } }; class UrlDecoder diff --git a/ext/test/http/url_parser_test.cc b/ext/test/http/url_parser_test.cc index 79a5e60a60..aceb43966a 100644 --- a/ext/test/http/url_parser_test.cc +++ b/ext/test/http/url_parser_test.cc @@ -123,7 +123,62 @@ TEST(UrlParserTests, BasicTests) {"path", "/path1@bbb/path2"}, {"query", "q1=a1&q2=a2"}, {"success", "true"}}}, - + {"http://1.2.3.4/path1/path2?q1=a1&q2=a2", + {{"host", "1.2.3.4"}, + {"port", "80"}, + {"scheme", "http"}, + {"path", "/path1/path2"}, + {"query", "q1=a1&q2=a2"}, + {"success", "true"}}}, + {"user:password@1.2.3.4:8080/path1/path2?q1=a1&q2=a2", + {{"host", "1.2.3.4"}, + {"port", "8080"}, + {"scheme", "http"}, + {"path", "/path1/path2"}, + {"query", "q1=a1&q2=a2"}, + {"success", "true"}}}, + {"https://user@1.2.3.4/path1/path2?q1=a1&q2=a2", + {{"host", "1.2.3.4"}, + {"port", "443"}, + {"scheme", "https"}, + {"path", "/path1/path2"}, + {"query", "q1=a1&q2=a2"}, + {"success", "true"}}}, + {"http://1.2.3.4/path1@bbb/path2?q1=a1&q2=a2", + {{"host", "1.2.3.4"}, + {"port", "80"}, + {"scheme", "http"}, + {"path", "/path1@bbb/path2"}, + {"query", "q1=a1&q2=a2"}, + {"success", "true"}}}, + {"http://[fe80::225:93da:bfde:b5f5]/path1/path2?q1=a1&q2=a2", + {{"host", "[fe80::225:93da:bfde:b5f5]"}, + {"port", "80"}, + {"scheme", "http"}, + {"path", "/path1/path2"}, + {"query", "q1=a1&q2=a2"}, + {"success", "true"}}}, + {"user:password@[fe80::225:93da:bfde:b5f5]:8080/path1/path2?q1=a1&q2=a2", + {{"host", "[fe80::225:93da:bfde:b5f5]"}, + {"port", "8080"}, + {"scheme", "http"}, + {"path", "/path1/path2"}, + {"query", "q1=a1&q2=a2"}, + {"success", "true"}}}, + {"https://user@[fe80::225:93da:bfde:b5f5]/path1/path2?q1=a1&q2=a2", + {{"host", "[fe80::225:93da:bfde:b5f5]"}, + {"port", "443"}, + {"scheme", "https"}, + {"path", "/path1/path2"}, + {"query", "q1=a1&q2=a2"}, + {"success", "true"}}}, + {"http://[fe80::225:93da:bfde:b5f5]/path1@bbb/path2?q1=a1&q2=a2", + {{"host", "[fe80::225:93da:bfde:b5f5]"}, + {"port", "80"}, + {"scheme", "http"}, + {"path", "/path1@bbb/path2"}, + {"query", "q1=a1&q2=a2"}, + {"success", "true"}}}, }; for (auto &url_map : urls_map) { From 35e8d17420ff9e216a72cfbb3a066f21aa5dba8b Mon Sep 17 00:00:00 2001 From: ShadowMaxLeb Date: Mon, 7 Oct 2024 22:44:24 +0200 Subject: [PATCH 37/89] [EXPORTER] Add possibility to give custom HttpHeaders for (#3083) --- .../elasticsearch/es_log_record_exporter.h | 19 +++++++++++++------ .../src/es_log_record_exporter.cc | 7 +++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_record_exporter.h b/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_record_exporter.h index 2035b32d4b..36f2dfbca4 100644 --- a/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_record_exporter.h +++ b/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_record_exporter.h @@ -26,6 +26,8 @@ namespace logs */ struct ElasticsearchExporterOptions { + using HttpHeaders = std::multimap; + // Configuration options to establish Elasticsearch connection std::string host_; int port_; @@ -37,6 +39,9 @@ struct ElasticsearchExporterOptions // Whether to print the status of the exporter in the console bool console_debug_; + /** Additional HTTP headers. */ + HttpHeaders http_headers_; + /** * Constructor for the ElasticsearchExporterOptions. By default, the endpoint is * localhost:9200/logs with a timeout of 30 seconds and disabled console debugging @@ -47,16 +52,18 @@ struct ElasticsearchExporterOptions * from elasticsearch * @param console_debug If true, print the status of the exporter methods in the console */ - ElasticsearchExporterOptions(std::string host = "localhost", - int port = 9200, - std::string index = "logs", - int response_timeout = 30, - bool console_debug = false) + ElasticsearchExporterOptions(std::string host = "localhost", + int port = 9200, + std::string index = "logs", + int response_timeout = 30, + bool console_debug = false, + HttpHeaders http_headers = {}) : host_{host}, port_{port}, index_{index}, response_timeout_{response_timeout}, - console_debug_{console_debug} + console_debug_{console_debug}, + http_headers_{http_headers} {} }; diff --git a/exporters/elasticsearch/src/es_log_record_exporter.cc b/exporters/elasticsearch/src/es_log_record_exporter.cc index bfc1ad3d64..f464df5006 100644 --- a/exporters/elasticsearch/src/es_log_record_exporter.cc +++ b/exporters/elasticsearch/src/es_log_record_exporter.cc @@ -330,6 +330,13 @@ sdk::common::ExportResult ElasticsearchLogRecordExporter::Export( request->SetUri(options_.index_ + "/_bulk?pretty"); request->SetMethod(http_client::Method::Post); request->AddHeader("Content-Type", "application/json"); + + // Add options headers + for (auto it = options_.http_headers_.cbegin(); it != options_.http_headers_.cend(); ++it) + { + request->AddHeader(it->first, it->second); + } + request->SetTimeoutMs(std::chrono::milliseconds(1000 * options_.response_timeout_)); // Create the request body From fa0a5200ddbe9ae6f487a228e658aedc102dab56 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Mon, 7 Oct 2024 23:57:27 +0200 Subject: [PATCH 38/89] [RELEASE] Release opentelemetry-cpp 1.17.0 (#3076) --- CHANGELOG.md | 89 +++++++++++++++++++ api/include/opentelemetry/version.h | 6 +- docs/public/conf.py | 2 +- .../opentelemetry/sdk/version/version.h | 2 +- sdk/src/version/version.cc | 10 +-- 5 files changed, 99 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66d60f3513..3bc2401d60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,15 +15,104 @@ Increment the: ## [Unreleased] +## [1.17 2024-10-07] + * [CI] Add a clang-tidy build [#3001](https://github.com/open-telemetry/opentelemetry-cpp/pull/3001) +* [BUILD] Upgrade to opentelemetry-proto 1.3.2 + [#2991](https://github.com/open-telemetry/opentelemetry-cpp/pull/2991) + * [REMOVAL] Remove build option `WITH_DEPRECATED_SDK_FACTORY` [#2717](https://github.com/open-telemetry/opentelemetry-cpp/pull/2717) +* [EXPORTER] ForceFlush before canceling the running requests on shutdown + [#2727](https://github.com/open-telemetry/opentelemetry-cpp/pull/2727) + +* [SDK] Fix crash in PeriodicExportingMetricReader + [#2983](https://github.com/open-telemetry/opentelemetry-cpp/pull/2983) + +* [SDK] Fix memory leak in TlsRandomNumberGenerator() constructor + [#2661](https://github.com/open-telemetry/opentelemetry-cpp/pull/2661) + +* [EXPORTER] Ignore exception when create thread in OTLP file exporter + [#3012](https://github.com/open-telemetry/opentelemetry-cpp/pull/3012) + +* [BUILD] Update the version in MODULE.bazel + [#3015](https://github.com/open-telemetry/opentelemetry-cpp/pull/3015) + +* [BUILD] Fix build without vcpkg on Windows when gRPC is disabled + [#3016](https://github.com/open-telemetry/opentelemetry-cpp/pull/3016) + +* [BUILD] Add abi_version_no bazel flag + [#3020](https://github.com/open-telemetry/opentelemetry-cpp/pull/3020) + +* [Code health] Expand iwyu coverage to include unit tests + [#3022](https://github.com/open-telemetry/opentelemetry-cpp/pull/3022) + +* [BUILD] Version opentelemetry_proto/proto_grpc shared libraries + [#2992](https://github.com/open-telemetry/opentelemetry-cpp/pull/2992) + +* [SEMANTIC CONVENTIONS] Upgrade semantic conventions to 1.27.0 + [#3023](https://github.com/open-telemetry/opentelemetry-cpp/pull/3023) + +* [SDK] Support empty histogram buckets + [#3027](https://github.com/open-telemetry/opentelemetry-cpp/pull/3027) + +* [TEST] Fix sync problems in OTLP File exporter tests + [#3031](https://github.com/open-telemetry/opentelemetry-cpp/pull/3031) + +* [SDK] PeriodicExportingMetricReader: future is never set, blocks until timeout + [#3030](https://github.com/open-telemetry/opentelemetry-cpp/pull/3030) + +* [Code Health] Clang Tidy cleanup, Part 2 + [#3038](https://github.com/open-telemetry/opentelemetry-cpp/pull/3038) + +* [Code Health] include-what-you-use cleanup, part 3 + [#3004](https://github.com/open-telemetry/opentelemetry-cpp/pull/3004) + +* [SDK] Fix overflow in timeout logic + [#3046](https://github.com/open-telemetry/opentelemetry-cpp/pull/3046) + +* [TEST] Add missing tests to Bazel build + [#3045](https://github.com/open-telemetry/opentelemetry-cpp/pull/3045) + +* [TEST] update collector tests with debug exporter + [#3050](https://github.com/open-telemetry/opentelemetry-cpp/pull/3050) + +* [EXAMPLE] update collector example with debug exporter + [#3049](https://github.com/open-telemetry/opentelemetry-cpp/pull/3049) + +* [TEST] update references to logging exporter + [#3053](https://github.com/open-telemetry/opentelemetry-cpp/pull/3053) + +* [EXAMPLE] Clean the tracer initialization in OStream example + [#3051](https://github.com/open-telemetry/opentelemetry-cpp/pull/3051) + +* [EXPORTER] Fix the format of SpanLink for ETW + [#3054](https://github.com/open-telemetry/opentelemetry-cpp/pull/3054) + * [EXPORTER] Add in-memory metric exporter [#3043](https://github.com/open-telemetry/opentelemetry-cpp/pull/3043) +* [Code Health] include-what-you-use cleanup, part 4 + [#3040](https://github.com/open-telemetry/opentelemetry-cpp/pull/3040) + +* [BUILD] add loongarch info + [#3052](https://github.com/open-telemetry/opentelemetry-cpp/pull/3052) + +* [CI] Update otel-collector version + [#3067](https://github.com/open-telemetry/opentelemetry-cpp/pull/3067) + +* [SDK] Update MetricProducer interface to match spec + [#3044](https://github.com/open-telemetry/opentelemetry-cpp/pull/3044) + +* [EXPORTER] Fix URL in ES exporter, fix ipv6 supporting for http client + [#3081](https://github.com/open-telemetry/opentelemetry-cpp/pull/3081) + +* [EXPORTER] Add HttpHeaders in ElasticsearchLogRecordExporter + [#3083](https://github.com/open-telemetry/opentelemetry-cpp/pull/3083) + Breaking changes: * [REMOVAL] Remove build option `WITH_DEPRECATED_SDK_FACTORY` diff --git a/api/include/opentelemetry/version.h b/api/include/opentelemetry/version.h index d98ac978f2..d3e18ce1d8 100644 --- a/api/include/opentelemetry/version.h +++ b/api/include/opentelemetry/version.h @@ -10,10 +10,10 @@ # define OPENTELEMETRY_ABI_VERSION_NO 1 #endif -#define OPENTELEMETRY_VERSION "1.16.1" +#define OPENTELEMETRY_VERSION "1.17.0" #define OPENTELEMETRY_VERSION_MAJOR 1 -#define OPENTELEMETRY_VERSION_MINOR 16 -#define OPENTELEMETRY_VERSION_PATCH 1 +#define OPENTELEMETRY_VERSION_MINOR 17 +#define OPENTELEMETRY_VERSION_PATCH 0 #define OPENTELEMETRY_ABI_VERSION OPENTELEMETRY_STRINGIFY(OPENTELEMETRY_ABI_VERSION_NO) diff --git a/docs/public/conf.py b/docs/public/conf.py index 96caa2b43a..96b70cb6fa 100644 --- a/docs/public/conf.py +++ b/docs/public/conf.py @@ -24,7 +24,7 @@ author = 'OpenTelemetry authors' # The full version, including alpha/beta/rc tags -release = "1.16.1" +release = "1.17.0" # Run sphinx on subprojects and copy output # ----------------------------------------- diff --git a/sdk/include/opentelemetry/sdk/version/version.h b/sdk/include/opentelemetry/sdk/version/version.h index 86b815e3bc..b8f4c076f1 100644 --- a/sdk/include/opentelemetry/sdk/version/version.h +++ b/sdk/include/opentelemetry/sdk/version/version.h @@ -3,7 +3,7 @@ #pragma once -#define OPENTELEMETRY_SDK_VERSION "1.16.1" +#define OPENTELEMETRY_SDK_VERSION "1.17.0" #include "opentelemetry/version.h" diff --git a/sdk/src/version/version.cc b/sdk/src/version/version.cc index 80f2226400..97e7f15549 100644 --- a/sdk/src/version/version.cc +++ b/sdk/src/version/version.cc @@ -12,13 +12,13 @@ namespace sdk namespace version { const int major_version = 1; -const int minor_version = 16; -const int patch_version = 1; +const int minor_version = 17; +const int patch_version = 0; const char *pre_release = "NONE"; const char *build_metadata = "NONE"; -const char *short_version = "1.16.1"; -const char *full_version = "1.16.1-NONE-NONE"; -const char *build_date = "Wed Jul 17 17:34:38 UTC 2024"; +const char *short_version = "1.17.0"; +const char *full_version = "1.17.0-NONE-NONE"; +const char *build_date = "Mon Oct 7 08:55:12 PM UTC 2024"; } // namespace version } // namespace sdk OPENTELEMETRY_END_NAMESPACE From 0ea1f2c6442ac53f567077633865930794649699 Mon Sep 17 00:00:00 2001 From: Maxime Leblanc Date: Tue, 8 Oct 2024 09:12:37 +0200 Subject: [PATCH 39/89] [EXPORTER] Fix crash in ElasticsearchLogRecordExporter when (#3082) using constructor with user given options (#3078) Closes #3078 --- .../elasticsearch/src/es_log_record_exporter.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/exporters/elasticsearch/src/es_log_record_exporter.cc b/exporters/elasticsearch/src/es_log_record_exporter.cc index f464df5006..1ec786a198 100644 --- a/exporters/elasticsearch/src/es_log_record_exporter.cc +++ b/exporters/elasticsearch/src/es_log_record_exporter.cc @@ -288,7 +288,12 @@ class AsyncResponseHandler : public http_client::EventHandler #endif ElasticsearchLogRecordExporter::ElasticsearchLogRecordExporter() - : options_{ElasticsearchExporterOptions()}, + : ElasticsearchLogRecordExporter(ElasticsearchExporterOptions()) +{} + +ElasticsearchLogRecordExporter::ElasticsearchLogRecordExporter( + const ElasticsearchExporterOptions &options) + : options_{options}, http_client_{ext::http::client::HttpClientFactory::Create()} #ifdef ENABLE_ASYNC_EXPORT , @@ -301,11 +306,6 @@ ElasticsearchLogRecordExporter::ElasticsearchLogRecordExporter() #endif } -ElasticsearchLogRecordExporter::ElasticsearchLogRecordExporter( - const ElasticsearchExporterOptions &options) - : options_{options}, http_client_{ext::http::client::HttpClientFactory::Create()} -{} - std::unique_ptr ElasticsearchLogRecordExporter::MakeRecordable() noexcept { return std::unique_ptr(new ElasticSearchRecordable()); From 3d9c2b538272b553cfb83f605061382724921426 Mon Sep 17 00:00:00 2001 From: "Romain Geissler @ Amadeus" Date: Tue, 8 Oct 2024 17:28:30 +0200 Subject: [PATCH 40/89] [BUILD] Avoid buggy "should be explicitly initialized in the copy constructor" warning with gcc <= 8 (#3087) gcc <= 8, when building with -Wextra (and -Werror) wrongly raises this: /data/mwrep/res/mdw/SIOTF/internal/opentelemetry_cpp/trace/18-0-0-7/include/opentelemetry/trace/default_span.h: In copy constructor 'opentelemetry::v1::trace::DefaultSpan::DefaultSpan(const opentelemetry::v1::trace::DefaultSpan&)': /data/mwrep/res/mdw/SIOTF/internal/opentelemetry_cpp/trace/18-0-0-7/include/opentelemetry/trace/default_span.h:70:3: error: base class 'class opentelemetry::v1::trace::Span' should be explicitly initialized in the copy constructor [-Werror=extra] DefaultSpan(const DefaultSpan &spn) noexcept : span_context_(spn.GetContext()) {} ^~~~~~~~~~~ See on Compiler Explorer here: https://godbolt.org/z/ed5rv74nT I believe Jason Merrill fixed it in gcc for all gcc >= 9 with: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=f3f7cefecc833b4ab652215ceb8b408c21dca225;hp=777083bb806dbe31ab97002b7d445191d3ee7a2d Workaround this by calling explicitly the empty Span constructor. --- api/include/opentelemetry/trace/default_span.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/include/opentelemetry/trace/default_span.h b/api/include/opentelemetry/trace/default_span.h index 7e3979501e..7ad6a3726e 100644 --- a/api/include/opentelemetry/trace/default_span.h +++ b/api/include/opentelemetry/trace/default_span.h @@ -66,8 +66,8 @@ class DefaultSpan : public Span DefaultSpan(SpanContext span_context) noexcept : span_context_(span_context) {} // movable and copiable - DefaultSpan(DefaultSpan &&spn) noexcept : span_context_(spn.GetContext()) {} - DefaultSpan(const DefaultSpan &spn) noexcept : span_context_(spn.GetContext()) {} + DefaultSpan(DefaultSpan &&spn) noexcept : Span(), span_context_(spn.GetContext()) {} + DefaultSpan(const DefaultSpan &spn) noexcept : Span(), span_context_(spn.GetContext()) {} private: SpanContext span_context_; From 6445819fceeb3bfea1444a88418f00a0df69cd2f Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Tue, 8 Oct 2024 18:49:56 +0200 Subject: [PATCH 41/89] [API] Jaeger Propagator should not be deprecated (#3086) --- CHANGELOG.md | 14 +++++++ DEPRECATED.md | 40 +------------------ .../opentelemetry/trace/propagation/jaeger.h | 6 +-- api/test/trace/propagation/CMakeLists.txt | 16 +------- 4 files changed, 18 insertions(+), 58 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bc2401d60..540479eb97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,20 @@ Increment the: ## [Unreleased] +* [API] Jaeger Propagator should not be deprecated + [#3086](https://github.com/open-telemetry/opentelemetry-cpp/pull/3086) + +Important changes: + +* [API] Jaeger Propagator should not be deprecated + [#3086](https://github.com/open-telemetry/opentelemetry-cpp/pull/3086) + + * Deprecation of the Jaeger propagator, as announced on 2023-01-31 + in version 1.8.2, is now reverted. + * This deprecation turned out to be not justified, + as the Jaeger propagator can be used without the (now removed) + Jaeger exporter. + ## [1.17 2024-10-07] * [CI] Add a clang-tidy build diff --git a/DEPRECATED.md b/DEPRECATED.md index 0632f50503..eea861ffe6 100644 --- a/DEPRECATED.md +++ b/DEPRECATED.md @@ -46,45 +46,7 @@ N/A ## [opentelemetry-cpp API] -### Jaeger propagator - -#### Announcement (Jaeger) - -* Version: 1.8.2 -* Date: 2023-01-31 -* PR: [DEPRECATION] Deprecate the Jaeger exporter - [#1923](https://github.com/open-telemetry/opentelemetry-cpp/pull/1923) - -This PR also listed the Jaeger propagator as deprecated. - -#### Motivation (Jaeger) - -The Jaeger Exporter is now (July 2023) removed from the OpenTelemetry specification. - -The Jaeger Propagator remains, because changing propagation is a longer -process compared to changing an export format. - -New deployments however are encouraged to use a W3C compliant propagator, -and avoid the Jaeger propagator, which is now deprecated. - -#### Scope (Jaeger) - -The following are deprecated and planned for removal: - -* the API header `opentelemetry/trace/propagation/jaeger.h`, including: - * the C++ class `JaegerPropagator` - -#### Mitigation (Jaeger) - -Use a W3C compliant propagator instead. - -That is, use class HttpTraceContext and "traceparent" tags. - -Do not use class JaegerPropagator and "uber-trace-id" tags. - -#### Planned removal (Jaeger) - -No date set yet for the Jaeger Propagator. +N/A ## [opentelemetry-cpp SDK] diff --git a/api/include/opentelemetry/trace/propagation/jaeger.h b/api/include/opentelemetry/trace/propagation/jaeger.h index 1f0195a248..45a9370919 100644 --- a/api/include/opentelemetry/trace/propagation/jaeger.h +++ b/api/include/opentelemetry/trace/propagation/jaeger.h @@ -3,10 +3,6 @@ #pragma once -#ifdef OPENTELEMETRY_NO_DEPRECATED_CODE -# error "header is deprecated." -#endif - #include "detail/hex.h" #include "detail/string.h" #include "opentelemetry/context/propagation/text_map_propagator.h" @@ -21,7 +17,7 @@ namespace propagation static const nostd::string_view kJaegerTraceHeader = "uber-trace-id"; -class OPENTELEMETRY_DEPRECATED JaegerPropagator : public context::propagation::TextMapPropagator +class JaegerPropagator : public context::propagation::TextMapPropagator { public: void Inject(context::propagation::TextMapCarrier &carrier, diff --git a/api/test/trace/propagation/CMakeLists.txt b/api/test/trace/propagation/CMakeLists.txt index a1cfcf83ee..f55c738165 100644 --- a/api/test/trace/propagation/CMakeLists.txt +++ b/api/test/trace/propagation/CMakeLists.txt @@ -3,7 +3,8 @@ add_subdirectory(detail) -foreach(testname http_text_format_test b3_propagation_test) +foreach(testname http_text_format_test b3_propagation_test + jaeger_propagation_test) add_executable(${testname} "${testname}.cc") target_link_libraries(${testname} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} opentelemetry_api) @@ -12,16 +13,3 @@ foreach(testname http_text_format_test b3_propagation_test) TEST_PREFIX trace. TEST_LIST ${testname}) endforeach() - -if(NOT WITH_NO_DEPRECATED_CODE) - foreach(testname jaeger_propagation_test) - - add_executable(${testname} "${testname}.cc") - target_link_libraries(${testname} ${GTEST_BOTH_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} opentelemetry_api) - gtest_add_tests( - TARGET ${testname} - TEST_PREFIX trace. - TEST_LIST ${testname}) - endforeach() -endif() From f69963f587b148d2eb20f7d30f8b4a1ccb184a6f Mon Sep 17 00:00:00 2001 From: WenTao Ou Date: Sun, 13 Oct 2024 23:18:22 +0800 Subject: [PATCH 42/89] Update bzlmod version (#3093) --- MODULE.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MODULE.bazel b/MODULE.bazel index 13175f2c21..a9171d7424 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -3,7 +3,7 @@ module( name = "opentelemetry-cpp", - version = "1.16.1", + version = "1.17.0", compatibility_level = 0, repo_name = "io_opentelemetry_cpp", ) From 70ed9bcac0739eb3981c5b8d71f1ab23bc279701 Mon Sep 17 00:00:00 2001 From: WenTao Ou Date: Wed, 16 Oct 2024 17:21:59 +0800 Subject: [PATCH 43/89] [BUILD] Remove std::make_unique (#3098) --- exporters/memory/src/in_memory_metric_exporter_factory.cc | 4 ++-- exporters/memory/test/in_memory_metric_data_test.cc | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/exporters/memory/src/in_memory_metric_exporter_factory.cc b/exporters/memory/src/in_memory_metric_exporter_factory.cc index f2577c4e9b..7f6ab83346 100644 --- a/exporters/memory/src/in_memory_metric_exporter_factory.cc +++ b/exporters/memory/src/in_memory_metric_exporter_factory.cc @@ -49,7 +49,7 @@ class InMemoryMetricExporter final : public sdk::metrics::PushMetricExporter OTEL_INTERNAL_LOG_ERROR("[In Memory Metric Exporter] Exporting failed, exporter is shutdown"); return ExportResult::kFailure; } - data_->Add(std::make_unique(data)); + data_->Add(std::unique_ptr(new ResourceMetrics{data})); return ExportResult::kSuccess; } @@ -85,7 +85,7 @@ std::unique_ptr InMemoryMetricExporterFactory::Create( const std::shared_ptr &data, const AggregationTemporalitySelector &temporality) { - return std::make_unique(data, temporality); + return std::unique_ptr(new InMemoryMetricExporter{data, temporality}); } } // namespace memory diff --git a/exporters/memory/test/in_memory_metric_data_test.cc b/exporters/memory/test/in_memory_metric_data_test.cc index ffaba2cfb9..3f2d661759 100644 --- a/exporters/memory/test/in_memory_metric_data_test.cc +++ b/exporters/memory/test/in_memory_metric_data_test.cc @@ -23,8 +23,8 @@ TEST(InMemoryMetricDataTest, CircularBuffer) { CircularBufferInMemoryMetricData buf(10); Resource resource = Resource::GetEmpty(); - buf.Add(std::make_unique( - &resource, std::vector{{nullptr, std::vector{}}})); + buf.Add(std::unique_ptr(new ResourceMetrics{ + &resource, std::vector{{nullptr, std::vector{}}}})); EXPECT_EQ((*buf.Get().begin())->resource_, &resource); } @@ -45,8 +45,8 @@ TEST(InMemoryMetricDataTest, SimpleAggregate) md.instrument_descriptor.name_ = "my-metric"; md.point_data_attr_.push_back(pda); - agg.Add(std::make_unique( - &resource, std::vector{{scope.get(), std::vector{md}}})); + agg.Add(std::unique_ptr(new ResourceMetrics{ + &resource, std::vector{{scope.get(), std::vector{md}}}})); auto it = agg.Get("my-scope", "my-metric").begin(); auto saved_point = opentelemetry::nostd::get(it->second); From 63683c1596484161c085ff642cb0e34b7bdf2bfb Mon Sep 17 00:00:00 2001 From: WenTao Ou Date: Thu, 17 Oct 2024 15:57:10 +0800 Subject: [PATCH 44/89] [BUILD] Fix compiling problems for gcc 4.8 (#3100) * Fix compiling problems for gcc 4.8 * Apply suggestions from code review --------- Co-authored-by: Marc Alff --- exporters/memory/src/in_memory_metric_data.cc | 7 +++++-- exporters/memory/src/in_memory_metric_exporter_factory.cc | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/exporters/memory/src/in_memory_metric_data.cc b/exporters/memory/src/in_memory_metric_data.cc index 2a77e0b5a3..90f1c1450f 100644 --- a/exporters/memory/src/in_memory_metric_data.cc +++ b/exporters/memory/src/in_memory_metric_data.cc @@ -31,7 +31,9 @@ void SimpleAggregateInMemoryMetricData::Add(std::unique_ptr res const auto &metric = m.instrument_descriptor.name_; for (const auto &pda : m.point_data_attr_) { - data_[{scope, metric}].insert({pda.attributes, pda.point_data}); + // NOTE: Explicit type conversion added for C++11 (gcc 4.8) + data_[std::tuple{scope, metric}].insert( + {pda.attributes, pda.point_data}); } } } @@ -41,7 +43,8 @@ const SimpleAggregateInMemoryMetricData::AttributeToPoint &SimpleAggregateInMemo const std::string &scope, const std::string &metric) { - return data_[{scope, metric}]; + // NOTE: Explicit type conversion added for C++11 (gcc 4.8) + return data_[std::tuple{scope, metric}]; } void SimpleAggregateInMemoryMetricData::Clear() diff --git a/exporters/memory/src/in_memory_metric_exporter_factory.cc b/exporters/memory/src/in_memory_metric_exporter_factory.cc index 7f6ab83346..0deff73dcd 100644 --- a/exporters/memory/src/in_memory_metric_exporter_factory.cc +++ b/exporters/memory/src/in_memory_metric_exporter_factory.cc @@ -78,7 +78,8 @@ class InMemoryMetricExporter final : public sdk::metrics::PushMetricExporter std::unique_ptr InMemoryMetricExporterFactory::Create( const std::shared_ptr &data) { - return Create(data, [](auto) { return AggregationTemporality::kCumulative; }); + return Create(data, + [](sdk::metrics::InstrumentType) { return AggregationTemporality::kCumulative; }); } std::unique_ptr InMemoryMetricExporterFactory::Create( From 1185405c46290175127f279193a71e2d4f68f7ce Mon Sep 17 00:00:00 2001 From: WenTao Ou Date: Fri, 18 Oct 2024 18:20:42 +0800 Subject: [PATCH 45/89] [TEST] Fix linking order and gmock linking (#3106) * Fix link order * Fix gmock linking --- ext/test/http/CMakeLists.txt | 6 +++--- test_common/src/http/client/nosend/CMakeLists.txt | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ext/test/http/CMakeLists.txt b/ext/test/http/CMakeLists.txt index 328f78638b..9f5514d07b 100644 --- a/ext/test/http/CMakeLists.txt +++ b/ext/test/http/CMakeLists.txt @@ -5,7 +5,7 @@ if(WITH_HTTP_CLIENT_CURL) set(FILENAME curl_http_test) add_compile_definitions(WITH_CURL) add_executable(${FILENAME} ${FILENAME}.cc) - target_link_libraries(${FILENAME} ${GTEST_BOTH_LIBRARIES} + target_link_libraries(${FILENAME} ${GMOCK_LIB} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) if(TARGET CURL::libcurl) @@ -24,8 +24,8 @@ endif() set(URL_PARSER_FILENAME url_parser_test) add_executable(${URL_PARSER_FILENAME} ${URL_PARSER_FILENAME}.cc) -target_link_libraries(${URL_PARSER_FILENAME} ${GTEST_BOTH_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} opentelemetry_api) +target_link_libraries(${URL_PARSER_FILENAME} opentelemetry_api ${GMOCK_LIB} + ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) gtest_add_tests( TARGET ${URL_PARSER_FILENAME} TEST_PREFIX ext.http.urlparser. diff --git a/test_common/src/http/client/nosend/CMakeLists.txt b/test_common/src/http/client/nosend/CMakeLists.txt index 92a2c1f98c..7394053a22 100644 --- a/test_common/src/http/client/nosend/CMakeLists.txt +++ b/test_common/src/http/client/nosend/CMakeLists.txt @@ -28,7 +28,7 @@ if(${BUILD_TESTING}) endif() target_link_libraries( - opentelemetry_http_client_nosend ${GTEST_BOTH_LIBRARIES} opentelemetry_ext - opentelemetry_test_common) + opentelemetry_http_client_nosend opentelemetry_ext + opentelemetry_test_common ${GMOCK_LIB} ${GTEST_BOTH_LIBRARIES}) endif() From b1488cd37c3077d67021c3a63b3dabe1d7147a10 Mon Sep 17 00:00:00 2001 From: Pranav Sharma Date: Mon, 21 Oct 2024 16:43:30 -0400 Subject: [PATCH 46/89] [EXPORTER] Add config options to prometheus exporter (#3104) --- .../exporters/prometheus/exporter_options.h | 6 ++ .../exporters/prometheus/exporter_utils.h | 12 ++- exporters/prometheus/src/exporter_options.cc | 25 ++++- exporters/prometheus/src/exporter_utils.cc | 62 +++++++----- .../prometheus/test/exporter_utils_test.cc | 94 ++++++++++++++++++- 5 files changed, 169 insertions(+), 30 deletions(-) diff --git a/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_options.h b/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_options.h index 5d8b4932fc..da9d124029 100644 --- a/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_options.h +++ b/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_options.h @@ -28,6 +28,12 @@ struct PrometheusExporterOptions // Populating otel_scope_name/otel_scope_labels attributes bool without_otel_scope = false; + + // Option to export metrics without the unit suffix + bool without_units = false; + + // Option to export metrics without the type suffix + bool without_type_suffix = false; }; } // namespace metrics diff --git a/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_utils.h b/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_utils.h index ccf3d03ff3..29c0f66daf 100644 --- a/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_utils.h +++ b/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_utils.h @@ -30,12 +30,18 @@ class PrometheusExporterUtils * @param populate_target_info whether to populate target_info * @param without_otel_scope whether to populate otel_scope_name and otel_scope_version * attributes + * @param without_units exporter configuration controlling whether to append unit suffix in + * the exported metrics. + * @param without_type_suffix exporter configuration controlling whether to append type suffix in + * the exported metrics. * @return a collection of translated metrics that is acceptable by Prometheus */ static std::vector<::prometheus::MetricFamily> TranslateToPrometheus( const sdk::metrics::ResourceMetrics &data, bool populate_target_info = true, - bool without_otel_scope = false); + bool without_otel_scope = false, + bool without_units = false, + bool without_type_suffix = false); private: /** @@ -61,7 +67,9 @@ class PrometheusExporterUtils static std::string MapToPrometheusName(const std::string &name, const std::string &unit, - ::prometheus::MetricType prometheus_type); + ::prometheus::MetricType prometheus_type, + bool without_units, + bool without_type_suffix); /** * A utility function that returns the equivalent Prometheus name for the provided OTLP metric diff --git a/exporters/prometheus/src/exporter_options.cc b/exporters/prometheus/src/exporter_options.cc index f2c49f7a57..a9de8f4eb4 100644 --- a/exporters/prometheus/src/exporter_options.cc +++ b/exporters/prometheus/src/exporter_options.cc @@ -48,10 +48,33 @@ inline bool GetPrometheusPopulateTargetInfo() return exists ? setting : true; } +inline bool GetPrometheusWithoutUnits() +{ + constexpr char kPrometheusWithoutUnits[] = "OTEL_CPP_PROMETHEUS_EXPORTER_WITHOUT_UNITS"; + bool setting; + const auto exists = + opentelemetry::sdk::common::GetBoolEnvironmentVariable(kPrometheusWithoutUnits, setting); + + return exists ? setting : false; +} + +inline bool GetPrometheusWithoutTypeSuffix() +{ + constexpr char kPrometheusWithoutTypeSuffix[] = + "OTEL_CPP_PROMETHEUS_EXPORTER_WITHOUT_TYPE_SUFFIX"; + bool setting; + const auto exists = + opentelemetry::sdk::common::GetBoolEnvironmentVariable(kPrometheusWithoutTypeSuffix, setting); + + return exists ? setting : false; +} + PrometheusExporterOptions::PrometheusExporterOptions() : url(GetPrometheusDefaultHttpEndpoint()), populate_target_info(GetPrometheusPopulateTargetInfo()), - without_otel_scope(GetPrometheusWithoutOtelScope()) + without_otel_scope(GetPrometheusWithoutOtelScope()), + without_units(GetPrometheusWithoutUnits()), + without_type_suffix(GetPrometheusWithoutTypeSuffix()) {} } // namespace metrics diff --git a/exporters/prometheus/src/exporter_utils.cc b/exporters/prometheus/src/exporter_utils.cc index 77fcd56ad2..27385f3f6f 100644 --- a/exporters/prometheus/src/exporter_utils.cc +++ b/exporters/prometheus/src/exporter_utils.cc @@ -102,13 +102,15 @@ std::string SanitizeLabel(std::string label_key) * Helper function to convert OpenTelemetry metrics data collection * to Prometheus metrics data collection * - * @param records a collection of metrics in OpenTelemetry + * @param data a collection of metrics in OpenTelemetry * @return a collection of translated metrics that is acceptable by Prometheus */ std::vector PrometheusExporterUtils::TranslateToPrometheus( const sdk::metrics::ResourceMetrics &data, bool populate_target_info, - bool without_otel_scope) + bool without_otel_scope, + bool without_units, + bool without_type_suffix) { // initialize output vector @@ -150,7 +152,8 @@ std::vector PrometheusExporterUtils::TranslateT } const prometheus_client::MetricType type = TranslateType(kind, is_monotonic); metric_family.name = MapToPrometheusName(metric_data.instrument_descriptor.name_, - metric_data.instrument_descriptor.unit_, type); + metric_data.instrument_descriptor.unit_, type, + without_units, without_type_suffix); metric_family.type = type; const opentelemetry::sdk::instrumentationscope::InstrumentationScope *scope = without_otel_scope ? nullptr : instrumentation_info.scope_; @@ -492,34 +495,43 @@ std::string PrometheusExporterUtils::CleanUpString(const std::string &str) std::string PrometheusExporterUtils::MapToPrometheusName( const std::string &name, const std::string &unit, - prometheus_client::MetricType prometheus_type) + prometheus_client::MetricType prometheus_type, + bool without_units, + bool without_type_suffix) { - auto sanitized_name = SanitizeNames(name); - std::string prometheus_equivalent_unit = GetEquivalentPrometheusUnit(unit); - - // Append prometheus unit if not null or empty. - if (!prometheus_equivalent_unit.empty() && - sanitized_name.find(prometheus_equivalent_unit) == std::string::npos) - { - sanitized_name += "_" + prometheus_equivalent_unit; - } - - // Special case - counter - if (prometheus_type == prometheus_client::MetricType::Counter) - { - auto t_pos = sanitized_name.rfind("_total"); - bool ends_with_total = t_pos == sanitized_name.size() - 6; - if (!ends_with_total) + auto sanitized_name = SanitizeNames(name); + // append unit suffixes + if (!without_units) + { + std::string prometheus_equivalent_unit = GetEquivalentPrometheusUnit(unit); + // Append prometheus unit if not null or empty. + if (!prometheus_equivalent_unit.empty() && + sanitized_name.find(prometheus_equivalent_unit) == std::string::npos) { - sanitized_name += "_total"; + sanitized_name += "_" + prometheus_equivalent_unit; + } + // Special case - gauge + if (unit == "1" && prometheus_type == prometheus_client::MetricType::Gauge && + sanitized_name.find("ratio") == std::string::npos) + { + // this is replacing the unit name + sanitized_name += "_ratio"; } } - // Special case - gauge - if (unit == "1" && prometheus_type == prometheus_client::MetricType::Gauge && - sanitized_name.find("ratio") == std::string::npos) + // append type suffixes + if (!without_type_suffix) { - sanitized_name += "_ratio"; + // Special case - counter + if (prometheus_type == prometheus_client::MetricType::Counter) + { + auto t_pos = sanitized_name.rfind("_total"); + bool ends_with_total = t_pos == sanitized_name.size() - 6; + if (!ends_with_total) + { + sanitized_name += "_total"; + } + } } return CleanUpString(SanitizeNames(sanitized_name)); diff --git a/exporters/prometheus/test/exporter_utils_test.cc b/exporters/prometheus/test/exporter_utils_test.cc index 7ad5eee1fd..76ec869a6f 100644 --- a/exporters/prometheus/test/exporter_utils_test.cc +++ b/exporters/prometheus/test/exporter_utils_test.cc @@ -54,9 +54,12 @@ class SanitizeNameTester } static std::string mapToPrometheusName(const std::string &name, const std::string &unit, - prometheus_client::MetricType prometheus_type) + prometheus_client::MetricType prometheus_type, + bool without_units = false, + bool without_type_suffix = false) { - return PrometheusExporterUtils::MapToPrometheusName(name, unit, prometheus_type); + return PrometheusExporterUtils::MapToPrometheusName(name, unit, prometheus_type, without_units, + without_type_suffix); } }; } // namespace metrics @@ -419,6 +422,93 @@ TEST(PrometheusExporterUtils, ConvertRateExpressedToPrometheusUnit) "_per_minute"); } +TEST(PromentheusExporterUtils, PrometheusNameMapping) +{ + // General test cases on unit expansions and name sanitization + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric___name", "g", prometheus::MetricType::Counter), + "sample_metric_name_grams_total"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "s", prometheus::MetricType::Counter), + "sample_metric_name_seconds_total"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "s", prometheus::MetricType::Gauge), + "sample_metric_name_seconds"); + // Test without_units & without_type_suffix with Counters and unit = 1 + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "1", prometheus::MetricType::Counter), + "sample_metric_name_total"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "1", prometheus::MetricType::Counter, true, false), + "sample_metric_name_total"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "1", prometheus::MetricType::Counter, false, true), + "sample_metric_name"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "1", prometheus::MetricType::Counter, true, true), + "sample_metric_name"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "1", prometheus::MetricType::Counter, true, true), + "sample_metric_name"); + // Test without_units & without_type_suffix with Counters and non-special units + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "%", prometheus::MetricType::Counter), + "sample_metric_name_percent_total"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "m", prometheus::MetricType::Counter, true, false), + "sample_metric_name_total"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "By", prometheus::MetricType::Counter, false, true), + "sample_metric_name_bytes"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "s", prometheus::MetricType::Counter, true, true), + "sample_metric_name"); + // Special case Gauges & ratio + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "1", prometheus::MetricType::Gauge), + "sample_metric_name_ratio"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "1", prometheus::MetricType::Gauge, false, true), + "sample_metric_name_ratio"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "1", prometheus::MetricType::Gauge, true, false), + "sample_metric_name"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "1", prometheus::MetricType::Gauge, true, true), + "sample_metric_name"); + // Test without_type_suffix affects only counters + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "Hz", prometheus::MetricType::Counter), + "sample_metric_name_hertz_total"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "Hz", prometheus::MetricType::Counter, false, true), + "sample_metric_name_hertz"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "Hz", prometheus::MetricType::Gauge), + "sample_metric_name_hertz"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "Hz", prometheus::MetricType::Gauge, false, true), + "sample_metric_name_hertz"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "Hz", prometheus::MetricType::Histogram), + "sample_metric_name_hertz"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "Hz", prometheus::MetricType::Histogram, false, true), + "sample_metric_name_hertz"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "Hz", prometheus::MetricType::Summary), + "sample_metric_name_hertz"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "Hz", prometheus::MetricType::Summary, false, true), + "sample_metric_name_hertz"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "Hz", prometheus::MetricType::Info), + "sample_metric_name_hertz"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "Hz", prometheus::MetricType::Info, false, true), + "sample_metric_name_hertz"); +} + TEST_F(AttributeCollisionTest, JoinsCollidingKeys) { CheckTranslation({{"foo.a", "value1"}, {"foo_a", "value2"}}, {{"foo_a", "value1;value2"}, From 7402ed9bac9265ea22ddb1dd4e61029f745f7436 Mon Sep 17 00:00:00 2001 From: tobim Date: Mon, 21 Oct 2024 23:27:57 +0200 Subject: [PATCH 47/89] [BUILD] Add a CMake option to disable shared libs (#3095) * Add a CMake option to disable shared libs This option is useful to support platforms that do not support dynamic libraries and `dlopen`. --- CMakeLists.txt | 4 ++++ api/test/CMakeLists.txt | 5 ++++- examples/plugin/CMakeLists.txt | 5 ++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fd41fa7148..a0710834bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -287,6 +287,10 @@ option(WITH_ASYNC_EXPORT_PREVIEW "Whether to enable async export" OFF) option(WITH_METRICS_EXEMPLAR_PREVIEW "Whether to enable exemplar within metrics" OFF) +option(OPENTELEMETRY_SKIP_DYNAMIC_LOADING_TESTS + "Whether to build test libraries that are always linked as shared libs" + OFF) + # # Verify options dependencies # diff --git a/api/test/CMakeLists.txt b/api/test/CMakeLists.txt index 20c9f4e949..66eeee2092 100644 --- a/api/test/CMakeLists.txt +++ b/api/test/CMakeLists.txt @@ -10,4 +10,7 @@ add_subdirectory(metrics) add_subdirectory(logs) add_subdirectory(common) add_subdirectory(baggage) -add_subdirectory(singleton) + +if(NOT OPENTELEMETRY_SKIP_DYNAMIC_LOADING_TESTS) + add_subdirectory(singleton) +endif() diff --git a/examples/plugin/CMakeLists.txt b/examples/plugin/CMakeLists.txt index e1a44690e4..5dfc79963c 100644 --- a/examples/plugin/CMakeLists.txt +++ b/examples/plugin/CMakeLists.txt @@ -2,4 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 add_subdirectory(load) -add_subdirectory(plugin) + +if(NOT OPENTELEMETRY_SKIP_DYNAMIC_LOADING_TESTS) + add_subdirectory(plugin) +endif() From 751ba5b48f6f6ce90b2b22466540e66b2e114851 Mon Sep 17 00:00:00 2001 From: Tom Tan Date: Tue, 22 Oct 2024 14:11:55 -0700 Subject: [PATCH 48/89] [EXPORTER] Remove out of date ETW exporter doc (#3103) --- exporters/etw/README.md | 214 +--------------------------------------- 1 file changed, 2 insertions(+), 212 deletions(-) diff --git a/exporters/etw/README.md b/exporters/etw/README.md index 3339223fa6..372aa5738e 100644 --- a/exporters/etw/README.md +++ b/exporters/etw/README.md @@ -12,215 +12,5 @@ subsequent data recording or forwarding to alternate pipelines and flows. Windows Event Tracing infrastructure is available to any vendor or application being deployed on Windows. -## API support - -These are the features planned to be supported by ETW exporter: - -- [x] OpenTelemetry Tracing API and SDK headers are **stable** and moving - towards GA. -- [ ] OpenTelemetry Logging API is work-in-progress, pending implementation of - [Latest Logging API spec - here](https://github.com/open-telemetry/oteps/pull/150) -- [ ] OpenTelemetry Metrics API is not implemented yet. - -Implementation of OpenTelemetry C++ SDK ETW exporter on Windows OS is `header -only` : - -- full definitions of all macros, functions and classes comprising the library -are visible to the compiler in a header file form. -- implementation does not need to be separately compiled, packaged and installed - in order to be used. - -All that is required is to point the compiler at the location of the headers, -and then `#include` the header files into the application source. Compiler's -optimizer can do a much better job when all the library's source code is -available. Several options below may be turned on to optimize the code with the -usage of standard C++ library, Microsoft Guidelines Support library, Google -Abseil Variant library. Or enabling support for non-standard features, such as -8-bit byte arrays support that enables performance-efficient representation of -binary blobs on ETW wire. - -## Example project - -The following include directories are required, relative to the top-level source -tree of OpenTelemetry C++ repo: - -- api/include/ -- exporters/etw/include/ -- sdk/include/ - -Code that instantiates ETW TracerProvider, subsequently obtaining a Tracer bound -to `OpenTelemetry-ETW-Provider`, and emitting a span named `MySpan` with -attributes on it, as well as `MyEvent` within that span. - -```cpp - -#include -#include - -#include "opentelemetry/exporters/etw/etw_tracer_exporter.h" - -using namespace OPENTELEMETRY_NAMESPACE; -using namespace opentelemetry::exporter::etw; - -// Supply unique instrumentation name (ETW Provider Name) here: -std::string providerName = "OpenTelemetry-ETW-Provider"; - -exporter::etw::TracerProvider tp; - -int main(int argc, const char* argv[]) -{ - // Obtain a Tracer object for instrumentation name. - // Each Tracer is associated with unique TraceId. - auto tracer = tp.GetTracer(providerName, "TLD"); - - // Properties is a helper class in ETW namespace that is otherwise compatible - // with Key-Value Iterable accepted by OpenTelemetry API. Using Properties - // should enable more efficient data transfer without unnecessary memcpy. - - // Span attributes - Properties attribs = - { - {"attrib1", 1}, - {"attrib2", 2} - }; - - // Start Span with attributes - auto span = tracer->StartSpan("MySpan", attribs); - - // Emit an event on Span - std::string eventName = "MyEvent1"; - Properties event = - { - {"uint32Key", (uint32_t)1234}, - {"uint64Key", (uint64_t)1234567890}, - {"strKey", "someValue"} - }; - span->AddEvent(eventName, event); - - // End Span. - span->End(); - - // Close the Tracer on application stop. - tracer->CloseWithMicroseconds(0); - - return 0; -} -``` - -Note that different `Tracer` objects may be bound to different ETW destinations. - -## Build options and Compiler Defines - -While including OpenTelemetry C++ SDK with ETW exporter, the customers are in -complete control of what options they would like to enable for their project -using `Preprocessor Definitions`. - -These options affect how "embedded in application" OpenTelemetry C++ SDK code is -compiled: - -| Name | Description | -|---------------------|------------------------------------------------------------------------------------------------------------------------| -| OPENTELEMETRY_STL_VERSION | Use STL classes for API surface. C++20 is recommended. Some customers may benefit from STL library provided with the compiler instead of using custom OpenTelemetry `nostd::` implementation due to security and performance considerations. | -| HAVE_GSL | Use [Microsoft GSL](https://github.com/microsoft/GSL) for `gsl::span` implementation. Library must be in include path. Microsoft GSL claims to be the most feature-complete implementation of `std::span`. It may be used instead of `nostd::span` implementation in projects that statically link OpenTelemetry SDK. | -| HAVE_TLD | Use ETW/TraceLogging Dynamic protocol. This is the default implementation compatible with existing C# "listeners" / "decoders" of ETW events. This option requires an additional optional Microsoft MIT-licensed `TraceLoggingDynamic.h` header. | - -## Debugging - -### ETW TraceLogging Dynamic Events - -ETW supports a mode that is called "Dynamic Manifest", where event may contain -strongly-typed key-value pairs, with primitive types such as `integer`, -`double`, `string`, etc. This mode requires `TraceLoggingDynamic.h` header. -Please refer to upstream repository containining [Microsoft TraceLogging Dynamic -framework](https://github.com/microsoft/tracelogging-dynamic-windows) licensed -under [MIT -License](https://github.com/microsoft/tracelogging-dynamic-windows/blob/main/LICENSE). - -Complete [list of ETW -types](https://docs.microsoft.com/en-us/windows/win32/wes/eventmanifestschema-outputtype-complextype#remarks). - -OpenTelemetry C++ ETW exporter implements the following type mapping: - -| OpenTelemetry C++ API type | ETW type | -|----------------------------|-----------------| -| bool | xs:byte | -| int (32-bit) | xs:int | -| int (64-bit) | xs:long | -| uint (32-bit) | xs:unsignedInt | -| uint (64-bit) | xs:unsignedLong | -| double | xs:double | -| string | win:Utf8 | - -Support for arrays of primitive types is not implemented yet. - -Visual Studio 2019 allows to use `View -> Other Windows -> Diagnostic Events` to -capture events that are emitted by instrumented application and sent to ETW -provider in a live view. Instrumentation name passed to `GetTracer` API above -corresponds to `ETW Provider Name`. If Instrumentation name contains a GUID - -starts with a curly brace, e.g. `{deadbeef-fade-dead-c0de-cafebabefeed}` then -the parameter is assumed to be `ETW Provider GUID`. - -Click on `Settings` and add the provider to monitor either by its Name or by -GUID. In above example, the provider name is `OpenTelemetry-ETW-Provider`. -Please refer to Diagnostic Events usage instructions -[here](https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-diagnostics-how-to-monitor-and-diagnose-services-locally#view-service-fabric-system-events-in-visual-studio) -to learn more. Note that running ETW Listener in Visual Studio requires -Elevation, i.e. Visual Studio would prompt you to confirm that you accept to run -the ETW Listener process as Administrator. This is a limitation of ETW -Listeners, they must be run as privileged process. - -### ETW events encoded in MessagePack - -OpenTelemetry ETW exporter optionally allows to encode the incoming event -payload using [MessagePack](https://msgpack.org/index.html) compact binary -protocol. ETW/MsgPack encoding requires -[nlohmann/json](https://github.com/nlohmann/json) library to be included in the -build of OpenTelemetry ETW exporter. Any recent version of `nlohmann/json` is -compatible with ETW exporter. For example, the version included in -`third_party/nlohmann-json` directory may be used. - -There is currently **no built-in decoder available** for this format. However, -there is ongoing effort to include the ETW/MsgPack decoder in -[Azure/diagnostics-eventflow](https://github.com/Azure/diagnostics-eventflow) -project, which may be used as a side-car listener to forward incoming -ETW/MsgPack events to many other destinations, such as: - -- StdOutput (console output) -- HTTP (json via http) -- Application Insights -- Azure EventHub -- Elasticsearch -- Azure Monitor Logs - -And community-contributed exporters: - -- Google Big Query output -- SQL Server output -- ReflectInsight output -- Splunk output - -[This PR](https://github.com/Azure/diagnostics-eventflow/pull/382) implements -the `Input adapter` for OpenTelemetry ETW/MsgPack protocol encoded events for -Azure EventFlow. - -Other standard tools for processing ETW events on Windows OS, such as: - -- [PerfView](https://github.com/microsoft/perfview) -- [PerfViewJS](https://github.com/microsoft/perfview/tree/main/src/PerfViewJS) - -will be augmented in future with support for ETW/MsgPack encoding. - -## Addendum - -This document needs to be supplemented with additional information: - -- [ ] mapping between OpenTelemetry fields and concepts and their corresponding - ETW counterparts -- [ ] links to E2E instrumentation example and ETW listener -- [ ] Logging API example -- [ ] Metrics API example (once Metrics spec is finalized) -- [ ] example how ETW Listener may employ OpenTelemetry .NET SDK to 1-1 - transform from ETW events back to OpenTelemetry flow -- [ ] links to NuGet package that contains the source code of SDK that includes - OpenTelemetry SDK and ETW exporter +It is recommended to consume this exporter via +[vcpkg](https://vcpkg.io/en/package/opentelemetry-cpp). From 994761988eed36a41014de6291d470c738190ae0 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Thu, 24 Oct 2024 14:32:48 +0200 Subject: [PATCH 49/89] [EXPORTER] Add logging for async gRPC errors (#3108) --- exporters/otlp/src/otlp_grpc_client.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/exporters/otlp/src/otlp_grpc_client.cc b/exporters/otlp/src/otlp_grpc_client.cc index d3d59bce6e..44d86004a9 100644 --- a/exporters/otlp/src/otlp_grpc_client.cc +++ b/exporters/otlp/src/otlp_grpc_client.cc @@ -207,7 +207,7 @@ static sdk::common::ExportResult InternalDelegateAsyncExport( stub->experimental_async() # endif ->Export(call_data->grpc_context.get(), call_data->request, call_data->response, - [call_data, async_data](::grpc::Status grpc_status) { + [call_data, async_data, export_data_name](::grpc::Status grpc_status) { --async_data->running_requests; ++async_data->finished_request_counter; @@ -216,6 +216,13 @@ static sdk::common::ExportResult InternalDelegateAsyncExport( { call_data->export_result = opentelemetry::sdk::common::ExportResult::kSuccess; } + else + { + OTEL_INTERNAL_LOG_ERROR("[OTLP GRPC Client] ERROR: Export " + << export_data_name << " failed with status_code: \"" + << grpc_status.error_code() << "\" error_message: \"" + << grpc_status.error_message() << "\""); + } if (call_data->grpc_async_callback) { From 2c912d50a52b14761b37dfadd6d26723d1025a1a Mon Sep 17 00:00:00 2001 From: ColoredCarrot <7807570+ColoredCarrot@users.noreply.github.com> Date: Sat, 26 Oct 2024 01:16:10 +0200 Subject: [PATCH 50/89] [BUILD] Remove aligned_storage from nostd (#3112) std::aligned_storage was deprecated in C++23. Abseil removed its aligned_storage in https://github.com/abseil/abseil-cpp/commit/42133464db0ae5383fef723067835ef768b849f8 --- .../nostd/internal/absl/meta/type_traits.h | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/api/include/opentelemetry/nostd/internal/absl/meta/type_traits.h b/api/include/opentelemetry/nostd/internal/absl/meta/type_traits.h index 00c90f82d1..7fba912312 100644 --- a/api/include/opentelemetry/nostd/internal/absl/meta/type_traits.h +++ b/api/include/opentelemetry/nostd/internal/absl/meta/type_traits.h @@ -106,18 +106,6 @@ struct VoidTImpl { using type = void; }; -// This trick to retrieve a default alignment is necessary for our -// implementation of aligned_storage_t to be consistent with any implementation -// of std::aligned_storage. -template > -struct default_alignment_of_aligned_storage; - -template -struct default_alignment_of_aligned_storage> { - static constexpr size_t value = Align; -}; - //////////////////////////////// // Library Fundamentals V2 TS // //////////////////////////////// @@ -619,10 +607,6 @@ using remove_extent_t = typename std::remove_extent::type; template using remove_all_extents_t = typename std::remove_all_extents::type; -template ::value> -using aligned_storage_t = typename std::aligned_storage::type; - template using decay_t = typename std::decay::type; From 5e62859ffce873fd8f996d1c72d7a87f8f61f07b Mon Sep 17 00:00:00 2001 From: Maxime Leblanc Date: Sun, 27 Oct 2024 17:50:41 +0100 Subject: [PATCH 51/89] [EXPORTER] Elastic Search exporter follow ECS guidelines (#3107) * [EXPORTERS]: elastic search log message within `message` key instead of `body` According to ECS logging reference https://www.elastic.co/guide/en/ecs/8.11/ecs-base.html#field-message Refs #3091 * [EXPORTERS]: elastic search set severity within `log.level` key instead of `severity` According to ECS logging reference https://www.elastic.co/guide/en/ecs/8.11/ecs-log.html#field-log-level Refs #3091 * [EXPORTERS]: elastic search set timestamp within `@timestamp` instead of `timestamp` Also changes the format to be a Date string. According to ECS logging reference https://www.elastic.co/guide/en/ecs/8.11/ecs-base.html#field-timestamp Refs #3091 * [EXPORTERS]: elastic search set instrumentation scope within `log.logger` instead of `name` According to ECS logging reference https://www.elastic.co/guide/en/ecs/8.11/ecs-log.html#field-log-logger Refs #3091 * EXPORTERS]: elastic search recorable constructor sets `ecs.version` field to 8.11.0 According to ECS guidelines this field is mandatory https://www.elastic.co/guide/en/ecs/8.11/ecs-guidelines.html Refs #3091 * [EXPORTERS]: elastic search put attributes in json root instead of under `attributes` This allows user to set other fields that are part of the [ECS log documentation](https://www.elastic.co/guide/en/ecs/8.11/ecs-log.html). For instance, it allows to have an attribute with key `log.file`, that will, thanks to `nlohmann::json`, appear as : ``` { "log": { "file": "xxx" } } ``` Closes #3091 --- .../elasticsearch/es_log_recordable.h | 2 + .../elasticsearch/src/es_log_recordable.cc | 50 ++++++++++++++++--- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h b/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h index af4ccb16ef..52d24cada6 100644 --- a/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h +++ b/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h @@ -42,6 +42,8 @@ class ElasticSearchRecordable final : public sdk::logs::Recordable void WriteValue(const opentelemetry::common::AttributeValue &value, const std::string &name); public: + ElasticSearchRecordable() noexcept; + /** * Returns a JSON object contain the log information */ diff --git a/exporters/elasticsearch/src/es_log_recordable.cc b/exporters/elasticsearch/src/es_log_recordable.cc index 663691273b..56d7cea71b 100644 --- a/exporters/elasticsearch/src/es_log_recordable.cc +++ b/exporters/elasticsearch/src/es_log_recordable.cc @@ -197,6 +197,11 @@ void ElasticSearchRecordable::WriteValue(const opentelemetry::common::AttributeV } } +ElasticSearchRecordable::ElasticSearchRecordable() noexcept : sdk::logs::Recordable() +{ + json_["ecs"]["version"] = "8.11.0"; +} + nlohmann::json ElasticSearchRecordable::GetJSON() noexcept { return json_; @@ -205,7 +210,38 @@ nlohmann::json ElasticSearchRecordable::GetJSON() noexcept void ElasticSearchRecordable::SetTimestamp( opentelemetry::common::SystemTimestamp timestamp) noexcept { - json_["timestamp"] = timestamp.time_since_epoch().count(); + const std::chrono::system_clock::time_point timePoint{timestamp}; + + // If built with with at least cpp 20 then use std::format + // Otherwise use the old style to format the timestamp in UTC +#if __cplusplus >= 202002L + const std::string dateStr = std::format("{:%FT%T%Ez}", timePoint); +#else + const static int dateToSecondsSize = 19; + const static int millisecondsSize = 8; + const static int timeZoneSize = 1; + const static int dateSize = dateToSecondsSize + millisecondsSize + timeZoneSize; + + std::time_t time = std::chrono::system_clock::to_time_t(timePoint); + std::tm tm = *std::gmtime(&time); + + char bufferDate[dateSize]; // example: 2024-10-18T07:26:00.123456Z + std::strftime(bufferDate, sizeof(bufferDate), "%Y-%m-%dT%H:%M:%S", &tm); + auto microseconds = + std::chrono::duration_cast(timePoint.time_since_epoch()) % + std::chrono::seconds(1); + + char bufferMilliseconds[millisecondsSize]; + std::snprintf(bufferMilliseconds, sizeof(bufferMilliseconds), ".%06ld", + static_cast(microseconds.count())); + + std::strcat(bufferDate, bufferMilliseconds); + std::strcat(bufferDate, "Z"); + + const std::string dateStr(bufferDate); +#endif + + json_["@timestamp"] = dateStr; } void ElasticSearchRecordable::SetObservedTimestamp( @@ -216,23 +252,25 @@ void ElasticSearchRecordable::SetObservedTimestamp( void ElasticSearchRecordable::SetSeverity(opentelemetry::logs::Severity severity) noexcept { + auto &severityField = json_["log"]["level"]; + // Convert the severity enum to a string std::uint32_t severity_index = static_cast(severity); if (severity_index >= std::extent::value) { std::stringstream sout; sout << "Invalid severity(" << severity_index << ")"; - json_["severity"] = sout.str(); + severityField = sout.str(); } else { - json_["severity"] = opentelemetry::logs::SeverityNumToText[severity_index]; + severityField = opentelemetry::logs::SeverityNumToText[severity_index]; } } void ElasticSearchRecordable::SetBody(const opentelemetry::common::AttributeValue &message) noexcept { - WriteValue(message, "body"); + WriteValue(message, "message"); } void ElasticSearchRecordable::SetTraceId(const opentelemetry::trace::TraceId &trace_id) noexcept @@ -275,7 +313,7 @@ void ElasticSearchRecordable::SetAttribute( nostd::string_view key, const opentelemetry::common::AttributeValue &value) noexcept { - WriteKeyValue(key, value, "attributes"); + WriteValue(value, key.data()); } void ElasticSearchRecordable::SetResource( @@ -291,7 +329,7 @@ void ElasticSearchRecordable::SetInstrumentationScope( const opentelemetry::sdk::instrumentationscope::InstrumentationScope &instrumentation_scope) noexcept { - json_["name"] = instrumentation_scope.GetName(); + json_["log"]["logger"] = instrumentation_scope.GetName(); } } // namespace logs From 6292a6a74e83f93c8270a0d2973f5702b34a1fa8 Mon Sep 17 00:00:00 2001 From: tobim Date: Wed, 30 Oct 2024 18:27:15 +0100 Subject: [PATCH 52/89] [INSTALL] Resolve dependencies in opentelemetry-cpp-config.cmake (#3094) * Resolve dependencies in opentelemetry-cpp-config.cmake Before this change, consumers of the exported CMake targets had to know which dependencies are needed to get the transitive target dependencies like `absl::*`, `gRPC::grpc++`, or `protobuf::libprotobuf`. * Add find_dependency calls for remaining deps Now we also resolve `OpenTracing`, and `prometheus-cpp`. If necessary, `CURL` and `ZLIB` are also resolved. --------- Co-authored-by: Marc Alff Co-authored-by: Lalit Kumar Bhasin --- cmake/opentelemetry-cpp-config.cmake.in | 34 ++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/cmake/opentelemetry-cpp-config.cmake.in b/cmake/opentelemetry-cpp-config.cmake.in index 36215c8af7..f5c6e5e722 100644 --- a/cmake/opentelemetry-cpp-config.cmake.in +++ b/cmake/opentelemetry-cpp-config.cmake.in @@ -70,7 +70,39 @@ set(OPENTELEMETRY_VERSION # ############################################################################## -find_package(Threads) +include(CMakeFindDependencyMacro) + +find_dependency(Threads) + +if(@WITH_ABSEIL@) + find_dependency(absl) +endif() + +if(@WITH_OTLP_GRPC@) + find_dependency(gRPC) +endif() + +if("@OpenTracing_FOUND@") + find_dependency(OpenTracing) +endif() + +if("@prometheus-cpp_FOUND@") + find_dependency(prometheus-cpp) +endif() + +if("@Protobuf_FOUND@" OR "@PROTOBUF_FOUND@") + find_dependency(Protobuf) +endif() + +if (@WITH_HTTP_CLIENT_CURL@ AND NOT @BUILD_SHARED_LIBS@) + if("@CURL_FOUND@") + find_dependency(CURL) + endif() + + if("@ZLIB_FOUND@") + find_dependency(ZLIB) + endif() +endif() set_and_check(OPENTELEMETRY_CPP_INCLUDE_DIRS "@PACKAGE_INCLUDE_INSTALL_DIR@") set_and_check(OPENTELEMETRY_CPP_LIBRARY_DIRS "@PACKAGE_CMAKE_INSTALL_LIBDIR@") From f30ab925c82ca817461ec9b5a6a268be0cfc3960 Mon Sep 17 00:00:00 2001 From: uuzay Date: Wed, 30 Oct 2024 17:34:25 -0400 Subject: [PATCH 53/89] [API] Add synchronous gauge (#3029) * Add synchronous gauge * Add ABI Version macro, update tests * Fix function description * Fix formatting * Remove ABI macros from SDK. * Add error log for gauge delta temporality. * Fix formatting * Apply suggestions from code review Move kGauge to the end, for better ABI compatibility. --------- Co-authored-by: Lalit Kumar Bhasin Co-authored-by: Marc Alff --- api/include/opentelemetry/metrics/meter.h | 24 +++ api/include/opentelemetry/metrics/noop.h | 36 ++++ .../opentelemetry/metrics/sync_instruments.h | 77 +++++++ .../common/metrics_foo_library/foo_library.cc | 19 ++ .../common/metrics_foo_library/foo_library.h | 3 + examples/metrics_simple/metrics_ostream.cc | 12 ++ examples/otlp/file_metric_main.cc | 12 ++ examples/otlp/grpc_metric_main.cc | 12 ++ examples/otlp/http_metric_main.cc | 12 ++ exporters/otlp/src/otlp_metric_utils.cc | 2 + .../metrics/aggregation/default_aggregation.h | 1 + .../opentelemetry/sdk/metrics/instruments.h | 3 +- sdk/include/opentelemetry/sdk/metrics/meter.h | 12 ++ .../sdk/metrics/sync_instruments.h | 34 ++++ sdk/src/metrics/meter.cc | 44 ++++ sdk/src/metrics/state/metric_collector.cc | 13 +- sdk/src/metrics/sync_instruments.cc | 121 +++++++++++ sdk/test/metrics/CMakeLists.txt | 1 + sdk/test/metrics/sync_instruments_test.cc | 39 ++++ .../metrics/sync_metric_storage_gauge_test.cc | 189 ++++++++++++++++++ 20 files changed, 664 insertions(+), 2 deletions(-) create mode 100644 sdk/test/metrics/sync_metric_storage_gauge_test.cc diff --git a/api/include/opentelemetry/metrics/meter.h b/api/include/opentelemetry/metrics/meter.h index ced5890310..59cfb87822 100644 --- a/api/include/opentelemetry/metrics/meter.h +++ b/api/include/opentelemetry/metrics/meter.h @@ -21,6 +21,9 @@ class Histogram; template class UpDownCounter; +template +class Gauge; + class ObservableInstrument; /** @@ -91,6 +94,27 @@ class Meter nostd::string_view description = "", nostd::string_view unit = "") noexcept = 0; +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + /** + * Creates a Gauge with the passed characteristics and returns a unique_ptr to that Gauge. + * + * @param name the name of the new Gauge. + * @param description a brief description of what the Gauge is used for. + * @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html. + * @return a unique pointer to the created Gauge. + */ + + virtual nostd::unique_ptr> CreateInt64Gauge( + nostd::string_view name, + nostd::string_view description = "", + nostd::string_view unit = "") noexcept = 0; + + virtual nostd::unique_ptr> CreateDoubleGauge( + nostd::string_view name, + nostd::string_view description = "", + nostd::string_view unit = "") noexcept = 0; +#endif + /** * Creates a Asynchronous (Observable) Gauge with the passed characteristics and returns a * shared_ptr to that Observable Gauge diff --git a/api/include/opentelemetry/metrics/noop.h b/api/include/opentelemetry/metrics/noop.h index d34a0e681b..1d508b9387 100644 --- a/api/include/opentelemetry/metrics/noop.h +++ b/api/include/opentelemetry/metrics/noop.h @@ -71,6 +71,26 @@ class NoopUpDownCounter : public UpDownCounter {} }; +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 +template +class NoopGauge : public Gauge +{ +public: + NoopGauge(nostd::string_view /* name */, + nostd::string_view /* description */, + nostd::string_view /* unit */) noexcept + {} + ~NoopGauge() override = default; + void Record(T /* value */) noexcept override {} + void Record(T /* value */, const context::Context & /* context */) noexcept override {} + void Record(T /* value */, const common::KeyValueIterable & /* attributes */) noexcept override {} + void Record(T /* value */, + const common::KeyValueIterable & /* attributes */, + const context::Context & /* context */) noexcept override + {} +}; +#endif + class NoopObservableInstrument : public ObservableInstrument { public: @@ -140,6 +160,22 @@ class NoopMeter final : public Meter return nostd::unique_ptr>{new NoopHistogram(name, description, unit)}; } +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + nostd::unique_ptr> CreateInt64Gauge(nostd::string_view name, + nostd::string_view description = "", + nostd::string_view unit = "") noexcept override + { + return nostd::unique_ptr>{new NoopGauge(name, description, unit)}; + } + + nostd::unique_ptr> CreateDoubleGauge(nostd::string_view name, + nostd::string_view description = "", + nostd::string_view unit = "") noexcept override + { + return nostd::unique_ptr>{new NoopGauge(name, description, unit)}; + } +#endif + nostd::shared_ptr CreateInt64ObservableGauge( nostd::string_view name, nostd::string_view description = "", diff --git a/api/include/opentelemetry/metrics/sync_instruments.h b/api/include/opentelemetry/metrics/sync_instruments.h index 4471677433..9eaec3352f 100644 --- a/api/include/opentelemetry/metrics/sync_instruments.h +++ b/api/include/opentelemetry/metrics/sync_instruments.h @@ -247,5 +247,82 @@ class UpDownCounter : public SynchronousInstrument } }; +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 +/* A Gauge instrument that records values. */ +template +class Gauge : public SynchronousInstrument +{ + +public: + /** + * Record a value + * + * @param value The measurement value. May be positive, negative or zero. + */ + virtual void Record(T value) noexcept = 0; + + /** + * Record a value + * + * @param value The measurement value. May be positive, negative or zero. + * @param context The explicit context to associate with this measurement. + */ + virtual void Record(T value, const context::Context &context) noexcept = 0; + + /** + * Record a value with a set of attributes. + * + * @param value The measurement value. May be positive, negative or zero. + * @param attributes A set of attributes to associate with the value. + */ + + virtual void Record(T value, const common::KeyValueIterable &attributes) noexcept = 0; + + /** + * Record a value with a set of attributes. + * + * @param value The measurement value. May be positive, negative or zero. + * @param attributes A set of attributes to associate with the value. + * @param context The explicit context to associate with this measurement. + */ + virtual void Record(T value, + const common::KeyValueIterable &attributes, + const context::Context &context) noexcept = 0; + + template ::value> * = nullptr> + void Record(T value, const U &attributes) noexcept + { + this->Record(value, common::KeyValueIterableView{attributes}); + } + + template ::value> * = nullptr> + void Record(T value, const U &attributes, const context::Context &context) noexcept + { + this->Record(value, common::KeyValueIterableView{attributes}, context); + } + + void Record(T value, + std::initializer_list> + attributes) noexcept + { + this->Record(value, nostd::span>{ + attributes.begin(), attributes.end()}); + } + + void Record( + T value, + std::initializer_list> attributes, + const context::Context &context) noexcept + { + this->Record(value, + nostd::span>{ + attributes.begin(), attributes.end()}, + context); + } +}; +#endif + } // namespace metrics OPENTELEMETRY_END_NAMESPACE diff --git a/examples/common/metrics_foo_library/foo_library.cc b/examples/common/metrics_foo_library/foo_library.cc index c4be2b530f..e288615293 100644 --- a/examples/common/metrics_foo_library/foo_library.cc +++ b/examples/common/metrics_foo_library/foo_library.cc @@ -107,3 +107,22 @@ void foo_library::histogram_example(const std::string &name) std::this_thread::sleep_for(std::chrono::milliseconds(250)); } } + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 +void foo_library::gauge_example(const std::string &name) +{ + std::string gauge_name = name + "_gauge"; + auto provider = metrics_api::Provider::GetMeterProvider(); + opentelemetry::nostd::shared_ptr meter = provider->GetMeter(name, "1.2.0"); + auto gauge = meter->CreateInt64Gauge(gauge_name, "des", "unit"); + auto context = opentelemetry::context::Context{}; + for (uint32_t i = 0; i < 20; ++i) + { + int64_t val = (rand() % 100) + 100; + std::map labels = get_random_attr(); + auto labelkv = opentelemetry::common::KeyValueIterableView{labels}; + gauge->Record(val, labelkv, context); + std::this_thread::sleep_for(std::chrono::milliseconds(250)); + } +} +#endif diff --git a/examples/common/metrics_foo_library/foo_library.h b/examples/common/metrics_foo_library/foo_library.h index 217f91671b..05f0f16c23 100644 --- a/examples/common/metrics_foo_library/foo_library.h +++ b/examples/common/metrics_foo_library/foo_library.h @@ -11,4 +11,7 @@ class foo_library static void counter_example(const std::string &name); static void histogram_example(const std::string &name); static void observable_counter_example(const std::string &name); +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + static void gauge_example(const std::string &name); +#endif }; diff --git a/examples/metrics_simple/metrics_ostream.cc b/examples/metrics_simple/metrics_ostream.cc index 5bdc7339eb..6d8c1ef6e0 100644 --- a/examples/metrics_simple/metrics_ostream.cc +++ b/examples/metrics_simple/metrics_ostream.cc @@ -148,15 +148,27 @@ int main(int argc, char **argv) { foo_library::histogram_example(name); } +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + else if (example_type == "gauge") + { + foo_library::gauge_example(name); + } +#endif else { std::thread counter_example{&foo_library::counter_example, name}; std::thread observable_counter_example{&foo_library::observable_counter_example, name}; std::thread histogram_example{&foo_library::histogram_example, name}; +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + std::thread gauge_example{&foo_library::gauge_example, name}; +#endif counter_example.join(); observable_counter_example.join(); histogram_example.join(); +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + gauge_example.join(); +#endif } CleanupMetrics(); diff --git a/examples/otlp/file_metric_main.cc b/examples/otlp/file_metric_main.cc index ce259005be..48be48171e 100644 --- a/examples/otlp/file_metric_main.cc +++ b/examples/otlp/file_metric_main.cc @@ -98,15 +98,27 @@ int main(int argc, char *argv[]) { foo_library::histogram_example(name); } +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + else if (example_type == "gauge") + { + foo_library::gauge_example(name); + } +#endif else { std::thread counter_example{&foo_library::counter_example, name}; std::thread observable_counter_example{&foo_library::observable_counter_example, name}; std::thread histogram_example{&foo_library::histogram_example, name}; +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + std::thread gauge_example{&foo_library::gauge_example, name}; +#endif counter_example.join(); observable_counter_example.join(); histogram_example.join(); +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + gauge_example.join(); +#endif } CleanupMetrics(); diff --git a/examples/otlp/grpc_metric_main.cc b/examples/otlp/grpc_metric_main.cc index 60d59d1e28..804bb91014 100644 --- a/examples/otlp/grpc_metric_main.cc +++ b/examples/otlp/grpc_metric_main.cc @@ -93,15 +93,27 @@ int main(int argc, char *argv[]) { foo_library::histogram_example(name); } +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + else if (example_type == "gauge") + { + foo_library::gauge_example(name); + } +#endif else { std::thread counter_example{&foo_library::counter_example, name}; std::thread observable_counter_example{&foo_library::observable_counter_example, name}; std::thread histogram_example{&foo_library::histogram_example, name}; +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + std::thread gauge_example{&foo_library::gauge_example, name}; +#endif counter_example.join(); observable_counter_example.join(); histogram_example.join(); +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + gauge_example.join(); +#endif } CleanupMetrics(); diff --git a/examples/otlp/http_metric_main.cc b/examples/otlp/http_metric_main.cc index 53f5fe38bc..f7afc975ac 100644 --- a/examples/otlp/http_metric_main.cc +++ b/examples/otlp/http_metric_main.cc @@ -133,15 +133,27 @@ int main(int argc, char *argv[]) { foo_library::histogram_example(name); } +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + else if (example_type == "gauge") + { + foo_library::gauge_example(name); + } +#endif else { std::thread counter_example{&foo_library::counter_example, name}; std::thread observable_counter_example{&foo_library::observable_counter_example, name}; std::thread histogram_example{&foo_library::histogram_example, name}; +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + std::thread gauge_example{&foo_library::gauge_example, name}; +#endif counter_example.join(); observable_counter_example.join(); histogram_example.join(); +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + gauge_example.join(); +#endif } CleanupMetrics(); diff --git a/exporters/otlp/src/otlp_metric_utils.cc b/exporters/otlp/src/otlp_metric_utils.cc index da162d117e..c8502d65c5 100644 --- a/exporters/otlp/src/otlp_metric_utils.cc +++ b/exporters/otlp/src/otlp_metric_utils.cc @@ -297,6 +297,7 @@ sdk::metrics::AggregationTemporality OtlpMetricUtils::DeltaTemporalitySelector( case sdk::metrics::InstrumentType::kObservableCounter: case sdk::metrics::InstrumentType::kHistogram: case sdk::metrics::InstrumentType::kObservableGauge: + case sdk::metrics::InstrumentType::kGauge: return sdk::metrics::AggregationTemporality::kDelta; case sdk::metrics::InstrumentType::kUpDownCounter: case sdk::metrics::InstrumentType::kObservableUpDownCounter: @@ -320,6 +321,7 @@ sdk::metrics::AggregationTemporality OtlpMetricUtils::LowMemoryTemporalitySelect case sdk::metrics::InstrumentType::kHistogram: return sdk::metrics::AggregationTemporality::kDelta; case sdk::metrics::InstrumentType::kObservableCounter: + case sdk::metrics::InstrumentType::kGauge: case sdk::metrics::InstrumentType::kObservableGauge: case sdk::metrics::InstrumentType::kUpDownCounter: case sdk::metrics::InstrumentType::kObservableUpDownCounter: diff --git a/sdk/include/opentelemetry/sdk/metrics/aggregation/default_aggregation.h b/sdk/include/opentelemetry/sdk/metrics/aggregation/default_aggregation.h index 4f3346707f..b33afb9d4e 100644 --- a/sdk/include/opentelemetry/sdk/metrics/aggregation/default_aggregation.h +++ b/sdk/include/opentelemetry/sdk/metrics/aggregation/default_aggregation.h @@ -180,6 +180,7 @@ class DefaultAggregation return AggregationType::kSum; case InstrumentType::kHistogram: return AggregationType::kHistogram; + case InstrumentType::kGauge: case InstrumentType::kObservableGauge: return AggregationType::kLastValue; default: diff --git a/sdk/include/opentelemetry/sdk/metrics/instruments.h b/sdk/include/opentelemetry/sdk/metrics/instruments.h index d7c6870945..76ad07b2e3 100644 --- a/sdk/include/opentelemetry/sdk/metrics/instruments.h +++ b/sdk/include/opentelemetry/sdk/metrics/instruments.h @@ -21,7 +21,8 @@ enum class InstrumentType kUpDownCounter, kObservableCounter, kObservableGauge, - kObservableUpDownCounter + kObservableUpDownCounter, + kGauge }; enum class InstrumentClass diff --git a/sdk/include/opentelemetry/sdk/metrics/meter.h b/sdk/include/opentelemetry/sdk/metrics/meter.h index b29bede012..2e9153e151 100644 --- a/sdk/include/opentelemetry/sdk/metrics/meter.h +++ b/sdk/include/opentelemetry/sdk/metrics/meter.h @@ -75,6 +75,18 @@ class Meter final : public opentelemetry::metrics::Meter nostd::string_view description = "", nostd::string_view unit = "") noexcept override; +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + nostd::unique_ptr> CreateInt64Gauge( + nostd::string_view name, + nostd::string_view description = "", + nostd::string_view unit = "") noexcept override; + + nostd::unique_ptr> CreateDoubleGauge( + nostd::string_view name, + nostd::string_view description = "", + nostd::string_view unit = "") noexcept override; +#endif + nostd::shared_ptr CreateInt64ObservableGauge( nostd::string_view name, nostd::string_view description = "", diff --git a/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h b/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h index 039a37e748..ff5eaeb282 100644 --- a/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h +++ b/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h @@ -100,6 +100,40 @@ class DoubleUpDownCounter : public Synchronous, public opentelemetry::metrics::U void Add(double value, const opentelemetry::context::Context &context) noexcept override; }; +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 +class LongGauge : public Synchronous, public opentelemetry::metrics::Gauge +{ +public: + LongGauge(const InstrumentDescriptor &instrument_descriptor, + std::unique_ptr storage); + + void Record(int64_t value, + const opentelemetry::common::KeyValueIterable &attributes) noexcept override; + void Record(int64_t value, + const opentelemetry::common::KeyValueIterable &attributes, + const opentelemetry::context::Context &context) noexcept override; + + void Record(int64_t value) noexcept override; + void Record(int64_t value, const opentelemetry::context::Context &context) noexcept override; +}; + +class DoubleGauge : public Synchronous, public opentelemetry::metrics::Gauge +{ +public: + DoubleGauge(const InstrumentDescriptor &instrument_descriptor, + std::unique_ptr storage); + + void Record(double value, + const opentelemetry::common::KeyValueIterable &attributes) noexcept override; + void Record(double value, + const opentelemetry::common::KeyValueIterable &attributes, + const opentelemetry::context::Context &context) noexcept override; + + void Record(double value) noexcept override; + void Record(double value, const opentelemetry::context::Context &context) noexcept override; +}; +#endif + class LongHistogram : public Synchronous, public opentelemetry::metrics::Histogram { public: diff --git a/sdk/src/metrics/meter.cc b/sdk/src/metrics/meter.cc index c61f3a8d31..6d09f264db 100644 --- a/sdk/src/metrics/meter.cc +++ b/sdk/src/metrics/meter.cc @@ -186,6 +186,50 @@ opentelemetry::nostd::unique_ptr> Meter::CreateDouble new DoubleHistogram(instrument_descriptor, std::move(storage))}; } +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 +opentelemetry::nostd::unique_ptr> Meter::CreateInt64Gauge( + opentelemetry::nostd::string_view name, + opentelemetry::nostd::string_view description, + opentelemetry::nostd::string_view unit) noexcept +{ + if (!ValidateInstrument(name, description, unit)) + { + OTEL_INTERNAL_LOG_ERROR("Meter::CreateInt64Gauge - failed. Invalid parameters." + << name << " " << description << " " << unit + << ". Measurements won't be recorded."); + return opentelemetry::nostd::unique_ptr>( + new metrics::NoopGauge(name, description, unit)); + } + InstrumentDescriptor instrument_descriptor = { + std::string{name.data(), name.size()}, std::string{description.data(), description.size()}, + std::string{unit.data(), unit.size()}, InstrumentType::kGauge, InstrumentValueType::kLong}; + auto storage = RegisterSyncMetricStorage(instrument_descriptor); + return opentelemetry::nostd::unique_ptr>{ + new LongGauge(instrument_descriptor, std::move(storage))}; +} + +opentelemetry::nostd::unique_ptr> Meter::CreateDoubleGauge( + opentelemetry::nostd::string_view name, + opentelemetry::nostd::string_view description, + opentelemetry::nostd::string_view unit) noexcept +{ + if (!ValidateInstrument(name, description, unit)) + { + OTEL_INTERNAL_LOG_ERROR("Meter::CreateDoubleGauge - failed. Invalid parameters." + << name << " " << description << " " << unit + << ". Measurements won't be recorded."); + return opentelemetry::nostd::unique_ptr>( + new metrics::NoopGauge(name, description, unit)); + } + InstrumentDescriptor instrument_descriptor = { + std::string{name.data(), name.size()}, std::string{description.data(), description.size()}, + std::string{unit.data(), unit.size()}, InstrumentType::kGauge, InstrumentValueType::kDouble}; + auto storage = RegisterSyncMetricStorage(instrument_descriptor); + return opentelemetry::nostd::unique_ptr>{ + new DoubleGauge(instrument_descriptor, std::move(storage))}; +} +#endif + opentelemetry::nostd::shared_ptr Meter::CreateInt64ObservableGauge(opentelemetry::nostd::string_view name, opentelemetry::nostd::string_view description, diff --git a/sdk/src/metrics/state/metric_collector.cc b/sdk/src/metrics/state/metric_collector.cc index 2a799b7fda..35d5e53939 100644 --- a/sdk/src/metrics/state/metric_collector.cc +++ b/sdk/src/metrics/state/metric_collector.cc @@ -36,7 +36,18 @@ MetricCollector::MetricCollector(opentelemetry::sdk::metrics::MeterContext *cont AggregationTemporality MetricCollector::GetAggregationTemporality( InstrumentType instrument_type) noexcept { - return metric_reader_->GetAggregationTemporality(instrument_type); + auto aggregation_temporality = metric_reader_->GetAggregationTemporality(instrument_type); + if (aggregation_temporality == AggregationTemporality::kDelta && + instrument_type == InstrumentType::kGauge) + { + OTEL_INTERNAL_LOG_ERROR( + "[MetricCollector::GetAggregationTemporality] - Error getting aggregation temporality." + << "Delta temporality for Synchronous Gauge is currently not supported, using cumulative " + "temporality"); + + return AggregationTemporality::kCumulative; + } + return aggregation_temporality; } MetricProducer::Result MetricCollector::Produce() noexcept diff --git a/sdk/src/metrics/sync_instruments.cc b/sdk/src/metrics/sync_instruments.cc index 56429a079f..de66e93054 100644 --- a/sdk/src/metrics/sync_instruments.cc +++ b/sdk/src/metrics/sync_instruments.cc @@ -292,6 +292,127 @@ void DoubleUpDownCounter::Add(double value, const opentelemetry::context::Contex return storage_->RecordDouble(value, context); } +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 +LongGauge::LongGauge(const InstrumentDescriptor &instrument_descriptor, + std::unique_ptr storage) + : Synchronous(instrument_descriptor, std::move(storage)) +{ + if (!storage_) + { + OTEL_INTERNAL_LOG_ERROR("[LongGauge::LongGauge] - Error constructing LongGauge." + << "The metric storage is invalid for " << instrument_descriptor.name_); + } +} + +void LongGauge::Record(int64_t value, + const opentelemetry::common::KeyValueIterable &attributes) noexcept +{ + auto context = opentelemetry::context::Context{}; + if (!storage_) + { + OTEL_INTERNAL_LOG_WARN("[LongGauge::Record(V,A)] Value not recorded - invalid storage for: " + << instrument_descriptor_.name_); + return; + } + return storage_->RecordLong(value, attributes, context); +} + +void LongGauge::Record(int64_t value, + const opentelemetry::common::KeyValueIterable &attributes, + const opentelemetry::context::Context &context) noexcept +{ + if (!storage_) + { + OTEL_INTERNAL_LOG_WARN("[LongGauge::Record(V,A,C)] Value not recorded - invalid storage for: " + << instrument_descriptor_.name_); + return; + } + return storage_->RecordLong(value, attributes, context); +} + +void LongGauge::Record(int64_t value) noexcept +{ + auto context = opentelemetry::context::Context{}; + if (!storage_) + { + OTEL_INTERNAL_LOG_WARN("[LongGauge::Record(V)] Value not recorded - invalid storage for: " + << instrument_descriptor_.name_); + return; + } + return storage_->RecordLong(value, context); +} + +void LongGauge::Record(int64_t value, const opentelemetry::context::Context &context) noexcept +{ + if (!storage_) + { + OTEL_INTERNAL_LOG_WARN("[LongGauge::Record(V,C)] Value not recorded - invalid storage for: " + << instrument_descriptor_.name_); + return; + } + return storage_->RecordLong(value, context); +} + +DoubleGauge::DoubleGauge(const InstrumentDescriptor &instrument_descriptor, + std::unique_ptr storage) + : Synchronous(instrument_descriptor, std::move(storage)) +{ + if (!storage_) + { + OTEL_INTERNAL_LOG_ERROR("[DoubleGauge::DoubleGauge] - Error constructing DoubleUpDownCounter." + << "The metric storage is invalid for " << instrument_descriptor.name_); + } +} + +void DoubleGauge::Record(double value, + const opentelemetry::common::KeyValueIterable &attributes) noexcept +{ + if (!storage_) + { + OTEL_INTERNAL_LOG_WARN("[DoubleGauge::Record(V,A)] Value not recorded - invalid storage for: " + << instrument_descriptor_.name_); + } + auto context = opentelemetry::context::Context{}; + return storage_->RecordDouble(value, attributes, context); +} + +void DoubleGauge::Record(double value, + const opentelemetry::common::KeyValueIterable &attributes, + const opentelemetry::context::Context &context) noexcept +{ + if (!storage_) + { + OTEL_INTERNAL_LOG_WARN("[DoubleGauge::Record(V,A,C)] Value not recorded - invalid storage for: " + << instrument_descriptor_.name_); + return; + } + return storage_->RecordDouble(value, attributes, context); +} + +void DoubleGauge::Record(double value) noexcept +{ + if (!storage_) + { + OTEL_INTERNAL_LOG_WARN("[DoubleGauge::Record(V)] Value not recorded - invalid storage for: " + << instrument_descriptor_.name_); + return; + } + auto context = opentelemetry::context::Context{}; + return storage_->RecordDouble(value, context); +} + +void DoubleGauge::Record(double value, const opentelemetry::context::Context &context) noexcept +{ + if (!storage_) + { + OTEL_INTERNAL_LOG_WARN("[DoubleGauge::Record(V,C)] Value not recorded - invalid storage for: " + << instrument_descriptor_.name_); + return; + } + return storage_->RecordDouble(value, context); +} +#endif + LongHistogram::LongHistogram(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage) : Synchronous(instrument_descriptor, std::move(storage)) diff --git a/sdk/test/metrics/CMakeLists.txt b/sdk/test/metrics/CMakeLists.txt index ccc31de689..9effa73a4c 100644 --- a/sdk/test/metrics/CMakeLists.txt +++ b/sdk/test/metrics/CMakeLists.txt @@ -19,6 +19,7 @@ foreach( cardinality_limit_test histogram_test sync_metric_storage_counter_test + sync_metric_storage_gauge_test sync_metric_storage_histogram_test sync_metric_storage_up_down_counter_test async_metric_storage_test diff --git a/sdk/test/metrics/sync_instruments_test.cc b/sdk/test/metrics/sync_instruments_test.cc index fb59e1d033..22a05988dc 100644 --- a/sdk/test/metrics/sync_instruments_test.cc +++ b/sdk/test/metrics/sync_instruments_test.cc @@ -112,6 +112,45 @@ TEST(SyncInstruments, DoubleUpDownCounter) counter.Add(10.10, opentelemetry::common::KeyValueIterableView({})); } +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 +TEST(SyncInstruments, LongGauge) +{ + InstrumentDescriptor instrument_descriptor = {"long_gauge", "description", "1", + InstrumentType::kGauge, InstrumentValueType::kLong}; + std::unique_ptr metric_storage(new SyncMultiMetricStorage()); + LongGauge gauge(instrument_descriptor, std::move(metric_storage)); + gauge.Record(10); + gauge.Record(10, opentelemetry::context::Context{}); + + gauge.Record(10, opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}}), + opentelemetry::context::Context{}); + gauge.Record(10, + opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}})); + gauge.Record(10, opentelemetry::common::KeyValueIterableView({}), + opentelemetry::context::Context{}); + gauge.Record(10, opentelemetry::common::KeyValueIterableView({})); +} + +TEST(SyncInstruments, DoubleGauge) +{ + InstrumentDescriptor instrument_descriptor = { + "double_gauge", "description", "1", InstrumentType::kGauge, InstrumentValueType::kDouble}; + std::unique_ptr metric_storage(new SyncMultiMetricStorage()); + DoubleGauge gauge(instrument_descriptor, std::move(metric_storage)); + gauge.Record(10.10); + gauge.Record(10.10, opentelemetry::context::Context{}); + + gauge.Record(10.10, + opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}}), + opentelemetry::context::Context{}); + gauge.Record(10.10, + opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}})); + gauge.Record(10.10, opentelemetry::common::KeyValueIterableView({}), + opentelemetry::context::Context{}); + gauge.Record(10.10, opentelemetry::common::KeyValueIterableView({})); +} +#endif + TEST(SyncInstruments, LongHistogram) { InstrumentDescriptor instrument_descriptor = { diff --git a/sdk/test/metrics/sync_metric_storage_gauge_test.cc b/sdk/test/metrics/sync_metric_storage_gauge_test.cc new file mode 100644 index 0000000000..f826755af3 --- /dev/null +++ b/sdk/test/metrics/sync_metric_storage_gauge_test.cc @@ -0,0 +1,189 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include "common.h" + +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/state/sync_metric_storage.h" +#include "opentelemetry/sdk/metrics/view/attributes_processor.h" + +#include +#include +#include + +using namespace opentelemetry::sdk::metrics; +using namespace opentelemetry::common; +namespace nostd = opentelemetry::nostd; + +class WritableMetricStorageTestFixture : public ::testing::TestWithParam +{}; + +TEST_P(WritableMetricStorageTestFixture, LongGaugeLastValueAggregation) +{ +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + AggregationTemporality temporality = GetParam(); + auto sdk_start_ts = std::chrono::system_clock::now(); + InstrumentDescriptor instr_desc = {"name", "desc", "1unit", InstrumentType::kGauge, + InstrumentValueType::kLong}; + std::map attributes_roomA = {{"Room.id", "Rack A"}}; + std::map attributes_roomB = {{"Room.id", "Rack B"}}; + + std::unique_ptr default_attributes_processor{ + new DefaultAttributesProcessor{}}; + opentelemetry::sdk::metrics::SyncMetricStorage storage( + instr_desc, AggregationType::kLastValue, default_attributes_processor.get(), +# ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW + ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), +# endif + nullptr); + + int64_t bg_noise_level_1_roomA = 10; + int64_t bg_noise_level_1_roomB = 20; + + storage.RecordLong(bg_noise_level_1_roomA, + KeyValueIterableView>(attributes_roomA), + opentelemetry::context::Context{}); + storage.RecordLong(bg_noise_level_1_roomB, + KeyValueIterableView>(attributes_roomB), + opentelemetry::context::Context{}); + + int64_t bg_noise_level_2_roomA = 43; + int64_t bg_noise_level_2_roomB = 25; + + storage.RecordLong(bg_noise_level_2_roomA, + KeyValueIterableView>(attributes_roomA), + opentelemetry::context::Context{}); + storage.RecordLong(bg_noise_level_2_roomB, + KeyValueIterableView>(attributes_roomB), + opentelemetry::context::Context{}); + + std::shared_ptr collector(new MockCollectorHandle(temporality)); + std::vector> collectors; + collectors.push_back(collector); + + // Some computation here + auto collection_ts = std::chrono::system_clock::now(); + size_t count_attributes = 0; + storage.Collect( + collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData &metric_data) { + for (const auto &data_attr : metric_data.point_data_attr_) + { + auto lastvalue_data = opentelemetry::nostd::get(data_attr.point_data); + if (opentelemetry::nostd::get( + data_attr.attributes.find("Room.id")->second) == "Rack A") + { + if (temporality == AggregationTemporality::kCumulative) + { + EXPECT_EQ(opentelemetry::nostd::get(lastvalue_data.value_), + bg_noise_level_2_roomA); + } + count_attributes++; + } + else if (opentelemetry::nostd::get( + data_attr.attributes.find("Room.id")->second) == "Rack B") + { + if (temporality == AggregationTemporality::kCumulative) + { + EXPECT_EQ(opentelemetry::nostd::get(lastvalue_data.value_), + bg_noise_level_2_roomB); + } + count_attributes++; + } + } + return true; + }); + EXPECT_EQ(count_attributes, 2); // RackA and RackB +#else + EXPECT_TRUE(true); +#endif +} + +INSTANTIATE_TEST_SUITE_P(WritableMetricStorageTestLong, + WritableMetricStorageTestFixture, + ::testing::Values(AggregationTemporality::kCumulative)); + +TEST_P(WritableMetricStorageTestFixture, DoubleGaugeLastValueAggregation) +{ +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + AggregationTemporality temporality = GetParam(); + auto sdk_start_ts = std::chrono::system_clock::now(); + InstrumentDescriptor instr_desc = {"name", "desc", "1unit", InstrumentType::kGauge, + InstrumentValueType::kDouble}; + std::map attributes_roomA = {{"Room.id", "Rack A"}}; + std::map attributes_roomB = {{"Room.id", "Rack B"}}; + + std::unique_ptr default_attributes_processor{ + new DefaultAttributesProcessor{}}; + opentelemetry::sdk::metrics::SyncMetricStorage storage( + instr_desc, AggregationType::kLastValue, default_attributes_processor.get(), +# ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW + ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), +# endif + nullptr); + + double bg_noise_level_1_roomA = 4.3; + double bg_noise_level_1_roomB = 2.5; + + storage.RecordDouble(bg_noise_level_1_roomA, + KeyValueIterableView>(attributes_roomA), + opentelemetry::context::Context{}); + storage.RecordDouble(bg_noise_level_1_roomB, + KeyValueIterableView>(attributes_roomB), + opentelemetry::context::Context{}); + + double bg_noise_level_2_roomA = 10.5; + double bg_noise_level_2_roomB = 20.5; + + storage.RecordDouble(bg_noise_level_2_roomA, + KeyValueIterableView>(attributes_roomA), + opentelemetry::context::Context{}); + storage.RecordDouble(bg_noise_level_2_roomB, + KeyValueIterableView>(attributes_roomB), + opentelemetry::context::Context{}); + + std::shared_ptr collector(new MockCollectorHandle(temporality)); + std::vector> collectors; + collectors.push_back(collector); + + // Some computation here + auto collection_ts = std::chrono::system_clock::now(); + size_t count_attributes = 0; + storage.Collect( + collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData &metric_data) { + for (const auto &data_attr : metric_data.point_data_attr_) + { + auto lastvalue_data = opentelemetry::nostd::get(data_attr.point_data); + if (opentelemetry::nostd::get( + data_attr.attributes.find("Room.id")->second) == "Rack A") + { + if (temporality == AggregationTemporality::kCumulative) + { + EXPECT_DOUBLE_EQ(opentelemetry::nostd::get(lastvalue_data.value_), + bg_noise_level_2_roomA); + } + count_attributes++; + } + else if (opentelemetry::nostd::get( + data_attr.attributes.find("Room.id")->second) == "Rack B") + { + if (temporality == AggregationTemporality::kCumulative) + { + EXPECT_DOUBLE_EQ(opentelemetry::nostd::get(lastvalue_data.value_), + bg_noise_level_2_roomB); + } + count_attributes++; + } + } + return true; + }); + EXPECT_EQ(count_attributes, 2); // RackA and RackB +#else + EXPECT_TRUE(true); +#endif +} + +INSTANTIATE_TEST_SUITE_P(WritableMetricStorageTestDouble, + WritableMetricStorageTestFixture, + ::testing::Values(AggregationTemporality::kCumulative)); From d16f7815effc1f6143066fb16b7a36542afdf47c Mon Sep 17 00:00:00 2001 From: "Claus F. Strasburger" <1156864+cfstras@users.noreply.github.com> Date: Tue, 5 Nov 2024 00:54:32 +0100 Subject: [PATCH 54/89] [BUILD] allow building with -DWITH_OTLP_HTTP_COMPRESSION=OFF without zlib (#3120) --- ext/src/http/client/curl/http_client_curl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/src/http/client/curl/http_client_curl.cc b/ext/src/http/client/curl/http_client_curl.cc index 22f20fb0e0..ae353c5509 100644 --- a/ext/src/http/client/curl/http_client_curl.cc +++ b/ext/src/http/client/curl/http_client_curl.cc @@ -3,7 +3,6 @@ #include #include -#include #include #include #include @@ -25,6 +24,7 @@ #include "opentelemetry/version.h" #ifdef ENABLE_OTLP_COMPRESSION_PREVIEW +# include # include #else # include "opentelemetry/sdk/common/global_log_handler.h" From 6fdf797acec6d8323e36de724dc60f024b85daae Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Wed, 6 Nov 2024 09:06:39 +0100 Subject: [PATCH 55/89] [CI] Comment the arm64 CI (#3125) --- .github/workflows/ci.yml | 62 +++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8c17bbece0..0cf9a5771f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,36 +7,38 @@ on: branches: [ main ] jobs: - arm64_test: - name: CMake test arm64 (with modern protobuf,grpc and abseil) - runs-on: actuated-arm64-4cpu-16gb - steps: - - uses: actions/checkout@v4 - with: - submodules: 'recursive' - - name: setup - env: - PROTOBUF_VERSION: '23.3' - ABSEIL_CPP_VERSION: '20230125.3' - CXX_STANDARD: '14' - CC: /usr/bin/gcc-10 - CXX: /usr/bin/g++-10 - run: | - sudo -E ./ci/setup_gcc10.sh - sudo -E ./ci/setup_cmake.sh - sudo -E ./ci/setup_ci_environment.sh - sudo -E ./ci/setup_googletest.sh - sudo -E ./ci/install_abseil.sh - sudo -E ./ci/install_protobuf.sh - - name: run otlp exporter tests - env: - CC: /usr/bin/gcc-10 - CXX: /usr/bin/g++-10 - WITH_ABSEIL: 'ON' - CXX_STANDARD: '14' - run: | - sudo -E ./ci/setup_grpc.sh -m -p protobuf -p abseil-cpp - ./ci/do_ci.sh cmake.exporter.otprotocol.test + +# Commented 2024-11-06, lack of workers in github causes CI failures +# arm64_test: +# name: CMake test arm64 (with modern protobuf,grpc and abseil) +# runs-on: actuated-arm64-4cpu-16gb +# steps: +# - uses: actions/checkout@v4 +# with: +# submodules: 'recursive' +# - name: setup +# env: +# PROTOBUF_VERSION: '23.3' +# ABSEIL_CPP_VERSION: '20230125.3' +# CXX_STANDARD: '14' +# CC: /usr/bin/gcc-10 +# CXX: /usr/bin/g++-10 +# run: | +# sudo -E ./ci/setup_gcc10.sh +# sudo -E ./ci/setup_cmake.sh +# sudo -E ./ci/setup_ci_environment.sh +# sudo -E ./ci/setup_googletest.sh +# sudo -E ./ci/install_abseil.sh +# sudo -E ./ci/install_protobuf.sh +# - name: run otlp exporter tests +# env: +# CC: /usr/bin/gcc-10 +# CXX: /usr/bin/g++-10 +# WITH_ABSEIL: 'ON' +# CXX_STANDARD: '14' +# run: | +# sudo -E ./ci/setup_grpc.sh -m -p protobuf -p abseil-cpp +# ./ci/do_ci.sh cmake.exporter.otprotocol.test cmake_test: name: CMake test (without otlp-exporter) From be1f43ca00b57902899d5ba7bf5759486613659a Mon Sep 17 00:00:00 2001 From: Pranav Sharma Date: Wed, 6 Nov 2024 12:35:40 -0500 Subject: [PATCH 56/89] [API] Comply with W3C Trace Context (#3115) --- .github/workflows/ci.yml | 39 ++++++++++++ CHANGELOG.md | 3 + .../opentelemetry/common/string_util.h | 4 +- .../trace/propagation/http_trace_context.h | 42 ++++++++----- api/include/opentelemetry/trace/trace_state.h | 3 +- api/test/common/string_util_test.cc | 8 ++- api/test/trace/propagation/detail/BUILD | 16 +++++ .../trace/propagation/detail/CMakeLists.txt | 2 +- .../trace/propagation/detail/string_test.cc | 62 +++++++++++++++++++ ci/do_ci.sh | 10 +++ .../ext/http/server/http_server.h | 10 ++- ext/test/w3c_tracecontext_test/README.md | 9 ++- ext/test/w3c_tracecontext_test/main.cc | 50 +++++++++++---- 13 files changed, 223 insertions(+), 35 deletions(-) create mode 100644 api/test/trace/propagation/detail/string_test.cc diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0cf9a5771f..26dda5449c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -925,3 +925,42 @@ jobs: - name: run ./ci/docfx.cmd shell: cmd run: ./ci/docfx.cmd + + w3c_trace_context_compliance_v1: + name: W3C Distributed Tracing Validation V1 + runs-on: ubuntu-latest + steps: + - name: Checkout open-telemetry/opentelemetry-cpp + uses: actions/checkout@v4 + with: + submodules: 'recursive' + - name: setup + env: + CC: /usr/bin/gcc-10 + CXX: /usr/bin/g++-10 + run: | + sudo -E ./ci/setup_googletest.sh + sudo -E ./ci/setup_ci_environment.sh + - name: run w3c trace-context test server (background) + env: + CXX_STANDARD: '14' + run: | + ./ci/do_ci.sh cmake.w3c.trace-context.build-server + cd $HOME/build/ext/test/w3c_tracecontext_test + ./w3c_tracecontext_test & + - name: Checkout w3c/trace-context repo + uses: actions/checkout@v4 + with: + repository: w3c/trace-context + path: trace-context + - name: install dependencies + run: | + sudo apt update && sudo apt install python3-pip + sudo pip3 install aiohttp + - name: run w3c trace-context test suite + env: + SPEC_LEVEL: 1 + run: + | + python ${GITHUB_WORKSPACE}/trace-context/test/test.py http://localhost:30000/test TraceContextTest AdvancedTest + curl http://localhost:30000/stop diff --git a/CHANGELOG.md b/CHANGELOG.md index 540479eb97..650aebcea5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,9 @@ Increment the: ## [Unreleased] +* [API] Comply with W3C Trace Context [#3115](https://github.com/open-telemetry/opentelemetry-cpp/pull/3115) + * Also adds CI check to ensure continued compliance + * [API] Jaeger Propagator should not be deprecated [#3086](https://github.com/open-telemetry/opentelemetry-cpp/pull/3086) diff --git a/api/include/opentelemetry/common/string_util.h b/api/include/opentelemetry/common/string_util.h index a7070a0acd..273a65272b 100644 --- a/api/include/opentelemetry/common/string_util.h +++ b/api/include/opentelemetry/common/string_util.h @@ -15,11 +15,11 @@ class StringUtil public: static nostd::string_view Trim(nostd::string_view str, size_t left, size_t right) noexcept { - while (left <= right && str[static_cast(left)] == ' ') + while (left <= right && isspace(str[left])) { left++; } - while (left <= right && str[static_cast(right)] == ' ') + while (left <= right && isspace(str[right])) { right--; } diff --git a/api/include/opentelemetry/trace/propagation/http_trace_context.h b/api/include/opentelemetry/trace/propagation/http_trace_context.h index a6b7e3b219..81d4c308ec 100644 --- a/api/include/opentelemetry/trace/propagation/http_trace_context.h +++ b/api/include/opentelemetry/trace/propagation/http_trace_context.h @@ -86,14 +86,8 @@ class HttpTraceContext : public context::propagation::TextMapPropagator } private: - static constexpr uint8_t kInvalidVersion = 0xFF; - - static bool IsValidVersion(nostd::string_view version_hex) - { - uint8_t version; - detail::HexToBinary(version_hex, &version, sizeof(version)); - return version != kInvalidVersion; - } + static constexpr uint8_t kInvalidVersion = 0xFF; + static constexpr uint8_t kDefaultAssumedVersion = 0x00; static void InjectImpl(context::propagation::TextMapCarrier &carrier, const SpanContext &span_context) @@ -122,11 +116,6 @@ class HttpTraceContext : public context::propagation::TextMapPropagator static SpanContext ExtractContextFromTraceHeaders(nostd::string_view trace_parent, nostd::string_view trace_state) { - if (trace_parent.size() != kTraceParentSize) - { - return SpanContext::GetInvalid(); - } - std::array fields{}; if (detail::SplitString(trace_parent, '-', fields.data(), 4) != 4) { @@ -150,11 +139,33 @@ class HttpTraceContext : public context::propagation::TextMapPropagator return SpanContext::GetInvalid(); } - if (!IsValidVersion(version_hex)) + // hex is valid, convert it to binary + uint8_t version_binary; + detail::HexToBinary(version_hex, &version_binary, sizeof(version_binary)); + if (version_binary == kInvalidVersion) { + // invalid version encountered return SpanContext::GetInvalid(); } + // See https://www.w3.org/TR/trace-context/#versioning-of-traceparent + if (version_binary > kDefaultAssumedVersion) + { + // higher than default version detected + if (trace_parent.size() < kTraceParentSize) + { + return SpanContext::GetInvalid(); + } + } + else + { + // version is either lower or same as the default version + if (trace_parent.size() != kTraceParentSize) + { + return SpanContext::GetInvalid(); + } + } + TraceId trace_id = TraceIdFromHex(trace_id_hex); SpanId span_id = SpanIdFromHex(span_id_hex); @@ -169,7 +180,8 @@ class HttpTraceContext : public context::propagation::TextMapPropagator static SpanContext ExtractImpl(const context::propagation::TextMapCarrier &carrier) { - nostd::string_view trace_parent = carrier.Get(kTraceParent); + // Get trace_parent after trimming the leading and trailing whitespaces + nostd::string_view trace_parent = common::StringUtil::Trim(carrier.Get(kTraceParent)); nostd::string_view trace_state = carrier.Get(kTraceState); if (trace_parent == "") { diff --git a/api/include/opentelemetry/trace/trace_state.h b/api/include/opentelemetry/trace/trace_state.h index 753f48c99e..df7a0e0fe9 100644 --- a/api/include/opentelemetry/trace/trace_state.h +++ b/api/include/opentelemetry/trace/trace_state.h @@ -59,7 +59,8 @@ class OPENTELEMETRY_EXPORT TraceState size_t cnt = kv_str_tokenizer.NumTokens(); // upper bound on number of kv pairs if (cnt > kMaxKeyValuePairs) { - cnt = kMaxKeyValuePairs; + // trace state should be discarded if count exceeds + return GetDefault(); } nostd::shared_ptr ts(new TraceState(cnt)); diff --git a/api/test/common/string_util_test.cc b/api/test/common/string_util_test.cc index f074d4fbe3..8746607766 100644 --- a/api/test/common/string_util_test.cc +++ b/api/test/common/string_util_test.cc @@ -35,9 +35,15 @@ TEST(StringUtilTest, TrimString) {"k1=v1,k2=v2, k3=v3", "k1=v1,k2=v2, k3=v3"}, {" k1=v1", "k1=v1"}, {"k1=v1 ", "k1=v1"}, + {"k1=v1\t", "k1=v1"}, + {"\t k1=v1 \t", "k1=v1"}, + {"\t\t k1=v1\t ", "k1=v1"}, + {"\t\t k1=v1\t ,k2=v2", "k1=v1\t ,k2=v2"}, {" k1=v1 ", "k1=v1"}, {" ", ""}, - {"", ""}}; + {"", ""}, + {"\n_some string_\t", "_some string_"}}; + for (auto &testcase : testcases) { EXPECT_EQ(StringUtil::Trim(testcase.input), testcase.expected); diff --git a/api/test/trace/propagation/detail/BUILD b/api/test/trace/propagation/detail/BUILD index a082586650..322c892937 100644 --- a/api/test/trace/propagation/detail/BUILD +++ b/api/test/trace/propagation/detail/BUILD @@ -18,3 +18,19 @@ cc_test( "@com_google_googletest//:gtest_main", ], ) + +cc_test( + name = "string_test", + srcs = [ + "string_test.cc", + ], + tags = [ + "api", + "test", + "trace", + ], + deps = [ + "//api", + "@com_google_googletest//:gtest_main", + ], +) diff --git a/api/test/trace/propagation/detail/CMakeLists.txt b/api/test/trace/propagation/detail/CMakeLists.txt index 34e2f6ae40..c70478efa1 100644 --- a/api/test/trace/propagation/detail/CMakeLists.txt +++ b/api/test/trace/propagation/detail/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 -foreach(testname hex_test) +foreach(testname hex_test string_test) add_executable(${testname} "${testname}.cc") target_link_libraries(${testname} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} opentelemetry_api) diff --git a/api/test/trace/propagation/detail/string_test.cc b/api/test/trace/propagation/detail/string_test.cc new file mode 100644 index 0000000000..67a48a354c --- /dev/null +++ b/api/test/trace/propagation/detail/string_test.cc @@ -0,0 +1,62 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include +#include +#include + +#include "opentelemetry/nostd/string_view.h" + +using namespace opentelemetry; + +namespace +{ + +struct SplitStringTestData +{ + opentelemetry::nostd::string_view input; + char separator; + size_t max_count; + size_t expected_number_strings; + + // When googletest registers parameterized tests, it uses this method to format the parameters. + // The default implementation prints hex dump of all bytes in the object. If there is any padding + // in these bytes, valgrind reports this as a warning - "Use of uninitialized bytes". + // See https://github.com/google/googletest/issues/3805. + friend void PrintTo(const SplitStringTestData &data, std::ostream *os) + { + *os << "(" << data.input << "," << data.separator << "," << data.max_count << "," + << data.expected_number_strings << ")"; + } +}; + +const SplitStringTestData split_string_test_cases[] = { + {"foo,bar,baz", ',', 4, 3}, + {"foo,bar,baz,foobar", ',', 4, 4}, + {"foo,bar,baz,foobar", '.', 4, 1}, + {"foo,bar,baz,", ',', 4, 4}, + {"foo,bar,baz,", ',', 2, 2}, + {"foo ,bar, baz ", ',', 4, 3}, + {"foo ,bar, baz ", ',', 4, 3}, + {"00-0af7651916cd43dd8448eb211c80319c-00f067aa0ba902b7-01", '-', 4, 4}, +}; +} // namespace + +// Test fixture +class SplitStringTestFixture : public ::testing::TestWithParam +{}; + +TEST_P(SplitStringTestFixture, SplitsAsExpected) +{ + const SplitStringTestData test_param = GetParam(); + std::vector fields(test_param.expected_number_strings); + size_t got_splits_num = opentelemetry::trace::propagation::detail::SplitString( + test_param.input, test_param.separator, fields.data(), test_param.max_count); + + // Assert on the output + EXPECT_EQ(got_splits_num, test_param.expected_number_strings); +} + +INSTANTIATE_TEST_SUITE_P(SplitStringTestCases, + SplitStringTestFixture, + ::testing::ValuesIn(split_string_test_cases)); diff --git a/ci/do_ci.sh b/ci/do_ci.sh index c31d5e887a..11dbe4ef80 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -393,6 +393,16 @@ elif [[ "$1" == "cmake.exporter.otprotocol.with_async_export.test" ]]; then make -j $(nproc) cd exporters/otlp && make test exit 0 +elif [[ "$1" == "cmake.w3c.trace-context.build-server" ]]; then + echo "Building w3c trace context test server" + cd "${BUILD_DIR}" + rm -rf * + cmake "${CMAKE_OPTIONS[@]}" \ + -DBUILD_W3CTRACECONTEXT_TEST=ON \ + -DCMAKE_CXX_STANDARD=${CXX_STANDARD} \ + "${SRC_DIR}" + eval "$MAKE_COMMAND" + exit 0 elif [[ "$1" == "cmake.do_not_install.test" ]]; then cd "${BUILD_DIR}" rm -rf * diff --git a/ext/include/opentelemetry/ext/http/server/http_server.h b/ext/include/opentelemetry/ext/http/server/http_server.h index 5ea7debc43..21efac94e0 100644 --- a/ext/include/opentelemetry/ext/http/server/http_server.h +++ b/ext/include/opentelemetry/ext/http/server/http_server.h @@ -648,7 +648,15 @@ class HttpServer : private SocketTools::Reactor::SocketCallback { ptr++; } - conn.request.headers[name] = std::string(begin, ptr); + if (!conn.request.headers[name].empty()) + { + conn.request.headers[name] = + conn.request.headers[name].append(",").append(std::string(begin, ptr)); + } + else + { + conn.request.headers[name] = std::string(begin, ptr); + } if (*ptr == '\r') { ptr++; diff --git a/ext/test/w3c_tracecontext_test/README.md b/ext/test/w3c_tracecontext_test/README.md index 8eda092f82..6f4db4513d 100644 --- a/ext/test/w3c_tracecontext_test/README.md +++ b/ext/test/w3c_tracecontext_test/README.md @@ -3,7 +3,7 @@ This test application is intended to be used as a test service for the [W3C Distributed Tracing Validation Service](https://github.com/w3c/trace-context/tree/master/test). It is -implemented according to [this +implemented according to [these instructions](https://github.com/w3c/trace-context/tree/master/test#implement-test-service). ## Usage @@ -47,4 +47,9 @@ docker run --network host w3c_driver http://localhost:31339/test 3: The validation service will run the test suite and print detailed test results. -4: Stop the test service by pressing enter. +4: Stop the test service by invoking `/stop`. Make sure to use the correct port number. + +```sh +# Assuming the service is currently running at port 30000 +curl http://localhost:30000/stop +``` diff --git a/ext/test/w3c_tracecontext_test/main.cc b/ext/test/w3c_tracecontext_test/main.cc index fed07a2398..d2ed772510 100644 --- a/ext/test/w3c_tracecontext_test/main.cc +++ b/ext/test/w3c_tracecontext_test/main.cc @@ -3,8 +3,6 @@ #include #include -#include -#include #include #include #include @@ -12,19 +10,16 @@ #include #include -#include "opentelemetry/context/context_value.h" #include "opentelemetry/context/propagation/text_map_propagator.h" #include "opentelemetry/context/runtime_context.h" #include "opentelemetry/exporters/ostream/span_exporter.h" #include "opentelemetry/ext/http/client/curl/http_client_curl.h" -#include "opentelemetry/ext/http/client/curl/http_operation_curl.h" #include "opentelemetry/ext/http/client/http_client.h" #include "opentelemetry/ext/http/server/http_server.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/trace/exporter.h" #include "opentelemetry/sdk/trace/processor.h" -#include "opentelemetry/sdk/trace/recordable.h" #include "opentelemetry/sdk/trace/simple_processor.h" #include "opentelemetry/sdk/trace/tracer_context.h" #include "opentelemetry/sdk/trace/tracer_provider.h" @@ -45,16 +40,34 @@ namespace { static trace_api::propagation::HttpTraceContext propagator_format; +static bool equalsIgnoreCase(const std::string &str1, const std::string &str2) +{ + if (str1.length() != str2.length()) + { + return false; + } + for (size_t i = 0; i < str1.length(); i++) + { + if (tolower(str1[i]) != tolower(str2[i])) + { + return false; + } + } + return true; +} + class TextMapCarrierTest : public context::propagation::TextMapCarrier { public: TextMapCarrierTest(std::map &headers) : headers_(headers) {} nostd::string_view Get(nostd::string_view key) const noexcept override { - auto it = headers_.find(std::string(key)); - if (it != headers_.end()) + for (const auto &elem : headers_) { - return nostd::string_view(it->second); + if (equalsIgnoreCase(elem.first, std::string(key))) + { + return nostd::string_view(elem.second); + } } return ""; } @@ -161,6 +174,7 @@ int main(int argc, char *argv[]) constexpr char default_host[] = "localhost"; constexpr uint16_t default_port = 30000; uint16_t port; + std::atomic_bool stop_server(false); // The port the validation service listens to can be specified via the command line. if (argc > 1) @@ -207,16 +221,28 @@ int main(int argc, char *argv[]) return 0; }}; + testing::HttpRequestCallback stop_cb{ + [&](testing::HttpRequest const & /*req*/, testing::HttpResponse &resp) { + std::cout << "Received request to stop server \n"; + stop_server.store(true); + resp.code = 200; + return 0; + }}; + server["/test"] = test_cb; + server["/stop"] = stop_cb; // Start server server.start(); std::cout << "Listening at http://" << default_host << ":" << port << "/test\n"; - // Wait for console input - std::cin.get(); - - // Stop server + // Wait for signal to stop server + while (!stop_server.load()) + { + std::this_thread::sleep_for(std::chrono::seconds(1)); + } + // received signal to stop server + std::cout << "Stopping server \n"; server.stop(); } From b0e8d7a57f81acb12c9d6c5bc7463fc4db83e172 Mon Sep 17 00:00:00 2001 From: Ehsan Saei <71217171+esigo@users.noreply.github.com> Date: Wed, 6 Nov 2024 21:20:33 +0100 Subject: [PATCH 57/89] [EXPORTER] bump prometheus to v1.3.0 (#3122) --- CHANGELOG.md | 3 + bazel/repository.bzl | 6 +- docs/maintaining-dependencies.md | 157 +++++++++++++++++++++++++++++++ third_party/prometheus-cpp | 2 +- third_party_release | 2 +- 5 files changed, 165 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 650aebcea5..04b1603c3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,9 @@ Important changes: as the Jaeger propagator can be used without the (now removed) Jaeger exporter. +* Upgrade to prometheus 1.3.0 + [#3122](https://github.com/open-telemetry/opentelemetry-cpp/pull/3122) + ## [1.17 2024-10-07] * [CI] Add a clang-tidy build diff --git a/bazel/repository.bzl b/bazel/repository.bzl index 508b95a39a..4827cffba3 100644 --- a/bazel/repository.bzl +++ b/bazel/repository.bzl @@ -110,10 +110,10 @@ def opentelemetry_cpp_deps(): maybe( http_archive, name = "com_github_jupp0r_prometheus_cpp", - sha256 = "48dbad454d314b836cc667ec4def93ec4a6e4255fc8387c20cacb3b8b6faee30", - strip_prefix = "prometheus-cpp-1.2.4", + sha256 = "ac6e958405a29fbbea9db70b00fa3c420e16ad32e1baf941ab233ba031dd72ee", + strip_prefix = "prometheus-cpp-1.3.0", urls = [ - "https://github.com/jupp0r/prometheus-cpp/archive/refs/tags/v1.2.4.tar.gz", + "https://github.com/jupp0r/prometheus-cpp/archive/refs/tags/v1.3.0.tar.gz", ], ) diff --git a/docs/maintaining-dependencies.md b/docs/maintaining-dependencies.md index 1c79810029..31a50db521 100644 --- a/docs/maintaining-dependencies.md +++ b/docs/maintaining-dependencies.md @@ -442,3 +442,160 @@ Last, in some special case like name collisions for a given symbol, the template itself may need to be adjusted for special logic. See for example how `messaging.client_id` is treated. + +## prometheus-cpp + +### Comments (prometheus-cpp) + +The `prometheus-cpp` library provides a C++ client for Prometheus, +facilitating the creation and registration of metrics that Prometheus scrapes. +`prometheus-cpp` is used as a git submodule under the `third_party` directory +for ease of inclusion in build system. + +### Origin (prometheus-cpp) + +The repository for `prometheus-cpp` can be found here: + +* [repository](https://github.com/jupp0r/prometheus-cpp) + +Check release notes at: + +* [release-notes](https://github.com/jupp0r/prometheus-cpp/releases) + +### Upgrade (prometheus-cpp) + +When upgrading `prometheus-cpp` to a newer release, +you’ll need to update a few key files in the codebase to reflect the new version. + +In this example, we upgrade from `v1.2.3` to `v1.2.4`. + +#### Directory `third_party/prometheus-cpp` + +`prometheus-cpp` is a `git submodule`, +so it needs to be pointed to the new release tag. + +```shell +cd third_party/prometheus-cpp +git log -1 +``` + +The current submodule should show something like: + +```shell +commit abcdef1234567890abcdef1234567890abcdef12 (HEAD, tag: v1.2.3) +Author: John Doe +Date: Fri Apr 25 17:55:35 2024 +0200 + + Minor fixes for performance and compatibility +``` + +Pull new tags: + +```shell +git pull --tag origin +``` + +Upgrade to the new tag: + +```shell +git pull origin v1.2.4 +``` + +Verify the new commit: + +```shell +git log -1 +commit 1234567890abcdef1234567890abcdef12345678 (HEAD, tag: v1.2.4) +Author: Jane Doe +Date: Thu Jun 28 08:19:11 2024 -0500 + + Improved metrics handling for high concurrency +``` + +Return to the root directory: + +```shell +cd ../.. +git status +``` + +The status should display: + +```shell +On branch upgrade_prometheus_1.2.4 +Changes not staged for commit: + (use "git add ..." to update what will be committed) + (use "git restore ..." to discard changes in working directory) + modified: third_party/prometheus-cpp (new commits) +``` + +Add the upgraded submodule: + +```shell +git add third_party/prometheus-cpp +``` + +File third_party_release +Update the line referencing the prometheus-cpp version. + +```shell +prometheus-cpp=v1.2.4 +``` + +Example change: + +```shell +$ git diff third_party_release +diff --git a/third_party_release b/third_party_release +index abc1234..def5678 100644 +--- a/third_party_release ++++ b/third_party_release +@@ -19,7 +19,7 @@ some-dependency=v0.8.3 + another-dependency=1.14.0 + prometheus-cpp=v1.2.3 ++prometheus-cpp=v1.2.4 +``` + +In file bazel/repository.bzl locate the entry for prometheus-cpp: + +```shell +# C++ Prometheus Client library. +maybe( + http_archive, + name = "com_github_jupp0r_prometheus_cpp", + sha256 = "ac6e958405a29fbbea9db70b00fa3c420e16ad32e1baf941ab233ba031dd72ee", + strip_prefix = "prometheus-cpp-1.2.3", + urls = [ + "https://github.com/jupp0r/prometheus-cpp/archive/refs/tags/v1.2.3.tar.gz", + ], +) +``` + +Update the URL to the new tag: + +```shell +urls = [ + "https://github.com/jupp0r/prometheus-cpp/archive/v1.2.4.tar.gz", +], +``` + +Update strip_prefix to match the new version: + +```shell +strip_prefix = "prometheus-cpp-1.2.4", +``` + +Download the new URL: + +```shell +wget https://github.com/jupp0r/prometheus-cpp/archive/v1.2.4.tar.gz +``` + +Calculate the checksum: + +```shell +sha256sum v1.2.4.tar.gz +abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234 v1.2.4.tar.gz +``` + +Update the `sha256`. diff --git a/third_party/prometheus-cpp b/third_party/prometheus-cpp index ad99e21f47..e5fada4313 160000 --- a/third_party/prometheus-cpp +++ b/third_party/prometheus-cpp @@ -1 +1 @@ -Subproject commit ad99e21f4706193670c42b36c9824dc997f4c475 +Subproject commit e5fada43131d251e9c4786b04263ce98b6767ba5 diff --git a/third_party_release b/third_party_release index 7362473f60..2a57541bf0 100644 --- a/third_party_release +++ b/third_party_release @@ -21,5 +21,5 @@ ms-gsl=v3.1.0-67-g6f45293 nlohmann-json=v3.11.3 opentelemetry-proto=v1.3.2 opentracing-cpp=v1.6.0 -prometheus-cpp=v1.2.4 +prometheus-cpp=v1.3.0 vcpkg=2024.02.14 From 84d427070899e4faf75d1a7be175e9c723a01171 Mon Sep 17 00:00:00 2001 From: "Alex E." <36134278+chusitoo@users.noreply.github.com> Date: Wed, 6 Nov 2024 16:50:51 -0500 Subject: [PATCH 58/89] [EXPORTER] Log SSL Connection Information (#3113) --- CMakeLists.txt | 3 + exporters/otlp/src/otlp_http_client.cc | 1 + .../ext/http/client/curl/http_client_curl.h | 3 + .../http/client/curl/http_operation_curl.h | 11 ++- .../ext/http/client/http_client.h | 2 + ext/src/http/client/curl/CMakeLists.txt | 5 + ext/src/http/client/curl/http_client_curl.cc | 8 +- .../http/client/curl/http_operation_curl.cc | 91 ++++++++++++++++++- .../http/client/nosend/http_client_nosend.h | 3 + 9 files changed, 121 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a0710834bf..b2f2e2764d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -215,6 +215,9 @@ option( "Whether to include gzip compression for the OTLP http exporter in the SDK" OFF) +option(WITH_CURL_LOGGING "Whether to enable select CURL verbosity in OTel logs" + OFF) + option(WITH_ZIPKIN "Whether to include the Zipkin exporter in the SDK" OFF) option(WITH_PROMETHEUS "Whether to include the Prometheus Client in the SDK" diff --git a/exporters/otlp/src/otlp_http_client.cc b/exporters/otlp/src/otlp_http_client.cc index 876719fa1e..c330ffae2f 100644 --- a/exporters/otlp/src/otlp_http_client.cc +++ b/exporters/otlp/src/otlp_http_client.cc @@ -989,6 +989,7 @@ OtlpHttpClient::createSession( request->SetBody(body_vec); request->ReplaceHeader("Content-Type", content_type); request->ReplaceHeader("User-Agent", options_.user_agent); + request->EnableLogging(options_.console_debug); if (options_.compression == "gzip") { diff --git a/ext/include/opentelemetry/ext/http/client/curl/http_client_curl.h b/ext/include/opentelemetry/ext/http/client/curl/http_client_curl.h index 902981f392..ef65388fe1 100644 --- a/ext/include/opentelemetry/ext/http/client/curl/http_client_curl.h +++ b/ext/include/opentelemetry/ext/http/client/curl/http_client_curl.h @@ -102,6 +102,8 @@ class Request : public opentelemetry::ext::http::client::Request compression_ = compression; } + void EnableLogging(bool is_log_enabled) noexcept override { is_log_enabled_ = is_log_enabled; } + public: opentelemetry::ext::http::client::Method method_; opentelemetry::ext::http::client::HttpSslOptions ssl_options_; @@ -111,6 +113,7 @@ class Request : public opentelemetry::ext::http::client::Request std::chrono::milliseconds timeout_ms_{5000}; // ms opentelemetry::ext::http::client::Compression compression_{ opentelemetry::ext::http::client::Compression::kNone}; + bool is_log_enabled_{false}; }; class Response : public opentelemetry::ext::http::client::Response diff --git a/ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h b/ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h index b6654ce3ad..b94c53b2d0 100644 --- a/ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h +++ b/ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h @@ -102,6 +102,12 @@ class HttpOperation static size_t ReadMemoryCallback(char *buffer, size_t size, size_t nitems, void *userp); + static int CurlLoggerCallback(const CURL * /* handle */, + curl_infotype type, + const char *data, + size_t size, + void * /* clientp */) noexcept; + #if LIBCURL_VERSION_NUM >= 0x075000 static int PreRequestCallback(void *clientp, char *conn_primary_ip, @@ -152,7 +158,8 @@ class HttpOperation // Default connectivity and response size options bool is_raw_response = false, std::chrono::milliseconds http_conn_timeout = default_http_conn_timeout, - bool reuse_connection = false); + bool reuse_connection = false, + bool is_log_enabled = false); /** * Destroy CURL instance @@ -300,6 +307,8 @@ class HttpOperation const opentelemetry::ext::http::client::Compression &compression_; + const bool is_log_enabled_; + // Processed response headers and body long response_code_; std::vector response_headers_; diff --git a/ext/include/opentelemetry/ext/http/client/http_client.h b/ext/include/opentelemetry/ext/http/client/http_client.h index d17215da9b..e467f9ef63 100644 --- a/ext/include/opentelemetry/ext/http/client/http_client.h +++ b/ext/include/opentelemetry/ext/http/client/http_client.h @@ -245,6 +245,8 @@ class Request virtual void SetCompression(const Compression &compression) noexcept = 0; + virtual void EnableLogging(bool is_log_enabled) noexcept = 0; + virtual ~Request() = default; }; diff --git a/ext/src/http/client/curl/CMakeLists.txt b/ext/src/http/client/curl/CMakeLists.txt index 6a69c7de51..c812fcefbf 100644 --- a/ext/src/http/client/curl/CMakeLists.txt +++ b/ext/src/http/client/curl/CMakeLists.txt @@ -24,6 +24,11 @@ else() PRIVATE ${CURL_LIBRARIES}) endif() +if(WITH_CURL_LOGGING) + target_compile_definitions(opentelemetry_http_client_curl + PRIVATE ENABLE_CURL_LOGGING) +endif() + if(WITH_OTLP_HTTP_COMPRESSION) if(TARGET ZLIB::ZLIB) target_link_libraries( diff --git a/ext/src/http/client/curl/http_client_curl.cc b/ext/src/http/client/curl/http_client_curl.cc index ae353c5509..6827b9f9c7 100644 --- a/ext/src/http/client/curl/http_client_curl.cc +++ b/ext/src/http/client/curl/http_client_curl.cc @@ -116,10 +116,10 @@ void Session::SendRequest( #endif } - curl_operation_.reset(new HttpOperation(http_request_->method_, url, http_request_->ssl_options_, - callback_ptr, http_request_->headers_, - http_request_->body_, http_request_->compression_, false, - http_request_->timeout_ms_, reuse_connection)); + curl_operation_.reset(new HttpOperation( + http_request_->method_, url, http_request_->ssl_options_, callback_ptr, + http_request_->headers_, http_request_->body_, http_request_->compression_, false, + http_request_->timeout_ms_, reuse_connection, http_request_->is_log_enabled_)); bool success = CURLE_OK == curl_operation_->SendAsync(this, [this, callback](HttpOperation &operation) { if (operation.WasAborted()) diff --git a/ext/src/http/client/curl/http_operation_curl.cc b/ext/src/http/client/curl/http_operation_curl.cc index 4de014fd82..b80624d069 100644 --- a/ext/src/http/client/curl/http_operation_curl.cc +++ b/ext/src/http/client/curl/http_operation_curl.cc @@ -22,6 +22,7 @@ #include "opentelemetry/ext/http/client/curl/http_client_curl.h" #include "opentelemetry/ext/http/client/curl/http_operation_curl.h" #include "opentelemetry/ext/http/client/http_client.h" +#include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/common/global_log_handler.h" #include "opentelemetry/version.h" @@ -261,7 +262,8 @@ HttpOperation::HttpOperation(opentelemetry::ext::http::client::Method method, // Default connectivity and response size options bool is_raw_response, std::chrono::milliseconds http_conn_timeout, - bool reuse_connection) + bool reuse_connection, + bool is_log_enabled) : is_aborted_(false), is_finished_(false), is_cleaned_(false), @@ -281,6 +283,7 @@ HttpOperation::HttpOperation(opentelemetry::ext::http::client::Method method, request_nwrite_(0), session_state_(opentelemetry::ext::http::client::SessionState::Created), compression_(compression), + is_log_enabled_(is_log_enabled), response_code_(0) { /* get a curl handle */ @@ -569,8 +572,77 @@ CURLcode HttpOperation::SetCurlOffOption(CURLoption option, curl_off_t value) return rc; } +int HttpOperation::CurlLoggerCallback(const CURL * /* handle */, + curl_infotype type, + const char *data, + size_t size, + void * /* clientp */) noexcept +{ + nostd::string_view text_to_log{data, size}; + + if (!text_to_log.empty() && text_to_log[size - 1] == '\n') + { + text_to_log = text_to_log.substr(0, size - 1); + } + + if (type == CURLINFO_TEXT) + { + static const auto kTlsInfo = nostd::string_view("SSL connection using"); + static const auto kFailureMsg = nostd::string_view("Recv failure:"); + + if (text_to_log.substr(0, kTlsInfo.size()) == kTlsInfo) + { + OTEL_INTERNAL_LOG_INFO(text_to_log); + } + else if (text_to_log.substr(0, kFailureMsg.size()) == kFailureMsg) + { + OTEL_INTERNAL_LOG_ERROR(text_to_log); + } +// This guard serves as a catch-all block for all other less interesting output that should +// remain available for maintainer internal use and for debugging purposes only. +#ifdef OTEL_CURL_DEBUG + else + { + OTEL_INTERNAL_LOG_DEBUG(text_to_log); + } +#endif // OTEL_CURL_DEBUG + } +// Same as above, this guard is meant only for internal use by maintainers, and should not be used +// in production (information leak). +#ifdef OTEL_CURL_DEBUG + else if (type == CURLINFO_HEADER_OUT) + { + static const auto kHeaderSent = nostd::string_view("Send header => "); + + while (!text_to_log.empty() && !std::iscntrl(text_to_log[0])) + { + const auto pos = text_to_log.find('\n'); + + if (pos != nostd::string_view::npos) + { + OTEL_INTERNAL_LOG_DEBUG(kHeaderSent << text_to_log.substr(0, pos - 1)); + text_to_log = text_to_log.substr(pos + 1); + } + } + } + else if (type == CURLINFO_HEADER_IN) + { + static const auto kHeaderRecv = nostd::string_view("Recv header => "); + OTEL_INTERNAL_LOG_DEBUG(kHeaderRecv << text_to_log); + } +#endif // OTEL_CURL_DEBUG + + return 0; +} + CURLcode HttpOperation::Setup() { +#ifdef ENABLE_CURL_LOGGING + static constexpr auto kEnableCurlLogging = true; +#else + static constexpr auto kEnableCurlLogging = false; +#endif // ENABLE_CURL_LOGGING + if (!curl_resource_.easy_handle) { return CURLE_FAILED_INIT; @@ -581,11 +653,28 @@ CURLcode HttpOperation::Setup() curl_error_message_[0] = '\0'; curl_easy_setopt(curl_resource_.easy_handle, CURLOPT_ERRORBUFFER, curl_error_message_); +// Support for custom debug function callback was added in version 7.9.6 so we guard against +// exposing the default CURL output by keeping verbosity always disabled in lower versions. +#if LIBCURL_VERSION_NUM < CURL_VERSION_BITS(7, 9, 6) rc = SetCurlLongOption(CURLOPT_VERBOSE, 0L); if (rc != CURLE_OK) { return rc; } +#else + rc = SetCurlLongOption(CURLOPT_VERBOSE, (is_log_enabled_ && kEnableCurlLogging) ? 1L : 0L); + if (rc != CURLE_OK) + { + return rc; + } + + rc = SetCurlPtrOption(CURLOPT_DEBUGFUNCTION, + reinterpret_cast(&HttpOperation::CurlLoggerCallback)); + if (rc != CURLE_OK) + { + return rc; + } +#endif // Specify target URL rc = SetCurlStrOption(CURLOPT_URL, url_.c_str()); diff --git a/test_common/include/opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h b/test_common/include/opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h index a5f8c2f0e1..211b5b3720 100644 --- a/test_common/include/opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h +++ b/test_common/include/opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h @@ -69,6 +69,8 @@ class Request : public opentelemetry::ext::http::client::Request compression_ = compression; } + void EnableLogging(bool is_log_enabled) noexcept override { is_log_enabled_ = is_log_enabled; } + public: opentelemetry::ext::http::client::Method method_; opentelemetry::ext::http::client::HttpSslOptions ssl_options_; @@ -78,6 +80,7 @@ class Request : public opentelemetry::ext::http::client::Request std::chrono::milliseconds timeout_ms_{5000}; // ms opentelemetry::ext::http::client::Compression compression_{ opentelemetry::ext::http::client::Compression::kNone}; + bool is_log_enabled_{false}; }; class Response : public opentelemetry::ext::http::client::Response From ff2447df6360378105a79618cba9e5dacf9e3bce Mon Sep 17 00:00:00 2001 From: Santiago Date: Thu, 7 Nov 2024 19:01:59 -0300 Subject: [PATCH 59/89] [BUILD] Improve how to handle yield() in ARM. (#3129) --- api/include/opentelemetry/common/spin_lock_mutex.h | 6 ++++-- api/test/common/spinlock_benchmark.cc | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/api/include/opentelemetry/common/spin_lock_mutex.h b/api/include/opentelemetry/common/spin_lock_mutex.h index 369183b953..7031fa4d23 100644 --- a/api/include/opentelemetry/common/spin_lock_mutex.h +++ b/api/include/opentelemetry/common/spin_lock_mutex.h @@ -68,8 +68,10 @@ class SpinLockMutex # else __builtin_ia32_pause(); # endif -#elif defined(__arm__) - __asm__ volatile("yield" ::: "memory"); +#elif defined(__armel__) || defined(__ARMEL__) + asm volatile("nop" ::: "memory"); +#elif defined(__arm__) || defined(__aarch64__) // arm big endian / arm64 + __asm__ __volatile__("yield" ::: "memory"); #else // TODO: Issue PAGE/YIELD on other architectures. #endif diff --git a/api/test/common/spinlock_benchmark.cc b/api/test/common/spinlock_benchmark.cc index b5e98a2108..da588b7e30 100644 --- a/api/test/common/spinlock_benchmark.cc +++ b/api/test/common/spinlock_benchmark.cc @@ -102,8 +102,10 @@ static void BM_ProcYieldSpinLockThrashing(benchmark::State &s) # else __builtin_ia32_pause(); # endif -#elif defined(__arm__) - __asm__ volatile("yield" ::: "memory"); +#elif defined(__armel__) || defined(__ARMEL__) + asm volatile("nop" ::: "memory"); +#elif defined(__arm__) || defined(__aarch64__) // arm big endian / arm64 + __asm__ __volatile__("yield" ::: "memory"); #endif } }, From 95d039c08a4091e6543a0f26650a0a9315eef279 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Thu, 7 Nov 2024 15:09:26 -0800 Subject: [PATCH 60/89] [BUILD] Fix -Wmissing-template-arg-list-after-template-kw warning (#3133) --- api/include/opentelemetry/logs/event_logger.h | 5 ++--- api/include/opentelemetry/logs/logger.h | 5 ++--- api/include/opentelemetry/logs/logger_type_traits.h | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/api/include/opentelemetry/logs/event_logger.h b/api/include/opentelemetry/logs/event_logger.h index b5c94a7067..d3049953bc 100644 --- a/api/include/opentelemetry/logs/event_logger.h +++ b/api/include/opentelemetry/logs/event_logger.h @@ -65,9 +65,8 @@ class EventLogger } nostd::unique_ptr log_record = delegate_logger->CreateLogRecord(); - IgnoreTraitResult( - detail::LogRecordSetterTrait::type>::template Set( - log_record.get(), std::forward(args))...); + IgnoreTraitResult(detail::LogRecordSetterTrait::type>::Set( + log_record.get(), std::forward(args))...); EmitEvent(event_name, std::move(log_record)); } diff --git a/api/include/opentelemetry/logs/logger.h b/api/include/opentelemetry/logs/logger.h index dc09a0c2b4..519516f297 100644 --- a/api/include/opentelemetry/logs/logger.h +++ b/api/include/opentelemetry/logs/logger.h @@ -72,9 +72,8 @@ class Logger return; } - IgnoreTraitResult( - detail::LogRecordSetterTrait::type>::template Set( - log_record.get(), std::forward(args))...); + IgnoreTraitResult(detail::LogRecordSetterTrait::type>::Set( + log_record.get(), std::forward(args))...); EmitLogRecord(std::move(log_record)); } diff --git a/api/include/opentelemetry/logs/logger_type_traits.h b/api/include/opentelemetry/logs/logger_type_traits.h index 486135137d..d88a6ffbdc 100644 --- a/api/include/opentelemetry/logs/logger_type_traits.h +++ b/api/include/opentelemetry/logs/logger_type_traits.h @@ -166,8 +166,8 @@ struct LogRecordSetterTrait * = nullptr> inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept { - return LogRecordSetterTrait::template Set( - log_record, std::forward(arg)); + return LogRecordSetterTrait::Set(log_record, + std::forward(arg)); } template Date: Fri, 8 Nov 2024 16:37:22 +0100 Subject: [PATCH 61/89] [EXPORTER]: Elasticsearch exporter put log resource in root instead of under 'resources' (#3131) --- CHANGELOG.md | 5 ++ .../elasticsearch/es_log_recordable.h | 14 ++--- .../elasticsearch/src/es_log_recordable.cc | 55 +++---------------- 3 files changed, 19 insertions(+), 55 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04b1603c3c..6d8ca3317f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,11 @@ Important changes: * Upgrade to prometheus 1.3.0 [#3122](https://github.com/open-telemetry/opentelemetry-cpp/pull/3122) +* [EXPORTER] Change log resources location for ElasticsearchLogRecordExporter + [#3119](https://github.com/open-telemetry/opentelemetry-cpp/pull/3131) + + * Moved from `root/resources` to `root` + ## [1.17 2024-10-07] * [CI] Add a clang-tidy build diff --git a/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h b/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h index 52d24cada6..9baf9ef7bd 100644 --- a/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h +++ b/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h @@ -28,16 +28,12 @@ class ElasticSearchRecordable final : public sdk::logs::Recordable { private: /** - * A helper method that writes a key/value pair under a specified name, the two names used here - * being "attributes" and "resources" + * A helper method that writes a value under a specified name. + * `name` will be at the root of the JSON object. If it has to be nested under some other keys, + * then write `name` as `key1.key2.[...].name` */ - void WriteKeyValue(nostd::string_view key, - const opentelemetry::common::AttributeValue &value, - const std::string &name); - - void WriteKeyValue(nostd::string_view key, - const opentelemetry::sdk::common::OwnedAttributeValue &value, - const std::string &name); + void WriteValue(const opentelemetry::sdk::common::OwnedAttributeValue &value, + const std::string &name); void WriteValue(const opentelemetry::common::AttributeValue &value, const std::string &name); diff --git a/exporters/elasticsearch/src/es_log_recordable.cc b/exporters/elasticsearch/src/es_log_recordable.cc index 56d7cea71b..3412a8cc61 100644 --- a/exporters/elasticsearch/src/es_log_recordable.cc +++ b/exporters/elasticsearch/src/es_log_recordable.cc @@ -14,44 +14,7 @@ namespace exporter { namespace logs { -void ElasticSearchRecordable::WriteKeyValue(nostd::string_view key, - const opentelemetry::common::AttributeValue &value, - const std::string &name) -{ - switch (value.index()) - { - case common::AttributeType::kTypeBool: - json_[name][key.data()] = opentelemetry::nostd::get(value) ? true : false; - return; - case common::AttributeType::kTypeInt: - json_[name][key.data()] = opentelemetry::nostd::get(value); - return; - case common::AttributeType::kTypeInt64: - json_[name][key.data()] = opentelemetry::nostd::get(value); - return; - case common::AttributeType::kTypeUInt: - json_[name][key.data()] = opentelemetry::nostd::get(value); - return; - case common::AttributeType::kTypeUInt64: - json_[name][key.data()] = opentelemetry::nostd::get(value); - return; - case common::AttributeType::kTypeDouble: - json_[name][key.data()] = opentelemetry::nostd::get(value); - return; - case common::AttributeType::kTypeCString: - json_[name][key.data()] = opentelemetry::nostd::get(value); - return; - case common::AttributeType::kTypeString: - json_[name][key.data()] = - opentelemetry::nostd::get(value).data(); - return; - default: - return; - } -} - -void ElasticSearchRecordable::WriteKeyValue( - nostd::string_view key, +void ElasticSearchRecordable::WriteValue( const opentelemetry::sdk::common::OwnedAttributeValue &value, const std::string &name) { @@ -59,25 +22,25 @@ void ElasticSearchRecordable::WriteKeyValue( switch (value.index()) { case common::kTypeBool: - json_[name][key.data()] = opentelemetry::nostd::get(value) ? true : false; + json_[name] = opentelemetry::nostd::get(value) ? true : false; return; case common::kTypeInt: - json_[name][key.data()] = opentelemetry::nostd::get(value); + json_[name] = opentelemetry::nostd::get(value); return; case common::kTypeInt64: - json_[name][key.data()] = opentelemetry::nostd::get(value); + json_[name] = opentelemetry::nostd::get(value); return; case common::kTypeUInt: - json_[name][key.data()] = opentelemetry::nostd::get(value); + json_[name] = opentelemetry::nostd::get(value); return; case common::kTypeUInt64: - json_[name][key.data()] = opentelemetry::nostd::get(value); + json_[name] = opentelemetry::nostd::get(value); return; case common::kTypeDouble: - json_[name][key.data()] = opentelemetry::nostd::get(value); + json_[name] = opentelemetry::nostd::get(value); return; case common::kTypeString: - json_[name][key.data()] = opentelemetry::nostd::get(value).data(); + json_[name] = opentelemetry::nostd::get(value).data(); return; default: return; @@ -321,7 +284,7 @@ void ElasticSearchRecordable::SetResource( { for (auto &attribute : resource.GetAttributes()) { - WriteKeyValue(attribute.first, attribute.second, "resource"); + WriteValue(attribute.second, attribute.first); } } From 1863fe723dabf46c46413422d72e54365182ab45 Mon Sep 17 00:00:00 2001 From: Pranav Sharma Date: Fri, 8 Nov 2024 14:58:52 -0500 Subject: [PATCH 62/89] [TEST] Rename w3c_tracecontext_test to w3c_tracecontext_http_test_server (#3132) --- .github/workflows/ci.yml | 4 ++-- ext/test/CMakeLists.txt | 2 +- .../BUILD | 2 +- .../CMakeLists.txt | 7 ++++--- .../Dockerfile | 0 .../README.md | 4 ++-- .../main.cc | 2 +- 7 files changed, 11 insertions(+), 10 deletions(-) rename ext/test/{w3c_tracecontext_test => w3c_tracecontext_http_test_server}/BUILD (92%) rename ext/test/{w3c_tracecontext_test => w3c_tracecontext_http_test_server}/CMakeLists.txt (66%) rename ext/test/{w3c_tracecontext_test => w3c_tracecontext_http_test_server}/Dockerfile (100%) rename ext/test/{w3c_tracecontext_test => w3c_tracecontext_http_test_server}/README.md (94%) rename ext/test/{w3c_tracecontext_test => w3c_tracecontext_http_test_server}/main.cc (99%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 26dda5449c..f3a214ecde 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -946,8 +946,8 @@ jobs: CXX_STANDARD: '14' run: | ./ci/do_ci.sh cmake.w3c.trace-context.build-server - cd $HOME/build/ext/test/w3c_tracecontext_test - ./w3c_tracecontext_test & + cd $HOME/build/ext/test/w3c_tracecontext_http_test_server + ./w3c_tracecontext_http_test_server & - name: Checkout w3c/trace-context repo uses: actions/checkout@v4 with: diff --git a/ext/test/CMakeLists.txt b/ext/test/CMakeLists.txt index cc3d4cd1e1..4dabab3821 100644 --- a/ext/test/CMakeLists.txt +++ b/ext/test/CMakeLists.txt @@ -3,5 +3,5 @@ add_subdirectory(http) if(BUILD_W3CTRACECONTEXT_TEST) - add_subdirectory(w3c_tracecontext_test) + add_subdirectory(w3c_tracecontext_http_test_server) endif() diff --git a/ext/test/w3c_tracecontext_test/BUILD b/ext/test/w3c_tracecontext_http_test_server/BUILD similarity index 92% rename from ext/test/w3c_tracecontext_test/BUILD rename to ext/test/w3c_tracecontext_http_test_server/BUILD index c67ab11a9c..8c1c8c17e9 100644 --- a/ext/test/w3c_tracecontext_test/BUILD +++ b/ext/test/w3c_tracecontext_http_test_server/BUILD @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 cc_binary( - name = "w3c_tracecontext_test", + name = "w3c_tracecontext_http_test_server", srcs = [ "main.cc", ], diff --git a/ext/test/w3c_tracecontext_test/CMakeLists.txt b/ext/test/w3c_tracecontext_http_test_server/CMakeLists.txt similarity index 66% rename from ext/test/w3c_tracecontext_test/CMakeLists.txt rename to ext/test/w3c_tracecontext_http_test_server/CMakeLists.txt index cc2ae43b1c..85e3c3eea0 100644 --- a/ext/test/w3c_tracecontext_test/CMakeLists.txt +++ b/ext/test/w3c_tracecontext_http_test_server/CMakeLists.txt @@ -3,12 +3,13 @@ include_directories(${CMAKE_SOURCE_DIR}/exporters/ostream/include) -add_executable(w3c_tracecontext_test main.cc) +add_executable(w3c_tracecontext_http_test_server main.cc) target_link_libraries( - w3c_tracecontext_test + w3c_tracecontext_http_test_server PRIVATE ${CMAKE_THREAD_LIBS_INIT} opentelemetry_trace opentelemetry_http_client_curl opentelemetry_exporter_ostream_span ${CURL_LIBRARIES} nlohmann_json::nlohmann_json) if(nlohmann_json_clone) - add_dependencies(w3c_tracecontext_test nlohmann_json::nlohmann_json) + add_dependencies(w3c_tracecontext_http_test_server + nlohmann_json::nlohmann_json) endif() diff --git a/ext/test/w3c_tracecontext_test/Dockerfile b/ext/test/w3c_tracecontext_http_test_server/Dockerfile similarity index 100% rename from ext/test/w3c_tracecontext_test/Dockerfile rename to ext/test/w3c_tracecontext_http_test_server/Dockerfile diff --git a/ext/test/w3c_tracecontext_test/README.md b/ext/test/w3c_tracecontext_http_test_server/README.md similarity index 94% rename from ext/test/w3c_tracecontext_test/README.md rename to ext/test/w3c_tracecontext_http_test_server/README.md index 6f4db4513d..afe2a68638 100644 --- a/ext/test/w3c_tracecontext_test/README.md +++ b/ext/test/w3c_tracecontext_http_test_server/README.md @@ -11,7 +11,7 @@ instructions](https://github.com/w3c/trace-context/tree/master/test#implement-te 1: Build and start the test service endpoint: ```sh -./w3c_tracecontext_test +./w3c_tracecontext_http_test_server Listening to http://localhost:30000/test ``` @@ -19,7 +19,7 @@ Listening to http://localhost:30000/test A custom port number for the test service to listen to can be specified: ```sh -./w3c_tracecontext_test 31339 +./w3c_tracecontext_http_test_server 31339 Listening to http://localhost:31339/test ``` diff --git a/ext/test/w3c_tracecontext_test/main.cc b/ext/test/w3c_tracecontext_http_test_server/main.cc similarity index 99% rename from ext/test/w3c_tracecontext_test/main.cc rename to ext/test/w3c_tracecontext_http_test_server/main.cc index d2ed772510..5af8c141de 100644 --- a/ext/test/w3c_tracecontext_test/main.cc +++ b/ext/test/w3c_tracecontext_http_test_server/main.cc @@ -98,7 +98,7 @@ void initTracer() nostd::shared_ptr get_tracer() { auto provider = trace_api::Provider::GetTracerProvider(); - return provider->GetTracer("w3c_tracecontext_test"); + return provider->GetTracer("w3c_tracecontext_http_test_server"); } struct Uri From a713947e5956bbc4b5a398b148e497ce21278e69 Mon Sep 17 00:00:00 2001 From: Chris Ward Date: Tue, 12 Nov 2024 07:43:36 +0000 Subject: [PATCH 63/89] [BUILD] Patches for building on AIX (#3127) --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b2f2e2764d..aa0ae9ef43 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,13 @@ else() elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) set(ARCH x86) endif() + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "powerpc") + # AIX will report the processor as 'powerpc' even if building in 64-bit mode + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(ARCH ppc64) + else() + set(ARCH ppc32) + endif() elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*|arm64.*|ARM64.*)") set(ARCH arm64) From f7a9aea0637f0b29e1668b4a7e83b25106489b87 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Wed, 13 Nov 2024 19:14:12 +0100 Subject: [PATCH 64/89] [SEMANTIC CONVENTIONS] Migration to weaver (#3105) --- CHANGELOG.md | 21 +- DEPRECATED.md | 78 ++ .../opentelemetry/semconv/client_attributes.h | 41 + .../opentelemetry/semconv/error_attributes.h | 57 + .../semconv/exception_attributes.h | 59 + .../opentelemetry/semconv/http_attributes.h | 153 +++ .../opentelemetry/semconv/http_metrics.h | 79 ++ .../semconv/incubating/artifact_attributes.h | 81 ++ .../semconv/incubating/aws_attributes.h | 356 +++++ .../semconv/incubating/az_attributes.h | 30 + .../semconv/incubating/browser_attributes.h | 65 + .../semconv/incubating/cicd_attributes.h | 76 ++ .../semconv/incubating/client_attributes.h | 41 + .../semconv/incubating/cloud_attributes.h | 272 ++++ .../incubating/cloudevents_attributes.h | 58 + .../semconv/incubating/code_attributes.h | 60 + .../semconv/incubating/container_attributes.h | 141 ++ .../semconv/incubating/container_metrics.h | 181 +++ .../semconv/incubating/cpu_attributes.h | 73 + .../semconv/incubating/db_attributes.h | 820 +++++++++++ .../semconv/incubating/db_metrics.h | 816 +++++++++++ .../incubating/deployment_attributes.h | 76 ++ .../incubating/destination_attributes.h | 37 + .../semconv/incubating/device_attributes.h | 66 + .../semconv/incubating/disk_attributes.h | 43 + .../semconv/incubating/dns_attributes.h | 34 + .../semconv/incubating/dns_metrics.h | 49 + .../semconv/incubating/enduser_attributes.h | 51 + .../semconv/incubating/error_attributes.h | 57 + .../semconv/incubating/event_attributes.h | 34 + .../semconv/incubating/exception_attributes.h | 59 + .../semconv/incubating/faas_attributes.h | 232 ++++ .../semconv/incubating/faas_metrics.h | 287 ++++ .../incubating/feature_flag_attributes.h | 47 + .../semconv/incubating/file_attributes.h | 53 + .../semconv/incubating/gcp_attributes.h | 64 + .../semconv/incubating/gen_ai_attributes.h | 206 +++ .../semconv/incubating/gen_ai_metrics.h | 158 +++ .../semconv/incubating/graphql_attributes.h | 60 + .../semconv/incubating/heroku_attributes.h | 39 + .../semconv/incubating/host_attributes.h | 159 +++ .../semconv/incubating/http_attributes.h | 365 +++++ .../semconv/incubating/http_metrics.h | 353 +++++ .../semconv/incubating/k8s_attributes.h | 180 +++ .../semconv/incubating/linux_attributes.h | 43 + .../semconv/incubating/log_attributes.h | 82 ++ .../semconv/incubating/message_attributes.h | 74 + .../semconv/incubating/messaging_attributes.h | 534 ++++++++ .../semconv/incubating/messaging_metrics.h | 396 ++++++ .../semconv/incubating/net_attributes.h | 209 +++ .../semconv/incubating/network_attributes.h | 308 +++++ .../semconv/incubating/oci_attributes.h | 36 + .../incubating/opentracing_attributes.h | 45 + .../semconv/incubating/os_attributes.h | 110 ++ .../semconv/incubating/otel_attributes.h | 73 + .../semconv/incubating/other_attributes.h | 47 + .../semconv/incubating/peer_attributes.h | 31 + .../semconv/incubating/pool_attributes.h | 33 + .../semconv/incubating/process_attributes.h | 226 ++++ .../semconv/incubating/process_metrics.h | 416 ++++++ .../semconv/incubating/rpc_attributes.h | 355 +++++ .../semconv/incubating/rpc_metrics.h | 312 +++++ .../semconv/incubating/server_attributes.h | 41 + .../semconv/incubating/service_attributes.h | 84 ++ .../semconv/incubating/session_attributes.h | 34 + .../semconv/incubating/source_attributes.h | 37 + .../semconv/incubating/system_attributes.h | 383 ++++++ .../semconv/incubating/system_metrics.h | 1200 +++++++++++++++++ .../semconv/incubating/telemetry_attributes.h | 125 ++ .../semconv/incubating/test_attributes.h | 93 ++ .../semconv/incubating/thread_attributes.h | 34 + .../semconv/incubating/tls_attributes.h | 221 +++ .../semconv/incubating/url_attributes.h | 137 ++ .../incubating/user_agent_attributes.h | 51 + .../semconv/incubating/user_attributes.h | 57 + .../semconv/incubating/vcs_attributes.h | 86 ++ .../semconv/incubating/webengine_attributes.h | 39 + .../semconv/network_attributes.h | 120 ++ .../opentelemetry/semconv/otel_attributes.h | 59 + .../opentelemetry/semconv/schema_url.h | 24 + .../opentelemetry/semconv/server_attributes.h | 41 + .../semconv/service_attributes.h | 41 + .../semconv/telemetry_attributes.h | 111 ++ .../opentelemetry/semconv/url_attributes.h | 66 + .../semconv/user_agent_attributes.h | 30 + .../trace/semantic_conventions.h | 10 +- buildscripts/semantic-convention/generate.sh | 128 +- .../templates/SemanticAttributes.h.j2 | 123 -- .../templates/registry/schema_url-h.j2 | 48 + .../registry/semantic_attributes-h.j2 | 132 ++ .../templates/registry/semantic_metrics-h.j2 | 228 ++++ .../templates/registry/weaver.yaml | 156 +++ .../common/metrics_foo_library/foo_library.cc | 50 + .../common/metrics_foo_library/foo_library.h | 3 + examples/grpc/client.cc | 24 +- examples/grpc/server.cc | 11 +- examples/http/client.cc | 12 +- examples/http/server.cc | 18 +- examples/metrics_simple/metrics_ostream.cc | 19 + .../otlp/test/otlp_log_recordable_test.cc | 1 - exporters/prometheus/src/exporter_utils.cc | 5 +- exporters/zipkin/src/recordable.cc | 6 +- .../opentracingshim/shim_utils.h | 10 +- opentracing-shim/src/span_shim.cc | 8 +- .../sdk/resource/semantic_conventions.h | 10 +- sdk/src/resource/resource.cc | 16 +- sdk/src/resource/resource_detector.cc | 4 +- sdk/test/resource/resource_test.cc | 30 +- 108 files changed, 13511 insertions(+), 252 deletions(-) create mode 100644 api/include/opentelemetry/semconv/client_attributes.h create mode 100644 api/include/opentelemetry/semconv/error_attributes.h create mode 100644 api/include/opentelemetry/semconv/exception_attributes.h create mode 100644 api/include/opentelemetry/semconv/http_attributes.h create mode 100644 api/include/opentelemetry/semconv/http_metrics.h create mode 100644 api/include/opentelemetry/semconv/incubating/artifact_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/aws_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/az_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/browser_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/cicd_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/client_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/cloud_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/cloudevents_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/code_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/container_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/container_metrics.h create mode 100644 api/include/opentelemetry/semconv/incubating/cpu_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/db_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/db_metrics.h create mode 100644 api/include/opentelemetry/semconv/incubating/deployment_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/destination_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/device_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/disk_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/dns_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/dns_metrics.h create mode 100644 api/include/opentelemetry/semconv/incubating/enduser_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/error_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/event_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/exception_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/faas_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/faas_metrics.h create mode 100644 api/include/opentelemetry/semconv/incubating/feature_flag_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/file_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/gcp_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/gen_ai_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/gen_ai_metrics.h create mode 100644 api/include/opentelemetry/semconv/incubating/graphql_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/heroku_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/host_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/http_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/http_metrics.h create mode 100644 api/include/opentelemetry/semconv/incubating/k8s_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/linux_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/log_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/message_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/messaging_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/messaging_metrics.h create mode 100644 api/include/opentelemetry/semconv/incubating/net_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/network_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/oci_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/opentracing_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/os_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/otel_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/other_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/peer_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/pool_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/process_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/process_metrics.h create mode 100644 api/include/opentelemetry/semconv/incubating/rpc_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/rpc_metrics.h create mode 100644 api/include/opentelemetry/semconv/incubating/server_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/service_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/session_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/source_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/system_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/system_metrics.h create mode 100644 api/include/opentelemetry/semconv/incubating/telemetry_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/test_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/thread_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/tls_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/url_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/user_agent_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/user_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/vcs_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/webengine_attributes.h create mode 100644 api/include/opentelemetry/semconv/network_attributes.h create mode 100644 api/include/opentelemetry/semconv/otel_attributes.h create mode 100644 api/include/opentelemetry/semconv/schema_url.h create mode 100644 api/include/opentelemetry/semconv/server_attributes.h create mode 100644 api/include/opentelemetry/semconv/service_attributes.h create mode 100644 api/include/opentelemetry/semconv/telemetry_attributes.h create mode 100644 api/include/opentelemetry/semconv/url_attributes.h create mode 100644 api/include/opentelemetry/semconv/user_agent_attributes.h delete mode 100644 buildscripts/semantic-convention/templates/SemanticAttributes.h.j2 create mode 100644 buildscripts/semantic-convention/templates/registry/schema_url-h.j2 create mode 100644 buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 create mode 100644 buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 create mode 100644 buildscripts/semantic-convention/templates/registry/weaver.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d8ca3317f..3e3521797d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,12 +15,18 @@ Increment the: ## [Unreleased] -* [API] Comply with W3C Trace Context [#3115](https://github.com/open-telemetry/opentelemetry-cpp/pull/3115) - * Also adds CI check to ensure continued compliance +* [API] Comply with W3C Trace Context + [#3115](https://github.com/open-telemetry/opentelemetry-cpp/pull/3115) * [API] Jaeger Propagator should not be deprecated [#3086](https://github.com/open-telemetry/opentelemetry-cpp/pull/3086) +* Upgrade to prometheus 1.3.0 + [#3122](https://github.com/open-telemetry/opentelemetry-cpp/pull/3122) + +* [SEMANTIC CONVENTIONS] Migration to weaver + [#3105](https://github.com/open-telemetry/opentelemetry-cpp/pull/3105) + Important changes: * [API] Jaeger Propagator should not be deprecated @@ -32,14 +38,19 @@ Important changes: as the Jaeger propagator can be used without the (now removed) Jaeger exporter. -* Upgrade to prometheus 1.3.0 - [#3122](https://github.com/open-telemetry/opentelemetry-cpp/pull/3122) - * [EXPORTER] Change log resources location for ElasticsearchLogRecordExporter [#3119](https://github.com/open-telemetry/opentelemetry-cpp/pull/3131) * Moved from `root/resources` to `root` +* [SEMANTIC CONVENTIONS] Migration to weaver + [#3105](https://github.com/open-telemetry/opentelemetry-cpp/pull/3105) + + * `semantic_convention.h` header files are deprecated, + replaced by `semconv/xxx_attributes.h` header files, + for each `xxx` semantic attribute group. + * See file DEPRECATED.md for details. + ## [1.17 2024-10-07] * [CI] Add a clang-tidy build diff --git a/DEPRECATED.md b/DEPRECATED.md index eea861ffe6..ec97f420fe 100644 --- a/DEPRECATED.md +++ b/DEPRECATED.md @@ -59,3 +59,81 @@ N/A ## [Documentation] N/A + +## Semantic conventions + +### Header files "semantic_conventions.h" + +#### Announcement (semantic_conventions.h) + +Deprecation is announced as part of the migration to weaver: + +* `Version:` release following opentelemetry-cpp 1.17.0 +* `Date:` Nov 9, 2024 +* `PR:` [PR 3105](https://github.com/open-telemetry/opentelemetry-cpp/pull/3105) + +#### Motivation (semantic_conventions.h) + +The header files for semantic conventions are generated automatically. +The tooling to generate these files is changing: + +* before, the build-tool repository was used +* now, the weaver repository is used + +Changes in tooling allows to generate code that is better organized, +with dedicated header files per group of semantic conventions, +instead of a single header file for everything. + +#### Scope (semantic_conventions.h) + +The following files: + +* `api/include/opentelemetry/trace/semantic_conventions.h` +* `sdk/include/opentelemetry/sdk/resource/semantic_conventions.h` + +are now deprecated. + +They correspond to semantic conventions v1.27.0, +and will no longer be maintained up to date. + +These files will be removed in the future. + +#### Mitigation (semantic_conventions.h) + +Two things have changed: + +* the header file to use +* the symbol name to use. + +Before, the semantic convention for `url.full` was: + +* declared in file `semantic_conventions.h` +* declared as symbol `SemanticConventions::kUrlFull` + +Now, the `url.full` convention, which is part or the `url` group, is: + +* declared in file `semconv/url_attributes.h` +* declared as symbol `semconv::url::kUrlFull` + +Application code that uses semantic conventions must be adjusted +accordingly. + +In addition, semantic conventions that are not marked as stable +are generated in a different header file, placed under directory +`incubating`, to better separate stable and non stable code. + +For example, file `semconv/incubating/url_attributes.h` +defines `semconv::url::kUrlDomain`, +which is not marked as stable in semconv v1.27.0 + +#### Planned removal (semantic_conventions.h) + +The following files: + +* `api/include/opentelemetry/trace/semantic_conventions.h` +* `sdk/include/opentelemetry/sdk/resource/semantic_conventions.h` + +will be removed. + +The removal date is planned for July 1, 2025. +This allows more than six months for applications to adjust. diff --git a/api/include/opentelemetry/semconv/client_attributes.h b/api/include/opentelemetry/semconv/client_attributes.h new file mode 100644 index 0000000000..ec984cc406 --- /dev/null +++ b/api/include/opentelemetry/semconv/client_attributes.h @@ -0,0 +1,41 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace client +{ + +/** + * Client address - domain name if available without reverse DNS lookup; otherwise, IP address or + * Unix domain socket name.

        When observed from the server side, and when communicating through + * an intermediary, @code client.address @endcode SHOULD represent the client address behind any + * intermediaries, for example proxies, if it's available. + */ +static constexpr const char *kClientAddress = "client.address"; + +/** + * Client port number. + *

        + * When observed from the server side, and when communicating through an intermediary, @code + * client.port @endcode SHOULD represent the client port behind any intermediaries, for example + * proxies, if it's available. + */ +static constexpr const char *kClientPort = "client.port"; + +} // namespace client +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/error_attributes.h b/api/include/opentelemetry/semconv/error_attributes.h new file mode 100644 index 0000000000..1b711ff112 --- /dev/null +++ b/api/include/opentelemetry/semconv/error_attributes.h @@ -0,0 +1,57 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace error +{ + +/** + * Describes a class of error the operation ended with. + *

        + * The @code error.type @endcode SHOULD be predictable, and SHOULD have low cardinality. + *

        + * When @code error.type @endcode is set to a type (e.g., an exception type), its + * canonical class name identifying the type within the artifact SHOULD be used. + *

        + * Instrumentations SHOULD document the list of errors they report. + *

        + * The cardinality of @code error.type @endcode within one instrumentation library SHOULD be low. + * Telemetry consumers that aggregate data from multiple instrumentation libraries and applications + * should be prepared for @code error.type @endcode to have high cardinality at query time when no + * additional filters are applied. + *

        + * If the operation has completed successfully, instrumentations SHOULD NOT set @code error.type + * @endcode.

        If a specific domain defines its own set of error identifiers (such as HTTP or gRPC + * status codes), it's RECOMMENDED to:

        • Use a domain-specific attribute
        • Set + * @code error.type @endcode to capture all errors, regardless of whether they are defined within + * the domain-specific set or not.
        • + *
        + */ +static constexpr const char *kErrorType = "error.type"; + +namespace ErrorTypeValues +{ +/** + * A fallback error value to be used when the instrumentation doesn't define a custom value. + */ +static constexpr const char *kOther = "_OTHER"; + +} // namespace ErrorTypeValues + +} // namespace error +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/exception_attributes.h b/api/include/opentelemetry/semconv/exception_attributes.h new file mode 100644 index 0000000000..fdc19ac6d0 --- /dev/null +++ b/api/include/opentelemetry/semconv/exception_attributes.h @@ -0,0 +1,59 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace exception +{ + +/** + * SHOULD be set to true if the exception event is recorded at a point where it is known that the + * exception is escaping the scope of the span.

        An exception is considered to have escaped (or + * left) the scope of a span, if that span is ended while the exception is still logically "in + * flight". This may be actually "in flight" in some languages (e.g. if the exception is passed to a + * Context manager's @code __exit__ @endcode method in Python) but will usually be caught at the + * point of recording the exception in most languages.

        It is usually not possible to determine + * at the point where an exception is thrown whether it will escape the scope of a span. However, it + * is trivial to know that an exception will escape, if one checks for an active exception just + * before ending the span, as done in the example + * for recording span exceptions.

        It follows that an exception may still escape the scope of + * the span even if the @code exception.escaped @endcode attribute was not set or set to false, + * since the event might have been recorded at a time where it was not + * clear whether the exception will escape. + */ +static constexpr const char *kExceptionEscaped = "exception.escaped"; + +/** + * The exception message. + */ +static constexpr const char *kExceptionMessage = "exception.message"; + +/** + * A stacktrace as a string in the natural representation for the language runtime. The + * representation is to be determined and documented by each language SIG. + */ +static constexpr const char *kExceptionStacktrace = "exception.stacktrace"; + +/** + * The type of the exception (its fully-qualified class name, if applicable). The dynamic type of + * the exception should be preferred over the static type in languages that support it. + */ +static constexpr const char *kExceptionType = "exception.type"; + +} // namespace exception +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/http_attributes.h b/api/include/opentelemetry/semconv/http_attributes.h new file mode 100644 index 0000000000..6011674e84 --- /dev/null +++ b/api/include/opentelemetry/semconv/http_attributes.h @@ -0,0 +1,153 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace http +{ + +/** + * HTTP request headers, @code @endcode being the normalized HTTP Header name (lowercase), the + * value being the header values.

        Instrumentations SHOULD require an explicit configuration of + * which headers are to be captured. Including all request headers can be a security risk - explicit + * configuration helps avoid leaking sensitive information. The @code User-Agent @endcode header is + * already captured in the @code user_agent.original @endcode attribute. Users MAY explicitly + * configure instrumentations to capture them even though it is not recommended. The attribute value + * MUST consist of either multiple header values as an array of strings or a single-item array + * containing a possibly comma-concatenated string, depending on the way the HTTP library provides + * access to headers. + */ +static constexpr const char *kHttpRequestHeader = "http.request.header"; + +/** + * HTTP request method. + *

        + * HTTP request method value SHOULD be "known" to the instrumentation. + * By default, this convention defines "known" methods as the ones listed in RFC9110 and the PATCH method + * defined in RFC5789.

        If the HTTP + * request method is not known to instrumentation, it MUST set the @code http.request.method + * @endcode attribute to @code _OTHER @endcode.

        If the HTTP instrumentation could end up + * converting valid HTTP request methods to @code _OTHER @endcode, then it MUST provide a way to + * override the list of known HTTP methods. If this override is done via environment variable, then + * the environment variable MUST be named OTEL_INSTRUMENTATION_HTTP_KNOWN_METHODS and support a + * comma-separated list of case-sensitive known HTTP methods (this list MUST be a full override of + * the default known method, it is not a list of known methods in addition to the defaults).

        + * HTTP method names are case-sensitive and @code http.request.method @endcode attribute value MUST + * match a known HTTP method name exactly. Instrumentations for specific web frameworks that + * consider HTTP methods to be case insensitive, SHOULD populate a canonical equivalent. Tracing + * instrumentations that do so, MUST also set @code http.request.method_original @endcode to the + * original value. + */ +static constexpr const char *kHttpRequestMethod = "http.request.method"; + +/** + * Original HTTP method sent by the client in the request line. + */ +static constexpr const char *kHttpRequestMethodOriginal = "http.request.method_original"; + +/** + * The ordinal number of request resending attempt (for any reason, including redirects). + *

        + * The resend count SHOULD be updated each time an HTTP request gets resent by the client, + * regardless of what was the cause of the resending (e.g. redirection, authorization failure, 503 + * Server Unavailable, network issues, or any other). + */ +static constexpr const char *kHttpRequestResendCount = "http.request.resend_count"; + +/** + * HTTP response headers, @code @endcode being the normalized HTTP Header name (lowercase), + * the value being the header values.

        Instrumentations SHOULD require an explicit configuration + * of which headers are to be captured. Including all response headers can be a security risk - + * explicit configuration helps avoid leaking sensitive information. Users MAY explicitly configure + * instrumentations to capture them even though it is not recommended. The attribute value MUST + * consist of either multiple header values as an array of strings or a single-item array containing + * a possibly comma-concatenated string, depending on the way the HTTP library provides access to + * headers. + */ +static constexpr const char *kHttpResponseHeader = "http.response.header"; + +/** + * HTTP response status code. + */ +static constexpr const char *kHttpResponseStatusCode = "http.response.status_code"; + +/** + * The matched route, that is, the path template in the format used by the respective server + * framework.

        MUST NOT be populated when this is not supported by the HTTP server framework as + * the route attribute should have low-cardinality and the URI path can NOT substitute it. SHOULD + * include the application root if + * there is one. + */ +static constexpr const char *kHttpRoute = "http.route"; + +namespace HttpRequestMethodValues +{ +/** + * CONNECT method. + */ +static constexpr const char *kConnect = "CONNECT"; + +/** + * DELETE method. + */ +static constexpr const char *kDelete = "DELETE"; + +/** + * GET method. + */ +static constexpr const char *kGet = "GET"; + +/** + * HEAD method. + */ +static constexpr const char *kHead = "HEAD"; + +/** + * OPTIONS method. + */ +static constexpr const char *kOptions = "OPTIONS"; + +/** + * PATCH method. + */ +static constexpr const char *kPatch = "PATCH"; + +/** + * POST method. + */ +static constexpr const char *kPost = "POST"; + +/** + * PUT method. + */ +static constexpr const char *kPut = "PUT"; + +/** + * TRACE method. + */ +static constexpr const char *kTrace = "TRACE"; + +/** + * Any HTTP method that the instrumentation has no prior knowledge of. + */ +static constexpr const char *kOther = "_OTHER"; + +} // namespace HttpRequestMethodValues + +} // namespace http +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/http_metrics.h b/api/include/opentelemetry/semconv/http_metrics.h new file mode 100644 index 0000000000..f83172e80e --- /dev/null +++ b/api/include/opentelemetry/semconv/http_metrics.h @@ -0,0 +1,79 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace http +{ + +/** + * Duration of HTTP client requests. + *

        + * histogram + */ +static constexpr const char *kMetricHttpClientRequestDuration = + "metric.http.client.request.duration"; +static constexpr const char *descrMetricHttpClientRequestDuration = + "Duration of HTTP client requests."; +static constexpr const char *unitMetricHttpClientRequestDuration = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHttpClientRequestDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricHttpClientRequestDuration, + descrMetricHttpClientRequestDuration, + unitMetricHttpClientRequestDuration); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHttpClientRequestDuration(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricHttpClientRequestDuration, + descrMetricHttpClientRequestDuration, + unitMetricHttpClientRequestDuration); +} + +/** + * Duration of HTTP server requests. + *

        + * histogram + */ +static constexpr const char *kMetricHttpServerRequestDuration = + "metric.http.server.request.duration"; +static constexpr const char *descrMetricHttpServerRequestDuration = + "Duration of HTTP server requests."; +static constexpr const char *unitMetricHttpServerRequestDuration = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHttpServerRequestDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricHttpServerRequestDuration, + descrMetricHttpServerRequestDuration, + unitMetricHttpServerRequestDuration); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHttpServerRequestDuration(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricHttpServerRequestDuration, + descrMetricHttpServerRequestDuration, + unitMetricHttpServerRequestDuration); +} + +} // namespace http +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/artifact_attributes.h b/api/include/opentelemetry/semconv/incubating/artifact_attributes.h new file mode 100644 index 0000000000..d3bb99f6e5 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/artifact_attributes.h @@ -0,0 +1,81 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace artifact +{ + +/** + * The provenance filename of the built attestation which directly relates to the build artifact + * filename. This filename SHOULD accompany the artifact at publish time. See the SLSA + * Relationship specification for more information. + */ +static constexpr const char *kArtifactAttestationFilename = "artifact.attestation.filename"; + +/** + * The full hash value (see + * glossary), of the built attestation. Some envelopes in the software attestation space also + * refer to this as the digest. + */ +static constexpr const char *kArtifactAttestationHash = "artifact.attestation.hash"; + +/** + * The id of the build software attestation. + */ +static constexpr const char *kArtifactAttestationId = "artifact.attestation.id"; + +/** + * The human readable file name of the artifact, typically generated during build and release + * processes. Often includes the package name and version in the file name.

        This file name can + * also act as the Package Name + * in cases where the package ecosystem maps accordingly. + * Additionally, the artifact can be published for + * others, but that is not a guarantee. + */ +static constexpr const char *kArtifactFilename = "artifact.filename"; + +/** + * The full hash value (see + * glossary), often found in checksum.txt on a release of the artifact and used to verify + * package integrity.

        The specific algorithm used to create the cryptographic hash value is not + * defined. In situations where an artifact has multiple cryptographic hashes, it is up to the + * implementer to choose which hash value to set here; this should be the most secure hash algorithm + * that is suitable for the situation and consistent with the + * corresponding attestation. The implementer can then provide the other + * hash values through an additional set of attribute extensions as they + * deem necessary. + */ +static constexpr const char *kArtifactHash = "artifact.hash"; + +/** + * The Package URL of the package artifact provides a + * standard way to identify and locate the packaged artifact. + */ +static constexpr const char *kArtifactPurl = "artifact.purl"; + +/** + * The version of the artifact. + */ +static constexpr const char *kArtifactVersion = "artifact.version"; + +} // namespace artifact +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/aws_attributes.h b/api/include/opentelemetry/semconv/incubating/aws_attributes.h new file mode 100644 index 0000000000..d0eaa6d08a --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/aws_attributes.h @@ -0,0 +1,356 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace aws +{ + +/** + * The JSON-serialized value of each item in the @code AttributeDefinitions @endcode request field. + */ +static constexpr const char *kAwsDynamodbAttributeDefinitions = + "aws.dynamodb.attribute_definitions"; + +/** + * The value of the @code AttributesToGet @endcode request parameter. + */ +static constexpr const char *kAwsDynamodbAttributesToGet = "aws.dynamodb.attributes_to_get"; + +/** + * The value of the @code ConsistentRead @endcode request parameter. + */ +static constexpr const char *kAwsDynamodbConsistentRead = "aws.dynamodb.consistent_read"; + +/** + * The JSON-serialized value of each item in the @code ConsumedCapacity @endcode response field. + */ +static constexpr const char *kAwsDynamodbConsumedCapacity = "aws.dynamodb.consumed_capacity"; + +/** + * The value of the @code Count @endcode response parameter. + */ +static constexpr const char *kAwsDynamodbCount = "aws.dynamodb.count"; + +/** + * The value of the @code ExclusiveStartTableName @endcode request parameter. + */ +static constexpr const char *kAwsDynamodbExclusiveStartTable = "aws.dynamodb.exclusive_start_table"; + +/** + * The JSON-serialized value of each item in the @code GlobalSecondaryIndexUpdates @endcode request + * field. + */ +static constexpr const char *kAwsDynamodbGlobalSecondaryIndexUpdates = + "aws.dynamodb.global_secondary_index_updates"; + +/** + * The JSON-serialized value of each item of the @code GlobalSecondaryIndexes @endcode request field + */ +static constexpr const char *kAwsDynamodbGlobalSecondaryIndexes = + "aws.dynamodb.global_secondary_indexes"; + +/** + * The value of the @code IndexName @endcode request parameter. + */ +static constexpr const char *kAwsDynamodbIndexName = "aws.dynamodb.index_name"; + +/** + * The JSON-serialized value of the @code ItemCollectionMetrics @endcode response field. + */ +static constexpr const char *kAwsDynamodbItemCollectionMetrics = + "aws.dynamodb.item_collection_metrics"; + +/** + * The value of the @code Limit @endcode request parameter. + */ +static constexpr const char *kAwsDynamodbLimit = "aws.dynamodb.limit"; + +/** + * The JSON-serialized value of each item of the @code LocalSecondaryIndexes @endcode request field. + */ +static constexpr const char *kAwsDynamodbLocalSecondaryIndexes = + "aws.dynamodb.local_secondary_indexes"; + +/** + * The value of the @code ProjectionExpression @endcode request parameter. + */ +static constexpr const char *kAwsDynamodbProjection = "aws.dynamodb.projection"; + +/** + * The value of the @code ProvisionedThroughput.ReadCapacityUnits @endcode request parameter. + */ +static constexpr const char *kAwsDynamodbProvisionedReadCapacity = + "aws.dynamodb.provisioned_read_capacity"; + +/** + * The value of the @code ProvisionedThroughput.WriteCapacityUnits @endcode request parameter. + */ +static constexpr const char *kAwsDynamodbProvisionedWriteCapacity = + "aws.dynamodb.provisioned_write_capacity"; + +/** + * The value of the @code ScanIndexForward @endcode request parameter. + */ +static constexpr const char *kAwsDynamodbScanForward = "aws.dynamodb.scan_forward"; + +/** + * The value of the @code ScannedCount @endcode response parameter. + */ +static constexpr const char *kAwsDynamodbScannedCount = "aws.dynamodb.scanned_count"; + +/** + * The value of the @code Segment @endcode request parameter. + */ +static constexpr const char *kAwsDynamodbSegment = "aws.dynamodb.segment"; + +/** + * The value of the @code Select @endcode request parameter. + */ +static constexpr const char *kAwsDynamodbSelect = "aws.dynamodb.select"; + +/** + * The number of items in the @code TableNames @endcode response parameter. + */ +static constexpr const char *kAwsDynamodbTableCount = "aws.dynamodb.table_count"; + +/** + * The keys in the @code RequestItems @endcode object field. + */ +static constexpr const char *kAwsDynamodbTableNames = "aws.dynamodb.table_names"; + +/** + * The value of the @code TotalSegments @endcode request parameter. + */ +static constexpr const char *kAwsDynamodbTotalSegments = "aws.dynamodb.total_segments"; + +/** + * The ARN of an ECS cluster. + */ +static constexpr const char *kAwsEcsClusterArn = "aws.ecs.cluster.arn"; + +/** + * The Amazon Resource Name (ARN) of an ECS + * container instance. + */ +static constexpr const char *kAwsEcsContainerArn = "aws.ecs.container.arn"; + +/** + * The launch + * type for an ECS task. + */ +static constexpr const char *kAwsEcsLaunchtype = "aws.ecs.launchtype"; + +/** + * The ARN of a running ECS + * task. + */ +static constexpr const char *kAwsEcsTaskArn = "aws.ecs.task.arn"; + +/** + * The family name of the ECS task + * definition used to create the ECS task. + */ +static constexpr const char *kAwsEcsTaskFamily = "aws.ecs.task.family"; + +/** + * The ID of a running ECS task. The ID MUST be extracted from @code task.arn @endcode. + */ +static constexpr const char *kAwsEcsTaskId = "aws.ecs.task.id"; + +/** + * The revision for the task definition used to create the ECS task. + */ +static constexpr const char *kAwsEcsTaskRevision = "aws.ecs.task.revision"; + +/** + * The ARN of an EKS cluster. + */ +static constexpr const char *kAwsEksClusterArn = "aws.eks.cluster.arn"; + +/** + * The full invoked ARN as provided on the @code Context @endcode passed to the function (@code + * Lambda-Runtime-Invoked-Function-Arn @endcode header on the @code /runtime/invocation/next + * @endcode applicable).

        This may be different from @code cloud.resource_id @endcode if an alias + * is involved. + */ +static constexpr const char *kAwsLambdaInvokedArn = "aws.lambda.invoked_arn"; + +/** + * The Amazon Resource Name(s) (ARN) of the AWS log group(s). + *

        + * See the log + * group ARN format documentation. + */ +static constexpr const char *kAwsLogGroupArns = "aws.log.group.arns"; + +/** + * The name(s) of the AWS log group(s) an application is writing to. + *

        + * Multiple log groups must be supported for cases like multi-container applications, where a single + * application has sidecar containers, and each write to their own log group. + */ +static constexpr const char *kAwsLogGroupNames = "aws.log.group.names"; + +/** + * The ARN(s) of the AWS log stream(s). + *

        + * See the log + * stream ARN format documentation. One log group can contain several log streams, so these ARNs + * necessarily identify both a log group and a log stream. + */ +static constexpr const char *kAwsLogStreamArns = "aws.log.stream.arns"; + +/** + * The name(s) of the AWS log stream(s) an application is writing to. + */ +static constexpr const char *kAwsLogStreamNames = "aws.log.stream.names"; + +/** + * The AWS request ID as returned in the response headers @code x-amz-request-id @endcode or @code + * x-amz-requestid @endcode. + */ +static constexpr const char *kAwsRequestId = "aws.request_id"; + +/** + * The S3 bucket name the request refers to. Corresponds to the @code --bucket @endcode parameter of + * the S3 API + * operations.

        The @code bucket @endcode attribute is applicable to all S3 operations that + * reference a bucket, i.e. that require the bucket name as a mandatory parameter. This applies to + * almost all S3 operations except @code list-buckets @endcode. + */ +static constexpr const char *kAwsS3Bucket = "aws.s3.bucket"; + +/** + * The source object (in the form @code bucket @endcode/@code key @endcode) for the copy operation. + *

        + * The @code copy_source @endcode attribute applies to S3 copy operations and corresponds to the + * @code --copy-source @endcode parameter of the copy-object + * operation within the S3 API. This applies in particular to the following operations:

        + */ +static constexpr const char *kAwsS3CopySource = "aws.s3.copy_source"; + +/** + * The delete request container that specifies the objects to be deleted. + *

        + * The @code delete @endcode attribute is only applicable to the delete-object + * operation. The @code delete @endcode attribute corresponds to the @code --delete @endcode + * parameter of the delete-objects + * operation within the S3 API. + */ +static constexpr const char *kAwsS3Delete = "aws.s3.delete"; + +/** + * The S3 object key the request refers to. Corresponds to the @code --key @endcode parameter of the + * S3 API + * operations.

        The @code key @endcode attribute is applicable to all object-related S3 + * operations, i.e. that require the object key as a mandatory parameter. This applies in particular + * to the following operations:

        + */ +static constexpr const char *kAwsS3Key = "aws.s3.key"; + +/** + * The part number of the part being uploaded in a multipart-upload operation. This is a positive + * integer between 1 and 10,000.

        The @code part_number @endcode attribute is only applicable to + * the upload-part + * and upload-part-copy + * operations. The @code part_number @endcode attribute corresponds to the @code --part-number + * @endcode parameter of the upload-part + * operation within the S3 API. + */ +static constexpr const char *kAwsS3PartNumber = "aws.s3.part_number"; + +/** + * Upload ID that identifies the multipart upload. + *

        + * The @code upload_id @endcode attribute applies to S3 multipart-upload operations and corresponds + * to the @code --upload-id @endcode parameter of the S3 API multipart + * operations. This applies in particular to the following operations:

        + */ +static constexpr const char *kAwsS3UploadId = "aws.s3.upload_id"; + +namespace AwsEcsLaunchtypeValues +{ +/** + * none + */ +static constexpr const char *kEc2 = "ec2"; + +/** + * none + */ +static constexpr const char *kFargate = "fargate"; + +} // namespace AwsEcsLaunchtypeValues + +} // namespace aws +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/az_attributes.h b/api/include/opentelemetry/semconv/incubating/az_attributes.h new file mode 100644 index 0000000000..5e12c82f7b --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/az_attributes.h @@ -0,0 +1,30 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace az +{ + +/** + * The unique identifier of the service request. It's generated by the Azure service and returned + * with the response. + */ +static constexpr const char *kAzServiceRequestId = "az.service_request_id"; + +} // namespace az +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/browser_attributes.h b/api/include/opentelemetry/semconv/incubating/browser_attributes.h new file mode 100644 index 0000000000..5ddb61eae5 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/browser_attributes.h @@ -0,0 +1,65 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace browser +{ + +/** + * Array of brand name and version separated by a space + *

        + * This value is intended to be taken from the UA client hints API (@code + * navigator.userAgentData.brands @endcode). + */ +static constexpr const char *kBrowserBrands = "browser.brands"; + +/** + * Preferred language of the user using the browser + *

        + * This value is intended to be taken from the Navigator API @code navigator.language @endcode. + */ +static constexpr const char *kBrowserLanguage = "browser.language"; + +/** + * A boolean that is true if the browser is running on a mobile device + *

        + * This value is intended to be taken from the UA client hints API (@code + * navigator.userAgentData.mobile @endcode). If unavailable, this attribute SHOULD be left unset. + */ +static constexpr const char *kBrowserMobile = "browser.mobile"; + +/** + * The platform on which the browser is running + *

        + * This value is intended to be taken from the UA client hints API (@code + * navigator.userAgentData.platform @endcode). If unavailable, the legacy @code navigator.platform + * @endcode API SHOULD NOT be used instead and this attribute SHOULD be left unset in order for the + * values to be consistent. The list of possible values is defined in the W3C User-Agent Client Hints + * specification. Note that some (but not all) of these values can overlap with values in the @code os.type @endcode and @code os.name @endcode attributes. However, for + * consistency, the values in the @code browser.platform @endcode attribute should capture the exact + * value that the user agent provides. + */ +static constexpr const char *kBrowserPlatform = "browser.platform"; + +} // namespace browser +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/cicd_attributes.h b/api/include/opentelemetry/semconv/incubating/cicd_attributes.h new file mode 100644 index 0000000000..246563a8e8 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/cicd_attributes.h @@ -0,0 +1,76 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace cicd +{ + +/** + * The human readable name of the pipeline within a CI/CD system. + */ +static constexpr const char *kCicdPipelineName = "cicd.pipeline.name"; + +/** + * The unique identifier of a pipeline run within a CI/CD system. + */ +static constexpr const char *kCicdPipelineRunId = "cicd.pipeline.run.id"; + +/** + * The human readable name of a task within a pipeline. Task here most closely aligns with a computing process in a pipeline. + * Other terms for tasks include commands, steps, and procedures. + */ +static constexpr const char *kCicdPipelineTaskName = "cicd.pipeline.task.name"; + +/** + * The unique identifier of a task run within a pipeline. + */ +static constexpr const char *kCicdPipelineTaskRunId = "cicd.pipeline.task.run.id"; + +/** + * The URL of the pipeline run providing the + * complete address in order to locate and identify the pipeline run. + */ +static constexpr const char *kCicdPipelineTaskRunUrlFull = "cicd.pipeline.task.run.url.full"; + +/** + * The type of the task within a pipeline. + */ +static constexpr const char *kCicdPipelineTaskType = "cicd.pipeline.task.type"; + +namespace CicdPipelineTaskTypeValues +{ +/** + * build + */ +static constexpr const char *kBuild = "build"; + +/** + * test + */ +static constexpr const char *kTest = "test"; + +/** + * deploy + */ +static constexpr const char *kDeploy = "deploy"; + +} // namespace CicdPipelineTaskTypeValues + +} // namespace cicd +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/client_attributes.h b/api/include/opentelemetry/semconv/incubating/client_attributes.h new file mode 100644 index 0000000000..ec984cc406 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/client_attributes.h @@ -0,0 +1,41 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace client +{ + +/** + * Client address - domain name if available without reverse DNS lookup; otherwise, IP address or + * Unix domain socket name.

        When observed from the server side, and when communicating through + * an intermediary, @code client.address @endcode SHOULD represent the client address behind any + * intermediaries, for example proxies, if it's available. + */ +static constexpr const char *kClientAddress = "client.address"; + +/** + * Client port number. + *

        + * When observed from the server side, and when communicating through an intermediary, @code + * client.port @endcode SHOULD represent the client port behind any intermediaries, for example + * proxies, if it's available. + */ +static constexpr const char *kClientPort = "client.port"; + +} // namespace client +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/cloud_attributes.h b/api/include/opentelemetry/semconv/incubating/cloud_attributes.h new file mode 100644 index 0000000000..cd76489eba --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/cloud_attributes.h @@ -0,0 +1,272 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace cloud +{ + +/** + * The cloud account ID the resource is assigned to. + */ +static constexpr const char *kCloudAccountId = "cloud.account.id"; + +/** + * Cloud regions often have multiple, isolated locations known as zones to increase availability. + * Availability zone represents the zone where the resource is running.

        Availability zones are + * called "zones" on Alibaba Cloud and Google Cloud. + */ +static constexpr const char *kCloudAvailabilityZone = "cloud.availability_zone"; + +/** + * The cloud platform in use. + *

        + * The prefix of the service SHOULD match the one specified in @code cloud.provider @endcode. + */ +static constexpr const char *kCloudPlatform = "cloud.platform"; + +/** + * Name of the cloud provider. + */ +static constexpr const char *kCloudProvider = "cloud.provider"; + +/** + * The geographical region the resource is running. + *

        + * Refer to your provider's docs to see the available regions, for example Alibaba Cloud regions, AWS regions, Azure regions, Google Cloud regions, or Tencent Cloud regions. + */ +static constexpr const char *kCloudRegion = "cloud.region"; + +/** + * Cloud provider-specific native identifier of the monitored cloud resource (e.g. an ARN on AWS, + * a fully qualified + * resource ID on Azure, a full resource + * name on GCP)

        On some cloud providers, it may not be possible to determine the full ID at + * startup, so it may be necessary to set @code cloud.resource_id @endcode as a span attribute + * instead.

        The exact value to use for @code cloud.resource_id @endcode depends on the cloud + * provider. The following well-known definitions MUST be used if you set this attribute and they + * apply:

        • AWS Lambda: The function ARN. Take + * care not to use the "invoked ARN" directly but replace any alias suffix + * with the resolved function version, as the same runtime instance may be invocable with + * multiple different aliases.
        • + *
        • GCP: The URI of the resource
        • + *
        • Azure: The Fully Qualified Resource + * ID of the invoked function, not the function app, having the form + * @code + * /subscriptions//resourceGroups//providers/Microsoft.Web/sites//functions/ + * @endcode. This means that a span attribute MUST be used, as an Azure function app can host + * multiple functions that would usually share a TracerProvider.
        • + *
        + */ +static constexpr const char *kCloudResourceId = "cloud.resource_id"; + +namespace CloudPlatformValues +{ +/** + * Alibaba Cloud Elastic Compute Service + */ +static constexpr const char *kAlibabaCloudEcs = "alibaba_cloud_ecs"; + +/** + * Alibaba Cloud Function Compute + */ +static constexpr const char *kAlibabaCloudFc = "alibaba_cloud_fc"; + +/** + * Red Hat OpenShift on Alibaba Cloud + */ +static constexpr const char *kAlibabaCloudOpenshift = "alibaba_cloud_openshift"; + +/** + * AWS Elastic Compute Cloud + */ +static constexpr const char *kAwsEc2 = "aws_ec2"; + +/** + * AWS Elastic Container Service + */ +static constexpr const char *kAwsEcs = "aws_ecs"; + +/** + * AWS Elastic Kubernetes Service + */ +static constexpr const char *kAwsEks = "aws_eks"; + +/** + * AWS Lambda + */ +static constexpr const char *kAwsLambda = "aws_lambda"; + +/** + * AWS Elastic Beanstalk + */ +static constexpr const char *kAwsElasticBeanstalk = "aws_elastic_beanstalk"; + +/** + * AWS App Runner + */ +static constexpr const char *kAwsAppRunner = "aws_app_runner"; + +/** + * Red Hat OpenShift on AWS (ROSA) + */ +static constexpr const char *kAwsOpenshift = "aws_openshift"; + +/** + * Azure Virtual Machines + */ +static constexpr const char *kAzureVm = "azure_vm"; + +/** + * Azure Container Apps + */ +static constexpr const char *kAzureContainerApps = "azure_container_apps"; + +/** + * Azure Container Instances + */ +static constexpr const char *kAzureContainerInstances = "azure_container_instances"; + +/** + * Azure Kubernetes Service + */ +static constexpr const char *kAzureAks = "azure_aks"; + +/** + * Azure Functions + */ +static constexpr const char *kAzureFunctions = "azure_functions"; + +/** + * Azure App Service + */ +static constexpr const char *kAzureAppService = "azure_app_service"; + +/** + * Azure Red Hat OpenShift + */ +static constexpr const char *kAzureOpenshift = "azure_openshift"; + +/** + * Google Bare Metal Solution (BMS) + */ +static constexpr const char *kGcpBareMetalSolution = "gcp_bare_metal_solution"; + +/** + * Google Cloud Compute Engine (GCE) + */ +static constexpr const char *kGcpComputeEngine = "gcp_compute_engine"; + +/** + * Google Cloud Run + */ +static constexpr const char *kGcpCloudRun = "gcp_cloud_run"; + +/** + * Google Cloud Kubernetes Engine (GKE) + */ +static constexpr const char *kGcpKubernetesEngine = "gcp_kubernetes_engine"; + +/** + * Google Cloud Functions (GCF) + */ +static constexpr const char *kGcpCloudFunctions = "gcp_cloud_functions"; + +/** + * Google Cloud App Engine (GAE) + */ +static constexpr const char *kGcpAppEngine = "gcp_app_engine"; + +/** + * Red Hat OpenShift on Google Cloud + */ +static constexpr const char *kGcpOpenshift = "gcp_openshift"; + +/** + * Red Hat OpenShift on IBM Cloud + */ +static constexpr const char *kIbmCloudOpenshift = "ibm_cloud_openshift"; + +/** + * Tencent Cloud Cloud Virtual Machine (CVM) + */ +static constexpr const char *kTencentCloudCvm = "tencent_cloud_cvm"; + +/** + * Tencent Cloud Elastic Kubernetes Service (EKS) + */ +static constexpr const char *kTencentCloudEks = "tencent_cloud_eks"; + +/** + * Tencent Cloud Serverless Cloud Function (SCF) + */ +static constexpr const char *kTencentCloudScf = "tencent_cloud_scf"; + +} // namespace CloudPlatformValues + +namespace CloudProviderValues +{ +/** + * Alibaba Cloud + */ +static constexpr const char *kAlibabaCloud = "alibaba_cloud"; + +/** + * Amazon Web Services + */ +static constexpr const char *kAws = "aws"; + +/** + * Microsoft Azure + */ +static constexpr const char *kAzure = "azure"; + +/** + * Google Cloud Platform + */ +static constexpr const char *kGcp = "gcp"; + +/** + * Heroku Platform as a Service + */ +static constexpr const char *kHeroku = "heroku"; + +/** + * IBM Cloud + */ +static constexpr const char *kIbmCloud = "ibm_cloud"; + +/** + * Tencent Cloud + */ +static constexpr const char *kTencentCloud = "tencent_cloud"; + +} // namespace CloudProviderValues + +} // namespace cloud +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/cloudevents_attributes.h b/api/include/opentelemetry/semconv/incubating/cloudevents_attributes.h new file mode 100644 index 0000000000..363feed157 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/cloudevents_attributes.h @@ -0,0 +1,58 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace cloudevents +{ + +/** + * The event_id + * uniquely identifies the event. + */ +static constexpr const char *kCloudeventsEventId = "cloudevents.event_id"; + +/** + * The source + * identifies the context in which an event happened. + */ +static constexpr const char *kCloudeventsEventSource = "cloudevents.event_source"; + +/** + * The version of + * the CloudEvents specification which the event uses. + */ +static constexpr const char *kCloudeventsEventSpecVersion = "cloudevents.event_spec_version"; + +/** + * The subject of + * the event in the context of the event producer (identified by source). + */ +static constexpr const char *kCloudeventsEventSubject = "cloudevents.event_subject"; + +/** + * The event_type + * contains a value describing the type of event related to the originating occurrence. + */ +static constexpr const char *kCloudeventsEventType = "cloudevents.event_type"; + +} // namespace cloudevents +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/code_attributes.h b/api/include/opentelemetry/semconv/incubating/code_attributes.h new file mode 100644 index 0000000000..f2715e87b6 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/code_attributes.h @@ -0,0 +1,60 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace code +{ + +/** + * The column number in @code code.filepath @endcode best representing the operation. It SHOULD + * point within the code unit named in @code code.function @endcode. + */ +static constexpr const char *kCodeColumn = "code.column"; + +/** + * The source code file name that identifies the code unit as uniquely as possible (preferably an + * absolute file path). + */ +static constexpr const char *kCodeFilepath = "code.filepath"; + +/** + * The method or function name, or equivalent (usually rightmost part of the code unit's name). + */ +static constexpr const char *kCodeFunction = "code.function"; + +/** + * The line number in @code code.filepath @endcode best representing the operation. It SHOULD point + * within the code unit named in @code code.function @endcode. + */ +static constexpr const char *kCodeLineno = "code.lineno"; + +/** + * The "namespace" within which @code code.function @endcode is defined. Usually the qualified class + * or module name, such that @code code.namespace @endcode + some separator + @code code.function + * @endcode form a unique identifier for the code unit. + */ +static constexpr const char *kCodeNamespace = "code.namespace"; + +/** + * A stacktrace as a string in the natural representation for the language runtime. The + * representation is to be determined and documented by each language SIG. + */ +static constexpr const char *kCodeStacktrace = "code.stacktrace"; + +} // namespace code +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/container_attributes.h b/api/include/opentelemetry/semconv/incubating/container_attributes.h new file mode 100644 index 0000000000..5bd1118c3b --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/container_attributes.h @@ -0,0 +1,141 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace container +{ + +/** + * The command used to run the container (i.e. the command name). + *

        + * If using embedded credentials or sensitive data, it is recommended to remove them to prevent + * potential leakage. + */ +static constexpr const char *kContainerCommand = "container.command"; + +/** + * All the command arguments (including the command/executable itself) run by the container. [2] + */ +static constexpr const char *kContainerCommandArgs = "container.command_args"; + +/** + * The full command run by the container as a single string representing the full command. [2] + */ +static constexpr const char *kContainerCommandLine = "container.command_line"; + +/** + * Deprecated, use @code cpu.mode @endcode instead. + *

        + * @deprecated + * Replaced by @code cpu.mode @endcode + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kContainerCpuState = "container.cpu.state"; + +/** + * Container ID. Usually a UUID, as for example used to identify Docker + * containers. The UUID might be abbreviated. + */ +static constexpr const char *kContainerId = "container.id"; + +/** + * Runtime specific image identifier. Usually a hash algorithm followed by a UUID. + *

        + * Docker defines a sha256 of the image id; @code container.image.id @endcode corresponds to the + * @code Image @endcode field from the Docker container inspect API + * endpoint. K8s defines a link to the container registry repository with digest @code "imageID": + * "registry.azurecr.io + * /namespace/service/dockerfile@sha256:bdeabd40c3a8a492eaf9e8e44d0ebbb84bac7ee25ac0cf8a7159d25f62555625" + * @endcode. The ID is assigned by the container runtime and can vary in different environments. + * Consider using @code oci.manifest.digest @endcode if it is important to identify the same image + * in different environments/runtimes. + */ +static constexpr const char *kContainerImageId = "container.image.id"; + +/** + * Name of the image the container was built on. + */ +static constexpr const char *kContainerImageName = "container.image.name"; + +/** + * Repo digests of the container image as provided by the container runtime. + *

        + * Docker + * and CRI + * report those under the @code RepoDigests @endcode field. + */ +static constexpr const char *kContainerImageRepoDigests = "container.image.repo_digests"; + +/** + * Container image tags. An example can be found in Docker Image + * Inspect. Should be only the @code @endcode section of the full name for example from + * @code registry.example.com/my-org/my-image: @endcode. + */ +static constexpr const char *kContainerImageTags = "container.image.tags"; + +/** + * Container labels, @code @endcode being the label name, the value being the label value. + */ +static constexpr const char *kContainerLabel = "container.label"; + +/** + * Deprecated, use @code container.label @endcode instead. + *

        + * @deprecated + * Replaced by @code container.label @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kContainerLabels = "container.labels"; + +/** + * Container name used by container runtime. + */ +static constexpr const char *kContainerName = "container.name"; + +/** + * The container runtime managing this container. + */ +static constexpr const char *kContainerRuntime = "container.runtime"; + +namespace ContainerCpuStateValues +{ +/** + * When tasks of the cgroup are in user mode (Linux). When all container processes are in user mode + * (Windows). + */ +static constexpr const char *kUser = "user"; + +/** + * When CPU is used by the system (host OS) + */ +static constexpr const char *kSystem = "system"; + +/** + * When tasks of the cgroup are in kernel mode (Linux). When all container processes are in kernel + * mode (Windows). + */ +static constexpr const char *kKernel = "kernel"; + +} // namespace ContainerCpuStateValues + +} // namespace container +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/container_metrics.h b/api/include/opentelemetry/semconv/incubating/container_metrics.h new file mode 100644 index 0000000000..e670fb3788 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/container_metrics.h @@ -0,0 +1,181 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace container +{ + +/** + * Total CPU time consumed + *

        + * Total CPU time consumed by the specific container on all available CPU cores + *

        + * counter + */ +static constexpr const char *kMetricContainerCpuTime = "metric.container.cpu.time"; +static constexpr const char *descrMetricContainerCpuTime = "Total CPU time consumed"; +static constexpr const char *unitMetricContainerCpuTime = "s"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricContainerCpuTime( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricContainerCpuTime, descrMetricContainerCpuTime, + unitMetricContainerCpuTime); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricContainerCpuTime( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricContainerCpuTime, descrMetricContainerCpuTime, + unitMetricContainerCpuTime); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricContainerCpuTime(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricContainerCpuTime, descrMetricContainerCpuTime, + unitMetricContainerCpuTime); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricContainerCpuTime(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricContainerCpuTime, descrMetricContainerCpuTime, + unitMetricContainerCpuTime); +} + +/** + * Disk bytes for the container. + *

        + * The total number of bytes read/written successfully (aggregated from all disks). + *

        + * counter + */ +static constexpr const char *kMetricContainerDiskIo = "metric.container.disk.io"; +static constexpr const char *descrMetricContainerDiskIo = "Disk bytes for the container."; +static constexpr const char *unitMetricContainerDiskIo = "By"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricContainerDiskIo( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricContainerDiskIo, descrMetricContainerDiskIo, + unitMetricContainerDiskIo); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricContainerDiskIo( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricContainerDiskIo, descrMetricContainerDiskIo, + unitMetricContainerDiskIo); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricContainerDiskIo(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricContainerDiskIo, descrMetricContainerDiskIo, + unitMetricContainerDiskIo); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricContainerDiskIo(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricContainerDiskIo, descrMetricContainerDiskIo, + unitMetricContainerDiskIo); +} + +/** + * Memory usage of the container. + *

        + * Memory usage of the container. + *

        + * counter + */ +static constexpr const char *kMetricContainerMemoryUsage = "metric.container.memory.usage"; +static constexpr const char *descrMetricContainerMemoryUsage = "Memory usage of the container."; +static constexpr const char *unitMetricContainerMemoryUsage = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricContainerMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricContainerMemoryUsage, descrMetricContainerMemoryUsage, + unitMetricContainerMemoryUsage); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricContainerMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricContainerMemoryUsage, descrMetricContainerMemoryUsage, + unitMetricContainerMemoryUsage); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricContainerMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter( + kMetricContainerMemoryUsage, descrMetricContainerMemoryUsage, unitMetricContainerMemoryUsage); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricContainerMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter( + kMetricContainerMemoryUsage, descrMetricContainerMemoryUsage, unitMetricContainerMemoryUsage); +} + +/** + * Network bytes for the container. + *

        + * The number of bytes sent/received on all network interfaces by the container. + *

        + * counter + */ +static constexpr const char *kMetricContainerNetworkIo = "metric.container.network.io"; +static constexpr const char *descrMetricContainerNetworkIo = "Network bytes for the container."; +static constexpr const char *unitMetricContainerNetworkIo = "By"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricContainerNetworkIo( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricContainerNetworkIo, descrMetricContainerNetworkIo, + unitMetricContainerNetworkIo); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricContainerNetworkIo( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricContainerNetworkIo, descrMetricContainerNetworkIo, + unitMetricContainerNetworkIo); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricContainerNetworkIo(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter( + kMetricContainerNetworkIo, descrMetricContainerNetworkIo, unitMetricContainerNetworkIo); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricContainerNetworkIo(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter( + kMetricContainerNetworkIo, descrMetricContainerNetworkIo, unitMetricContainerNetworkIo); +} + +} // namespace container +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/cpu_attributes.h b/api/include/opentelemetry/semconv/incubating/cpu_attributes.h new file mode 100644 index 0000000000..b5ca637e31 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/cpu_attributes.h @@ -0,0 +1,73 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace cpu +{ + +/** + * The mode of the CPU + */ +static constexpr const char *kCpuMode = "cpu.mode"; + +namespace CpuModeValues +{ +/** + * none + */ +static constexpr const char *kUser = "user"; + +/** + * none + */ +static constexpr const char *kSystem = "system"; + +/** + * none + */ +static constexpr const char *kNice = "nice"; + +/** + * none + */ +static constexpr const char *kIdle = "idle"; + +/** + * none + */ +static constexpr const char *kIowait = "iowait"; + +/** + * none + */ +static constexpr const char *kInterrupt = "interrupt"; + +/** + * none + */ +static constexpr const char *kSteal = "steal"; + +/** + * none + */ +static constexpr const char *kKernel = "kernel"; + +} // namespace CpuModeValues + +} // namespace cpu +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/db_attributes.h b/api/include/opentelemetry/semconv/incubating/db_attributes.h new file mode 100644 index 0000000000..940f88b7da --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/db_attributes.h @@ -0,0 +1,820 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace db +{ + +/** + * The consistency level of the query. Based on consistency values from CQL. + */ +static constexpr const char *kDbCassandraConsistencyLevel = "db.cassandra.consistency_level"; + +/** + * The data center of the coordinating node for a query. + */ +static constexpr const char *kDbCassandraCoordinatorDc = "db.cassandra.coordinator.dc"; + +/** + * The ID of the coordinating node for a query. + */ +static constexpr const char *kDbCassandraCoordinatorId = "db.cassandra.coordinator.id"; + +/** + * Whether or not the query is idempotent. + */ +static constexpr const char *kDbCassandraIdempotence = "db.cassandra.idempotence"; + +/** + * The fetch size used for paging, i.e. how many rows will be returned at once. + */ +static constexpr const char *kDbCassandraPageSize = "db.cassandra.page_size"; + +/** + * The number of times a query was speculatively executed. Not set or @code 0 @endcode if the query + * was not executed speculatively. + */ +static constexpr const char *kDbCassandraSpeculativeExecutionCount = + "db.cassandra.speculative_execution_count"; + +/** + * Deprecated, use @code db.collection.name @endcode instead. + *

        + * @deprecated + * Replaced by @code db.collection.name @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbCassandraTable = "db.cassandra.table"; + +/** + * The name of the connection pool; unique within the instrumented application. In case the + * connection pool implementation doesn't provide a name, instrumentation SHOULD use a combination + * of parameters that would make the name unique, for example, combining attributes @code + * server.address @endcode, @code server.port @endcode, and @code db.namespace @endcode, formatted + * as @code server.address:server.port/db.namespace @endcode. Instrumentations that generate + * connection pool name following different patterns SHOULD document it. + */ +static constexpr const char *kDbClientConnectionPoolName = "db.client.connection.pool.name"; + +/** + * The state of a connection in the pool + */ +static constexpr const char *kDbClientConnectionState = "db.client.connection.state"; + +/** + * Deprecated, use @code db.client.connection.pool.name @endcode instead. + *

        + * @deprecated + * Replaced by @code db.client.connection.pool.name @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbClientConnectionsPoolName = "db.client.connections.pool.name"; + +/** + * Deprecated, use @code db.client.connection.state @endcode instead. + *

        + * @deprecated + * Replaced by @code db.client.connection.state @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbClientConnectionsState = "db.client.connections.state"; + +/** + * The name of a collection (table, container) within the database. + *

        + * It is RECOMMENDED to capture the value as provided by the application without attempting to do + * any case normalization. If the collection name is parsed from the query text, it SHOULD be the + * first collection name found in the query and it SHOULD match the value provided in the query text + * including any schema and database name prefix. For batch operations, if the individual operations + * are known to have the same collection name then that collection name SHOULD be used, otherwise + * @code db.collection.name @endcode SHOULD NOT be captured. + */ +static constexpr const char *kDbCollectionName = "db.collection.name"; + +/** + * Deprecated, use @code server.address @endcode, @code server.port @endcode attributes instead. + *

        + * @deprecated + * "Replaced by @code server.address @endcode and @code server.port @endcode." + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbConnectionString = "db.connection_string"; + +/** + * Unique Cosmos client instance id. + */ +static constexpr const char *kDbCosmosdbClientId = "db.cosmosdb.client_id"; + +/** + * Cosmos client connection mode. + */ +static constexpr const char *kDbCosmosdbConnectionMode = "db.cosmosdb.connection_mode"; + +/** + * Deprecated, use @code db.collection.name @endcode instead. + *

        + * @deprecated + * Replaced by @code db.collection.name @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbCosmosdbContainer = "db.cosmosdb.container"; + +/** + * CosmosDB Operation Type. + */ +static constexpr const char *kDbCosmosdbOperationType = "db.cosmosdb.operation_type"; + +/** + * RU consumed for that operation + */ +static constexpr const char *kDbCosmosdbRequestCharge = "db.cosmosdb.request_charge"; + +/** + * Request payload size in bytes + */ +static constexpr const char *kDbCosmosdbRequestContentLength = "db.cosmosdb.request_content_length"; + +/** + * Cosmos DB status code. + */ +static constexpr const char *kDbCosmosdbStatusCode = "db.cosmosdb.status_code"; + +/** + * Cosmos DB sub status code. + */ +static constexpr const char *kDbCosmosdbSubStatusCode = "db.cosmosdb.sub_status_code"; + +/** + * Deprecated, use @code db.namespace @endcode instead. + *

        + * @deprecated + * Replaced by @code db.namespace @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbElasticsearchClusterName = "db.elasticsearch.cluster.name"; + +/** + * Represents the human-readable identifier of the node/instance to which a request was routed. + */ +static constexpr const char *kDbElasticsearchNodeName = "db.elasticsearch.node.name"; + +/** + * A dynamic value in the url path. + *

        + * Many Elasticsearch url paths allow dynamic values. These SHOULD be recorded in span attributes in + * the format @code db.elasticsearch.path_parts. @endcode, where @code @endcode is the + * url path part name. The implementation SHOULD reference the elasticsearch + * schema in order to map the path part values to their names. + */ +static constexpr const char *kDbElasticsearchPathParts = "db.elasticsearch.path_parts"; + +/** + * Deprecated, no general replacement at this time. For Elasticsearch, use @code + * db.elasticsearch.node.name @endcode instead.

        + * @deprecated + * Deprecated, no general replacement at this time. For Elasticsearch, use @code + * db.elasticsearch.node.name @endcode instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbInstanceId = "db.instance.id"; + +/** + * Removed, no replacement at this time. + *

        + * @deprecated + * Removed as not used. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbJdbcDriverClassname = "db.jdbc.driver_classname"; + +/** + * Deprecated, use @code db.collection.name @endcode instead. + *

        + * @deprecated + * Replaced by @code db.collection.name @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbMongodbCollection = "db.mongodb.collection"; + +/** + * Deprecated, SQL Server instance is now populated as a part of @code db.namespace @endcode + * attribute.

        + * @deprecated + * Deprecated, no replacement at this time. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbMssqlInstanceName = "db.mssql.instance_name"; + +/** + * Deprecated, use @code db.namespace @endcode instead. + *

        + * @deprecated + * Replaced by @code db.namespace @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbName = "db.name"; + +/** + * The name of the database, fully qualified within the server address and port. + *

        + * If a database system has multiple namespace components, they SHOULD be concatenated (potentially + * using database system specific conventions) from most general to most specific namespace + * component, and more specific namespaces SHOULD NOT be captured without the more general + * namespaces, to ensure that "startswith" queries for the more general namespaces will be valid. + * Semantic conventions for individual database systems SHOULD document what @code db.namespace + * @endcode means in the context of that system. It is RECOMMENDED to capture the value as provided + * by the application without attempting to do any case normalization. + */ +static constexpr const char *kDbNamespace = "db.namespace"; + +/** + * Deprecated, use @code db.operation.name @endcode instead. + *

        + * @deprecated + * Replaced by @code db.operation.name @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbOperation = "db.operation"; + +/** + * The number of queries included in a batch operation.

        Operations are + * only considered batches when they contain two or more operations, and so @code + * db.operation.batch.size @endcode SHOULD never be @code 1 @endcode. + */ +static constexpr const char *kDbOperationBatchSize = "db.operation.batch.size"; + +/** + * The name of the operation or command being executed. + *

        + * It is RECOMMENDED to capture the value as provided by the application without attempting to do + * any case normalization. If the operation name is parsed from the query text, it SHOULD be the + * first operation name found in the query. For batch operations, if the individual operations are + * known to have the same operation name then that operation name SHOULD be used prepended by @code + * BATCH @endcode, otherwise @code db.operation.name @endcode SHOULD be @code BATCH @endcode or + * some other database system specific term if more applicable. + */ +static constexpr const char *kDbOperationName = "db.operation.name"; + +/** + * A query parameter used in @code db.query.text @endcode, with @code @endcode being the + * parameter name, and the attribute value being a string representation of the parameter value.

        + * Query parameters should only be captured when @code db.query.text @endcode is parameterized with + * placeholders. If a parameter has no name and instead is referenced only by index, then @code + * @endcode SHOULD be the 0-based index. + */ +static constexpr const char *kDbQueryParameter = "db.query.parameter"; + +/** + * The database query being executed. + *

        + * For sanitization see Sanitization of @code + * db.query.text @endcode. For batch operations, if the individual operations are known to have + * the same query text then that query text SHOULD be used, otherwise all of the individual query + * texts SHOULD be concatenated with separator @code ; @endcode or some other database system + * specific separator if more applicable. Even though parameterized query text can potentially have + * sensitive data, by using a parameterized query the user is giving a strong signal that any + * sensitive data will be passed as parameter values, and the benefit to observability of capturing + * the static part of the query text by default outweighs the risk. + */ +static constexpr const char *kDbQueryText = "db.query.text"; + +/** + * Deprecated, use @code db.namespace @endcode instead. + *

        + * @deprecated + * Replaced by @code db.namespace @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbRedisDatabaseIndex = "db.redis.database_index"; + +/** + * Deprecated, use @code db.collection.name @endcode instead. + *

        + * @deprecated + * Replaced by @code db.collection.name @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbSqlTable = "db.sql.table"; + +/** + * The database statement being executed. + *

        + * @deprecated + * Replaced by @code db.query.text @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbStatement = "db.statement"; + +/** + * The database management system (DBMS) product as identified by the client instrumentation. + *

        + * The actual DBMS may differ from the one identified by the client. For example, when using + * PostgreSQL client libraries to connect to a CockroachDB, the @code db.system @endcode is set to + * @code postgresql @endcode based on the instrumentation's best knowledge. + */ +static constexpr const char *kDbSystem = "db.system"; + +/** + * Deprecated, no replacement at this time. + *

        + * @deprecated + * No replacement at this time. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbUser = "db.user"; + +namespace DbCassandraConsistencyLevelValues +{ +/** + * none + */ +static constexpr const char *kAll = "all"; + +/** + * none + */ +static constexpr const char *kEachQuorum = "each_quorum"; + +/** + * none + */ +static constexpr const char *kQuorum = "quorum"; + +/** + * none + */ +static constexpr const char *kLocalQuorum = "local_quorum"; + +/** + * none + */ +static constexpr const char *kOne = "one"; + +/** + * none + */ +static constexpr const char *kTwo = "two"; + +/** + * none + */ +static constexpr const char *kThree = "three"; + +/** + * none + */ +static constexpr const char *kLocalOne = "local_one"; + +/** + * none + */ +static constexpr const char *kAny = "any"; + +/** + * none + */ +static constexpr const char *kSerial = "serial"; + +/** + * none + */ +static constexpr const char *kLocalSerial = "local_serial"; + +} // namespace DbCassandraConsistencyLevelValues + +namespace DbClientConnectionStateValues +{ +/** + * none + */ +static constexpr const char *kIdle = "idle"; + +/** + * none + */ +static constexpr const char *kUsed = "used"; + +} // namespace DbClientConnectionStateValues + +namespace DbClientConnectionsStateValues +{ +/** + * none + */ +static constexpr const char *kIdle = "idle"; + +/** + * none + */ +static constexpr const char *kUsed = "used"; + +} // namespace DbClientConnectionsStateValues + +namespace DbCosmosdbConnectionModeValues +{ +/** + * Gateway (HTTP) connections mode + */ +static constexpr const char *kGateway = "gateway"; + +/** + * Direct connection. + */ +static constexpr const char *kDirect = "direct"; + +} // namespace DbCosmosdbConnectionModeValues + +namespace DbCosmosdbOperationTypeValues +{ +/** + * none + */ +static constexpr const char *kInvalid = "Invalid"; + +/** + * none + */ +static constexpr const char *kCreate = "Create"; + +/** + * none + */ +static constexpr const char *kPatch = "Patch"; + +/** + * none + */ +static constexpr const char *kRead = "Read"; + +/** + * none + */ +static constexpr const char *kReadFeed = "ReadFeed"; + +/** + * none + */ +static constexpr const char *kDelete = "Delete"; + +/** + * none + */ +static constexpr const char *kReplace = "Replace"; + +/** + * none + */ +static constexpr const char *kExecute = "Execute"; + +/** + * none + */ +static constexpr const char *kQuery = "Query"; + +/** + * none + */ +static constexpr const char *kHead = "Head"; + +/** + * none + */ +static constexpr const char *kHeadFeed = "HeadFeed"; + +/** + * none + */ +static constexpr const char *kUpsert = "Upsert"; + +/** + * none + */ +static constexpr const char *kBatch = "Batch"; + +/** + * none + */ +static constexpr const char *kQueryPlan = "QueryPlan"; + +/** + * none + */ +static constexpr const char *kExecuteJavascript = "ExecuteJavaScript"; + +} // namespace DbCosmosdbOperationTypeValues + +namespace DbSystemValues +{ +/** + * Some other SQL database. Fallback only. See notes. + */ +static constexpr const char *kOtherSql = "other_sql"; + +/** + * Adabas (Adaptable Database System) + */ +static constexpr const char *kAdabas = "adabas"; + +/** + * Deprecated, use @code intersystems_cache @endcode instead. + *

        + * @deprecated + * Replaced by @code intersystems_cache @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kCache = "cache"; + +/** + * InterSystems Caché + */ +static constexpr const char *kIntersystemsCache = "intersystems_cache"; + +/** + * Apache Cassandra + */ +static constexpr const char *kCassandra = "cassandra"; + +/** + * ClickHouse + */ +static constexpr const char *kClickhouse = "clickhouse"; + +/** + * Deprecated, use @code other_sql @endcode instead. + *

        + * @deprecated + * Replaced by @code other_sql @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kCloudscape = "cloudscape"; + +/** + * CockroachDB + */ +static constexpr const char *kCockroachdb = "cockroachdb"; + +/** + * Deprecated, no replacement at this time. + *

        + * @deprecated + * Removed. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kColdfusion = "coldfusion"; + +/** + * Microsoft Azure Cosmos DB + */ +static constexpr const char *kCosmosdb = "cosmosdb"; + +/** + * Couchbase + */ +static constexpr const char *kCouchbase = "couchbase"; + +/** + * CouchDB + */ +static constexpr const char *kCouchdb = "couchdb"; + +/** + * IBM Db2 + */ +static constexpr const char *kDb2 = "db2"; + +/** + * Apache Derby + */ +static constexpr const char *kDerby = "derby"; + +/** + * Amazon DynamoDB + */ +static constexpr const char *kDynamodb = "dynamodb"; + +/** + * EnterpriseDB + */ +static constexpr const char *kEdb = "edb"; + +/** + * Elasticsearch + */ +static constexpr const char *kElasticsearch = "elasticsearch"; + +/** + * FileMaker + */ +static constexpr const char *kFilemaker = "filemaker"; + +/** + * Firebird + */ +static constexpr const char *kFirebird = "firebird"; + +/** + * Deprecated, use @code other_sql @endcode instead. + *

        + * @deprecated + * Replaced by @code other_sql @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kFirstsql = "firstsql"; + +/** + * Apache Geode + */ +static constexpr const char *kGeode = "geode"; + +/** + * H2 + */ +static constexpr const char *kH2 = "h2"; + +/** + * SAP HANA + */ +static constexpr const char *kHanadb = "hanadb"; + +/** + * Apache HBase + */ +static constexpr const char *kHbase = "hbase"; + +/** + * Apache Hive + */ +static constexpr const char *kHive = "hive"; + +/** + * HyperSQL DataBase + */ +static constexpr const char *kHsqldb = "hsqldb"; + +/** + * InfluxDB + */ +static constexpr const char *kInfluxdb = "influxdb"; + +/** + * Informix + */ +static constexpr const char *kInformix = "informix"; + +/** + * Ingres + */ +static constexpr const char *kIngres = "ingres"; + +/** + * InstantDB + */ +static constexpr const char *kInstantdb = "instantdb"; + +/** + * InterBase + */ +static constexpr const char *kInterbase = "interbase"; + +/** + * MariaDB + */ +static constexpr const char *kMariadb = "mariadb"; + +/** + * SAP MaxDB + */ +static constexpr const char *kMaxdb = "maxdb"; + +/** + * Memcached + */ +static constexpr const char *kMemcached = "memcached"; + +/** + * MongoDB + */ +static constexpr const char *kMongodb = "mongodb"; + +/** + * Microsoft SQL Server + */ +static constexpr const char *kMssql = "mssql"; + +/** + * Deprecated, Microsoft SQL Server Compact is discontinued. + *

        + * @deprecated + * Removed, use @code other_sql @endcode instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMssqlcompact = "mssqlcompact"; + +/** + * MySQL + */ +static constexpr const char *kMysql = "mysql"; + +/** + * Neo4j + */ +static constexpr const char *kNeo4j = "neo4j"; + +/** + * Netezza + */ +static constexpr const char *kNetezza = "netezza"; + +/** + * OpenSearch + */ +static constexpr const char *kOpensearch = "opensearch"; + +/** + * Oracle Database + */ +static constexpr const char *kOracle = "oracle"; + +/** + * Pervasive PSQL + */ +static constexpr const char *kPervasive = "pervasive"; + +/** + * PointBase + */ +static constexpr const char *kPointbase = "pointbase"; + +/** + * PostgreSQL + */ +static constexpr const char *kPostgresql = "postgresql"; + +/** + * Progress Database + */ +static constexpr const char *kProgress = "progress"; + +/** + * Redis + */ +static constexpr const char *kRedis = "redis"; + +/** + * Amazon Redshift + */ +static constexpr const char *kRedshift = "redshift"; + +/** + * Cloud Spanner + */ +static constexpr const char *kSpanner = "spanner"; + +/** + * SQLite + */ +static constexpr const char *kSqlite = "sqlite"; + +/** + * Sybase + */ +static constexpr const char *kSybase = "sybase"; + +/** + * Teradata + */ +static constexpr const char *kTeradata = "teradata"; + +/** + * Trino + */ +static constexpr const char *kTrino = "trino"; + +/** + * Vertica + */ +static constexpr const char *kVertica = "vertica"; + +} // namespace DbSystemValues + +} // namespace db +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/db_metrics.h b/api/include/opentelemetry/semconv/incubating/db_metrics.h new file mode 100644 index 0000000000..6ea8e095c7 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/db_metrics.h @@ -0,0 +1,816 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace db +{ + +/** + * The number of connections that are currently in state described by the @code state @endcode + * attribute

        updowncounter + */ +static constexpr const char *kMetricDbClientConnectionCount = "metric.db.client.connection.count"; +static constexpr const char *descrMetricDbClientConnectionCount = + "The number of connections that are currently in state described by the `state` attribute"; +static constexpr const char *unitMetricDbClientConnectionCount = "{connection}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionCount(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricDbClientConnectionCount, + descrMetricDbClientConnectionCount, + unitMetricDbClientConnectionCount); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionCount(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricDbClientConnectionCount, + descrMetricDbClientConnectionCount, + unitMetricDbClientConnectionCount); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricDbClientConnectionCount(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricDbClientConnectionCount, + descrMetricDbClientConnectionCount, + unitMetricDbClientConnectionCount); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricDbClientConnectionCount(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricDbClientConnectionCount, + descrMetricDbClientConnectionCount, + unitMetricDbClientConnectionCount); +} + +/** + * The time it took to create a new connection + *

        + * histogram + */ +static constexpr const char *kMetricDbClientConnectionCreateTime = + "metric.db.client.connection.create_time"; +static constexpr const char *descrMetricDbClientConnectionCreateTime = + "The time it took to create a new connection"; +static constexpr const char *unitMetricDbClientConnectionCreateTime = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionCreateTime(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricDbClientConnectionCreateTime, + descrMetricDbClientConnectionCreateTime, + unitMetricDbClientConnectionCreateTime); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionCreateTime(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricDbClientConnectionCreateTime, + descrMetricDbClientConnectionCreateTime, + unitMetricDbClientConnectionCreateTime); +} + +/** + * The maximum number of idle open connections allowed + *

        + * updowncounter + */ +static constexpr const char *kMetricDbClientConnectionIdleMax = + "metric.db.client.connection.idle.max"; +static constexpr const char *descrMetricDbClientConnectionIdleMax = + "The maximum number of idle open connections allowed"; +static constexpr const char *unitMetricDbClientConnectionIdleMax = "{connection}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionIdleMax(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricDbClientConnectionIdleMax, + descrMetricDbClientConnectionIdleMax, + unitMetricDbClientConnectionIdleMax); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionIdleMax(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricDbClientConnectionIdleMax, + descrMetricDbClientConnectionIdleMax, + unitMetricDbClientConnectionIdleMax); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricDbClientConnectionIdleMax(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricDbClientConnectionIdleMax, + descrMetricDbClientConnectionIdleMax, + unitMetricDbClientConnectionIdleMax); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricDbClientConnectionIdleMax(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricDbClientConnectionIdleMax, + descrMetricDbClientConnectionIdleMax, + unitMetricDbClientConnectionIdleMax); +} + +/** + * The minimum number of idle open connections allowed + *

        + * updowncounter + */ +static constexpr const char *kMetricDbClientConnectionIdleMin = + "metric.db.client.connection.idle.min"; +static constexpr const char *descrMetricDbClientConnectionIdleMin = + "The minimum number of idle open connections allowed"; +static constexpr const char *unitMetricDbClientConnectionIdleMin = "{connection}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionIdleMin(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricDbClientConnectionIdleMin, + descrMetricDbClientConnectionIdleMin, + unitMetricDbClientConnectionIdleMin); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionIdleMin(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricDbClientConnectionIdleMin, + descrMetricDbClientConnectionIdleMin, + unitMetricDbClientConnectionIdleMin); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricDbClientConnectionIdleMin(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricDbClientConnectionIdleMin, + descrMetricDbClientConnectionIdleMin, + unitMetricDbClientConnectionIdleMin); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricDbClientConnectionIdleMin(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricDbClientConnectionIdleMin, + descrMetricDbClientConnectionIdleMin, + unitMetricDbClientConnectionIdleMin); +} + +/** + * The maximum number of open connections allowed + *

        + * updowncounter + */ +static constexpr const char *kMetricDbClientConnectionMax = "metric.db.client.connection.max"; +static constexpr const char *descrMetricDbClientConnectionMax = + "The maximum number of open connections allowed"; +static constexpr const char *unitMetricDbClientConnectionMax = "{connection}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionMax(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricDbClientConnectionMax, + descrMetricDbClientConnectionMax, + unitMetricDbClientConnectionMax); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionMax(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricDbClientConnectionMax, + descrMetricDbClientConnectionMax, + unitMetricDbClientConnectionMax); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricDbClientConnectionMax(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricDbClientConnectionMax, + descrMetricDbClientConnectionMax, + unitMetricDbClientConnectionMax); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricDbClientConnectionMax(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricDbClientConnectionMax, + descrMetricDbClientConnectionMax, + unitMetricDbClientConnectionMax); +} + +/** + * The number of pending requests for an open connection, cumulative for the entire pool + *

        + * updowncounter + */ +static constexpr const char *kMetricDbClientConnectionPendingRequests = + "metric.db.client.connection.pending_requests"; +static constexpr const char *descrMetricDbClientConnectionPendingRequests = + "The number of pending requests for an open connection, cumulative for the entire pool"; +static constexpr const char *unitMetricDbClientConnectionPendingRequests = "{request}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionPendingRequests(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricDbClientConnectionPendingRequests, + descrMetricDbClientConnectionPendingRequests, + unitMetricDbClientConnectionPendingRequests); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionPendingRequests(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricDbClientConnectionPendingRequests, + descrMetricDbClientConnectionPendingRequests, + unitMetricDbClientConnectionPendingRequests); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricDbClientConnectionPendingRequests(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricDbClientConnectionPendingRequests, + descrMetricDbClientConnectionPendingRequests, + unitMetricDbClientConnectionPendingRequests); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricDbClientConnectionPendingRequests(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricDbClientConnectionPendingRequests, + descrMetricDbClientConnectionPendingRequests, + unitMetricDbClientConnectionPendingRequests); +} + +/** + * The number of connection timeouts that have occurred trying to obtain a connection from the pool + *

        + * counter + */ +static constexpr const char *kMetricDbClientConnectionTimeouts = + "metric.db.client.connection.timeouts"; +static constexpr const char *descrMetricDbClientConnectionTimeouts = + "The number of connection timeouts that have occurred trying to obtain a connection from the " + "pool"; +static constexpr const char *unitMetricDbClientConnectionTimeouts = "{timeout}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionTimeouts(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricDbClientConnectionTimeouts, + descrMetricDbClientConnectionTimeouts, + unitMetricDbClientConnectionTimeouts); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionTimeouts(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricDbClientConnectionTimeouts, + descrMetricDbClientConnectionTimeouts, + unitMetricDbClientConnectionTimeouts); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricDbClientConnectionTimeouts(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricDbClientConnectionTimeouts, + descrMetricDbClientConnectionTimeouts, + unitMetricDbClientConnectionTimeouts); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricDbClientConnectionTimeouts(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricDbClientConnectionTimeouts, + descrMetricDbClientConnectionTimeouts, + unitMetricDbClientConnectionTimeouts); +} + +/** + * The time between borrowing a connection and returning it to the pool + *

        + * histogram + */ +static constexpr const char *kMetricDbClientConnectionUseTime = + "metric.db.client.connection.use_time"; +static constexpr const char *descrMetricDbClientConnectionUseTime = + "The time between borrowing a connection and returning it to the pool"; +static constexpr const char *unitMetricDbClientConnectionUseTime = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionUseTime(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricDbClientConnectionUseTime, + descrMetricDbClientConnectionUseTime, + unitMetricDbClientConnectionUseTime); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionUseTime(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricDbClientConnectionUseTime, + descrMetricDbClientConnectionUseTime, + unitMetricDbClientConnectionUseTime); +} + +/** + * The time it took to obtain an open connection from the pool + *

        + * histogram + */ +static constexpr const char *kMetricDbClientConnectionWaitTime = + "metric.db.client.connection.wait_time"; +static constexpr const char *descrMetricDbClientConnectionWaitTime = + "The time it took to obtain an open connection from the pool"; +static constexpr const char *unitMetricDbClientConnectionWaitTime = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionWaitTime(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricDbClientConnectionWaitTime, + descrMetricDbClientConnectionWaitTime, + unitMetricDbClientConnectionWaitTime); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionWaitTime(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricDbClientConnectionWaitTime, + descrMetricDbClientConnectionWaitTime, + unitMetricDbClientConnectionWaitTime); +} + +/** + * Deprecated, use @code db.client.connection.create_time @endcode instead. Note: the unit also + * changed from @code ms @endcode to @code s @endcode.

        + * @deprecated + * Replaced by @code db.client.connection.create_time @endcode. Note: the unit also changed from + * @code ms @endcode to @code s @endcode.

        histogram + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMetricDbClientConnectionsCreateTimeDeprecated = + "metric.db.client.connections.create_time.deprecated"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *descrMetricDbClientConnectionsCreateTimeDeprecated = + "Deprecated, use `db.client.connection.create_time` instead. Note: the unit also changed from " + "`ms` to `s`."; +OPENTELEMETRY_DEPRECATED +static constexpr const char *unitMetricDbClientConnectionsCreateTimeDeprecated = "ms"; + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionsCreateTimeDeprecated(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricDbClientConnectionsCreateTimeDeprecated, + descrMetricDbClientConnectionsCreateTimeDeprecated, + unitMetricDbClientConnectionsCreateTimeDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionsCreateTimeDeprecated(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricDbClientConnectionsCreateTimeDeprecated, + descrMetricDbClientConnectionsCreateTimeDeprecated, + unitMetricDbClientConnectionsCreateTimeDeprecated); +} + +/** + * Deprecated, use @code db.client.connection.idle.max @endcode instead. + *

        + * @deprecated + * Replaced by @code db.client.connection.idle.max @endcode. + *

        + * updowncounter + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMetricDbClientConnectionsIdleMaxDeprecated = + "metric.db.client.connections.idle.max.deprecated"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *descrMetricDbClientConnectionsIdleMaxDeprecated = + "Deprecated, use `db.client.connection.idle.max` instead."; +OPENTELEMETRY_DEPRECATED +static constexpr const char *unitMetricDbClientConnectionsIdleMaxDeprecated = "{connection}"; + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionsIdleMaxDeprecated(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricDbClientConnectionsIdleMaxDeprecated, + descrMetricDbClientConnectionsIdleMaxDeprecated, + unitMetricDbClientConnectionsIdleMaxDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionsIdleMaxDeprecated(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricDbClientConnectionsIdleMaxDeprecated, + descrMetricDbClientConnectionsIdleMaxDeprecated, + unitMetricDbClientConnectionsIdleMaxDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncInt64MetricDbClientConnectionsIdleMaxDeprecated(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricDbClientConnectionsIdleMaxDeprecated, + descrMetricDbClientConnectionsIdleMaxDeprecated, + unitMetricDbClientConnectionsIdleMaxDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncDoubleMetricDbClientConnectionsIdleMaxDeprecated(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricDbClientConnectionsIdleMaxDeprecated, + descrMetricDbClientConnectionsIdleMaxDeprecated, + unitMetricDbClientConnectionsIdleMaxDeprecated); +} + +/** + * Deprecated, use @code db.client.connection.idle.min @endcode instead. + *

        + * @deprecated + * Replaced by @code db.client.connection.idle.min @endcode. + *

        + * updowncounter + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMetricDbClientConnectionsIdleMinDeprecated = + "metric.db.client.connections.idle.min.deprecated"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *descrMetricDbClientConnectionsIdleMinDeprecated = + "Deprecated, use `db.client.connection.idle.min` instead."; +OPENTELEMETRY_DEPRECATED +static constexpr const char *unitMetricDbClientConnectionsIdleMinDeprecated = "{connection}"; + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionsIdleMinDeprecated(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricDbClientConnectionsIdleMinDeprecated, + descrMetricDbClientConnectionsIdleMinDeprecated, + unitMetricDbClientConnectionsIdleMinDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionsIdleMinDeprecated(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricDbClientConnectionsIdleMinDeprecated, + descrMetricDbClientConnectionsIdleMinDeprecated, + unitMetricDbClientConnectionsIdleMinDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncInt64MetricDbClientConnectionsIdleMinDeprecated(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricDbClientConnectionsIdleMinDeprecated, + descrMetricDbClientConnectionsIdleMinDeprecated, + unitMetricDbClientConnectionsIdleMinDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncDoubleMetricDbClientConnectionsIdleMinDeprecated(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricDbClientConnectionsIdleMinDeprecated, + descrMetricDbClientConnectionsIdleMinDeprecated, + unitMetricDbClientConnectionsIdleMinDeprecated); +} + +/** + * Deprecated, use @code db.client.connection.max @endcode instead. + *

        + * @deprecated + * Replaced by @code db.client.connection.max @endcode. + *

        + * updowncounter + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMetricDbClientConnectionsMaxDeprecated = + "metric.db.client.connections.max.deprecated"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *descrMetricDbClientConnectionsMaxDeprecated = + "Deprecated, use `db.client.connection.max` instead."; +OPENTELEMETRY_DEPRECATED +static constexpr const char *unitMetricDbClientConnectionsMaxDeprecated = "{connection}"; + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionsMaxDeprecated(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricDbClientConnectionsMaxDeprecated, + descrMetricDbClientConnectionsMaxDeprecated, + unitMetricDbClientConnectionsMaxDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionsMaxDeprecated(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricDbClientConnectionsMaxDeprecated, + descrMetricDbClientConnectionsMaxDeprecated, + unitMetricDbClientConnectionsMaxDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncInt64MetricDbClientConnectionsMaxDeprecated(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricDbClientConnectionsMaxDeprecated, + descrMetricDbClientConnectionsMaxDeprecated, + unitMetricDbClientConnectionsMaxDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncDoubleMetricDbClientConnectionsMaxDeprecated(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricDbClientConnectionsMaxDeprecated, + descrMetricDbClientConnectionsMaxDeprecated, + unitMetricDbClientConnectionsMaxDeprecated); +} + +/** + * Deprecated, use @code db.client.connection.pending_requests @endcode instead. + *

        + * @deprecated + * Replaced by @code db.client.connection.pending_requests @endcode. + *

        + * updowncounter + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMetricDbClientConnectionsPendingRequestsDeprecated = + "metric.db.client.connections.pending_requests.deprecated"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *descrMetricDbClientConnectionsPendingRequestsDeprecated = + "Deprecated, use `db.client.connection.pending_requests` instead."; +OPENTELEMETRY_DEPRECATED +static constexpr const char *unitMetricDbClientConnectionsPendingRequestsDeprecated = "{request}"; + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionsPendingRequestsDeprecated(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricDbClientConnectionsPendingRequestsDeprecated, + descrMetricDbClientConnectionsPendingRequestsDeprecated, + unitMetricDbClientConnectionsPendingRequestsDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionsPendingRequestsDeprecated(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricDbClientConnectionsPendingRequestsDeprecated, + descrMetricDbClientConnectionsPendingRequestsDeprecated, + unitMetricDbClientConnectionsPendingRequestsDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncInt64MetricDbClientConnectionsPendingRequestsDeprecated(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter( + kMetricDbClientConnectionsPendingRequestsDeprecated, + descrMetricDbClientConnectionsPendingRequestsDeprecated, + unitMetricDbClientConnectionsPendingRequestsDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncDoubleMetricDbClientConnectionsPendingRequestsDeprecated(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter( + kMetricDbClientConnectionsPendingRequestsDeprecated, + descrMetricDbClientConnectionsPendingRequestsDeprecated, + unitMetricDbClientConnectionsPendingRequestsDeprecated); +} + +/** + * Deprecated, use @code db.client.connection.timeouts @endcode instead. + *

        + * @deprecated + * Replaced by @code db.client.connection.timeouts @endcode. + *

        + * counter + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMetricDbClientConnectionsTimeoutsDeprecated = + "metric.db.client.connections.timeouts.deprecated"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *descrMetricDbClientConnectionsTimeoutsDeprecated = + "Deprecated, use `db.client.connection.timeouts` instead."; +OPENTELEMETRY_DEPRECATED +static constexpr const char *unitMetricDbClientConnectionsTimeoutsDeprecated = "{timeout}"; + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionsTimeoutsDeprecated(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricDbClientConnectionsTimeoutsDeprecated, + descrMetricDbClientConnectionsTimeoutsDeprecated, + unitMetricDbClientConnectionsTimeoutsDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionsTimeoutsDeprecated(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricDbClientConnectionsTimeoutsDeprecated, + descrMetricDbClientConnectionsTimeoutsDeprecated, + unitMetricDbClientConnectionsTimeoutsDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncInt64MetricDbClientConnectionsTimeoutsDeprecated(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricDbClientConnectionsTimeoutsDeprecated, + descrMetricDbClientConnectionsTimeoutsDeprecated, + unitMetricDbClientConnectionsTimeoutsDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncDoubleMetricDbClientConnectionsTimeoutsDeprecated(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricDbClientConnectionsTimeoutsDeprecated, + descrMetricDbClientConnectionsTimeoutsDeprecated, + unitMetricDbClientConnectionsTimeoutsDeprecated); +} + +/** + * Deprecated, use @code db.client.connection.count @endcode instead. + *

        + * @deprecated + * Replaced by @code db.client.connection.count @endcode. + *

        + * updowncounter + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMetricDbClientConnectionsCountDeprecated = + "metric.db.client.connections.count.deprecated"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *descrMetricDbClientConnectionsCountDeprecated = + "Deprecated, use `db.client.connection.count` instead."; +OPENTELEMETRY_DEPRECATED +static constexpr const char *unitMetricDbClientConnectionsCountDeprecated = "{connection}"; + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionsCountDeprecated(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricDbClientConnectionsCountDeprecated, + descrMetricDbClientConnectionsCountDeprecated, + unitMetricDbClientConnectionsCountDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionsCountDeprecated(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricDbClientConnectionsCountDeprecated, + descrMetricDbClientConnectionsCountDeprecated, + unitMetricDbClientConnectionsCountDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncInt64MetricDbClientConnectionsCountDeprecated(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricDbClientConnectionsCountDeprecated, + descrMetricDbClientConnectionsCountDeprecated, + unitMetricDbClientConnectionsCountDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncDoubleMetricDbClientConnectionsCountDeprecated(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricDbClientConnectionsCountDeprecated, + descrMetricDbClientConnectionsCountDeprecated, + unitMetricDbClientConnectionsCountDeprecated); +} + +/** + * Deprecated, use @code db.client.connection.use_time @endcode instead. Note: the unit also changed + * from @code ms @endcode to @code s @endcode.

        + * @deprecated + * Replaced by @code db.client.connection.use_time @endcode. Note: the unit also changed from @code + * ms @endcode to @code s @endcode.

        histogram + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMetricDbClientConnectionsUseTimeDeprecated = + "metric.db.client.connections.use_time.deprecated"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *descrMetricDbClientConnectionsUseTimeDeprecated = + "Deprecated, use `db.client.connection.use_time` instead. Note: the unit also changed from " + "`ms` to `s`."; +OPENTELEMETRY_DEPRECATED +static constexpr const char *unitMetricDbClientConnectionsUseTimeDeprecated = "ms"; + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionsUseTimeDeprecated(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricDbClientConnectionsUseTimeDeprecated, + descrMetricDbClientConnectionsUseTimeDeprecated, + unitMetricDbClientConnectionsUseTimeDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionsUseTimeDeprecated(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricDbClientConnectionsUseTimeDeprecated, + descrMetricDbClientConnectionsUseTimeDeprecated, + unitMetricDbClientConnectionsUseTimeDeprecated); +} + +/** + * Deprecated, use @code db.client.connection.wait_time @endcode instead. Note: the unit also + * changed from @code ms @endcode to @code s @endcode.

        + * @deprecated + * Replaced by @code db.client.connection.wait_time @endcode. Note: the unit also changed from @code + * ms @endcode to @code s @endcode.

        histogram + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMetricDbClientConnectionsWaitTimeDeprecated = + "metric.db.client.connections.wait_time.deprecated"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *descrMetricDbClientConnectionsWaitTimeDeprecated = + "Deprecated, use `db.client.connection.wait_time` instead. Note: the unit also changed from " + "`ms` to `s`."; +OPENTELEMETRY_DEPRECATED +static constexpr const char *unitMetricDbClientConnectionsWaitTimeDeprecated = "ms"; + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionsWaitTimeDeprecated(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricDbClientConnectionsWaitTimeDeprecated, + descrMetricDbClientConnectionsWaitTimeDeprecated, + unitMetricDbClientConnectionsWaitTimeDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionsWaitTimeDeprecated(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricDbClientConnectionsWaitTimeDeprecated, + descrMetricDbClientConnectionsWaitTimeDeprecated, + unitMetricDbClientConnectionsWaitTimeDeprecated); +} + +/** + * Duration of database client operations. + *

        + * Batch operations SHOULD be recorded as a single operation. + *

        + * histogram + */ +static constexpr const char *kMetricDbClientOperationDuration = + "metric.db.client.operation.duration"; +static constexpr const char *descrMetricDbClientOperationDuration = + "Duration of database client operations."; +static constexpr const char *unitMetricDbClientOperationDuration = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientOperationDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricDbClientOperationDuration, + descrMetricDbClientOperationDuration, + unitMetricDbClientOperationDuration); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientOperationDuration(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricDbClientOperationDuration, + descrMetricDbClientOperationDuration, + unitMetricDbClientOperationDuration); +} + +} // namespace db +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/deployment_attributes.h b/api/include/opentelemetry/semconv/incubating/deployment_attributes.h new file mode 100644 index 0000000000..9c4594b7f3 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/deployment_attributes.h @@ -0,0 +1,76 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace deployment +{ + +/** + * 'Deprecated, use @code deployment.environment.name @endcode instead.' + *

        + * @deprecated + * Deprecated, use @code deployment.environment.name @endcode instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDeploymentEnvironment = "deployment.environment"; + +/** + * Name of the deployment + * environment (aka deployment tier).

        + * @code deployment.environment.name @endcode does not affect the uniqueness constraints defined + * through the @code service.namespace @endcode, @code service.name @endcode and @code + * service.instance.id @endcode resource attributes. This implies that resources carrying the + * following attribute combinations MUST be considered to be identifying the same service:

          + *
        • @code service.name=frontend @endcode, @code deployment.environment.name=production + * @endcode
        • @code service.name=frontend @endcode, @code deployment.environment.name=staging + * @endcode.
        • + *
        + */ +static constexpr const char *kDeploymentEnvironmentName = "deployment.environment.name"; + +/** + * The id of the deployment. + */ +static constexpr const char *kDeploymentId = "deployment.id"; + +/** + * The name of the deployment. + */ +static constexpr const char *kDeploymentName = "deployment.name"; + +/** + * The status of the deployment. + */ +static constexpr const char *kDeploymentStatus = "deployment.status"; + +namespace DeploymentStatusValues +{ +/** + * failed + */ +static constexpr const char *kFailed = "failed"; + +/** + * succeeded + */ +static constexpr const char *kSucceeded = "succeeded"; + +} // namespace DeploymentStatusValues + +} // namespace deployment +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/destination_attributes.h b/api/include/opentelemetry/semconv/incubating/destination_attributes.h new file mode 100644 index 0000000000..5069fc03b7 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/destination_attributes.h @@ -0,0 +1,37 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace destination +{ + +/** + * Destination address - domain name if available without reverse DNS lookup; otherwise, IP address + * or Unix domain socket name.

        When observed from the source side, and when communicating + * through an intermediary, @code destination.address @endcode SHOULD represent the destination + * address behind any intermediaries, for example proxies, if it's available. + */ +static constexpr const char *kDestinationAddress = "destination.address"; + +/** + * Destination port number + */ +static constexpr const char *kDestinationPort = "destination.port"; + +} // namespace destination +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/device_attributes.h b/api/include/opentelemetry/semconv/incubating/device_attributes.h new file mode 100644 index 0000000000..c2c80f5fd2 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/device_attributes.h @@ -0,0 +1,66 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace device +{ + +/** + * A unique identifier representing the device + *

        + * The device identifier MUST only be defined using the values outlined below. This value is not an + * advertising identifier and MUST NOT be used as such. On iOS (Swift or Objective-C), this value + * MUST be equal to the vendor + * identifier. On Android (Java or Kotlin), this value MUST be equal to the Firebase + * Installation ID or a globally unique UUID which is persisted across sessions in your application. + * More information can be found here on best practices + * and exact implementation details. Caution should be taken when storing personal data or anything + * which can identify a user. GDPR and data protection laws may apply, ensure you do your own due + * diligence. + */ +static constexpr const char *kDeviceId = "device.id"; + +/** + * The name of the device manufacturer + *

        + * The Android OS provides this field via Build. iOS apps + * SHOULD hardcode the value @code Apple @endcode. + */ +static constexpr const char *kDeviceManufacturer = "device.manufacturer"; + +/** + * The model identifier for the device + *

        + * It's recommended this value represents a machine-readable version of the model identifier rather + * than the market or consumer-friendly name of the device. + */ +static constexpr const char *kDeviceModelIdentifier = "device.model.identifier"; + +/** + * The marketing name for the device model + *

        + * It's recommended this value represents a human-readable version of the device model rather than a + * machine-readable alternative. + */ +static constexpr const char *kDeviceModelName = "device.model.name"; + +} // namespace device +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/disk_attributes.h b/api/include/opentelemetry/semconv/incubating/disk_attributes.h new file mode 100644 index 0000000000..ff938a9612 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/disk_attributes.h @@ -0,0 +1,43 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace disk +{ + +/** + * The disk IO operation direction. + */ +static constexpr const char *kDiskIoDirection = "disk.io.direction"; + +namespace DiskIoDirectionValues +{ +/** + * none + */ +static constexpr const char *kRead = "read"; + +/** + * none + */ +static constexpr const char *kWrite = "write"; + +} // namespace DiskIoDirectionValues + +} // namespace disk +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/dns_attributes.h b/api/include/opentelemetry/semconv/incubating/dns_attributes.h new file mode 100644 index 0000000000..b835e2a73a --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/dns_attributes.h @@ -0,0 +1,34 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace dns +{ + +/** + * The name being queried. + *

        + * If the name field contains non-printable characters (below 32 or above 126), those characters + * should be represented as escaped base 10 integers (\DDD). Back slashes and quotes should be + * escaped. Tabs, carriage returns, and line feeds should be converted to \t, \r, and \n + * respectively. + */ +static constexpr const char *kDnsQuestionName = "dns.question.name"; + +} // namespace dns +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/dns_metrics.h b/api/include/opentelemetry/semconv/incubating/dns_metrics.h new file mode 100644 index 0000000000..7f3915870b --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/dns_metrics.h @@ -0,0 +1,49 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace dns +{ + +/** + * Measures the time taken to perform a DNS lookup. + *

        + * histogram + */ +static constexpr const char *kMetricDnsLookupDuration = "metric.dns.lookup.duration"; +static constexpr const char *descrMetricDnsLookupDuration = + "Measures the time taken to perform a DNS lookup."; +static constexpr const char *unitMetricDnsLookupDuration = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricDnsLookupDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricDnsLookupDuration, descrMetricDnsLookupDuration, + unitMetricDnsLookupDuration); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricDnsLookupDuration( + metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricDnsLookupDuration, descrMetricDnsLookupDuration, + unitMetricDnsLookupDuration); +} + +} // namespace dns +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/enduser_attributes.h b/api/include/opentelemetry/semconv/incubating/enduser_attributes.h new file mode 100644 index 0000000000..217d5dd414 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/enduser_attributes.h @@ -0,0 +1,51 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace enduser +{ + +/** + * Deprecated, use @code user.id @endcode instead. + *

        + * @deprecated + * Replaced by @code user.id @endcode attribute. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kEnduserId = "enduser.id"; + +/** + * Deprecated, use @code user.roles @endcode instead. + *

        + * @deprecated + * Replaced by @code user.roles @endcode attribute. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kEnduserRole = "enduser.role"; + +/** + * Deprecated, no replacement at this time. + *

        + * @deprecated + * Removed. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kEnduserScope = "enduser.scope"; + +} // namespace enduser +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/error_attributes.h b/api/include/opentelemetry/semconv/incubating/error_attributes.h new file mode 100644 index 0000000000..1b711ff112 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/error_attributes.h @@ -0,0 +1,57 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace error +{ + +/** + * Describes a class of error the operation ended with. + *

        + * The @code error.type @endcode SHOULD be predictable, and SHOULD have low cardinality. + *

        + * When @code error.type @endcode is set to a type (e.g., an exception type), its + * canonical class name identifying the type within the artifact SHOULD be used. + *

        + * Instrumentations SHOULD document the list of errors they report. + *

        + * The cardinality of @code error.type @endcode within one instrumentation library SHOULD be low. + * Telemetry consumers that aggregate data from multiple instrumentation libraries and applications + * should be prepared for @code error.type @endcode to have high cardinality at query time when no + * additional filters are applied. + *

        + * If the operation has completed successfully, instrumentations SHOULD NOT set @code error.type + * @endcode.

        If a specific domain defines its own set of error identifiers (such as HTTP or gRPC + * status codes), it's RECOMMENDED to:

        • Use a domain-specific attribute
        • Set + * @code error.type @endcode to capture all errors, regardless of whether they are defined within + * the domain-specific set or not.
        • + *
        + */ +static constexpr const char *kErrorType = "error.type"; + +namespace ErrorTypeValues +{ +/** + * A fallback error value to be used when the instrumentation doesn't define a custom value. + */ +static constexpr const char *kOther = "_OTHER"; + +} // namespace ErrorTypeValues + +} // namespace error +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/event_attributes.h b/api/include/opentelemetry/semconv/incubating/event_attributes.h new file mode 100644 index 0000000000..c2faa437cf --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/event_attributes.h @@ -0,0 +1,34 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace event +{ + +/** + * Identifies the class / type of event. + *

        + * Event names are subject to the same rules as attribute names. Notably, event names are namespaced + * to avoid collisions and provide a clean separation of semantics for events in separate domains + * like browser, mobile, and kubernetes. + */ +static constexpr const char *kEventName = "event.name"; + +} // namespace event +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/exception_attributes.h b/api/include/opentelemetry/semconv/incubating/exception_attributes.h new file mode 100644 index 0000000000..fdc19ac6d0 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/exception_attributes.h @@ -0,0 +1,59 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace exception +{ + +/** + * SHOULD be set to true if the exception event is recorded at a point where it is known that the + * exception is escaping the scope of the span.

        An exception is considered to have escaped (or + * left) the scope of a span, if that span is ended while the exception is still logically "in + * flight". This may be actually "in flight" in some languages (e.g. if the exception is passed to a + * Context manager's @code __exit__ @endcode method in Python) but will usually be caught at the + * point of recording the exception in most languages.

        It is usually not possible to determine + * at the point where an exception is thrown whether it will escape the scope of a span. However, it + * is trivial to know that an exception will escape, if one checks for an active exception just + * before ending the span, as done in the example + * for recording span exceptions.

        It follows that an exception may still escape the scope of + * the span even if the @code exception.escaped @endcode attribute was not set or set to false, + * since the event might have been recorded at a time where it was not + * clear whether the exception will escape. + */ +static constexpr const char *kExceptionEscaped = "exception.escaped"; + +/** + * The exception message. + */ +static constexpr const char *kExceptionMessage = "exception.message"; + +/** + * A stacktrace as a string in the natural representation for the language runtime. The + * representation is to be determined and documented by each language SIG. + */ +static constexpr const char *kExceptionStacktrace = "exception.stacktrace"; + +/** + * The type of the exception (its fully-qualified class name, if applicable). The dynamic type of + * the exception should be preferred over the static type in languages that support it. + */ +static constexpr const char *kExceptionType = "exception.type"; + +} // namespace exception +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/faas_attributes.h b/api/include/opentelemetry/semconv/incubating/faas_attributes.h new file mode 100644 index 0000000000..ed9076ec39 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/faas_attributes.h @@ -0,0 +1,232 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace faas +{ + +/** + * A boolean that is true if the serverless function is executed for the first time (aka + * cold-start). + */ +static constexpr const char *kFaasColdstart = "faas.coldstart"; + +/** + * A string containing the schedule period as Cron + * Expression. + */ +static constexpr const char *kFaasCron = "faas.cron"; + +/** + * The name of the source on which the triggering operation was performed. For example, in Cloud + * Storage or S3 corresponds to the bucket name, and in Cosmos DB to the database name. + */ +static constexpr const char *kFaasDocumentCollection = "faas.document.collection"; + +/** + * The document name/table subjected to the operation. For example, in Cloud Storage or S3 is the + * name of the file, and in Cosmos DB the table name. + */ +static constexpr const char *kFaasDocumentName = "faas.document.name"; + +/** + * Describes the type of the operation that was performed on the data. + */ +static constexpr const char *kFaasDocumentOperation = "faas.document.operation"; + +/** + * A string containing the time when the data was accessed in the ISO 8601 format expressed in UTC. + */ +static constexpr const char *kFaasDocumentTime = "faas.document.time"; + +/** + * The execution environment ID as a string, that will be potentially reused for other invocations + * to the same function/function version.

        • AWS Lambda: Use the (full) + * log stream name.
        • + *
        + */ +static constexpr const char *kFaasInstance = "faas.instance"; + +/** + * The invocation ID of the current function invocation. + */ +static constexpr const char *kFaasInvocationId = "faas.invocation_id"; + +/** + * The name of the invoked function. + *

        + * SHOULD be equal to the @code faas.name @endcode resource attribute of the invoked function. + */ +static constexpr const char *kFaasInvokedName = "faas.invoked_name"; + +/** + * The cloud provider of the invoked function. + *

        + * SHOULD be equal to the @code cloud.provider @endcode resource attribute of the invoked function. + */ +static constexpr const char *kFaasInvokedProvider = "faas.invoked_provider"; + +/** + * The cloud region of the invoked function. + *

        + * SHOULD be equal to the @code cloud.region @endcode resource attribute of the invoked function. + */ +static constexpr const char *kFaasInvokedRegion = "faas.invoked_region"; + +/** + * The amount of memory available to the serverless function converted to Bytes. + *

        + * It's recommended to set this attribute since e.g. too little memory can easily stop a Java AWS + * Lambda function from working correctly. On AWS Lambda, the environment variable @code + * AWS_LAMBDA_FUNCTION_MEMORY_SIZE @endcode provides this information (which must be multiplied by + * 1,048,576). + */ +static constexpr const char *kFaasMaxMemory = "faas.max_memory"; + +/** + * The name of the single function that this runtime instance executes. + *

        + * This is the name of the function as configured/deployed on the FaaS + * platform and is usually different from the name of the callback + * function (which may be stored in the + * @code code.namespace @endcode/@code + * code.function @endcode span attributes).

        For some cloud providers, the above definition + * is ambiguous. The following definition of function name MUST be used for this attribute (and + * consequently the span name) for the listed cloud providers/products:

          + *
        • Azure: The full name @code / @endcode, i.e., function app + * name followed by a forward slash followed by the function name (this form can also be seen in the + * resource JSON for the function). This means that a span attribute MUST be used, as an Azure + * function app can host multiple functions that would usually share a TracerProvider (see also the + * @code cloud.resource_id @endcode attribute).
        • + *
        + */ +static constexpr const char *kFaasName = "faas.name"; + +/** + * A string containing the function invocation time in the ISO 8601 format expressed in UTC. + */ +static constexpr const char *kFaasTime = "faas.time"; + +/** + * Type of the trigger which caused this function invocation. + */ +static constexpr const char *kFaasTrigger = "faas.trigger"; + +/** + * The immutable version of the function being executed. + *

        + * Depending on the cloud provider and platform, use: + *

        + *

        + */ +static constexpr const char *kFaasVersion = "faas.version"; + +namespace FaasDocumentOperationValues +{ +/** + * When a new object is created. + */ +static constexpr const char *kInsert = "insert"; + +/** + * When an object is modified. + */ +static constexpr const char *kEdit = "edit"; + +/** + * When an object is deleted. + */ +static constexpr const char *kDelete = "delete"; + +} // namespace FaasDocumentOperationValues + +namespace FaasInvokedProviderValues +{ +/** + * Alibaba Cloud + */ +static constexpr const char *kAlibabaCloud = "alibaba_cloud"; + +/** + * Amazon Web Services + */ +static constexpr const char *kAws = "aws"; + +/** + * Microsoft Azure + */ +static constexpr const char *kAzure = "azure"; + +/** + * Google Cloud Platform + */ +static constexpr const char *kGcp = "gcp"; + +/** + * Tencent Cloud + */ +static constexpr const char *kTencentCloud = "tencent_cloud"; + +} // namespace FaasInvokedProviderValues + +namespace FaasTriggerValues +{ +/** + * A response to some data source operation such as a database or filesystem read/write + */ +static constexpr const char *kDatasource = "datasource"; + +/** + * To provide an answer to an inbound HTTP request + */ +static constexpr const char *kHttp = "http"; + +/** + * A function is set to be executed when messages are sent to a messaging system + */ +static constexpr const char *kPubsub = "pubsub"; + +/** + * A function is scheduled to be executed regularly + */ +static constexpr const char *kTimer = "timer"; + +/** + * If none of the others apply + */ +static constexpr const char *kOther = "other"; + +} // namespace FaasTriggerValues + +} // namespace faas +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/faas_metrics.h b/api/include/opentelemetry/semconv/incubating/faas_metrics.h new file mode 100644 index 0000000000..73dc2989a6 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/faas_metrics.h @@ -0,0 +1,287 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace faas +{ + +/** + * Number of invocation cold starts + *

        + * counter + */ +static constexpr const char *kMetricFaasColdstarts = "metric.faas.coldstarts"; +static constexpr const char *descrMetricFaasColdstarts = "Number of invocation cold starts"; +static constexpr const char *unitMetricFaasColdstarts = "{coldstart}"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricFaasColdstarts( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricFaasColdstarts, descrMetricFaasColdstarts, + unitMetricFaasColdstarts); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricFaasColdstarts( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricFaasColdstarts, descrMetricFaasColdstarts, + unitMetricFaasColdstarts); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricFaasColdstarts( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricFaasColdstarts, descrMetricFaasColdstarts, + unitMetricFaasColdstarts); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricFaasColdstarts(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricFaasColdstarts, descrMetricFaasColdstarts, + unitMetricFaasColdstarts); +} + +/** + * Distribution of CPU usage per invocation + *

        + * histogram + */ +static constexpr const char *kMetricFaasCpuUsage = "metric.faas.cpu_usage"; +static constexpr const char *descrMetricFaasCpuUsage = "Distribution of CPU usage per invocation"; +static constexpr const char *unitMetricFaasCpuUsage = "s"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricFaasCpuUsage( + metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricFaasCpuUsage, descrMetricFaasCpuUsage, + unitMetricFaasCpuUsage); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricFaasCpuUsage( + metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricFaasCpuUsage, descrMetricFaasCpuUsage, + unitMetricFaasCpuUsage); +} + +/** + * Number of invocation errors + *

        + * counter + */ +static constexpr const char *kMetricFaasErrors = "metric.faas.errors"; +static constexpr const char *descrMetricFaasErrors = "Number of invocation errors"; +static constexpr const char *unitMetricFaasErrors = "{error}"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricFaasErrors( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricFaasErrors, descrMetricFaasErrors, unitMetricFaasErrors); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricFaasErrors( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricFaasErrors, descrMetricFaasErrors, unitMetricFaasErrors); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricFaasErrors( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricFaasErrors, descrMetricFaasErrors, + unitMetricFaasErrors); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricFaasErrors( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricFaasErrors, descrMetricFaasErrors, + unitMetricFaasErrors); +} + +/** + * Measures the duration of the function's initialization, such as a cold start + *

        + * histogram + */ +static constexpr const char *kMetricFaasInitDuration = "metric.faas.init_duration"; +static constexpr const char *descrMetricFaasInitDuration = + "Measures the duration of the function's initialization, such as a cold start"; +static constexpr const char *unitMetricFaasInitDuration = "s"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricFaasInitDuration( + metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricFaasInitDuration, descrMetricFaasInitDuration, + unitMetricFaasInitDuration); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricFaasInitDuration( + metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricFaasInitDuration, descrMetricFaasInitDuration, + unitMetricFaasInitDuration); +} + +/** + * Number of successful invocations + *

        + * counter + */ +static constexpr const char *kMetricFaasInvocations = "metric.faas.invocations"; +static constexpr const char *descrMetricFaasInvocations = "Number of successful invocations"; +static constexpr const char *unitMetricFaasInvocations = "{invocation}"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricFaasInvocations( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricFaasInvocations, descrMetricFaasInvocations, + unitMetricFaasInvocations); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricFaasInvocations( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricFaasInvocations, descrMetricFaasInvocations, + unitMetricFaasInvocations); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricFaasInvocations(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricFaasInvocations, descrMetricFaasInvocations, + unitMetricFaasInvocations); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricFaasInvocations(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricFaasInvocations, descrMetricFaasInvocations, + unitMetricFaasInvocations); +} + +/** + * Measures the duration of the function's logic execution + *

        + * histogram + */ +static constexpr const char *kMetricFaasInvokeDuration = "metric.faas.invoke_duration"; +static constexpr const char *descrMetricFaasInvokeDuration = + "Measures the duration of the function's logic execution"; +static constexpr const char *unitMetricFaasInvokeDuration = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricFaasInvokeDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricFaasInvokeDuration, descrMetricFaasInvokeDuration, + unitMetricFaasInvokeDuration); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricFaasInvokeDuration(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricFaasInvokeDuration, descrMetricFaasInvokeDuration, + unitMetricFaasInvokeDuration); +} + +/** + * Distribution of max memory usage per invocation + *

        + * histogram + */ +static constexpr const char *kMetricFaasMemUsage = "metric.faas.mem_usage"; +static constexpr const char *descrMetricFaasMemUsage = + "Distribution of max memory usage per invocation"; +static constexpr const char *unitMetricFaasMemUsage = "By"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricFaasMemUsage( + metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricFaasMemUsage, descrMetricFaasMemUsage, + unitMetricFaasMemUsage); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricFaasMemUsage( + metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricFaasMemUsage, descrMetricFaasMemUsage, + unitMetricFaasMemUsage); +} + +/** + * Distribution of net I/O usage per invocation + *

        + * histogram + */ +static constexpr const char *kMetricFaasNetIo = "metric.faas.net_io"; +static constexpr const char *descrMetricFaasNetIo = "Distribution of net I/O usage per invocation"; +static constexpr const char *unitMetricFaasNetIo = "By"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricFaasNetIo( + metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricFaasNetIo, descrMetricFaasNetIo, unitMetricFaasNetIo); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricFaasNetIo( + metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricFaasNetIo, descrMetricFaasNetIo, unitMetricFaasNetIo); +} + +/** + * Number of invocation timeouts + *

        + * counter + */ +static constexpr const char *kMetricFaasTimeouts = "metric.faas.timeouts"; +static constexpr const char *descrMetricFaasTimeouts = "Number of invocation timeouts"; +static constexpr const char *unitMetricFaasTimeouts = "{timeout}"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricFaasTimeouts( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricFaasTimeouts, descrMetricFaasTimeouts, + unitMetricFaasTimeouts); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricFaasTimeouts( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricFaasTimeouts, descrMetricFaasTimeouts, + unitMetricFaasTimeouts); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricFaasTimeouts( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricFaasTimeouts, descrMetricFaasTimeouts, + unitMetricFaasTimeouts); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricFaasTimeouts( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricFaasTimeouts, descrMetricFaasTimeouts, + unitMetricFaasTimeouts); +} + +} // namespace faas +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/feature_flag_attributes.h b/api/include/opentelemetry/semconv/incubating/feature_flag_attributes.h new file mode 100644 index 0000000000..3cd8b8eb2c --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/feature_flag_attributes.h @@ -0,0 +1,47 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace feature_flag +{ + +/** + * The unique identifier of the feature flag. + */ +static constexpr const char *kFeatureFlagKey = "feature_flag.key"; + +/** + * The name of the service provider that performs the flag evaluation. + */ +static constexpr const char *kFeatureFlagProviderName = "feature_flag.provider_name"; + +/** + * SHOULD be a semantic identifier for a value. If one is unavailable, a stringified version of the + * value can be used.

        A semantic identifier, commonly referred to as a variant, provides a means + * for referring to a value without including the value itself. This can + * provide additional context for understanding the meaning behind a value. + * For example, the variant @code red @endcode maybe be used for the value @code #c05543 @endcode. + *

        + * A stringified version of the value can be used in situations where a + * semantic identifier is unavailable. String representation of the value + * should be determined by the implementer. + */ +static constexpr const char *kFeatureFlagVariant = "feature_flag.variant"; + +} // namespace feature_flag +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/file_attributes.h b/api/include/opentelemetry/semconv/incubating/file_attributes.h new file mode 100644 index 0000000000..eb65a811ec --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/file_attributes.h @@ -0,0 +1,53 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace file +{ + +/** + * Directory where the file is located. It should include the drive letter, when appropriate. + */ +static constexpr const char *kFileDirectory = "file.directory"; + +/** + * File extension, excluding the leading dot. + *

        + * When the file name has multiple extensions (example.tar.gz), only the last one should be captured + * ("gz", not "tar.gz"). + */ +static constexpr const char *kFileExtension = "file.extension"; + +/** + * Name of the file including the extension, without the directory. + */ +static constexpr const char *kFileName = "file.name"; + +/** + * Full path to the file, including the file name. It should include the drive letter, when + * appropriate. + */ +static constexpr const char *kFilePath = "file.path"; + +/** + * File size in bytes. + */ +static constexpr const char *kFileSize = "file.size"; + +} // namespace file +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/gcp_attributes.h b/api/include/opentelemetry/semconv/incubating/gcp_attributes.h new file mode 100644 index 0000000000..53518251bb --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/gcp_attributes.h @@ -0,0 +1,64 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace gcp +{ + +/** + * Identifies the Google Cloud service for which the official client library is intended. + *

        + * Intended to be a stable identifier for Google Cloud client libraries that is uniform across + * implementation languages. The value should be derived from the canonical service domain for the + * service; for example, 'foo.googleapis.com' should result in a value of 'foo'. + */ +static constexpr const char *kGcpClientService = "gcp.client.service"; + +/** + * The name of the Cloud Run execution being run for the + * Job, as set by the @code + * CLOUD_RUN_EXECUTION @endcode environment variable. + */ +static constexpr const char *kGcpCloudRunJobExecution = "gcp.cloud_run.job.execution"; + +/** + * The index for a task within an execution as provided by the @code + * CLOUD_RUN_TASK_INDEX @endcode environment variable. + */ +static constexpr const char *kGcpCloudRunJobTaskIndex = "gcp.cloud_run.job.task_index"; + +/** + * The hostname of a GCE instance. This is the full value of the default or custom hostname. + */ +static constexpr const char *kGcpGceInstanceHostname = "gcp.gce.instance.hostname"; + +/** + * The instance name of a GCE instance. This is the value provided by @code host.name @endcode, the + * visible name of the instance in the Cloud Console UI, and the prefix for the default hostname of + * the instance as defined by the default + * internal DNS name. + */ +static constexpr const char *kGcpGceInstanceName = "gcp.gce.instance.name"; + +} // namespace gcp +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/gen_ai_attributes.h b/api/include/opentelemetry/semconv/incubating/gen_ai_attributes.h new file mode 100644 index 0000000000..03f2eebc2c --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/gen_ai_attributes.h @@ -0,0 +1,206 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace gen_ai +{ + +/** + * The full response received from the GenAI model. + *

        + * It's RECOMMENDED to format completions as JSON string matching OpenAI messages format + */ +static constexpr const char *kGenAiCompletion = "gen_ai.completion"; + +/** + * The name of the operation being performed. + *

        + * If one of the predefined values applies, but specific system uses a different name it's + * RECOMMENDED to document it in the semantic conventions for specific GenAI system and use + * system-specific name in the instrumentation. If a different name is not documented, + * instrumentation libraries SHOULD use applicable predefined value. + */ +static constexpr const char *kGenAiOperationName = "gen_ai.operation.name"; + +/** + * The full prompt sent to the GenAI model. + *

        + * It's RECOMMENDED to format prompts as JSON string matching OpenAI messages format + */ +static constexpr const char *kGenAiPrompt = "gen_ai.prompt"; + +/** + * The frequency penalty setting for the GenAI request. + */ +static constexpr const char *kGenAiRequestFrequencyPenalty = "gen_ai.request.frequency_penalty"; + +/** + * The maximum number of tokens the model generates for a request. + */ +static constexpr const char *kGenAiRequestMaxTokens = "gen_ai.request.max_tokens"; + +/** + * The name of the GenAI model a request is being made to. + */ +static constexpr const char *kGenAiRequestModel = "gen_ai.request.model"; + +/** + * The presence penalty setting for the GenAI request. + */ +static constexpr const char *kGenAiRequestPresencePenalty = "gen_ai.request.presence_penalty"; + +/** + * List of sequences that the model will use to stop generating further tokens. + */ +static constexpr const char *kGenAiRequestStopSequences = "gen_ai.request.stop_sequences"; + +/** + * The temperature setting for the GenAI request. + */ +static constexpr const char *kGenAiRequestTemperature = "gen_ai.request.temperature"; + +/** + * The top_k sampling setting for the GenAI request. + */ +static constexpr const char *kGenAiRequestTopK = "gen_ai.request.top_k"; + +/** + * The top_p sampling setting for the GenAI request. + */ +static constexpr const char *kGenAiRequestTopP = "gen_ai.request.top_p"; + +/** + * Array of reasons the model stopped generating tokens, corresponding to each generation received. + */ +static constexpr const char *kGenAiResponseFinishReasons = "gen_ai.response.finish_reasons"; + +/** + * The unique identifier for the completion. + */ +static constexpr const char *kGenAiResponseId = "gen_ai.response.id"; + +/** + * The name of the model that generated the response. + */ +static constexpr const char *kGenAiResponseModel = "gen_ai.response.model"; + +/** + * The Generative AI product as identified by the client or server instrumentation. + *

        + * The @code gen_ai.system @endcode describes a family of GenAI models with specific model + * identified by @code gen_ai.request.model @endcode and @code gen_ai.response.model @endcode + * attributes.

        The actual GenAI product may differ from the one identified by the client. For + * example, when using OpenAI client libraries to communicate with Mistral, the @code gen_ai.system + * @endcode is set to @code openai @endcode based on the instrumentation's best knowledge.

        For + * custom model, a custom friendly name SHOULD be used. If none of these options apply, the @code + * gen_ai.system @endcode SHOULD be set to @code _OTHER @endcode. + */ +static constexpr const char *kGenAiSystem = "gen_ai.system"; + +/** + * The type of token being counted. + */ +static constexpr const char *kGenAiTokenType = "gen_ai.token.type"; + +/** + * Deprecated, use @code gen_ai.usage.output_tokens @endcode instead. + *

        + * @deprecated + * Replaced by @code gen_ai.usage.output_tokens @endcode attribute. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kGenAiUsageCompletionTokens = "gen_ai.usage.completion_tokens"; + +/** + * The number of tokens used in the GenAI input (prompt). + */ +static constexpr const char *kGenAiUsageInputTokens = "gen_ai.usage.input_tokens"; + +/** + * The number of tokens used in the GenAI response (completion). + */ +static constexpr const char *kGenAiUsageOutputTokens = "gen_ai.usage.output_tokens"; + +/** + * Deprecated, use @code gen_ai.usage.input_tokens @endcode instead. + *

        + * @deprecated + * Replaced by @code gen_ai.usage.input_tokens @endcode attribute. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kGenAiUsagePromptTokens = "gen_ai.usage.prompt_tokens"; + +namespace GenAiOperationNameValues +{ +/** + * Chat completion operation such as OpenAI Chat API + */ +static constexpr const char *kChat = "chat"; + +/** + * Text completions operation such as OpenAI Completions API + * (Legacy) + */ +static constexpr const char *kTextCompletion = "text_completion"; + +} // namespace GenAiOperationNameValues + +namespace GenAiSystemValues +{ +/** + * OpenAI + */ +static constexpr const char *kOpenai = "openai"; + +/** + * Vertex AI + */ +static constexpr const char *kVertexAi = "vertex_ai"; + +/** + * Anthropic + */ +static constexpr const char *kAnthropic = "anthropic"; + +/** + * Cohere + */ +static constexpr const char *kCohere = "cohere"; + +} // namespace GenAiSystemValues + +namespace GenAiTokenTypeValues +{ +/** + * Input tokens (prompt, input, etc.) + */ +static constexpr const char *kInput = "input"; + +/** + * Output tokens (completion, response, etc.) + */ +static constexpr const char *kCompletion = "output"; + +} // namespace GenAiTokenTypeValues + +} // namespace gen_ai +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/gen_ai_metrics.h b/api/include/opentelemetry/semconv/incubating/gen_ai_metrics.h new file mode 100644 index 0000000000..6a9064c3e7 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/gen_ai_metrics.h @@ -0,0 +1,158 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace gen_ai +{ + +/** + * GenAI operation duration + *

        + * histogram + */ +static constexpr const char *kMetricGenAiClientOperationDuration = + "metric.gen_ai.client.operation.duration"; +static constexpr const char *descrMetricGenAiClientOperationDuration = "GenAI operation duration"; +static constexpr const char *unitMetricGenAiClientOperationDuration = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricGenAiClientOperationDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricGenAiClientOperationDuration, + descrMetricGenAiClientOperationDuration, + unitMetricGenAiClientOperationDuration); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricGenAiClientOperationDuration(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricGenAiClientOperationDuration, + descrMetricGenAiClientOperationDuration, + unitMetricGenAiClientOperationDuration); +} + +/** + * Measures number of input and output tokens used + *

        + * histogram + */ +static constexpr const char *kMetricGenAiClientTokenUsage = "metric.gen_ai.client.token.usage"; +static constexpr const char *descrMetricGenAiClientTokenUsage = + "Measures number of input and output tokens used"; +static constexpr const char *unitMetricGenAiClientTokenUsage = "{token}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricGenAiClientTokenUsage(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricGenAiClientTokenUsage, + descrMetricGenAiClientTokenUsage, + unitMetricGenAiClientTokenUsage); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricGenAiClientTokenUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricGenAiClientTokenUsage, + descrMetricGenAiClientTokenUsage, + unitMetricGenAiClientTokenUsage); +} + +/** + * Generative AI server request duration such as time-to-last byte or last output token + *

        + * histogram + */ +static constexpr const char *kMetricGenAiServerRequestDuration = + "metric.gen_ai.server.request.duration"; +static constexpr const char *descrMetricGenAiServerRequestDuration = + "Generative AI server request duration such as time-to-last byte or last output token"; +static constexpr const char *unitMetricGenAiServerRequestDuration = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricGenAiServerRequestDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricGenAiServerRequestDuration, + descrMetricGenAiServerRequestDuration, + unitMetricGenAiServerRequestDuration); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricGenAiServerRequestDuration(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricGenAiServerRequestDuration, + descrMetricGenAiServerRequestDuration, + unitMetricGenAiServerRequestDuration); +} + +/** + * Time per output token generated after the first token for successful responses + *

        + * histogram + */ +static constexpr const char *kMetricGenAiServerTimePerOutputToken = + "metric.gen_ai.server.time_per_output_token"; +static constexpr const char *descrMetricGenAiServerTimePerOutputToken = + "Time per output token generated after the first token for successful responses"; +static constexpr const char *unitMetricGenAiServerTimePerOutputToken = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricGenAiServerTimePerOutputToken(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricGenAiServerTimePerOutputToken, + descrMetricGenAiServerTimePerOutputToken, + unitMetricGenAiServerTimePerOutputToken); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricGenAiServerTimePerOutputToken(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricGenAiServerTimePerOutputToken, + descrMetricGenAiServerTimePerOutputToken, + unitMetricGenAiServerTimePerOutputToken); +} + +/** + * Time to generate first token for successful responses + *

        + * histogram + */ +static constexpr const char *kMetricGenAiServerTimeToFirstToken = + "metric.gen_ai.server.time_to_first_token"; +static constexpr const char *descrMetricGenAiServerTimeToFirstToken = + "Time to generate first token for successful responses"; +static constexpr const char *unitMetricGenAiServerTimeToFirstToken = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricGenAiServerTimeToFirstToken(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricGenAiServerTimeToFirstToken, + descrMetricGenAiServerTimeToFirstToken, + unitMetricGenAiServerTimeToFirstToken); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricGenAiServerTimeToFirstToken(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricGenAiServerTimeToFirstToken, + descrMetricGenAiServerTimeToFirstToken, + unitMetricGenAiServerTimeToFirstToken); +} + +} // namespace gen_ai +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/graphql_attributes.h b/api/include/opentelemetry/semconv/incubating/graphql_attributes.h new file mode 100644 index 0000000000..fe899d1c69 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/graphql_attributes.h @@ -0,0 +1,60 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace graphql +{ + +/** + * The GraphQL document being executed. + *

        + * The value may be sanitized to exclude sensitive information. + */ +static constexpr const char *kGraphqlDocument = "graphql.document"; + +/** + * The name of the operation being executed. + */ +static constexpr const char *kGraphqlOperationName = "graphql.operation.name"; + +/** + * The type of the operation being executed. + */ +static constexpr const char *kGraphqlOperationType = "graphql.operation.type"; + +namespace GraphqlOperationTypeValues +{ +/** + * GraphQL query + */ +static constexpr const char *kQuery = "query"; + +/** + * GraphQL mutation + */ +static constexpr const char *kMutation = "mutation"; + +/** + * GraphQL subscription + */ +static constexpr const char *kSubscription = "subscription"; + +} // namespace GraphqlOperationTypeValues + +} // namespace graphql +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/heroku_attributes.h b/api/include/opentelemetry/semconv/incubating/heroku_attributes.h new file mode 100644 index 0000000000..a16bd33161 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/heroku_attributes.h @@ -0,0 +1,39 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace heroku +{ + +/** + * Unique identifier for the application + */ +static constexpr const char *kHerokuAppId = "heroku.app.id"; + +/** + * Commit hash for the current release + */ +static constexpr const char *kHerokuReleaseCommit = "heroku.release.commit"; + +/** + * Time and date the release was created + */ +static constexpr const char *kHerokuReleaseCreationTimestamp = "heroku.release.creation_timestamp"; + +} // namespace heroku +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/host_attributes.h b/api/include/opentelemetry/semconv/incubating/host_attributes.h new file mode 100644 index 0000000000..e608bd5d46 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/host_attributes.h @@ -0,0 +1,159 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace host +{ + +/** + * The CPU architecture the host system is running on. + */ +static constexpr const char *kHostArch = "host.arch"; + +/** + * The amount of level 2 memory cache available to the processor (in Bytes). + */ +static constexpr const char *kHostCpuCacheL2Size = "host.cpu.cache.l2.size"; + +/** + * Family or generation of the CPU. + */ +static constexpr const char *kHostCpuFamily = "host.cpu.family"; + +/** + * Model identifier. It provides more granular information about the CPU, distinguishing it from + * other CPUs within the same family. + */ +static constexpr const char *kHostCpuModelId = "host.cpu.model.id"; + +/** + * Model designation of the processor. + */ +static constexpr const char *kHostCpuModelName = "host.cpu.model.name"; + +/** + * Stepping or core revisions. + */ +static constexpr const char *kHostCpuStepping = "host.cpu.stepping"; + +/** + * Processor manufacturer identifier. A maximum 12-character string. + *

        + * CPUID command returns the vendor ID string in EBX, EDX + * and ECX registers. Writing these to memory in this order results in a 12-character string. + */ +static constexpr const char *kHostCpuVendorId = "host.cpu.vendor.id"; + +/** + * Unique host ID. For Cloud, this must be the instance_id assigned by the cloud provider. For + * non-containerized systems, this should be the @code machine-id @endcode. See the table below for + * the sources to use to determine the @code machine-id @endcode based on operating system. + */ +static constexpr const char *kHostId = "host.id"; + +/** + * VM image ID or host OS image ID. For Cloud, this value is from the provider. + */ +static constexpr const char *kHostImageId = "host.image.id"; + +/** + * Name of the VM image or OS install the host was instantiated from. + */ +static constexpr const char *kHostImageName = "host.image.name"; + +/** + * The version string of the VM image or host OS as defined in Version Attributes. + */ +static constexpr const char *kHostImageVersion = "host.image.version"; + +/** + * Available IP addresses of the host, excluding loopback interfaces. + *

        + * IPv4 Addresses MUST be specified in dotted-quad notation. IPv6 addresses MUST be specified in the + * RFC 5952 format. + */ +static constexpr const char *kHostIp = "host.ip"; + +/** + * Available MAC addresses of the host, excluding loopback interfaces. + *

        + * MAC Addresses MUST be represented in IEEE RA + * hexadecimal form: as hyphen-separated octets in uppercase hexadecimal form from most to least + * significant. + */ +static constexpr const char *kHostMac = "host.mac"; + +/** + * Name of the host. On Unix systems, it may contain what the hostname command returns, or the fully + * qualified hostname, or another name specified by the user. + */ +static constexpr const char *kHostName = "host.name"; + +/** + * Type of host. For Cloud, this must be the machine type. + */ +static constexpr const char *kHostType = "host.type"; + +namespace HostArchValues +{ +/** + * AMD64 + */ +static constexpr const char *kAmd64 = "amd64"; + +/** + * ARM32 + */ +static constexpr const char *kArm32 = "arm32"; + +/** + * ARM64 + */ +static constexpr const char *kArm64 = "arm64"; + +/** + * Itanium + */ +static constexpr const char *kIa64 = "ia64"; + +/** + * 32-bit PowerPC + */ +static constexpr const char *kPpc32 = "ppc32"; + +/** + * 64-bit PowerPC + */ +static constexpr const char *kPpc64 = "ppc64"; + +/** + * IBM z/Architecture + */ +static constexpr const char *kS390x = "s390x"; + +/** + * 32-bit x86 + */ +static constexpr const char *kX86 = "x86"; + +} // namespace HostArchValues + +} // namespace host +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/http_attributes.h b/api/include/opentelemetry/semconv/incubating/http_attributes.h new file mode 100644 index 0000000000..3e06e4e925 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/http_attributes.h @@ -0,0 +1,365 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace http +{ + +/** + * Deprecated, use @code client.address @endcode instead. + *

        + * @deprecated + * Replaced by @code client.address @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpClientIp = "http.client_ip"; + +/** + * State of the HTTP connection in the HTTP connection pool. + */ +static constexpr const char *kHttpConnectionState = "http.connection.state"; + +/** + * Deprecated, use @code network.protocol.name @endcode instead. + *

        + * @deprecated + * Replaced by @code network.protocol.name @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpFlavor = "http.flavor"; + +/** + * Deprecated, use one of @code server.address @endcode, @code client.address @endcode or @code + * http.request.header.host @endcode instead, depending on the usage.

        + * @deprecated + * Replaced by one of @code server.address @endcode, @code client.address @endcode or @code + * http.request.header.host @endcode, depending on the usage. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpHost = "http.host"; + +/** + * Deprecated, use @code http.request.method @endcode instead. + *

        + * @deprecated + * Replaced by @code http.request.method @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpMethod = "http.method"; + +/** + * The size of the request payload body in bytes. This is the number of bytes transferred excluding + * headers and is often, but not always, present as the Content-Length + * header. For requests using transport encoding, this should be the compressed size. + */ +static constexpr const char *kHttpRequestBodySize = "http.request.body.size"; + +/** + * HTTP request headers, @code @endcode being the normalized HTTP Header name (lowercase), the + * value being the header values.

        Instrumentations SHOULD require an explicit configuration of + * which headers are to be captured. Including all request headers can be a security risk - explicit + * configuration helps avoid leaking sensitive information. The @code User-Agent @endcode header is + * already captured in the @code user_agent.original @endcode attribute. Users MAY explicitly + * configure instrumentations to capture them even though it is not recommended. The attribute value + * MUST consist of either multiple header values as an array of strings or a single-item array + * containing a possibly comma-concatenated string, depending on the way the HTTP library provides + * access to headers. + */ +static constexpr const char *kHttpRequestHeader = "http.request.header"; + +/** + * HTTP request method. + *

        + * HTTP request method value SHOULD be "known" to the instrumentation. + * By default, this convention defines "known" methods as the ones listed in RFC9110 and the PATCH method + * defined in RFC5789.

        If the HTTP + * request method is not known to instrumentation, it MUST set the @code http.request.method + * @endcode attribute to @code _OTHER @endcode.

        If the HTTP instrumentation could end up + * converting valid HTTP request methods to @code _OTHER @endcode, then it MUST provide a way to + * override the list of known HTTP methods. If this override is done via environment variable, then + * the environment variable MUST be named OTEL_INSTRUMENTATION_HTTP_KNOWN_METHODS and support a + * comma-separated list of case-sensitive known HTTP methods (this list MUST be a full override of + * the default known method, it is not a list of known methods in addition to the defaults).

        + * HTTP method names are case-sensitive and @code http.request.method @endcode attribute value MUST + * match a known HTTP method name exactly. Instrumentations for specific web frameworks that + * consider HTTP methods to be case insensitive, SHOULD populate a canonical equivalent. Tracing + * instrumentations that do so, MUST also set @code http.request.method_original @endcode to the + * original value. + */ +static constexpr const char *kHttpRequestMethod = "http.request.method"; + +/** + * Original HTTP method sent by the client in the request line. + */ +static constexpr const char *kHttpRequestMethodOriginal = "http.request.method_original"; + +/** + * The ordinal number of request resending attempt (for any reason, including redirects). + *

        + * The resend count SHOULD be updated each time an HTTP request gets resent by the client, + * regardless of what was the cause of the resending (e.g. redirection, authorization failure, 503 + * Server Unavailable, network issues, or any other). + */ +static constexpr const char *kHttpRequestResendCount = "http.request.resend_count"; + +/** + * The total size of the request in bytes. This should be the total number of bytes sent over the + * wire, including the request line (HTTP/1.1), framing (HTTP/2 and HTTP/3), headers, and request + * body if any. + */ +static constexpr const char *kHttpRequestSize = "http.request.size"; + +/** + * Deprecated, use @code http.request.header.content-length @endcode instead. + *

        + * @deprecated + * Replaced by @code http.request.header.content-length @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpRequestContentLength = "http.request_content_length"; + +/** + * Deprecated, use @code http.request.body.size @endcode instead. + *

        + * @deprecated + * Replaced by @code http.request.body.size @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpRequestContentLengthUncompressed = + "http.request_content_length_uncompressed"; + +/** + * The size of the response payload body in bytes. This is the number of bytes transferred excluding + * headers and is often, but not always, present as the Content-Length + * header. For requests using transport encoding, this should be the compressed size. + */ +static constexpr const char *kHttpResponseBodySize = "http.response.body.size"; + +/** + * HTTP response headers, @code @endcode being the normalized HTTP Header name (lowercase), + * the value being the header values.

        Instrumentations SHOULD require an explicit configuration + * of which headers are to be captured. Including all response headers can be a security risk - + * explicit configuration helps avoid leaking sensitive information. Users MAY explicitly configure + * instrumentations to capture them even though it is not recommended. The attribute value MUST + * consist of either multiple header values as an array of strings or a single-item array containing + * a possibly comma-concatenated string, depending on the way the HTTP library provides access to + * headers. + */ +static constexpr const char *kHttpResponseHeader = "http.response.header"; + +/** + * The total size of the response in bytes. This should be the total number of bytes sent over the + * wire, including the status line (HTTP/1.1), framing (HTTP/2 and HTTP/3), headers, and response + * body and trailers if any. + */ +static constexpr const char *kHttpResponseSize = "http.response.size"; + +/** + * HTTP response status code. + */ +static constexpr const char *kHttpResponseStatusCode = "http.response.status_code"; + +/** + * Deprecated, use @code http.response.header.content-length @endcode instead. + *

        + * @deprecated + * Replaced by @code http.response.header.content-length @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpResponseContentLength = "http.response_content_length"; + +/** + * Deprecated, use @code http.response.body.size @endcode instead. + *

        + * @deprecated + * Replace by @code http.response.body.size @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpResponseContentLengthUncompressed = + "http.response_content_length_uncompressed"; + +/** + * The matched route, that is, the path template in the format used by the respective server + * framework.

        MUST NOT be populated when this is not supported by the HTTP server framework as + * the route attribute should have low-cardinality and the URI path can NOT substitute it. SHOULD + * include the application root if + * there is one. + */ +static constexpr const char *kHttpRoute = "http.route"; + +/** + * Deprecated, use @code url.scheme @endcode instead. + *

        + * @deprecated + * Replaced by @code url.scheme @endcode instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpScheme = "http.scheme"; + +/** + * Deprecated, use @code server.address @endcode instead. + *

        + * @deprecated + * Replaced by @code server.address @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpServerName = "http.server_name"; + +/** + * Deprecated, use @code http.response.status_code @endcode instead. + *

        + * @deprecated + * Replaced by @code http.response.status_code @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpStatusCode = "http.status_code"; + +/** + * Deprecated, use @code url.path @endcode and @code url.query @endcode instead. + *

        + * @deprecated + * Split to @code url.path @endcode and `url.query. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpTarget = "http.target"; + +/** + * Deprecated, use @code url.full @endcode instead. + *

        + * @deprecated + * Replaced by @code url.full @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpUrl = "http.url"; + +/** + * Deprecated, use @code user_agent.original @endcode instead. + *

        + * @deprecated + * Replaced by @code user_agent.original @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpUserAgent = "http.user_agent"; + +namespace HttpConnectionStateValues +{ +/** + * active state. + */ +static constexpr const char *kActive = "active"; + +/** + * idle state. + */ +static constexpr const char *kIdle = "idle"; + +} // namespace HttpConnectionStateValues + +namespace HttpFlavorValues +{ +/** + * HTTP/1.0 + */ +static constexpr const char *kHttp10 = "1.0"; + +/** + * HTTP/1.1 + */ +static constexpr const char *kHttp11 = "1.1"; + +/** + * HTTP/2 + */ +static constexpr const char *kHttp20 = "2.0"; + +/** + * HTTP/3 + */ +static constexpr const char *kHttp30 = "3.0"; + +/** + * SPDY protocol. + */ +static constexpr const char *kSpdy = "SPDY"; + +/** + * QUIC protocol. + */ +static constexpr const char *kQuic = "QUIC"; + +} // namespace HttpFlavorValues + +namespace HttpRequestMethodValues +{ +/** + * CONNECT method. + */ +static constexpr const char *kConnect = "CONNECT"; + +/** + * DELETE method. + */ +static constexpr const char *kDelete = "DELETE"; + +/** + * GET method. + */ +static constexpr const char *kGet = "GET"; + +/** + * HEAD method. + */ +static constexpr const char *kHead = "HEAD"; + +/** + * OPTIONS method. + */ +static constexpr const char *kOptions = "OPTIONS"; + +/** + * PATCH method. + */ +static constexpr const char *kPatch = "PATCH"; + +/** + * POST method. + */ +static constexpr const char *kPost = "POST"; + +/** + * PUT method. + */ +static constexpr const char *kPut = "PUT"; + +/** + * TRACE method. + */ +static constexpr const char *kTrace = "TRACE"; + +/** + * Any HTTP method that the instrumentation has no prior knowledge of. + */ +static constexpr const char *kOther = "_OTHER"; + +} // namespace HttpRequestMethodValues + +} // namespace http +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/http_metrics.h b/api/include/opentelemetry/semconv/incubating/http_metrics.h new file mode 100644 index 0000000000..9142b6c44f --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/http_metrics.h @@ -0,0 +1,353 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace http +{ + +/** + * Number of active HTTP requests. + *

        + * updowncounter + */ +static constexpr const char *kMetricHttpClientActiveRequests = "metric.http.client.active_requests"; +static constexpr const char *descrMetricHttpClientActiveRequests = + "Number of active HTTP requests."; +static constexpr const char *unitMetricHttpClientActiveRequests = "{request}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHttpClientActiveRequests(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricHttpClientActiveRequests, + descrMetricHttpClientActiveRequests, + unitMetricHttpClientActiveRequests); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHttpClientActiveRequests(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricHttpClientActiveRequests, + descrMetricHttpClientActiveRequests, + unitMetricHttpClientActiveRequests); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricHttpClientActiveRequests(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricHttpClientActiveRequests, + descrMetricHttpClientActiveRequests, + unitMetricHttpClientActiveRequests); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHttpClientActiveRequests(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricHttpClientActiveRequests, + descrMetricHttpClientActiveRequests, + unitMetricHttpClientActiveRequests); +} + +/** + * The duration of the successfully established outbound HTTP connections. + *

        + * histogram + */ +static constexpr const char *kMetricHttpClientConnectionDuration = + "metric.http.client.connection.duration"; +static constexpr const char *descrMetricHttpClientConnectionDuration = + "The duration of the successfully established outbound HTTP connections."; +static constexpr const char *unitMetricHttpClientConnectionDuration = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHttpClientConnectionDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricHttpClientConnectionDuration, + descrMetricHttpClientConnectionDuration, + unitMetricHttpClientConnectionDuration); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHttpClientConnectionDuration(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricHttpClientConnectionDuration, + descrMetricHttpClientConnectionDuration, + unitMetricHttpClientConnectionDuration); +} + +/** + * Number of outbound HTTP connections that are currently active or idle on the client. + *

        + * updowncounter + */ +static constexpr const char *kMetricHttpClientOpenConnections = + "metric.http.client.open_connections"; +static constexpr const char *descrMetricHttpClientOpenConnections = + "Number of outbound HTTP connections that are currently active or idle on the client."; +static constexpr const char *unitMetricHttpClientOpenConnections = "{connection}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHttpClientOpenConnections(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricHttpClientOpenConnections, + descrMetricHttpClientOpenConnections, + unitMetricHttpClientOpenConnections); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHttpClientOpenConnections(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricHttpClientOpenConnections, + descrMetricHttpClientOpenConnections, + unitMetricHttpClientOpenConnections); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricHttpClientOpenConnections(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricHttpClientOpenConnections, + descrMetricHttpClientOpenConnections, + unitMetricHttpClientOpenConnections); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHttpClientOpenConnections(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricHttpClientOpenConnections, + descrMetricHttpClientOpenConnections, + unitMetricHttpClientOpenConnections); +} + +/** + * Size of HTTP client request bodies. + *

        + * The size of the request payload body in bytes. This is the number of bytes transferred excluding + * headers and is often, but not always, present as the Content-Length + * header. For requests using transport encoding, this should be the compressed size.

        histogram + */ +static constexpr const char *kMetricHttpClientRequestBodySize = + "metric.http.client.request.body.size"; +static constexpr const char *descrMetricHttpClientRequestBodySize = + "Size of HTTP client request bodies."; +static constexpr const char *unitMetricHttpClientRequestBodySize = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHttpClientRequestBodySize(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricHttpClientRequestBodySize, + descrMetricHttpClientRequestBodySize, + unitMetricHttpClientRequestBodySize); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHttpClientRequestBodySize(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricHttpClientRequestBodySize, + descrMetricHttpClientRequestBodySize, + unitMetricHttpClientRequestBodySize); +} + +/** + * Duration of HTTP client requests. + *

        + * histogram + */ +static constexpr const char *kMetricHttpClientRequestDuration = + "metric.http.client.request.duration"; +static constexpr const char *descrMetricHttpClientRequestDuration = + "Duration of HTTP client requests."; +static constexpr const char *unitMetricHttpClientRequestDuration = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHttpClientRequestDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricHttpClientRequestDuration, + descrMetricHttpClientRequestDuration, + unitMetricHttpClientRequestDuration); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHttpClientRequestDuration(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricHttpClientRequestDuration, + descrMetricHttpClientRequestDuration, + unitMetricHttpClientRequestDuration); +} + +/** + * Size of HTTP client response bodies. + *

        + * The size of the response payload body in bytes. This is the number of bytes transferred excluding + * headers and is often, but not always, present as the Content-Length + * header. For requests using transport encoding, this should be the compressed size.

        histogram + */ +static constexpr const char *kMetricHttpClientResponseBodySize = + "metric.http.client.response.body.size"; +static constexpr const char *descrMetricHttpClientResponseBodySize = + "Size of HTTP client response bodies."; +static constexpr const char *unitMetricHttpClientResponseBodySize = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHttpClientResponseBodySize(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricHttpClientResponseBodySize, + descrMetricHttpClientResponseBodySize, + unitMetricHttpClientResponseBodySize); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHttpClientResponseBodySize(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricHttpClientResponseBodySize, + descrMetricHttpClientResponseBodySize, + unitMetricHttpClientResponseBodySize); +} + +/** + * Number of active HTTP server requests. + *

        + * updowncounter + */ +static constexpr const char *kMetricHttpServerActiveRequests = "metric.http.server.active_requests"; +static constexpr const char *descrMetricHttpServerActiveRequests = + "Number of active HTTP server requests."; +static constexpr const char *unitMetricHttpServerActiveRequests = "{request}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHttpServerActiveRequests(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricHttpServerActiveRequests, + descrMetricHttpServerActiveRequests, + unitMetricHttpServerActiveRequests); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHttpServerActiveRequests(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricHttpServerActiveRequests, + descrMetricHttpServerActiveRequests, + unitMetricHttpServerActiveRequests); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricHttpServerActiveRequests(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricHttpServerActiveRequests, + descrMetricHttpServerActiveRequests, + unitMetricHttpServerActiveRequests); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHttpServerActiveRequests(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricHttpServerActiveRequests, + descrMetricHttpServerActiveRequests, + unitMetricHttpServerActiveRequests); +} + +/** + * Size of HTTP server request bodies. + *

        + * The size of the request payload body in bytes. This is the number of bytes transferred excluding + * headers and is often, but not always, present as the Content-Length + * header. For requests using transport encoding, this should be the compressed size.

        histogram + */ +static constexpr const char *kMetricHttpServerRequestBodySize = + "metric.http.server.request.body.size"; +static constexpr const char *descrMetricHttpServerRequestBodySize = + "Size of HTTP server request bodies."; +static constexpr const char *unitMetricHttpServerRequestBodySize = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHttpServerRequestBodySize(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricHttpServerRequestBodySize, + descrMetricHttpServerRequestBodySize, + unitMetricHttpServerRequestBodySize); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHttpServerRequestBodySize(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricHttpServerRequestBodySize, + descrMetricHttpServerRequestBodySize, + unitMetricHttpServerRequestBodySize); +} + +/** + * Duration of HTTP server requests. + *

        + * histogram + */ +static constexpr const char *kMetricHttpServerRequestDuration = + "metric.http.server.request.duration"; +static constexpr const char *descrMetricHttpServerRequestDuration = + "Duration of HTTP server requests."; +static constexpr const char *unitMetricHttpServerRequestDuration = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHttpServerRequestDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricHttpServerRequestDuration, + descrMetricHttpServerRequestDuration, + unitMetricHttpServerRequestDuration); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHttpServerRequestDuration(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricHttpServerRequestDuration, + descrMetricHttpServerRequestDuration, + unitMetricHttpServerRequestDuration); +} + +/** + * Size of HTTP server response bodies. + *

        + * The size of the response payload body in bytes. This is the number of bytes transferred excluding + * headers and is often, but not always, present as the Content-Length + * header. For requests using transport encoding, this should be the compressed size.

        histogram + */ +static constexpr const char *kMetricHttpServerResponseBodySize = + "metric.http.server.response.body.size"; +static constexpr const char *descrMetricHttpServerResponseBodySize = + "Size of HTTP server response bodies."; +static constexpr const char *unitMetricHttpServerResponseBodySize = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHttpServerResponseBodySize(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricHttpServerResponseBodySize, + descrMetricHttpServerResponseBodySize, + unitMetricHttpServerResponseBodySize); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHttpServerResponseBodySize(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricHttpServerResponseBodySize, + descrMetricHttpServerResponseBodySize, + unitMetricHttpServerResponseBodySize); +} + +} // namespace http +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/k8s_attributes.h b/api/include/opentelemetry/semconv/incubating/k8s_attributes.h new file mode 100644 index 0000000000..2d51d057c7 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/k8s_attributes.h @@ -0,0 +1,180 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace k8s +{ + +/** + * The name of the cluster. + */ +static constexpr const char *kK8sClusterName = "k8s.cluster.name"; + +/** + * A pseudo-ID for the cluster, set to the UID of the @code kube-system @endcode namespace. + *

        + * K8s doesn't have support for obtaining a cluster ID. If this is ever + * added, we will recommend collecting the @code k8s.cluster.uid @endcode through the + * official APIs. In the meantime, we are able to use the @code uid @endcode of the + * @code kube-system @endcode namespace as a proxy for cluster ID. Read on for the + * rationale. + *

        + * Every object created in a K8s cluster is assigned a distinct UID. The + * @code kube-system @endcode namespace is used by Kubernetes itself and will exist + * for the lifetime of the cluster. Using the @code uid @endcode of the @code kube-system @endcode + * namespace is a reasonable proxy for the K8s ClusterID as it will only + * change if the cluster is rebuilt. Furthermore, Kubernetes UIDs are + * UUIDs as standardized by + * ISO/IEC 9834-8 and ITU-T + * X.667. Which states:

        If generated according to one of the mechanisms defined + * in Rec. ITU-T X.667 | ISO/IEC 9834-8, a UUID is either guaranteed to be different from all other + * UUIDs generated before 3603 A.D., or is extremely likely to be different (depending on the + * mechanism chosen).
        + * + *

        + * Therefore, UIDs between clusters should be extremely unlikely to + * conflict. + */ +static constexpr const char *kK8sClusterUid = "k8s.cluster.uid"; + +/** + * The name of the Container from Pod specification, must be unique within a Pod. Container runtime + * usually uses different globally unique name (@code container.name @endcode). + */ +static constexpr const char *kK8sContainerName = "k8s.container.name"; + +/** + * Number of times the container was restarted. This attribute can be used to identify a particular + * container (running or stopped) within a container spec. + */ +static constexpr const char *kK8sContainerRestartCount = "k8s.container.restart_count"; + +/** + * Last terminated reason of the Container. + */ +static constexpr const char *kK8sContainerStatusLastTerminatedReason = + "k8s.container.status.last_terminated_reason"; + +/** + * The name of the CronJob. + */ +static constexpr const char *kK8sCronjobName = "k8s.cronjob.name"; + +/** + * The UID of the CronJob. + */ +static constexpr const char *kK8sCronjobUid = "k8s.cronjob.uid"; + +/** + * The name of the DaemonSet. + */ +static constexpr const char *kK8sDaemonsetName = "k8s.daemonset.name"; + +/** + * The UID of the DaemonSet. + */ +static constexpr const char *kK8sDaemonsetUid = "k8s.daemonset.uid"; + +/** + * The name of the Deployment. + */ +static constexpr const char *kK8sDeploymentName = "k8s.deployment.name"; + +/** + * The UID of the Deployment. + */ +static constexpr const char *kK8sDeploymentUid = "k8s.deployment.uid"; + +/** + * The name of the Job. + */ +static constexpr const char *kK8sJobName = "k8s.job.name"; + +/** + * The UID of the Job. + */ +static constexpr const char *kK8sJobUid = "k8s.job.uid"; + +/** + * The name of the namespace that the pod is running in. + */ +static constexpr const char *kK8sNamespaceName = "k8s.namespace.name"; + +/** + * The name of the Node. + */ +static constexpr const char *kK8sNodeName = "k8s.node.name"; + +/** + * The UID of the Node. + */ +static constexpr const char *kK8sNodeUid = "k8s.node.uid"; + +/** + * The annotation key-value pairs placed on the Pod, the @code @endcode being the annotation + * name, the value being the annotation value. + */ +static constexpr const char *kK8sPodAnnotation = "k8s.pod.annotation"; + +/** + * The label key-value pairs placed on the Pod, the @code @endcode being the label name, the + * value being the label value. + */ +static constexpr const char *kK8sPodLabel = "k8s.pod.label"; + +/** + * Deprecated, use @code k8s.pod.label @endcode instead. + *

        + * @deprecated + * Replaced by @code k8s.pod.label @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kK8sPodLabels = "k8s.pod.labels"; + +/** + * The name of the Pod. + */ +static constexpr const char *kK8sPodName = "k8s.pod.name"; + +/** + * The UID of the Pod. + */ +static constexpr const char *kK8sPodUid = "k8s.pod.uid"; + +/** + * The name of the ReplicaSet. + */ +static constexpr const char *kK8sReplicasetName = "k8s.replicaset.name"; + +/** + * The UID of the ReplicaSet. + */ +static constexpr const char *kK8sReplicasetUid = "k8s.replicaset.uid"; + +/** + * The name of the StatefulSet. + */ +static constexpr const char *kK8sStatefulsetName = "k8s.statefulset.name"; + +/** + * The UID of the StatefulSet. + */ +static constexpr const char *kK8sStatefulsetUid = "k8s.statefulset.uid"; + +} // namespace k8s +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/linux_attributes.h b/api/include/opentelemetry/semconv/incubating/linux_attributes.h new file mode 100644 index 0000000000..024e2b60e6 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/linux_attributes.h @@ -0,0 +1,43 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace linux +{ + +/** + * The Linux Slab memory state + */ +static constexpr const char *kLinuxMemorySlabState = "linux.memory.slab.state"; + +namespace LinuxMemorySlabStateValues +{ +/** + * none + */ +static constexpr const char *kReclaimable = "reclaimable"; + +/** + * none + */ +static constexpr const char *kUnreclaimable = "unreclaimable"; + +} // namespace LinuxMemorySlabStateValues + +} // namespace linux +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/log_attributes.h b/api/include/opentelemetry/semconv/incubating/log_attributes.h new file mode 100644 index 0000000000..6bda8a4d31 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/log_attributes.h @@ -0,0 +1,82 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace log +{ + +/** + * The basename of the file. + */ +static constexpr const char *kLogFileName = "log.file.name"; + +/** + * The basename of the file, with symlinks resolved. + */ +static constexpr const char *kLogFileNameResolved = "log.file.name_resolved"; + +/** + * The full path to the file. + */ +static constexpr const char *kLogFilePath = "log.file.path"; + +/** + * The full path to the file, with symlinks resolved. + */ +static constexpr const char *kLogFilePathResolved = "log.file.path_resolved"; + +/** + * The stream associated with the log. See below for a list of well-known values. + */ +static constexpr const char *kLogIostream = "log.iostream"; + +/** + * The complete orignal Log Record. + *

        + * This value MAY be added when processing a Log Record which was originally transmitted as a string + * or equivalent data type AND the Body field of the Log Record does not contain the same value. + * (e.g. a syslog or a log record read from a file.) + */ +static constexpr const char *kLogRecordOriginal = "log.record.original"; + +/** + * A unique identifier for the Log Record. + *

        + * If an id is provided, other log records with the same id will be considered duplicates and can be + * removed safely. This means, that two distinguishable log records MUST have different values. The + * id MAY be an Universally Unique Lexicographically Sortable + * Identifier (ULID), but other identifiers (e.g. UUID) may be used as needed. + */ +static constexpr const char *kLogRecordUid = "log.record.uid"; + +namespace LogIostreamValues +{ +/** + * Logs from stdout stream + */ +static constexpr const char *kStdout = "stdout"; + +/** + * Events from stderr stream + */ +static constexpr const char *kStderr = "stderr"; + +} // namespace LogIostreamValues + +} // namespace log +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/message_attributes.h b/api/include/opentelemetry/semconv/incubating/message_attributes.h new file mode 100644 index 0000000000..508a1e58f6 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/message_attributes.h @@ -0,0 +1,74 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace message +{ + +/** + * Deprecated, use @code rpc.message.compressed_size @endcode instead. + *

        + * @deprecated + * Replaced by @code rpc.message.compressed_size @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessageCompressedSize = "message.compressed_size"; + +/** + * Deprecated, use @code rpc.message.id @endcode instead. + *

        + * @deprecated + * Replaced by @code rpc.message.id @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessageId = "message.id"; + +/** + * Deprecated, use @code rpc.message.type @endcode instead. + *

        + * @deprecated + * Replaced by @code rpc.message.type @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessageType = "message.type"; + +/** + * Deprecated, use @code rpc.message.uncompressed_size @endcode instead. + *

        + * @deprecated + * Replaced by @code rpc.message.uncompressed_size @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessageUncompressedSize = "message.uncompressed_size"; + +namespace MessageTypeValues +{ +/** + * none + */ +static constexpr const char *kSent = "SENT"; + +/** + * none + */ +static constexpr const char *kReceived = "RECEIVED"; + +} // namespace MessageTypeValues + +} // namespace message +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/messaging_attributes.h b/api/include/opentelemetry/semconv/incubating/messaging_attributes.h new file mode 100644 index 0000000000..c5f07fe241 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/messaging_attributes.h @@ -0,0 +1,534 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace messaging +{ + +/** + * The number of messages sent, received, or processed in the scope of the batching operation. + *

        + * Instrumentations SHOULD NOT set @code messaging.batch.message_count @endcode on spans that + * operate with a single message. When a messaging client library supports both batch and + * single-message API for the same operation, instrumentations SHOULD use @code + * messaging.batch.message_count @endcode for batching APIs and SHOULD NOT use it for single-message + * APIs. + */ +static constexpr const char *kMessagingBatchMessageCount = "messaging.batch.message_count"; + +/** + * A unique identifier for the client that consumes or produces a message. + */ +static constexpr const char *kMessagingClientId = "messaging.client.id"; + +#if 0 +// Excluded attribute: +/** + * Deprecated, use @code messaging.client.id @endcode instead. + *

        + * @deprecated + * Replaced by @code messaging.client.id @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingClientId + = "messaging.client_id"; +#endif + +/** + * The name of the consumer group with which a consumer is associated. + *

        + * Semantic conventions for individual messaging systems SHOULD document whether @code + * messaging.consumer.group.name @endcode is applicable and what it means in the context of that + * system. + */ +static constexpr const char *kMessagingConsumerGroupName = "messaging.consumer.group.name"; + +/** + * A boolean that is true if the message destination is anonymous (could be unnamed or have + * auto-generated name). + */ +static constexpr const char *kMessagingDestinationAnonymous = "messaging.destination.anonymous"; + +/** + * The message destination name + *

        + * Destination name SHOULD uniquely identify a specific queue, topic or other entity within the + * broker. If the broker doesn't have such notion, the destination name SHOULD uniquely identify the + * broker. + */ +static constexpr const char *kMessagingDestinationName = "messaging.destination.name"; + +/** + * The identifier of the partition messages are sent to or received from, unique within the @code + * messaging.destination.name @endcode. + */ +static constexpr const char *kMessagingDestinationPartitionId = + "messaging.destination.partition.id"; + +/** + * The name of the destination subscription from which a message is consumed. + *

        + * Semantic conventions for individual messaging systems SHOULD document whether @code + * messaging.destination.subscription.name @endcode is applicable and what it means in the context + * of that system. + */ +static constexpr const char *kMessagingDestinationSubscriptionName = + "messaging.destination.subscription.name"; + +/** + * Low cardinality representation of the messaging destination name + *

        + * Destination names could be constructed from templates. An example would be a destination name + * involving a user name or product id. Although the destination name in this case is of high + * cardinality, the underlying template is of low cardinality and can be effectively used for + * grouping and aggregation. + */ +static constexpr const char *kMessagingDestinationTemplate = "messaging.destination.template"; + +/** + * A boolean that is true if the message destination is temporary and might not exist anymore after + * messages are processed. + */ +static constexpr const char *kMessagingDestinationTemporary = "messaging.destination.temporary"; + +/** + * Deprecated, no replacement at this time. + *

        + * @deprecated + * No replacement at this time. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingDestinationPublishAnonymous = + "messaging.destination_publish.anonymous"; + +/** + * Deprecated, no replacement at this time. + *

        + * @deprecated + * No replacement at this time. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingDestinationPublishName = + "messaging.destination_publish.name"; + +/** + * Deprecated, use @code messaging.consumer.group.name @endcode instead. + *

        + * @deprecated + * Replaced by @code messaging.consumer.group.name @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingEventhubsConsumerGroup = + "messaging.eventhubs.consumer.group"; + +/** + * The UTC epoch seconds at which the message has been accepted and stored in the entity. + */ +static constexpr const char *kMessagingEventhubsMessageEnqueuedTime = + "messaging.eventhubs.message.enqueued_time"; + +/** + * The ack deadline in seconds set for the modify ack deadline request. + */ +static constexpr const char *kMessagingGcpPubsubMessageAckDeadline = + "messaging.gcp_pubsub.message.ack_deadline"; + +/** + * The ack id for a given message. + */ +static constexpr const char *kMessagingGcpPubsubMessageAckId = + "messaging.gcp_pubsub.message.ack_id"; + +/** + * The delivery attempt for a given message. + */ +static constexpr const char *kMessagingGcpPubsubMessageDeliveryAttempt = + "messaging.gcp_pubsub.message.delivery_attempt"; + +/** + * The ordering key for a given message. If the attribute is not present, the message does not have + * an ordering key. + */ +static constexpr const char *kMessagingGcpPubsubMessageOrderingKey = + "messaging.gcp_pubsub.message.ordering_key"; + +/** + * Deprecated, use @code messaging.consumer.group.name @endcode instead. + *

        + * @deprecated + * Replaced by @code messaging.consumer.group.name @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingKafkaConsumerGroup = "messaging.kafka.consumer.group"; + +/** + * Deprecated, use @code messaging.destination.partition.id @endcode instead. + *

        + * @deprecated + * Replaced by @code messaging.destination.partition.id @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingKafkaDestinationPartition = + "messaging.kafka.destination.partition"; + +/** + * Message keys in Kafka are used for grouping alike messages to ensure they're processed on the + * same partition. They differ from @code messaging.message.id @endcode in that they're not unique. + * If the key is @code null @endcode, the attribute MUST NOT be set.

        If the key type is not + * string, it's string representation has to be supplied for the attribute. If the key has no + * unambiguous, canonical string form, don't include its value. + */ +static constexpr const char *kMessagingKafkaMessageKey = "messaging.kafka.message.key"; + +/** + * Deprecated, use @code messaging.kafka.offset @endcode instead. + *

        + * @deprecated + * Replaced by @code messaging.kafka.offset @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingKafkaMessageOffset = "messaging.kafka.message.offset"; + +/** + * A boolean that is true if the message is a tombstone. + */ +static constexpr const char *kMessagingKafkaMessageTombstone = "messaging.kafka.message.tombstone"; + +/** + * The offset of a record in the corresponding Kafka partition. + */ +static constexpr const char *kMessagingKafkaOffset = "messaging.kafka.offset"; + +/** + * The size of the message body in bytes. + *

        + * This can refer to both the compressed or uncompressed body size. If both sizes are known, the + * uncompressed body size should be used. + */ +static constexpr const char *kMessagingMessageBodySize = "messaging.message.body.size"; + +/** + * The conversation ID identifying the conversation to which the message belongs, represented as a + * string. Sometimes called "Correlation ID". + */ +static constexpr const char *kMessagingMessageConversationId = "messaging.message.conversation_id"; + +/** + * The size of the message body and metadata in bytes. + *

        + * This can refer to both the compressed or uncompressed size. If both sizes are known, the + * uncompressed size should be used. + */ +static constexpr const char *kMessagingMessageEnvelopeSize = "messaging.message.envelope.size"; + +/** + * A value used by the messaging system as an identifier for the message, represented as a string. + */ +static constexpr const char *kMessagingMessageId = "messaging.message.id"; + +/** + * Deprecated, use @code messaging.operation.type @endcode instead. + *

        + * @deprecated + * Replaced by @code messaging.operation.type @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingOperation = "messaging.operation"; + +/** + * The system-specific name of the messaging operation. + */ +static constexpr const char *kMessagingOperationName = "messaging.operation.name"; + +/** + * A string identifying the type of the messaging operation. + *

        + * If a custom value is used, it MUST be of low cardinality. + */ +static constexpr const char *kMessagingOperationType = "messaging.operation.type"; + +/** + * RabbitMQ message routing key. + */ +static constexpr const char *kMessagingRabbitmqDestinationRoutingKey = + "messaging.rabbitmq.destination.routing_key"; + +/** + * RabbitMQ message delivery tag + */ +static constexpr const char *kMessagingRabbitmqMessageDeliveryTag = + "messaging.rabbitmq.message.delivery_tag"; + +/** + * Deprecated, use @code messaging.consumer.group.name @endcode instead. + *

        + * @deprecated + * Replaced by @code messaging.consumer.group.name @endcode on the consumer spans. No replacement + * for producer spans. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingRocketmqClientGroup = "messaging.rocketmq.client_group"; + +/** + * Model of message consumption. This only applies to consumer spans. + */ +static constexpr const char *kMessagingRocketmqConsumptionModel = + "messaging.rocketmq.consumption_model"; + +/** + * The delay time level for delay message, which determines the message delay time. + */ +static constexpr const char *kMessagingRocketmqMessageDelayTimeLevel = + "messaging.rocketmq.message.delay_time_level"; + +/** + * The timestamp in milliseconds that the delay message is expected to be delivered to consumer. + */ +static constexpr const char *kMessagingRocketmqMessageDeliveryTimestamp = + "messaging.rocketmq.message.delivery_timestamp"; + +/** + * It is essential for FIFO message. Messages that belong to the same message group are always + * processed one by one within the same consumer group. + */ +static constexpr const char *kMessagingRocketmqMessageGroup = "messaging.rocketmq.message.group"; + +/** + * Key(s) of message, another way to mark message besides message id. + */ +static constexpr const char *kMessagingRocketmqMessageKeys = "messaging.rocketmq.message.keys"; + +/** + * The secondary classifier of message besides topic. + */ +static constexpr const char *kMessagingRocketmqMessageTag = "messaging.rocketmq.message.tag"; + +/** + * Type of message. + */ +static constexpr const char *kMessagingRocketmqMessageType = "messaging.rocketmq.message.type"; + +/** + * Namespace of RocketMQ resources, resources in different namespaces are individual. + */ +static constexpr const char *kMessagingRocketmqNamespace = "messaging.rocketmq.namespace"; + +/** + * Deprecated, use @code messaging.servicebus.destination.subscription_name @endcode instead. + *

        + * @deprecated + * Replaced by @code messaging.servicebus.destination.subscription_name @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingServicebusDestinationSubscriptionName = + "messaging.servicebus.destination.subscription_name"; + +/** + * Describes the settlement + * type. + */ +static constexpr const char *kMessagingServicebusDispositionStatus = + "messaging.servicebus.disposition_status"; + +/** + * Number of deliveries that have been attempted for this message. + */ +static constexpr const char *kMessagingServicebusMessageDeliveryCount = + "messaging.servicebus.message.delivery_count"; + +/** + * The UTC epoch seconds at which the message has been accepted and stored in the entity. + */ +static constexpr const char *kMessagingServicebusMessageEnqueuedTime = + "messaging.servicebus.message.enqueued_time"; + +/** + * The messaging system as identified by the client instrumentation. + *

        + * The actual messaging system may differ from the one known by the client. For example, when using + * Kafka client libraries to communicate with Azure Event Hubs, the @code messaging.system @endcode + * is set to @code kafka @endcode based on the instrumentation's best knowledge. + */ +static constexpr const char *kMessagingSystem = "messaging.system"; + +namespace MessagingOperationTypeValues +{ +/** + * One or more messages are provided for publishing to an intermediary. If a single message is + * published, the context of the "Publish" span can be used as the creation context and no "Create" + * span needs to be created. + */ +static constexpr const char *kPublish = "publish"; + +/** + * A message is created. "Create" spans always refer to a single message and are used to provide a + * unique creation context for messages in batch publishing scenarios. + */ +static constexpr const char *kCreate = "create"; + +/** + * One or more messages are requested by a consumer. This operation refers to pull-based scenarios, + * where consumers explicitly call methods of messaging SDKs to receive messages. + */ +static constexpr const char *kReceive = "receive"; + +/** + * One or more messages are processed by a consumer. + */ +static constexpr const char *kProcess = "process"; + +/** + * One or more messages are settled. + */ +static constexpr const char *kSettle = "settle"; + +/** + * Deprecated. Use @code process @endcode instead. + *

        + * @deprecated + * Replaced by @code process @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDeliver = "deliver"; + +} // namespace MessagingOperationTypeValues + +namespace MessagingRocketmqConsumptionModelValues +{ +/** + * Clustering consumption model + */ +static constexpr const char *kClustering = "clustering"; + +/** + * Broadcasting consumption model + */ +static constexpr const char *kBroadcasting = "broadcasting"; + +} // namespace MessagingRocketmqConsumptionModelValues + +namespace MessagingRocketmqMessageTypeValues +{ +/** + * Normal message + */ +static constexpr const char *kNormal = "normal"; + +/** + * FIFO message + */ +static constexpr const char *kFifo = "fifo"; + +/** + * Delay message + */ +static constexpr const char *kDelay = "delay"; + +/** + * Transaction message + */ +static constexpr const char *kTransaction = "transaction"; + +} // namespace MessagingRocketmqMessageTypeValues + +namespace MessagingServicebusDispositionStatusValues +{ +/** + * Message is completed + */ +static constexpr const char *kComplete = "complete"; + +/** + * Message is abandoned + */ +static constexpr const char *kAbandon = "abandon"; + +/** + * Message is sent to dead letter queue + */ +static constexpr const char *kDeadLetter = "dead_letter"; + +/** + * Message is deferred + */ +static constexpr const char *kDefer = "defer"; + +} // namespace MessagingServicebusDispositionStatusValues + +namespace MessagingSystemValues +{ +/** + * Apache ActiveMQ + */ +static constexpr const char *kActivemq = "activemq"; + +/** + * Amazon Simple Queue Service (SQS) + */ +static constexpr const char *kAwsSqs = "aws_sqs"; + +/** + * Azure Event Grid + */ +static constexpr const char *kEventgrid = "eventgrid"; + +/** + * Azure Event Hubs + */ +static constexpr const char *kEventhubs = "eventhubs"; + +/** + * Azure Service Bus + */ +static constexpr const char *kServicebus = "servicebus"; + +/** + * Google Cloud Pub/Sub + */ +static constexpr const char *kGcpPubsub = "gcp_pubsub"; + +/** + * Java Message Service + */ +static constexpr const char *kJms = "jms"; + +/** + * Apache Kafka + */ +static constexpr const char *kKafka = "kafka"; + +/** + * RabbitMQ + */ +static constexpr const char *kRabbitmq = "rabbitmq"; + +/** + * Apache RocketMQ + */ +static constexpr const char *kRocketmq = "rocketmq"; + +/** + * Apache Pulsar + */ +static constexpr const char *kPulsar = "pulsar"; + +} // namespace MessagingSystemValues + +} // namespace messaging +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/messaging_metrics.h b/api/include/opentelemetry/semconv/incubating/messaging_metrics.h new file mode 100644 index 0000000000..5da042da2d --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/messaging_metrics.h @@ -0,0 +1,396 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace messaging +{ + +/** + * Number of messages that were delivered to the application. + *

        + * Records the number of messages pulled from the broker or number of messages dispatched to the + * application in push-based scenarios. The metric SHOULD be reported once per message delivery. For + * example, if receiving and processing operations are both instrumented for a single message + * delivery, this counter is incremented when the message is received and not reported when it is + * processed.

        counter + */ +static constexpr const char *kMetricMessagingClientConsumedMessages = + "metric.messaging.client.consumed.messages"; +static constexpr const char *descrMetricMessagingClientConsumedMessages = + "Number of messages that were delivered to the application."; +static constexpr const char *unitMetricMessagingClientConsumedMessages = "{message}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricMessagingClientConsumedMessages(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricMessagingClientConsumedMessages, + descrMetricMessagingClientConsumedMessages, + unitMetricMessagingClientConsumedMessages); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricMessagingClientConsumedMessages(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricMessagingClientConsumedMessages, + descrMetricMessagingClientConsumedMessages, + unitMetricMessagingClientConsumedMessages); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricMessagingClientConsumedMessages(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricMessagingClientConsumedMessages, + descrMetricMessagingClientConsumedMessages, + unitMetricMessagingClientConsumedMessages); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricMessagingClientConsumedMessages(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricMessagingClientConsumedMessages, + descrMetricMessagingClientConsumedMessages, + unitMetricMessagingClientConsumedMessages); +} + +/** + * Duration of messaging operation initiated by a producer or consumer client. + *

        + * This metric SHOULD NOT be used to report processing duration - processing duration is reported in + * @code messaging.process.duration @endcode metric.

        histogram + */ +static constexpr const char *kMetricMessagingClientOperationDuration = + "metric.messaging.client.operation.duration"; +static constexpr const char *descrMetricMessagingClientOperationDuration = + "Duration of messaging operation initiated by a producer or consumer client."; +static constexpr const char *unitMetricMessagingClientOperationDuration = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricMessagingClientOperationDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricMessagingClientOperationDuration, + descrMetricMessagingClientOperationDuration, + unitMetricMessagingClientOperationDuration); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricMessagingClientOperationDuration(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricMessagingClientOperationDuration, + descrMetricMessagingClientOperationDuration, + unitMetricMessagingClientOperationDuration); +} + +/** + * Number of messages producer attempted to publish to the broker. + *

        + * This metric MUST NOT count messages that were created haven't yet been attempted to be published. + *

        + * counter + */ +static constexpr const char *kMetricMessagingClientPublishedMessages = + "metric.messaging.client.published.messages"; +static constexpr const char *descrMetricMessagingClientPublishedMessages = + "Number of messages producer attempted to publish to the broker."; +static constexpr const char *unitMetricMessagingClientPublishedMessages = "{message}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricMessagingClientPublishedMessages(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricMessagingClientPublishedMessages, + descrMetricMessagingClientPublishedMessages, + unitMetricMessagingClientPublishedMessages); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricMessagingClientPublishedMessages(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricMessagingClientPublishedMessages, + descrMetricMessagingClientPublishedMessages, + unitMetricMessagingClientPublishedMessages); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricMessagingClientPublishedMessages(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricMessagingClientPublishedMessages, + descrMetricMessagingClientPublishedMessages, + unitMetricMessagingClientPublishedMessages); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricMessagingClientPublishedMessages(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricMessagingClientPublishedMessages, + descrMetricMessagingClientPublishedMessages, + unitMetricMessagingClientPublishedMessages); +} + +/** + * Duration of processing operation. + *

        + * This metric MUST be reported for operations with @code messaging.operation.type @endcode that + * matches @code process @endcode.

        histogram + */ +static constexpr const char *kMetricMessagingProcessDuration = "metric.messaging.process.duration"; +static constexpr const char *descrMetricMessagingProcessDuration = + "Duration of processing operation."; +static constexpr const char *unitMetricMessagingProcessDuration = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricMessagingProcessDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricMessagingProcessDuration, + descrMetricMessagingProcessDuration, + unitMetricMessagingProcessDuration); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricMessagingProcessDuration(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricMessagingProcessDuration, + descrMetricMessagingProcessDuration, + unitMetricMessagingProcessDuration); +} + +/** + * Deprecated. Use @code messaging.client.consumed.messages @endcode instead. + *

        + * @deprecated + * Replaced by @code messaging.client.consumed.messages @endcode. + *

        + * counter + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMetricMessagingProcessMessages = "metric.messaging.process.messages"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *descrMetricMessagingProcessMessages = + "Deprecated. Use `messaging.client.consumed.messages` instead."; +OPENTELEMETRY_DEPRECATED +static constexpr const char *unitMetricMessagingProcessMessages = "{message}"; + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncInt64MetricMessagingProcessMessages(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricMessagingProcessMessages, + descrMetricMessagingProcessMessages, + unitMetricMessagingProcessMessages); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncDoubleMetricMessagingProcessMessages(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricMessagingProcessMessages, + descrMetricMessagingProcessMessages, + unitMetricMessagingProcessMessages); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncInt64MetricMessagingProcessMessages(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricMessagingProcessMessages, + descrMetricMessagingProcessMessages, + unitMetricMessagingProcessMessages); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncDoubleMetricMessagingProcessMessages(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricMessagingProcessMessages, + descrMetricMessagingProcessMessages, + unitMetricMessagingProcessMessages); +} + +/** + * Deprecated. Use @code messaging.client.operation.duration @endcode instead. + *

        + * @deprecated + * Replaced by @code messaging.client.operation.duration @endcode. + *

        + * histogram + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMetricMessagingPublishDuration = "metric.messaging.publish.duration"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *descrMetricMessagingPublishDuration = + "Deprecated. Use `messaging.client.operation.duration` instead."; +OPENTELEMETRY_DEPRECATED +static constexpr const char *unitMetricMessagingPublishDuration = "s"; + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncInt64MetricMessagingPublishDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricMessagingPublishDuration, + descrMetricMessagingPublishDuration, + unitMetricMessagingPublishDuration); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncDoubleMetricMessagingPublishDuration(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricMessagingPublishDuration, + descrMetricMessagingPublishDuration, + unitMetricMessagingPublishDuration); +} + +/** + * Deprecated. Use @code messaging.client.produced.messages @endcode instead. + *

        + * @deprecated + * Replaced by @code messaging.client.produced.messages @endcode. + *

        + * counter + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMetricMessagingPublishMessages = "metric.messaging.publish.messages"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *descrMetricMessagingPublishMessages = + "Deprecated. Use `messaging.client.produced.messages` instead."; +OPENTELEMETRY_DEPRECATED +static constexpr const char *unitMetricMessagingPublishMessages = "{message}"; + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncInt64MetricMessagingPublishMessages(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricMessagingPublishMessages, + descrMetricMessagingPublishMessages, + unitMetricMessagingPublishMessages); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncDoubleMetricMessagingPublishMessages(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricMessagingPublishMessages, + descrMetricMessagingPublishMessages, + unitMetricMessagingPublishMessages); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncInt64MetricMessagingPublishMessages(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricMessagingPublishMessages, + descrMetricMessagingPublishMessages, + unitMetricMessagingPublishMessages); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncDoubleMetricMessagingPublishMessages(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricMessagingPublishMessages, + descrMetricMessagingPublishMessages, + unitMetricMessagingPublishMessages); +} + +/** + * Deprecated. Use @code messaging.client.operation.duration @endcode instead. + *

        + * @deprecated + * Replaced by @code messaging.client.operation.duration @endcode. + *

        + * histogram + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMetricMessagingReceiveDuration = "metric.messaging.receive.duration"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *descrMetricMessagingReceiveDuration = + "Deprecated. Use `messaging.client.operation.duration` instead."; +OPENTELEMETRY_DEPRECATED +static constexpr const char *unitMetricMessagingReceiveDuration = "s"; + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncInt64MetricMessagingReceiveDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricMessagingReceiveDuration, + descrMetricMessagingReceiveDuration, + unitMetricMessagingReceiveDuration); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncDoubleMetricMessagingReceiveDuration(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricMessagingReceiveDuration, + descrMetricMessagingReceiveDuration, + unitMetricMessagingReceiveDuration); +} + +/** + * Deprecated. Use @code messaging.client.consumed.messages @endcode instead. + *

        + * @deprecated + * Replaced by @code messaging.client.consumed.messages @endcode. + *

        + * counter + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMetricMessagingReceiveMessages = "metric.messaging.receive.messages"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *descrMetricMessagingReceiveMessages = + "Deprecated. Use `messaging.client.consumed.messages` instead."; +OPENTELEMETRY_DEPRECATED +static constexpr const char *unitMetricMessagingReceiveMessages = "{message}"; + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncInt64MetricMessagingReceiveMessages(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricMessagingReceiveMessages, + descrMetricMessagingReceiveMessages, + unitMetricMessagingReceiveMessages); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncDoubleMetricMessagingReceiveMessages(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricMessagingReceiveMessages, + descrMetricMessagingReceiveMessages, + unitMetricMessagingReceiveMessages); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncInt64MetricMessagingReceiveMessages(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricMessagingReceiveMessages, + descrMetricMessagingReceiveMessages, + unitMetricMessagingReceiveMessages); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncDoubleMetricMessagingReceiveMessages(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricMessagingReceiveMessages, + descrMetricMessagingReceiveMessages, + unitMetricMessagingReceiveMessages); +} + +} // namespace messaging +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/net_attributes.h b/api/include/opentelemetry/semconv/incubating/net_attributes.h new file mode 100644 index 0000000000..9562299223 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/net_attributes.h @@ -0,0 +1,209 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace net +{ + +/** + * Deprecated, use @code network.local.address @endcode. + *

        + * @deprecated + * Replaced by @code network.local.address @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetHostIp = "net.host.ip"; + +/** + * Deprecated, use @code server.address @endcode. + *

        + * @deprecated + * Replaced by @code server.address @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetHostName = "net.host.name"; + +/** + * Deprecated, use @code server.port @endcode. + *

        + * @deprecated + * Replaced by @code server.port @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetHostPort = "net.host.port"; + +/** + * Deprecated, use @code network.peer.address @endcode. + *

        + * @deprecated + * Replaced by @code network.peer.address @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetPeerIp = "net.peer.ip"; + +/** + * Deprecated, use @code server.address @endcode on client spans and @code client.address @endcode + * on server spans.

        + * @deprecated + * Replaced by @code server.address @endcode on client spans and @code client.address @endcode on + * server spans. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetPeerName = "net.peer.name"; + +/** + * Deprecated, use @code server.port @endcode on client spans and @code client.port @endcode on + * server spans.

        + * @deprecated + * Replaced by @code server.port @endcode on client spans and @code client.port @endcode on server + * spans. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetPeerPort = "net.peer.port"; + +/** + * Deprecated, use @code network.protocol.name @endcode. + *

        + * @deprecated + * Replaced by @code network.protocol.name @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetProtocolName = "net.protocol.name"; + +/** + * Deprecated, use @code network.protocol.version @endcode. + *

        + * @deprecated + * Replaced by @code network.protocol.version @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetProtocolVersion = "net.protocol.version"; + +/** + * Deprecated, use @code network.transport @endcode and @code network.type @endcode. + *

        + * @deprecated + * Split to @code network.transport @endcode and @code network.type @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetSockFamily = "net.sock.family"; + +/** + * Deprecated, use @code network.local.address @endcode. + *

        + * @deprecated + * Replaced by @code network.local.address @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetSockHostAddr = "net.sock.host.addr"; + +/** + * Deprecated, use @code network.local.port @endcode. + *

        + * @deprecated + * Replaced by @code network.local.port @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetSockHostPort = "net.sock.host.port"; + +/** + * Deprecated, use @code network.peer.address @endcode. + *

        + * @deprecated + * Replaced by @code network.peer.address @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetSockPeerAddr = "net.sock.peer.addr"; + +/** + * Deprecated, no replacement at this time. + *

        + * @deprecated + * Removed. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetSockPeerName = "net.sock.peer.name"; + +/** + * Deprecated, use @code network.peer.port @endcode. + *

        + * @deprecated + * Replaced by @code network.peer.port @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetSockPeerPort = "net.sock.peer.port"; + +/** + * Deprecated, use @code network.transport @endcode. + *

        + * @deprecated + * Replaced by @code network.transport @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetTransport = "net.transport"; + +namespace NetSockFamilyValues +{ +/** + * IPv4 address + */ +static constexpr const char *kInet = "inet"; + +/** + * IPv6 address + */ +static constexpr const char *kInet6 = "inet6"; + +/** + * Unix domain socket path + */ +static constexpr const char *kUnix = "unix"; + +} // namespace NetSockFamilyValues + +namespace NetTransportValues +{ +/** + * none + */ +static constexpr const char *kIpTcp = "ip_tcp"; + +/** + * none + */ +static constexpr const char *kIpUdp = "ip_udp"; + +/** + * Named or anonymous pipe. + */ +static constexpr const char *kPipe = "pipe"; + +/** + * In-process communication. + */ +static constexpr const char *kInproc = "inproc"; + +/** + * Something else (non IP-based). + */ +static constexpr const char *kOther = "other"; + +} // namespace NetTransportValues + +} // namespace net +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/network_attributes.h b/api/include/opentelemetry/semconv/incubating/network_attributes.h new file mode 100644 index 0000000000..ea855c5735 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/network_attributes.h @@ -0,0 +1,308 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace network +{ + +/** + * The ISO 3166-1 alpha-2 2-character country code associated with the mobile carrier network. + */ +static constexpr const char *kNetworkCarrierIcc = "network.carrier.icc"; + +/** + * The mobile carrier country code. + */ +static constexpr const char *kNetworkCarrierMcc = "network.carrier.mcc"; + +/** + * The mobile carrier network code. + */ +static constexpr const char *kNetworkCarrierMnc = "network.carrier.mnc"; + +/** + * The name of the mobile carrier. + */ +static constexpr const char *kNetworkCarrierName = "network.carrier.name"; + +/** + * This describes more details regarding the connection.type. It may be the type of cell technology + * connection, but it could be used for describing details about a wifi connection. + */ +static constexpr const char *kNetworkConnectionSubtype = "network.connection.subtype"; + +/** + * The internet connection type. + */ +static constexpr const char *kNetworkConnectionType = "network.connection.type"; + +/** + * The network IO operation direction. + */ +static constexpr const char *kNetworkIoDirection = "network.io.direction"; + +/** + * Local address of the network connection - IP address or Unix domain socket name. + */ +static constexpr const char *kNetworkLocalAddress = "network.local.address"; + +/** + * Local port number of the network connection. + */ +static constexpr const char *kNetworkLocalPort = "network.local.port"; + +/** + * Peer address of the network connection - IP address or Unix domain socket name. + */ +static constexpr const char *kNetworkPeerAddress = "network.peer.address"; + +/** + * Peer port number of the network connection. + */ +static constexpr const char *kNetworkPeerPort = "network.peer.port"; + +/** + * OSI application layer or non-OSI + * equivalent.

        The value SHOULD be normalized to lowercase. + */ +static constexpr const char *kNetworkProtocolName = "network.protocol.name"; + +/** + * The actual version of the protocol used for network communication. + *

        + * If protocol version is subject to negotiation (for example using ALPN), this attribute SHOULD be set to the + * negotiated version. If the actual protocol version is not known, this attribute SHOULD NOT be + * set. + */ +static constexpr const char *kNetworkProtocolVersion = "network.protocol.version"; + +/** + * OSI transport layer or inter-process communication + * method.

        The value SHOULD be normalized to lowercase.

        Consider always setting the + * transport when setting a port number, since a port number is ambiguous without knowing the + * transport. For example different processes could be listening on TCP port 12345 and UDP port + * 12345. + */ +static constexpr const char *kNetworkTransport = "network.transport"; + +/** + * OSI network layer or non-OSI equivalent. + *

        + * The value SHOULD be normalized to lowercase. + */ +static constexpr const char *kNetworkType = "network.type"; + +namespace NetworkConnectionSubtypeValues +{ +/** + * GPRS + */ +static constexpr const char *kGprs = "gprs"; + +/** + * EDGE + */ +static constexpr const char *kEdge = "edge"; + +/** + * UMTS + */ +static constexpr const char *kUmts = "umts"; + +/** + * CDMA + */ +static constexpr const char *kCdma = "cdma"; + +/** + * EVDO Rel. 0 + */ +static constexpr const char *kEvdo0 = "evdo_0"; + +/** + * EVDO Rev. A + */ +static constexpr const char *kEvdoA = "evdo_a"; + +/** + * CDMA2000 1XRTT + */ +static constexpr const char *kCdma20001xrtt = "cdma2000_1xrtt"; + +/** + * HSDPA + */ +static constexpr const char *kHsdpa = "hsdpa"; + +/** + * HSUPA + */ +static constexpr const char *kHsupa = "hsupa"; + +/** + * HSPA + */ +static constexpr const char *kHspa = "hspa"; + +/** + * IDEN + */ +static constexpr const char *kIden = "iden"; + +/** + * EVDO Rev. B + */ +static constexpr const char *kEvdoB = "evdo_b"; + +/** + * LTE + */ +static constexpr const char *kLte = "lte"; + +/** + * EHRPD + */ +static constexpr const char *kEhrpd = "ehrpd"; + +/** + * HSPAP + */ +static constexpr const char *kHspap = "hspap"; + +/** + * GSM + */ +static constexpr const char *kGsm = "gsm"; + +/** + * TD-SCDMA + */ +static constexpr const char *kTdScdma = "td_scdma"; + +/** + * IWLAN + */ +static constexpr const char *kIwlan = "iwlan"; + +/** + * 5G NR (New Radio) + */ +static constexpr const char *kNr = "nr"; + +/** + * 5G NRNSA (New Radio Non-Standalone) + */ +static constexpr const char *kNrnsa = "nrnsa"; + +/** + * LTE CA + */ +static constexpr const char *kLteCa = "lte_ca"; + +} // namespace NetworkConnectionSubtypeValues + +namespace NetworkConnectionTypeValues +{ +/** + * none + */ +static constexpr const char *kWifi = "wifi"; + +/** + * none + */ +static constexpr const char *kWired = "wired"; + +/** + * none + */ +static constexpr const char *kCell = "cell"; + +/** + * none + */ +static constexpr const char *kUnavailable = "unavailable"; + +/** + * none + */ +static constexpr const char *kUnknown = "unknown"; + +} // namespace NetworkConnectionTypeValues + +namespace NetworkIoDirectionValues +{ +/** + * none + */ +static constexpr const char *kTransmit = "transmit"; + +/** + * none + */ +static constexpr const char *kReceive = "receive"; + +} // namespace NetworkIoDirectionValues + +namespace NetworkTransportValues +{ +/** + * TCP + */ +static constexpr const char *kTcp = "tcp"; + +/** + * UDP + */ +static constexpr const char *kUdp = "udp"; + +/** + * Named or anonymous pipe. + */ +static constexpr const char *kPipe = "pipe"; + +/** + * Unix domain socket + */ +static constexpr const char *kUnix = "unix"; + +/** + * QUIC + */ +static constexpr const char *kQuic = "quic"; + +} // namespace NetworkTransportValues + +namespace NetworkTypeValues +{ +/** + * IPv4 + */ +static constexpr const char *kIpv4 = "ipv4"; + +/** + * IPv6 + */ +static constexpr const char *kIpv6 = "ipv6"; + +} // namespace NetworkTypeValues + +} // namespace network +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/oci_attributes.h b/api/include/opentelemetry/semconv/incubating/oci_attributes.h new file mode 100644 index 0000000000..ade92d35c8 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/oci_attributes.h @@ -0,0 +1,36 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace oci +{ + +/** + * The digest of the OCI image manifest. For container images specifically is the digest by which + * the container image is known.

        Follows OCI Image Manifest + * Specification, and specifically the Digest + * property. An example can be found in Example Image + * Manifest. + */ +static constexpr const char *kOciManifestDigest = "oci.manifest.digest"; + +} // namespace oci +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/opentracing_attributes.h b/api/include/opentelemetry/semconv/incubating/opentracing_attributes.h new file mode 100644 index 0000000000..159645e76b --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/opentracing_attributes.h @@ -0,0 +1,45 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace opentracing +{ + +/** + * Parent-child Reference type + *

        + * The causal relationship between a child Span and a parent Span. + */ +static constexpr const char *kOpentracingRefType = "opentracing.ref_type"; + +namespace OpentracingRefTypeValues +{ +/** + * The parent Span depends on the child Span in some capacity + */ +static constexpr const char *kChildOf = "child_of"; + +/** + * The parent Span doesn't depend in any way on the result of the child Span + */ +static constexpr const char *kFollowsFrom = "follows_from"; + +} // namespace OpentracingRefTypeValues + +} // namespace opentracing +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/os_attributes.h b/api/include/opentelemetry/semconv/incubating/os_attributes.h new file mode 100644 index 0000000000..807deaaf92 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/os_attributes.h @@ -0,0 +1,110 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace os +{ + +/** + * Unique identifier for a particular build or compilation of the operating system. + */ +static constexpr const char *kOsBuildId = "os.build_id"; + +/** + * Human readable (not intended to be parsed) OS version information, like e.g. reported by @code + * ver @endcode or @code lsb_release -a @endcode commands. + */ +static constexpr const char *kOsDescription = "os.description"; + +/** + * Human readable operating system name. + */ +static constexpr const char *kOsName = "os.name"; + +/** + * The operating system type. + */ +static constexpr const char *kOsType = "os.type"; + +/** + * The version string of the operating system as defined in Version Attributes. + */ +static constexpr const char *kOsVersion = "os.version"; + +namespace OsTypeValues +{ +/** + * Microsoft Windows + */ +static constexpr const char *kWindows = "windows"; + +/** + * Linux + */ +static constexpr const char *kLinux = "linux"; + +/** + * Apple Darwin + */ +static constexpr const char *kDarwin = "darwin"; + +/** + * FreeBSD + */ +static constexpr const char *kFreebsd = "freebsd"; + +/** + * NetBSD + */ +static constexpr const char *kNetbsd = "netbsd"; + +/** + * OpenBSD + */ +static constexpr const char *kOpenbsd = "openbsd"; + +/** + * DragonFly BSD + */ +static constexpr const char *kDragonflybsd = "dragonflybsd"; + +/** + * HP-UX (Hewlett Packard Unix) + */ +static constexpr const char *kHpux = "hpux"; + +/** + * AIX (Advanced Interactive eXecutive) + */ +static constexpr const char *kAix = "aix"; + +/** + * SunOS, Oracle Solaris + */ +static constexpr const char *kSolaris = "solaris"; + +/** + * IBM z/OS + */ +static constexpr const char *kZOs = "z_os"; + +} // namespace OsTypeValues + +} // namespace os +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/otel_attributes.h b/api/include/opentelemetry/semconv/incubating/otel_attributes.h new file mode 100644 index 0000000000..241e07d1aa --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/otel_attributes.h @@ -0,0 +1,73 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace otel +{ + +/** + * @deprecated + * use the @code otel.scope.name @endcode attribute. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kOtelLibraryName = "otel.library.name"; + +/** + * @deprecated + * use the @code otel.scope.version @endcode attribute. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kOtelLibraryVersion = "otel.library.version"; + +/** + * The name of the instrumentation scope - (@code InstrumentationScope.Name @endcode in OTLP). + */ +static constexpr const char *kOtelScopeName = "otel.scope.name"; + +/** + * The version of the instrumentation scope - (@code InstrumentationScope.Version @endcode in OTLP). + */ +static constexpr const char *kOtelScopeVersion = "otel.scope.version"; + +/** + * Name of the code, either "OK" or "ERROR". MUST NOT be set if the status code is UNSET. + */ +static constexpr const char *kOtelStatusCode = "otel.status_code"; + +/** + * Description of the Status if it has a value, otherwise not set. + */ +static constexpr const char *kOtelStatusDescription = "otel.status_description"; + +namespace OtelStatusCodeValues +{ +/** + * The operation has been validated by an Application developer or Operator to have completed + * successfully. + */ +static constexpr const char *kOk = "OK"; + +/** + * The operation contains an error. + */ +static constexpr const char *kError = "ERROR"; + +} // namespace OtelStatusCodeValues + +} // namespace otel +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/other_attributes.h b/api/include/opentelemetry/semconv/incubating/other_attributes.h new file mode 100644 index 0000000000..bc6d26ef16 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/other_attributes.h @@ -0,0 +1,47 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace other +{ + +/** + * Deprecated, use @code db.client.connection.state @endcode instead. + *

        + * @deprecated + * Replaced by @code db.client.connection.state @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kState = "state"; + +namespace StateValues +{ +/** + * none + */ +static constexpr const char *kIdle = "idle"; + +/** + * none + */ +static constexpr const char *kUsed = "used"; + +} // namespace StateValues + +} // namespace other +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/peer_attributes.h b/api/include/opentelemetry/semconv/incubating/peer_attributes.h new file mode 100644 index 0000000000..6215d913f5 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/peer_attributes.h @@ -0,0 +1,31 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace peer +{ + +/** + * The @code service.name @endcode of the remote + * service. SHOULD be equal to the actual @code service.name @endcode resource attribute of the + * remote service if any. + */ +static constexpr const char *kPeerService = "peer.service"; + +} // namespace peer +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/pool_attributes.h b/api/include/opentelemetry/semconv/incubating/pool_attributes.h new file mode 100644 index 0000000000..6c26b22c23 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/pool_attributes.h @@ -0,0 +1,33 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace pool +{ + +/** + * Deprecated, use @code db.client.connection.pool.name @endcode instead. + *

        + * @deprecated + * Replaced by @code db.client.connection.pool.name @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kPoolName = "pool.name"; + +} // namespace pool +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/process_attributes.h b/api/include/opentelemetry/semconv/incubating/process_attributes.h new file mode 100644 index 0000000000..392ef869d1 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/process_attributes.h @@ -0,0 +1,226 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace process +{ + +/** + * The command used to launch the process (i.e. the command name). On Linux based systems, can be + * set to the zeroth string in @code proc/[pid]/cmdline @endcode. On Windows, can be set to the + * first parameter extracted from @code GetCommandLineW @endcode. + */ +static constexpr const char *kProcessCommand = "process.command"; + +/** + * All the command arguments (including the command/executable itself) as received by the process. + * On Linux-based systems (and some other Unixoid systems supporting procfs), can be set according + * to the list of null-delimited strings extracted from @code proc/[pid]/cmdline @endcode. For + * libc-based executables, this would be the full argv vector passed to @code main @endcode. + */ +static constexpr const char *kProcessCommandArgs = "process.command_args"; + +/** + * The full command used to launch the process as a single string representing the full command. On + * Windows, can be set to the result of @code GetCommandLineW @endcode. Do not set this if you have + * to assemble it just for monitoring; use @code process.command_args @endcode instead. + */ +static constexpr const char *kProcessCommandLine = "process.command_line"; + +/** + * Specifies whether the context switches for this data point were voluntary or involuntary. + */ +static constexpr const char *kProcessContextSwitchType = "process.context_switch_type"; + +/** + * Deprecated, use @code cpu.mode @endcode instead. + *

        + * @deprecated + * Replaced by @code cpu.mode @endcode + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kProcessCpuState = "process.cpu.state"; + +/** + * The date and time the process was created, in ISO 8601 format. + */ +static constexpr const char *kProcessCreationTime = "process.creation.time"; + +/** + * The name of the process executable. On Linux based systems, can be set to the @code Name @endcode + * in @code proc/[pid]/status @endcode. On Windows, can be set to the base name of @code + * GetProcessImageFileNameW @endcode. + */ +static constexpr const char *kProcessExecutableName = "process.executable.name"; + +/** + * The full path to the process executable. On Linux based systems, can be set to the target of + * @code proc/[pid]/exe @endcode. On Windows, can be set to the result of @code + * GetProcessImageFileNameW @endcode. + */ +static constexpr const char *kProcessExecutablePath = "process.executable.path"; + +/** + * The exit code of the process. + */ +static constexpr const char *kProcessExitCode = "process.exit.code"; + +/** + * The date and time the process exited, in ISO 8601 format. + */ +static constexpr const char *kProcessExitTime = "process.exit.time"; + +/** + * The PID of the process's group leader. This is also the process group ID (PGID) of the process. + */ +static constexpr const char *kProcessGroupLeaderPid = "process.group_leader.pid"; + +/** + * Whether the process is connected to an interactive shell. + */ +static constexpr const char *kProcessInteractive = "process.interactive"; + +/** + * The username of the user that owns the process. + */ +static constexpr const char *kProcessOwner = "process.owner"; + +/** + * The type of page fault for this data point. Type @code major @endcode is for major/hard page + * faults, and @code minor @endcode is for minor/soft page faults. + */ +static constexpr const char *kProcessPagingFaultType = "process.paging.fault_type"; + +/** + * Parent Process identifier (PPID). + */ +static constexpr const char *kProcessParentPid = "process.parent_pid"; + +/** + * Process identifier (PID). + */ +static constexpr const char *kProcessPid = "process.pid"; + +/** + * The real user ID (RUID) of the process. + */ +static constexpr const char *kProcessRealUserId = "process.real_user.id"; + +/** + * The username of the real user of the process. + */ +static constexpr const char *kProcessRealUserName = "process.real_user.name"; + +/** + * An additional description about the runtime of the process, for example a specific vendor + * customization of the runtime environment. + */ +static constexpr const char *kProcessRuntimeDescription = "process.runtime.description"; + +/** + * The name of the runtime of this process. + */ +static constexpr const char *kProcessRuntimeName = "process.runtime.name"; + +/** + * The version of the runtime of this process, as returned by the runtime without modification. + */ +static constexpr const char *kProcessRuntimeVersion = "process.runtime.version"; + +/** + * The saved user ID (SUID) of the process. + */ +static constexpr const char *kProcessSavedUserId = "process.saved_user.id"; + +/** + * The username of the saved user. + */ +static constexpr const char *kProcessSavedUserName = "process.saved_user.name"; + +/** + * The PID of the process's session leader. This is also the session ID (SID) of the process. + */ +static constexpr const char *kProcessSessionLeaderPid = "process.session_leader.pid"; + +/** + * The effective user ID (EUID) of the process. + */ +static constexpr const char *kProcessUserId = "process.user.id"; + +/** + * The username of the effective user of the process. + */ +static constexpr const char *kProcessUserName = "process.user.name"; + +/** + * Virtual process identifier. + *

        + * The process ID within a PID namespace. This is not necessarily unique across all processes on the + * host but it is unique within the process namespace that the process exists within. + */ +static constexpr const char *kProcessVpid = "process.vpid"; + +namespace ProcessContextSwitchTypeValues +{ +/** + * none + */ +static constexpr const char *kVoluntary = "voluntary"; + +/** + * none + */ +static constexpr const char *kInvoluntary = "involuntary"; + +} // namespace ProcessContextSwitchTypeValues + +namespace ProcessCpuStateValues +{ +/** + * none + */ +static constexpr const char *kSystem = "system"; + +/** + * none + */ +static constexpr const char *kUser = "user"; + +/** + * none + */ +static constexpr const char *kWait = "wait"; + +} // namespace ProcessCpuStateValues + +namespace ProcessPagingFaultTypeValues +{ +/** + * none + */ +static constexpr const char *kMajor = "major"; + +/** + * none + */ +static constexpr const char *kMinor = "minor"; + +} // namespace ProcessPagingFaultTypeValues + +} // namespace process +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/process_metrics.h b/api/include/opentelemetry/semconv/incubating/process_metrics.h new file mode 100644 index 0000000000..95a1853ccb --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/process_metrics.h @@ -0,0 +1,416 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace process +{ + +/** + * Number of times the process has been context switched. + *

        + * counter + */ +static constexpr const char *kMetricProcessContextSwitches = "metric.process.context_switches"; +static constexpr const char *descrMetricProcessContextSwitches = + "Number of times the process has been context switched."; +static constexpr const char *unitMetricProcessContextSwitches = "{count}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricProcessContextSwitches(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricProcessContextSwitches, + descrMetricProcessContextSwitches, + unitMetricProcessContextSwitches); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricProcessContextSwitches(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricProcessContextSwitches, + descrMetricProcessContextSwitches, + unitMetricProcessContextSwitches); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricProcessContextSwitches(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricProcessContextSwitches, + descrMetricProcessContextSwitches, + unitMetricProcessContextSwitches); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricProcessContextSwitches(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricProcessContextSwitches, + descrMetricProcessContextSwitches, + unitMetricProcessContextSwitches); +} + +/** + * Total CPU seconds broken down by different states. + *

        + * counter + */ +static constexpr const char *kMetricProcessCpuTime = "metric.process.cpu.time"; +static constexpr const char *descrMetricProcessCpuTime = + "Total CPU seconds broken down by different states."; +static constexpr const char *unitMetricProcessCpuTime = "s"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricProcessCpuTime( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricProcessCpuTime, descrMetricProcessCpuTime, + unitMetricProcessCpuTime); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricProcessCpuTime( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricProcessCpuTime, descrMetricProcessCpuTime, + unitMetricProcessCpuTime); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricProcessCpuTime( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricProcessCpuTime, descrMetricProcessCpuTime, + unitMetricProcessCpuTime); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricProcessCpuTime(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricProcessCpuTime, descrMetricProcessCpuTime, + unitMetricProcessCpuTime); +} + +/** + * Difference in process.cpu.time since the last measurement, divided by the elapsed time and number + * of CPUs available to the process.

        gauge + */ +static constexpr const char *kMetricProcessCpuUtilization = "metric.process.cpu.utilization"; +static constexpr const char *descrMetricProcessCpuUtilization = + "Difference in process.cpu.time since the last measurement, divided by the elapsed time and " + "number of CPUs available to the process."; +static constexpr const char *unitMetricProcessCpuUtilization = "1"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricProcessCpuUtilization( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricProcessCpuUtilization, descrMetricProcessCpuUtilization, + unitMetricProcessCpuUtilization); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricProcessCpuUtilization( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricProcessCpuUtilization, descrMetricProcessCpuUtilization, + unitMetricProcessCpuUtilization); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricProcessCpuUtilization(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricProcessCpuUtilization, + descrMetricProcessCpuUtilization, + unitMetricProcessCpuUtilization); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricProcessCpuUtilization(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricProcessCpuUtilization, + descrMetricProcessCpuUtilization, + unitMetricProcessCpuUtilization); +} + +/** + * Disk bytes transferred. + *

        + * counter + */ +static constexpr const char *kMetricProcessDiskIo = "metric.process.disk.io"; +static constexpr const char *descrMetricProcessDiskIo = "Disk bytes transferred."; +static constexpr const char *unitMetricProcessDiskIo = "By"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricProcessDiskIo( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricProcessDiskIo, descrMetricProcessDiskIo, + unitMetricProcessDiskIo); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricProcessDiskIo( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricProcessDiskIo, descrMetricProcessDiskIo, + unitMetricProcessDiskIo); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricProcessDiskIo( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricProcessDiskIo, descrMetricProcessDiskIo, + unitMetricProcessDiskIo); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricProcessDiskIo( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricProcessDiskIo, descrMetricProcessDiskIo, + unitMetricProcessDiskIo); +} + +/** + * The amount of physical memory in use. + *

        + * updowncounter + */ +static constexpr const char *kMetricProcessMemoryUsage = "metric.process.memory.usage"; +static constexpr const char *descrMetricProcessMemoryUsage = + "The amount of physical memory in use."; +static constexpr const char *unitMetricProcessMemoryUsage = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricProcessMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricProcessMemoryUsage, descrMetricProcessMemoryUsage, + unitMetricProcessMemoryUsage); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricProcessMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricProcessMemoryUsage, descrMetricProcessMemoryUsage, + unitMetricProcessMemoryUsage); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricProcessMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter( + kMetricProcessMemoryUsage, descrMetricProcessMemoryUsage, unitMetricProcessMemoryUsage); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricProcessMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter( + kMetricProcessMemoryUsage, descrMetricProcessMemoryUsage, unitMetricProcessMemoryUsage); +} + +/** + * The amount of committed virtual memory. + *

        + * updowncounter + */ +static constexpr const char *kMetricProcessMemoryVirtual = "metric.process.memory.virtual"; +static constexpr const char *descrMetricProcessMemoryVirtual = + "The amount of committed virtual memory."; +static constexpr const char *unitMetricProcessMemoryVirtual = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricProcessMemoryVirtual(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter( + kMetricProcessMemoryVirtual, descrMetricProcessMemoryVirtual, unitMetricProcessMemoryVirtual); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricProcessMemoryVirtual(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter( + kMetricProcessMemoryVirtual, descrMetricProcessMemoryVirtual, unitMetricProcessMemoryVirtual); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricProcessMemoryVirtual(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter( + kMetricProcessMemoryVirtual, descrMetricProcessMemoryVirtual, unitMetricProcessMemoryVirtual); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricProcessMemoryVirtual(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter( + kMetricProcessMemoryVirtual, descrMetricProcessMemoryVirtual, unitMetricProcessMemoryVirtual); +} + +/** + * Network bytes transferred. + *

        + * counter + */ +static constexpr const char *kMetricProcessNetworkIo = "metric.process.network.io"; +static constexpr const char *descrMetricProcessNetworkIo = "Network bytes transferred."; +static constexpr const char *unitMetricProcessNetworkIo = "By"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricProcessNetworkIo( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricProcessNetworkIo, descrMetricProcessNetworkIo, + unitMetricProcessNetworkIo); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricProcessNetworkIo( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricProcessNetworkIo, descrMetricProcessNetworkIo, + unitMetricProcessNetworkIo); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricProcessNetworkIo(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricProcessNetworkIo, descrMetricProcessNetworkIo, + unitMetricProcessNetworkIo); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricProcessNetworkIo(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricProcessNetworkIo, descrMetricProcessNetworkIo, + unitMetricProcessNetworkIo); +} + +/** + * Number of file descriptors in use by the process. + *

        + * updowncounter + */ +static constexpr const char *kMetricProcessOpenFileDescriptorCount = + "metric.process.open_file_descriptor.count"; +static constexpr const char *descrMetricProcessOpenFileDescriptorCount = + "Number of file descriptors in use by the process."; +static constexpr const char *unitMetricProcessOpenFileDescriptorCount = "{count}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricProcessOpenFileDescriptorCount(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricProcessOpenFileDescriptorCount, + descrMetricProcessOpenFileDescriptorCount, + unitMetricProcessOpenFileDescriptorCount); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricProcessOpenFileDescriptorCount(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricProcessOpenFileDescriptorCount, + descrMetricProcessOpenFileDescriptorCount, + unitMetricProcessOpenFileDescriptorCount); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricProcessOpenFileDescriptorCount(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricProcessOpenFileDescriptorCount, + descrMetricProcessOpenFileDescriptorCount, + unitMetricProcessOpenFileDescriptorCount); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricProcessOpenFileDescriptorCount(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricProcessOpenFileDescriptorCount, + descrMetricProcessOpenFileDescriptorCount, + unitMetricProcessOpenFileDescriptorCount); +} + +/** + * Number of page faults the process has made. + *

        + * counter + */ +static constexpr const char *kMetricProcessPagingFaults = "metric.process.paging.faults"; +static constexpr const char *descrMetricProcessPagingFaults = + "Number of page faults the process has made."; +static constexpr const char *unitMetricProcessPagingFaults = "{fault}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricProcessPagingFaults(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricProcessPagingFaults, descrMetricProcessPagingFaults, + unitMetricProcessPagingFaults); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricProcessPagingFaults( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricProcessPagingFaults, descrMetricProcessPagingFaults, + unitMetricProcessPagingFaults); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricProcessPagingFaults(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter( + kMetricProcessPagingFaults, descrMetricProcessPagingFaults, unitMetricProcessPagingFaults); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricProcessPagingFaults(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter( + kMetricProcessPagingFaults, descrMetricProcessPagingFaults, unitMetricProcessPagingFaults); +} + +/** + * Process threads count. + *

        + * updowncounter + */ +static constexpr const char *kMetricProcessThreadCount = "metric.process.thread.count"; +static constexpr const char *descrMetricProcessThreadCount = "Process threads count."; +static constexpr const char *unitMetricProcessThreadCount = "{thread}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricProcessThreadCount(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricProcessThreadCount, descrMetricProcessThreadCount, + unitMetricProcessThreadCount); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricProcessThreadCount(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricProcessThreadCount, descrMetricProcessThreadCount, + unitMetricProcessThreadCount); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricProcessThreadCount(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter( + kMetricProcessThreadCount, descrMetricProcessThreadCount, unitMetricProcessThreadCount); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricProcessThreadCount(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter( + kMetricProcessThreadCount, descrMetricProcessThreadCount, unitMetricProcessThreadCount); +} + +} // namespace process +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/rpc_attributes.h b/api/include/opentelemetry/semconv/incubating/rpc_attributes.h new file mode 100644 index 0000000000..49ba418512 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/rpc_attributes.h @@ -0,0 +1,355 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace rpc +{ + +/** + * The error codes of the Connect + * request. Error codes are always string values. + */ +static constexpr const char *kRpcConnectRpcErrorCode = "rpc.connect_rpc.error_code"; + +/** + * Connect request metadata, @code @endcode being the normalized Connect Metadata key + * (lowercase), the value being the metadata values.

        Instrumentations SHOULD require an explicit + * configuration of which metadata values are to be captured. Including all request metadata values + * can be a security risk - explicit configuration helps avoid leaking sensitive information. + */ +static constexpr const char *kRpcConnectRpcRequestMetadata = "rpc.connect_rpc.request.metadata"; + +/** + * Connect response metadata, @code @endcode being the normalized Connect Metadata key + * (lowercase), the value being the metadata values.

        Instrumentations SHOULD require an explicit + * configuration of which metadata values are to be captured. Including all response metadata values + * can be a security risk - explicit configuration helps avoid leaking sensitive information. + */ +static constexpr const char *kRpcConnectRpcResponseMetadata = "rpc.connect_rpc.response.metadata"; + +/** + * gRPC request metadata, @code @endcode being the normalized gRPC Metadata key (lowercase), + * the value being the metadata values.

        Instrumentations SHOULD require an explicit + * configuration of which metadata values are to be captured. Including all request metadata values + * can be a security risk - explicit configuration helps avoid leaking sensitive information. + */ +static constexpr const char *kRpcGrpcRequestMetadata = "rpc.grpc.request.metadata"; + +/** + * gRPC response metadata, @code @endcode being the normalized gRPC Metadata key (lowercase), + * the value being the metadata values.

        Instrumentations SHOULD require an explicit + * configuration of which metadata values are to be captured. Including all response metadata values + * can be a security risk - explicit configuration helps avoid leaking sensitive information. + */ +static constexpr const char *kRpcGrpcResponseMetadata = "rpc.grpc.response.metadata"; + +/** + * The numeric status + * code of the gRPC request. + */ +static constexpr const char *kRpcGrpcStatusCode = "rpc.grpc.status_code"; + +/** + * @code error.code @endcode property of response if it is an error response. + */ +static constexpr const char *kRpcJsonrpcErrorCode = "rpc.jsonrpc.error_code"; + +/** + * @code error.message @endcode property of response if it is an error response. + */ +static constexpr const char *kRpcJsonrpcErrorMessage = "rpc.jsonrpc.error_message"; + +/** + * @code id @endcode property of request or response. Since protocol allows id to be int, string, + * @code null @endcode or missing (for notifications), value is expected to be cast to string for + * simplicity. Use empty string in case of @code null @endcode value. Omit entirely if this is a + * notification. + */ +static constexpr const char *kRpcJsonrpcRequestId = "rpc.jsonrpc.request_id"; + +/** + * Protocol version as in @code jsonrpc @endcode property of request/response. Since JSON-RPC 1.0 + * doesn't specify this, the value can be omitted. + */ +static constexpr const char *kRpcJsonrpcVersion = "rpc.jsonrpc.version"; + +/** + * Compressed size of the message in bytes. + */ +static constexpr const char *kRpcMessageCompressedSize = "rpc.message.compressed_size"; + +/** + * MUST be calculated as two different counters starting from @code 1 @endcode one for sent messages + * and one for received message.

        This way we guarantee that the values will be consistent + * between different implementations. + */ +static constexpr const char *kRpcMessageId = "rpc.message.id"; + +/** + * Whether this is a received or sent message. + */ +static constexpr const char *kRpcMessageType = "rpc.message.type"; + +/** + * Uncompressed size of the message in bytes. + */ +static constexpr const char *kRpcMessageUncompressedSize = "rpc.message.uncompressed_size"; + +/** + * The name of the (logical) method being called, must be equal to the $method part in the span + * name.

        This is the logical name of the method from the RPC interface perspective, which can be + * different from the name of any implementing method/function. The @code code.function @endcode + * attribute may be used to store the latter (e.g., method actually executing the call on the server + * side, RPC client stub method on the client side). + */ +static constexpr const char *kRpcMethod = "rpc.method"; + +/** + * The full (logical) name of the service being called, including its package name, if applicable. + *

        + * This is the logical name of the service from the RPC interface perspective, which can be + * different from the name of any implementing class. The @code code.namespace @endcode attribute + * may be used to store the latter (despite the attribute name, it may include a class name; e.g., + * class with method actually executing the call on the server side, RPC client stub class on the + * client side). + */ +static constexpr const char *kRpcService = "rpc.service"; + +/** + * A string identifying the remoting system. See below for a list of well-known identifiers. + */ +static constexpr const char *kRpcSystem = "rpc.system"; + +namespace RpcConnectRpcErrorCodeValues +{ +/** + * none + */ +static constexpr const char *kCancelled = "cancelled"; + +/** + * none + */ +static constexpr const char *kUnknown = "unknown"; + +/** + * none + */ +static constexpr const char *kInvalidArgument = "invalid_argument"; + +/** + * none + */ +static constexpr const char *kDeadlineExceeded = "deadline_exceeded"; + +/** + * none + */ +static constexpr const char *kNotFound = "not_found"; + +/** + * none + */ +static constexpr const char *kAlreadyExists = "already_exists"; + +/** + * none + */ +static constexpr const char *kPermissionDenied = "permission_denied"; + +/** + * none + */ +static constexpr const char *kResourceExhausted = "resource_exhausted"; + +/** + * none + */ +static constexpr const char *kFailedPrecondition = "failed_precondition"; + +/** + * none + */ +static constexpr const char *kAborted = "aborted"; + +/** + * none + */ +static constexpr const char *kOutOfRange = "out_of_range"; + +/** + * none + */ +static constexpr const char *kUnimplemented = "unimplemented"; + +/** + * none + */ +static constexpr const char *kInternal = "internal"; + +/** + * none + */ +static constexpr const char *kUnavailable = "unavailable"; + +/** + * none + */ +static constexpr const char *kDataLoss = "data_loss"; + +/** + * none + */ +static constexpr const char *kUnauthenticated = "unauthenticated"; + +} // namespace RpcConnectRpcErrorCodeValues + +namespace RpcGrpcStatusCodeValues +{ +/** + * OK + */ +static constexpr int kOk = 0; + +/** + * CANCELLED + */ +static constexpr int kCancelled = 1; + +/** + * UNKNOWN + */ +static constexpr int kUnknown = 2; + +/** + * INVALID_ARGUMENT + */ +static constexpr int kInvalidArgument = 3; + +/** + * DEADLINE_EXCEEDED + */ +static constexpr int kDeadlineExceeded = 4; + +/** + * NOT_FOUND + */ +static constexpr int kNotFound = 5; + +/** + * ALREADY_EXISTS + */ +static constexpr int kAlreadyExists = 6; + +/** + * PERMISSION_DENIED + */ +static constexpr int kPermissionDenied = 7; + +/** + * RESOURCE_EXHAUSTED + */ +static constexpr int kResourceExhausted = 8; + +/** + * FAILED_PRECONDITION + */ +static constexpr int kFailedPrecondition = 9; + +/** + * ABORTED + */ +static constexpr int kAborted = 10; + +/** + * OUT_OF_RANGE + */ +static constexpr int kOutOfRange = 11; + +/** + * UNIMPLEMENTED + */ +static constexpr int kUnimplemented = 12; + +/** + * INTERNAL + */ +static constexpr int kInternal = 13; + +/** + * UNAVAILABLE + */ +static constexpr int kUnavailable = 14; + +/** + * DATA_LOSS + */ +static constexpr int kDataLoss = 15; + +/** + * UNAUTHENTICATED + */ +static constexpr int kUnauthenticated = 16; + +} // namespace RpcGrpcStatusCodeValues + +namespace RpcMessageTypeValues +{ +/** + * none + */ +static constexpr const char *kSent = "SENT"; + +/** + * none + */ +static constexpr const char *kReceived = "RECEIVED"; + +} // namespace RpcMessageTypeValues + +namespace RpcSystemValues +{ +/** + * gRPC + */ +static constexpr const char *kGrpc = "grpc"; + +/** + * Java RMI + */ +static constexpr const char *kJavaRmi = "java_rmi"; + +/** + * .NET WCF + */ +static constexpr const char *kDotnetWcf = "dotnet_wcf"; + +/** + * Apache Dubbo + */ +static constexpr const char *kApacheDubbo = "apache_dubbo"; + +/** + * Connect RPC + */ +static constexpr const char *kConnectRpc = "connect_rpc"; + +} // namespace RpcSystemValues + +} // namespace rpc +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/rpc_metrics.h b/api/include/opentelemetry/semconv/incubating/rpc_metrics.h new file mode 100644 index 0000000000..30e95ce710 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/rpc_metrics.h @@ -0,0 +1,312 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace rpc +{ + +/** + * Measures the duration of outbound RPC. + *

        + * While streaming RPCs may record this metric as start-of-batch + * to end-of-batch, it's hard to interpret in practice. + *

        + * Streaming: N/A. + *

        + * histogram + */ +static constexpr const char *kMetricRpcClientDuration = "metric.rpc.client.duration"; +static constexpr const char *descrMetricRpcClientDuration = + "Measures the duration of outbound RPC."; +static constexpr const char *unitMetricRpcClientDuration = "ms"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricRpcClientDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricRpcClientDuration, descrMetricRpcClientDuration, + unitMetricRpcClientDuration); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricRpcClientDuration( + metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricRpcClientDuration, descrMetricRpcClientDuration, + unitMetricRpcClientDuration); +} + +/** + * Measures the size of RPC request messages (uncompressed). + *

        + * Streaming: Recorded per message in a streaming batch + *

        + * histogram + */ +static constexpr const char *kMetricRpcClientRequestSize = "metric.rpc.client.request.size"; +static constexpr const char *descrMetricRpcClientRequestSize = + "Measures the size of RPC request messages (uncompressed)."; +static constexpr const char *unitMetricRpcClientRequestSize = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricRpcClientRequestSize(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricRpcClientRequestSize, descrMetricRpcClientRequestSize, + unitMetricRpcClientRequestSize); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricRpcClientRequestSize(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricRpcClientRequestSize, descrMetricRpcClientRequestSize, + unitMetricRpcClientRequestSize); +} + +/** + * Measures the number of messages received per RPC. + *

        + * Should be 1 for all non-streaming RPCs. + *

        + * Streaming: This metric is required for server and client streaming RPCs + *

        + * histogram + */ +static constexpr const char *kMetricRpcClientRequestsPerRpc = "metric.rpc.client.requests_per_rpc"; +static constexpr const char *descrMetricRpcClientRequestsPerRpc = + "Measures the number of messages received per RPC."; +static constexpr const char *unitMetricRpcClientRequestsPerRpc = "{count}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricRpcClientRequestsPerRpc(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricRpcClientRequestsPerRpc, + descrMetricRpcClientRequestsPerRpc, + unitMetricRpcClientRequestsPerRpc); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricRpcClientRequestsPerRpc(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricRpcClientRequestsPerRpc, + descrMetricRpcClientRequestsPerRpc, + unitMetricRpcClientRequestsPerRpc); +} + +/** + * Measures the size of RPC response messages (uncompressed). + *

        + * Streaming: Recorded per response in a streaming batch + *

        + * histogram + */ +static constexpr const char *kMetricRpcClientResponseSize = "metric.rpc.client.response.size"; +static constexpr const char *descrMetricRpcClientResponseSize = + "Measures the size of RPC response messages (uncompressed)."; +static constexpr const char *unitMetricRpcClientResponseSize = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricRpcClientResponseSize(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricRpcClientResponseSize, + descrMetricRpcClientResponseSize, + unitMetricRpcClientResponseSize); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricRpcClientResponseSize(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricRpcClientResponseSize, + descrMetricRpcClientResponseSize, + unitMetricRpcClientResponseSize); +} + +/** + * Measures the number of messages sent per RPC. + *

        + * Should be 1 for all non-streaming RPCs. + *

        + * Streaming: This metric is required for server and client streaming RPCs + *

        + * histogram + */ +static constexpr const char *kMetricRpcClientResponsesPerRpc = + "metric.rpc.client.responses_per_rpc"; +static constexpr const char *descrMetricRpcClientResponsesPerRpc = + "Measures the number of messages sent per RPC."; +static constexpr const char *unitMetricRpcClientResponsesPerRpc = "{count}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricRpcClientResponsesPerRpc(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricRpcClientResponsesPerRpc, + descrMetricRpcClientResponsesPerRpc, + unitMetricRpcClientResponsesPerRpc); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricRpcClientResponsesPerRpc(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricRpcClientResponsesPerRpc, + descrMetricRpcClientResponsesPerRpc, + unitMetricRpcClientResponsesPerRpc); +} + +/** + * Measures the duration of inbound RPC. + *

        + * While streaming RPCs may record this metric as start-of-batch + * to end-of-batch, it's hard to interpret in practice. + *

        + * Streaming: N/A. + *

        + * histogram + */ +static constexpr const char *kMetricRpcServerDuration = "metric.rpc.server.duration"; +static constexpr const char *descrMetricRpcServerDuration = "Measures the duration of inbound RPC."; +static constexpr const char *unitMetricRpcServerDuration = "ms"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricRpcServerDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricRpcServerDuration, descrMetricRpcServerDuration, + unitMetricRpcServerDuration); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricRpcServerDuration( + metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricRpcServerDuration, descrMetricRpcServerDuration, + unitMetricRpcServerDuration); +} + +/** + * Measures the size of RPC request messages (uncompressed). + *

        + * Streaming: Recorded per message in a streaming batch + *

        + * histogram + */ +static constexpr const char *kMetricRpcServerRequestSize = "metric.rpc.server.request.size"; +static constexpr const char *descrMetricRpcServerRequestSize = + "Measures the size of RPC request messages (uncompressed)."; +static constexpr const char *unitMetricRpcServerRequestSize = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricRpcServerRequestSize(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricRpcServerRequestSize, descrMetricRpcServerRequestSize, + unitMetricRpcServerRequestSize); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricRpcServerRequestSize(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricRpcServerRequestSize, descrMetricRpcServerRequestSize, + unitMetricRpcServerRequestSize); +} + +/** + * Measures the number of messages received per RPC. + *

        + * Should be 1 for all non-streaming RPCs. + *

        + * Streaming : This metric is required for server and client streaming RPCs + *

        + * histogram + */ +static constexpr const char *kMetricRpcServerRequestsPerRpc = "metric.rpc.server.requests_per_rpc"; +static constexpr const char *descrMetricRpcServerRequestsPerRpc = + "Measures the number of messages received per RPC."; +static constexpr const char *unitMetricRpcServerRequestsPerRpc = "{count}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricRpcServerRequestsPerRpc(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricRpcServerRequestsPerRpc, + descrMetricRpcServerRequestsPerRpc, + unitMetricRpcServerRequestsPerRpc); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricRpcServerRequestsPerRpc(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricRpcServerRequestsPerRpc, + descrMetricRpcServerRequestsPerRpc, + unitMetricRpcServerRequestsPerRpc); +} + +/** + * Measures the size of RPC response messages (uncompressed). + *

        + * Streaming: Recorded per response in a streaming batch + *

        + * histogram + */ +static constexpr const char *kMetricRpcServerResponseSize = "metric.rpc.server.response.size"; +static constexpr const char *descrMetricRpcServerResponseSize = + "Measures the size of RPC response messages (uncompressed)."; +static constexpr const char *unitMetricRpcServerResponseSize = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricRpcServerResponseSize(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricRpcServerResponseSize, + descrMetricRpcServerResponseSize, + unitMetricRpcServerResponseSize); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricRpcServerResponseSize(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricRpcServerResponseSize, + descrMetricRpcServerResponseSize, + unitMetricRpcServerResponseSize); +} + +/** + * Measures the number of messages sent per RPC. + *

        + * Should be 1 for all non-streaming RPCs. + *

        + * Streaming: This metric is required for server and client streaming RPCs + *

        + * histogram + */ +static constexpr const char *kMetricRpcServerResponsesPerRpc = + "metric.rpc.server.responses_per_rpc"; +static constexpr const char *descrMetricRpcServerResponsesPerRpc = + "Measures the number of messages sent per RPC."; +static constexpr const char *unitMetricRpcServerResponsesPerRpc = "{count}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricRpcServerResponsesPerRpc(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricRpcServerResponsesPerRpc, + descrMetricRpcServerResponsesPerRpc, + unitMetricRpcServerResponsesPerRpc); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricRpcServerResponsesPerRpc(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricRpcServerResponsesPerRpc, + descrMetricRpcServerResponsesPerRpc, + unitMetricRpcServerResponsesPerRpc); +} + +} // namespace rpc +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/server_attributes.h b/api/include/opentelemetry/semconv/incubating/server_attributes.h new file mode 100644 index 0000000000..21cb75d729 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/server_attributes.h @@ -0,0 +1,41 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace server +{ + +/** + * Server domain name if available without reverse DNS lookup; otherwise, IP address or Unix domain + * socket name.

        When observed from the client side, and when communicating through an + * intermediary, @code server.address @endcode SHOULD represent the server address behind any + * intermediaries, for example proxies, if it's available. + */ +static constexpr const char *kServerAddress = "server.address"; + +/** + * Server port number. + *

        + * When observed from the client side, and when communicating through an intermediary, @code + * server.port @endcode SHOULD represent the server port behind any intermediaries, for example + * proxies, if it's available. + */ +static constexpr const char *kServerPort = "server.port"; + +} // namespace server +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/service_attributes.h b/api/include/opentelemetry/semconv/incubating/service_attributes.h new file mode 100644 index 0000000000..7582c19868 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/service_attributes.h @@ -0,0 +1,84 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace service +{ + +/** + * The string ID of the service instance. + *

        + * MUST be unique for each instance of the same @code service.namespace,service.name @endcode pair + * (in other words + * @code service.namespace,service.name,service.instance.id @endcode triplet MUST be globally + * unique). The ID helps to distinguish instances of the same service that exist at the same time + * (e.g. instances of a horizontally scaled service).

        Implementations, such as SDKs, are + * recommended to generate a random Version 1 or Version 4 RFC 4122 UUID, but are free to use an inherent + * unique ID as the source of this value if stability is desirable. In that case, the ID SHOULD be + * used as source of a UUID Version 5 and SHOULD use the following UUID as the namespace: @code + * 4d63009a-8d0f-11ee-aad7-4c796ed8e320 @endcode.

        UUIDs are typically recommended, as only an + * opaque value for the purposes of identifying a service instance is needed. Similar to what can be + * seen in the man page for the @code /etc/machine-id + * @endcode file, the underlying data, such as pod name and namespace should be treated as + * confidential, being the user's choice to expose it or not via another resource attribute.

        For + * applications running behind an application server (like unicorn), we do not recommend using one + * identifier for all processes participating in the application. Instead, it's recommended each + * division (e.g. a worker thread in unicorn) to have its own instance.id.

        It's not recommended + * for a Collector to set @code service.instance.id @endcode if it can't unambiguously determine the + * service instance that is generating that telemetry. For instance, creating an UUID based on @code + * pod.name @endcode will likely be wrong, as the Collector might not know from which container + * within that pod the telemetry originated. However, Collectors can set the @code + * service.instance.id @endcode if they can unambiguously determine the service instance for that + * telemetry. This is typically the case for scraping receivers, as they know the target address and + * port. + */ +static constexpr const char *kServiceInstanceId = "service.instance.id"; + +/** + * Logical name of the service. + *

        + * MUST be the same for all instances of horizontally scaled services. If the value was not + * specified, SDKs MUST fallback to @code unknown_service: @endcode concatenated with @code process.executable.name @endcode, e.g. @code unknown_service:bash + * @endcode. If @code process.executable.name @endcode is not available, the value MUST be set to + * @code unknown_service @endcode. + */ +static constexpr const char *kServiceName = "service.name"; + +/** + * A namespace for @code service.name @endcode. + *

        + * A string value having a meaning that helps to distinguish a group of services, for example the + * team name that owns a group of services. @code service.name @endcode is expected to be unique + * within the same namespace. If @code service.namespace @endcode is not specified in the Resource + * then @code service.name @endcode is expected to be unique for all services that have no explicit + * namespace defined (so the empty/unspecified namespace is simply one more valid namespace). + * Zero-length namespace string is assumed equal to unspecified namespace. + */ +static constexpr const char *kServiceNamespace = "service.namespace"; + +/** + * The version string of the service API or implementation. The format is not defined by these + * conventions. + */ +static constexpr const char *kServiceVersion = "service.version"; + +} // namespace service +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/session_attributes.h b/api/include/opentelemetry/semconv/incubating/session_attributes.h new file mode 100644 index 0000000000..abbe9446d6 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/session_attributes.h @@ -0,0 +1,34 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace session +{ + +/** + * A unique id to identify a session. + */ +static constexpr const char *kSessionId = "session.id"; + +/** + * The previous @code session.id @endcode for this user, when known. + */ +static constexpr const char *kSessionPreviousId = "session.previous_id"; + +} // namespace session +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/source_attributes.h b/api/include/opentelemetry/semconv/incubating/source_attributes.h new file mode 100644 index 0000000000..06a6ddc2f6 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/source_attributes.h @@ -0,0 +1,37 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace source +{ + +/** + * Source address - domain name if available without reverse DNS lookup; otherwise, IP address or + * Unix domain socket name.

        When observed from the destination side, and when communicating + * through an intermediary, @code source.address @endcode SHOULD represent the source address behind + * any intermediaries, for example proxies, if it's available. + */ +static constexpr const char *kSourceAddress = "source.address"; + +/** + * Source port number + */ +static constexpr const char *kSourcePort = "source.port"; + +} // namespace source +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/system_attributes.h b/api/include/opentelemetry/semconv/incubating/system_attributes.h new file mode 100644 index 0000000000..be7ec80186 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/system_attributes.h @@ -0,0 +1,383 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace system +{ + +/** + * The logical CPU number [0..n-1] + */ +static constexpr const char *kSystemCpuLogicalNumber = "system.cpu.logical_number"; + +/** + * Deprecated, use @code cpu.mode @endcode instead. + *

        + * @deprecated + * Replaced by @code cpu.mode @endcode + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kSystemCpuState = "system.cpu.state"; + +/** + * The device identifier + */ +static constexpr const char *kSystemDevice = "system.device"; + +/** + * The filesystem mode + */ +static constexpr const char *kSystemFilesystemMode = "system.filesystem.mode"; + +/** + * The filesystem mount path + */ +static constexpr const char *kSystemFilesystemMountpoint = "system.filesystem.mountpoint"; + +/** + * The filesystem state + */ +static constexpr const char *kSystemFilesystemState = "system.filesystem.state"; + +/** + * The filesystem type + */ +static constexpr const char *kSystemFilesystemType = "system.filesystem.type"; + +/** + * The memory state + */ +static constexpr const char *kSystemMemoryState = "system.memory.state"; + +/** + * A stateless protocol MUST NOT set this attribute + */ +static constexpr const char *kSystemNetworkState = "system.network.state"; + +/** + * The paging access direction + */ +static constexpr const char *kSystemPagingDirection = "system.paging.direction"; + +/** + * The memory paging state + */ +static constexpr const char *kSystemPagingState = "system.paging.state"; + +/** + * The memory paging type + */ +static constexpr const char *kSystemPagingType = "system.paging.type"; + +/** + * The process state, e.g., Linux Process State + * Codes + */ +static constexpr const char *kSystemProcessStatus = "system.process.status"; + +/** + * Deprecated, use @code system.process.status @endcode instead. + *

        + * @deprecated + * Replaced by @code system.process.status @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kSystemProcessesStatus = "system.processes.status"; + +namespace SystemCpuStateValues +{ +/** + * none + */ +static constexpr const char *kUser = "user"; + +/** + * none + */ +static constexpr const char *kSystem = "system"; + +/** + * none + */ +static constexpr const char *kNice = "nice"; + +/** + * none + */ +static constexpr const char *kIdle = "idle"; + +/** + * none + */ +static constexpr const char *kIowait = "iowait"; + +/** + * none + */ +static constexpr const char *kInterrupt = "interrupt"; + +/** + * none + */ +static constexpr const char *kSteal = "steal"; + +} // namespace SystemCpuStateValues + +namespace SystemFilesystemStateValues +{ +/** + * none + */ +static constexpr const char *kUsed = "used"; + +/** + * none + */ +static constexpr const char *kFree = "free"; + +/** + * none + */ +static constexpr const char *kReserved = "reserved"; + +} // namespace SystemFilesystemStateValues + +namespace SystemFilesystemTypeValues +{ +/** + * none + */ +static constexpr const char *kFat32 = "fat32"; + +/** + * none + */ +static constexpr const char *kExfat = "exfat"; + +/** + * none + */ +static constexpr const char *kNtfs = "ntfs"; + +/** + * none + */ +static constexpr const char *kRefs = "refs"; + +/** + * none + */ +static constexpr const char *kHfsplus = "hfsplus"; + +/** + * none + */ +static constexpr const char *kExt4 = "ext4"; + +} // namespace SystemFilesystemTypeValues + +namespace SystemMemoryStateValues +{ +/** + * none + */ +static constexpr const char *kUsed = "used"; + +/** + * none + */ +static constexpr const char *kFree = "free"; + +/** + * none + *

        + * @deprecated + * Removed, report shared memory usage with @code metric.system.memory.shared @endcode metric + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kShared = "shared"; + +/** + * none + */ +static constexpr const char *kBuffers = "buffers"; + +/** + * none + */ +static constexpr const char *kCached = "cached"; + +} // namespace SystemMemoryStateValues + +namespace SystemNetworkStateValues +{ +/** + * none + */ +static constexpr const char *kClose = "close"; + +/** + * none + */ +static constexpr const char *kCloseWait = "close_wait"; + +/** + * none + */ +static constexpr const char *kClosing = "closing"; + +/** + * none + */ +static constexpr const char *kDelete = "delete"; + +/** + * none + */ +static constexpr const char *kEstablished = "established"; + +/** + * none + */ +static constexpr const char *kFinWait1 = "fin_wait_1"; + +/** + * none + */ +static constexpr const char *kFinWait2 = "fin_wait_2"; + +/** + * none + */ +static constexpr const char *kLastAck = "last_ack"; + +/** + * none + */ +static constexpr const char *kListen = "listen"; + +/** + * none + */ +static constexpr const char *kSynRecv = "syn_recv"; + +/** + * none + */ +static constexpr const char *kSynSent = "syn_sent"; + +/** + * none + */ +static constexpr const char *kTimeWait = "time_wait"; + +} // namespace SystemNetworkStateValues + +namespace SystemPagingDirectionValues +{ +/** + * none + */ +static constexpr const char *kIn = "in"; + +/** + * none + */ +static constexpr const char *kOut = "out"; + +} // namespace SystemPagingDirectionValues + +namespace SystemPagingStateValues +{ +/** + * none + */ +static constexpr const char *kUsed = "used"; + +/** + * none + */ +static constexpr const char *kFree = "free"; + +} // namespace SystemPagingStateValues + +namespace SystemPagingTypeValues +{ +/** + * none + */ +static constexpr const char *kMajor = "major"; + +/** + * none + */ +static constexpr const char *kMinor = "minor"; + +} // namespace SystemPagingTypeValues + +namespace SystemProcessStatusValues +{ +/** + * none + */ +static constexpr const char *kRunning = "running"; + +/** + * none + */ +static constexpr const char *kSleeping = "sleeping"; + +/** + * none + */ +static constexpr const char *kStopped = "stopped"; + +/** + * none + */ +static constexpr const char *kDefunct = "defunct"; + +} // namespace SystemProcessStatusValues + +namespace SystemProcessesStatusValues +{ +/** + * none + */ +static constexpr const char *kRunning = "running"; + +/** + * none + */ +static constexpr const char *kSleeping = "sleeping"; + +/** + * none + */ +static constexpr const char *kStopped = "stopped"; + +/** + * none + */ +static constexpr const char *kDefunct = "defunct"; + +} // namespace SystemProcessesStatusValues + +} // namespace system +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/system_metrics.h b/api/include/opentelemetry/semconv/incubating/system_metrics.h new file mode 100644 index 0000000000..b896015372 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/system_metrics.h @@ -0,0 +1,1200 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace system +{ + +/** + * Reports the current frequency of the CPU in Hz + *

        + * gauge + */ +static constexpr const char *kMetricSystemCpuFrequency = "metric.system.cpu.frequency"; +static constexpr const char *descrMetricSystemCpuFrequency = + "Reports the current frequency of the CPU in Hz"; +static constexpr const char *unitMetricSystemCpuFrequency = "{Hz}"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricSystemCpuFrequency( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricSystemCpuFrequency, descrMetricSystemCpuFrequency, + unitMetricSystemCpuFrequency); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricSystemCpuFrequency( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricSystemCpuFrequency, descrMetricSystemCpuFrequency, + unitMetricSystemCpuFrequency); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemCpuFrequency(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricSystemCpuFrequency, descrMetricSystemCpuFrequency, + unitMetricSystemCpuFrequency); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemCpuFrequency(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge( + kMetricSystemCpuFrequency, descrMetricSystemCpuFrequency, unitMetricSystemCpuFrequency); +} + +/** + * Reports the number of logical (virtual) processor cores created by the operating system to manage + * multitasking

        updowncounter + */ +static constexpr const char *kMetricSystemCpuLogicalCount = "metric.system.cpu.logical.count"; +static constexpr const char *descrMetricSystemCpuLogicalCount = + "Reports the number of logical (virtual) processor cores created by the operating system to " + "manage multitasking"; +static constexpr const char *unitMetricSystemCpuLogicalCount = "{cpu}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemCpuLogicalCount(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricSystemCpuLogicalCount, + descrMetricSystemCpuLogicalCount, + unitMetricSystemCpuLogicalCount); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemCpuLogicalCount(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricSystemCpuLogicalCount, + descrMetricSystemCpuLogicalCount, + unitMetricSystemCpuLogicalCount); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemCpuLogicalCount(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricSystemCpuLogicalCount, + descrMetricSystemCpuLogicalCount, + unitMetricSystemCpuLogicalCount); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemCpuLogicalCount(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricSystemCpuLogicalCount, + descrMetricSystemCpuLogicalCount, + unitMetricSystemCpuLogicalCount); +} + +/** + * Reports the number of actual physical processor cores on the hardware + *

        + * updowncounter + */ +static constexpr const char *kMetricSystemCpuPhysicalCount = "metric.system.cpu.physical.count"; +static constexpr const char *descrMetricSystemCpuPhysicalCount = + "Reports the number of actual physical processor cores on the hardware"; +static constexpr const char *unitMetricSystemCpuPhysicalCount = "{cpu}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemCpuPhysicalCount(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricSystemCpuPhysicalCount, + descrMetricSystemCpuPhysicalCount, + unitMetricSystemCpuPhysicalCount); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemCpuPhysicalCount(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricSystemCpuPhysicalCount, + descrMetricSystemCpuPhysicalCount, + unitMetricSystemCpuPhysicalCount); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemCpuPhysicalCount(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricSystemCpuPhysicalCount, + descrMetricSystemCpuPhysicalCount, + unitMetricSystemCpuPhysicalCount); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemCpuPhysicalCount(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricSystemCpuPhysicalCount, + descrMetricSystemCpuPhysicalCount, + unitMetricSystemCpuPhysicalCount); +} + +/** + * Seconds each logical CPU spent on each mode + *

        + * counter + */ +static constexpr const char *kMetricSystemCpuTime = "metric.system.cpu.time"; +static constexpr const char *descrMetricSystemCpuTime = + "Seconds each logical CPU spent on each mode"; +static constexpr const char *unitMetricSystemCpuTime = "s"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricSystemCpuTime( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricSystemCpuTime, descrMetricSystemCpuTime, + unitMetricSystemCpuTime); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricSystemCpuTime( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricSystemCpuTime, descrMetricSystemCpuTime, + unitMetricSystemCpuTime); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricSystemCpuTime( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricSystemCpuTime, descrMetricSystemCpuTime, + unitMetricSystemCpuTime); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricSystemCpuTime( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricSystemCpuTime, descrMetricSystemCpuTime, + unitMetricSystemCpuTime); +} + +/** + * Difference in system.cpu.time since the last measurement, divided by the elapsed time and number + * of logical CPUs

        gauge + */ +static constexpr const char *kMetricSystemCpuUtilization = "metric.system.cpu.utilization"; +static constexpr const char *descrMetricSystemCpuUtilization = + "Difference in system.cpu.time since the last measurement, divided by the elapsed time and " + "number of logical CPUs"; +static constexpr const char *unitMetricSystemCpuUtilization = "1"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricSystemCpuUtilization( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricSystemCpuUtilization, descrMetricSystemCpuUtilization, + unitMetricSystemCpuUtilization); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricSystemCpuUtilization( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricSystemCpuUtilization, descrMetricSystemCpuUtilization, + unitMetricSystemCpuUtilization); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemCpuUtilization(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge( + kMetricSystemCpuUtilization, descrMetricSystemCpuUtilization, unitMetricSystemCpuUtilization); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemCpuUtilization(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge( + kMetricSystemCpuUtilization, descrMetricSystemCpuUtilization, unitMetricSystemCpuUtilization); +} + +/** + * counter + */ +static constexpr const char *kMetricSystemDiskIo = "metric.system.disk.io"; +static constexpr const char *descrMetricSystemDiskIo = ""; +static constexpr const char *unitMetricSystemDiskIo = "By"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricSystemDiskIo( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricSystemDiskIo, descrMetricSystemDiskIo, + unitMetricSystemDiskIo); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricSystemDiskIo( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricSystemDiskIo, descrMetricSystemDiskIo, + unitMetricSystemDiskIo); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricSystemDiskIo( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricSystemDiskIo, descrMetricSystemDiskIo, + unitMetricSystemDiskIo); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricSystemDiskIo( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricSystemDiskIo, descrMetricSystemDiskIo, + unitMetricSystemDiskIo); +} + +/** + * Time disk spent activated + *

        + * The real elapsed time ("wall clock") used in the I/O path (time from operations running in + * parallel are not counted). Measured as:

        + * counter + */ +static constexpr const char *kMetricSystemDiskIoTime = "metric.system.disk.io_time"; +static constexpr const char *descrMetricSystemDiskIoTime = "Time disk spent activated"; +static constexpr const char *unitMetricSystemDiskIoTime = "s"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricSystemDiskIoTime( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricSystemDiskIoTime, descrMetricSystemDiskIoTime, + unitMetricSystemDiskIoTime); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricSystemDiskIoTime( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricSystemDiskIoTime, descrMetricSystemDiskIoTime, + unitMetricSystemDiskIoTime); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemDiskIoTime(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricSystemDiskIoTime, descrMetricSystemDiskIoTime, + unitMetricSystemDiskIoTime); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemDiskIoTime(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricSystemDiskIoTime, descrMetricSystemDiskIoTime, + unitMetricSystemDiskIoTime); +} + +/** + * counter + */ +static constexpr const char *kMetricSystemDiskMerged = "metric.system.disk.merged"; +static constexpr const char *descrMetricSystemDiskMerged = ""; +static constexpr const char *unitMetricSystemDiskMerged = "{operation}"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricSystemDiskMerged( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricSystemDiskMerged, descrMetricSystemDiskMerged, + unitMetricSystemDiskMerged); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricSystemDiskMerged( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricSystemDiskMerged, descrMetricSystemDiskMerged, + unitMetricSystemDiskMerged); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemDiskMerged(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricSystemDiskMerged, descrMetricSystemDiskMerged, + unitMetricSystemDiskMerged); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemDiskMerged(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricSystemDiskMerged, descrMetricSystemDiskMerged, + unitMetricSystemDiskMerged); +} + +/** + * Sum of the time each operation took to complete + *

        + * Because it is the sum of time each request took, parallel-issued requests each contribute to make + * the count grow. Measured as:

        • Linux: Fields 7 & 11 from procfs-diskstats
        • + *
        • Windows: "Avg. Disk sec/Read" perf counter multiplied by "Disk Reads/sec" perf counter + * (similar for Writes)
        • + *
        + * counter + */ +static constexpr const char *kMetricSystemDiskOperationTime = "metric.system.disk.operation_time"; +static constexpr const char *descrMetricSystemDiskOperationTime = + "Sum of the time each operation took to complete"; +static constexpr const char *unitMetricSystemDiskOperationTime = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemDiskOperationTime(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricSystemDiskOperationTime, + descrMetricSystemDiskOperationTime, + unitMetricSystemDiskOperationTime); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemDiskOperationTime(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricSystemDiskOperationTime, + descrMetricSystemDiskOperationTime, + unitMetricSystemDiskOperationTime); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemDiskOperationTime(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricSystemDiskOperationTime, + descrMetricSystemDiskOperationTime, + unitMetricSystemDiskOperationTime); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemDiskOperationTime(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricSystemDiskOperationTime, + descrMetricSystemDiskOperationTime, + unitMetricSystemDiskOperationTime); +} + +/** + * counter + */ +static constexpr const char *kMetricSystemDiskOperations = "metric.system.disk.operations"; +static constexpr const char *descrMetricSystemDiskOperations = ""; +static constexpr const char *unitMetricSystemDiskOperations = "{operation}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemDiskOperations(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricSystemDiskOperations, descrMetricSystemDiskOperations, + unitMetricSystemDiskOperations); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemDiskOperations(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricSystemDiskOperations, descrMetricSystemDiskOperations, + unitMetricSystemDiskOperations); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemDiskOperations(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter( + kMetricSystemDiskOperations, descrMetricSystemDiskOperations, unitMetricSystemDiskOperations); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemDiskOperations(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter( + kMetricSystemDiskOperations, descrMetricSystemDiskOperations, unitMetricSystemDiskOperations); +} + +/** + * updowncounter + */ +static constexpr const char *kMetricSystemFilesystemUsage = "metric.system.filesystem.usage"; +static constexpr const char *descrMetricSystemFilesystemUsage = ""; +static constexpr const char *unitMetricSystemFilesystemUsage = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemFilesystemUsage(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricSystemFilesystemUsage, + descrMetricSystemFilesystemUsage, + unitMetricSystemFilesystemUsage); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemFilesystemUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricSystemFilesystemUsage, + descrMetricSystemFilesystemUsage, + unitMetricSystemFilesystemUsage); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemFilesystemUsage(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricSystemFilesystemUsage, + descrMetricSystemFilesystemUsage, + unitMetricSystemFilesystemUsage); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemFilesystemUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricSystemFilesystemUsage, + descrMetricSystemFilesystemUsage, + unitMetricSystemFilesystemUsage); +} + +/** + * gauge + */ +static constexpr const char *kMetricSystemFilesystemUtilization = + "metric.system.filesystem.utilization"; +static constexpr const char *descrMetricSystemFilesystemUtilization = ""; +static constexpr const char *unitMetricSystemFilesystemUtilization = "1"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemFilesystemUtilization(metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricSystemFilesystemUtilization, + descrMetricSystemFilesystemUtilization, + unitMetricSystemFilesystemUtilization); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemFilesystemUtilization(metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricSystemFilesystemUtilization, + descrMetricSystemFilesystemUtilization, + unitMetricSystemFilesystemUtilization); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemFilesystemUtilization(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricSystemFilesystemUtilization, + descrMetricSystemFilesystemUtilization, + unitMetricSystemFilesystemUtilization); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemFilesystemUtilization(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricSystemFilesystemUtilization, + descrMetricSystemFilesystemUtilization, + unitMetricSystemFilesystemUtilization); +} + +/** + * An estimate of how much memory is available for starting new applications, without causing + * swapping

        This is an alternative to @code system.memory.usage @endcode metric with @code + * state=free @endcode. Linux starting from 3.14 exports "available" memory. It takes "free" memory + * as a baseline, and then factors in kernel-specific values. This is supposed to be more accurate + * than just "free" memory. For reference, see the calculations here. See also @code MemAvailable @endcode in /proc/meminfo.

        updowncounter + */ +static constexpr const char *kMetricSystemLinuxMemoryAvailable = + "metric.system.linux.memory.available"; +static constexpr const char *descrMetricSystemLinuxMemoryAvailable = + "An estimate of how much memory is available for starting new applications, without causing " + "swapping"; +static constexpr const char *unitMetricSystemLinuxMemoryAvailable = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemLinuxMemoryAvailable(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricSystemLinuxMemoryAvailable, + descrMetricSystemLinuxMemoryAvailable, + unitMetricSystemLinuxMemoryAvailable); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemLinuxMemoryAvailable(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricSystemLinuxMemoryAvailable, + descrMetricSystemLinuxMemoryAvailable, + unitMetricSystemLinuxMemoryAvailable); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemLinuxMemoryAvailable(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricSystemLinuxMemoryAvailable, + descrMetricSystemLinuxMemoryAvailable, + unitMetricSystemLinuxMemoryAvailable); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemLinuxMemoryAvailable(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricSystemLinuxMemoryAvailable, + descrMetricSystemLinuxMemoryAvailable, + unitMetricSystemLinuxMemoryAvailable); +} + +/** + * Reports the memory used by the Linux kernel for managing caches of frequently used objects. + *

        + * The sum over the @code reclaimable @endcode and @code unreclaimable @endcode state values in + * @code linux.memory.slab.usage @endcode SHOULD be equal to the total slab memory available on the + * system. Note that the total slab memory is not constant and may vary over time. See also the Slab + * allocator and @code Slab @endcode in /proc/meminfo.

        updowncounter + */ +static constexpr const char *kMetricSystemLinuxMemorySlabUsage = + "metric.system.linux.memory.slab.usage"; +static constexpr const char *descrMetricSystemLinuxMemorySlabUsage = + "Reports the memory used by the Linux kernel for managing caches of frequently used objects."; +static constexpr const char *unitMetricSystemLinuxMemorySlabUsage = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemLinuxMemorySlabUsage(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricSystemLinuxMemorySlabUsage, + descrMetricSystemLinuxMemorySlabUsage, + unitMetricSystemLinuxMemorySlabUsage); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemLinuxMemorySlabUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricSystemLinuxMemorySlabUsage, + descrMetricSystemLinuxMemorySlabUsage, + unitMetricSystemLinuxMemorySlabUsage); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemLinuxMemorySlabUsage(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricSystemLinuxMemorySlabUsage, + descrMetricSystemLinuxMemorySlabUsage, + unitMetricSystemLinuxMemorySlabUsage); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemLinuxMemorySlabUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricSystemLinuxMemorySlabUsage, + descrMetricSystemLinuxMemorySlabUsage, + unitMetricSystemLinuxMemorySlabUsage); +} + +/** + * Total memory available in the system. + *

        + * Its value SHOULD equal the sum of @code system.memory.state @endcode over all states. + *

        + * updowncounter + */ +static constexpr const char *kMetricSystemMemoryLimit = "metric.system.memory.limit"; +static constexpr const char *descrMetricSystemMemoryLimit = "Total memory available in the system."; +static constexpr const char *unitMetricSystemMemoryLimit = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemMemoryLimit(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricSystemMemoryLimit, descrMetricSystemMemoryLimit, + unitMetricSystemMemoryLimit); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemMemoryLimit(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricSystemMemoryLimit, descrMetricSystemMemoryLimit, + unitMetricSystemMemoryLimit); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemMemoryLimit(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter( + kMetricSystemMemoryLimit, descrMetricSystemMemoryLimit, unitMetricSystemMemoryLimit); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemMemoryLimit(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter( + kMetricSystemMemoryLimit, descrMetricSystemMemoryLimit, unitMetricSystemMemoryLimit); +} + +/** + * Shared memory used (mostly by tmpfs). + *

        + * Equivalent of @code shared @endcode from @code free @endcode command or + * @code Shmem @endcode from @code + * /proc/meminfo @endcode"

        updowncounter + */ +static constexpr const char *kMetricSystemMemoryShared = "metric.system.memory.shared"; +static constexpr const char *descrMetricSystemMemoryShared = + "Shared memory used (mostly by tmpfs)."; +static constexpr const char *unitMetricSystemMemoryShared = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemMemoryShared(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricSystemMemoryShared, descrMetricSystemMemoryShared, + unitMetricSystemMemoryShared); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemMemoryShared(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricSystemMemoryShared, descrMetricSystemMemoryShared, + unitMetricSystemMemoryShared); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemMemoryShared(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter( + kMetricSystemMemoryShared, descrMetricSystemMemoryShared, unitMetricSystemMemoryShared); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemMemoryShared(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter( + kMetricSystemMemoryShared, descrMetricSystemMemoryShared, unitMetricSystemMemoryShared); +} + +/** + * Reports memory in use by state. + *

        + * The sum over all @code system.memory.state @endcode values SHOULD equal the total memory + * available on the system, that is @code system.memory.limit @endcode. + *

        + * updowncounter + */ +static constexpr const char *kMetricSystemMemoryUsage = "metric.system.memory.usage"; +static constexpr const char *descrMetricSystemMemoryUsage = "Reports memory in use by state."; +static constexpr const char *unitMetricSystemMemoryUsage = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricSystemMemoryUsage, descrMetricSystemMemoryUsage, + unitMetricSystemMemoryUsage); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricSystemMemoryUsage, descrMetricSystemMemoryUsage, + unitMetricSystemMemoryUsage); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter( + kMetricSystemMemoryUsage, descrMetricSystemMemoryUsage, unitMetricSystemMemoryUsage); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter( + kMetricSystemMemoryUsage, descrMetricSystemMemoryUsage, unitMetricSystemMemoryUsage); +} + +/** + * gauge + */ +static constexpr const char *kMetricSystemMemoryUtilization = "metric.system.memory.utilization"; +static constexpr const char *descrMetricSystemMemoryUtilization = ""; +static constexpr const char *unitMetricSystemMemoryUtilization = "1"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemMemoryUtilization(metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricSystemMemoryUtilization, descrMetricSystemMemoryUtilization, + unitMetricSystemMemoryUtilization); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemMemoryUtilization(metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricSystemMemoryUtilization, + descrMetricSystemMemoryUtilization, + unitMetricSystemMemoryUtilization); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemMemoryUtilization(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricSystemMemoryUtilization, + descrMetricSystemMemoryUtilization, + unitMetricSystemMemoryUtilization); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemMemoryUtilization(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricSystemMemoryUtilization, + descrMetricSystemMemoryUtilization, + unitMetricSystemMemoryUtilization); +} + +/** + * updowncounter + */ +static constexpr const char *kMetricSystemNetworkConnections = "metric.system.network.connections"; +static constexpr const char *descrMetricSystemNetworkConnections = ""; +static constexpr const char *unitMetricSystemNetworkConnections = "{connection}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemNetworkConnections(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricSystemNetworkConnections, + descrMetricSystemNetworkConnections, + unitMetricSystemNetworkConnections); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemNetworkConnections(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricSystemNetworkConnections, + descrMetricSystemNetworkConnections, + unitMetricSystemNetworkConnections); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemNetworkConnections(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricSystemNetworkConnections, + descrMetricSystemNetworkConnections, + unitMetricSystemNetworkConnections); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemNetworkConnections(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricSystemNetworkConnections, + descrMetricSystemNetworkConnections, + unitMetricSystemNetworkConnections); +} + +/** + * Count of packets that are dropped or discarded even though there was no error + *

        + * Measured as: + *

        + *

        + * counter + */ +static constexpr const char *kMetricSystemNetworkDropped = "metric.system.network.dropped"; +static constexpr const char *descrMetricSystemNetworkDropped = + "Count of packets that are dropped or discarded even though there was no error"; +static constexpr const char *unitMetricSystemNetworkDropped = "{packet}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemNetworkDropped(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricSystemNetworkDropped, descrMetricSystemNetworkDropped, + unitMetricSystemNetworkDropped); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemNetworkDropped(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricSystemNetworkDropped, descrMetricSystemNetworkDropped, + unitMetricSystemNetworkDropped); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemNetworkDropped(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter( + kMetricSystemNetworkDropped, descrMetricSystemNetworkDropped, unitMetricSystemNetworkDropped); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemNetworkDropped(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter( + kMetricSystemNetworkDropped, descrMetricSystemNetworkDropped, unitMetricSystemNetworkDropped); +} + +/** + * Count of network errors detected + *

        + * Measured as: + *

        + *

        + * counter + */ +static constexpr const char *kMetricSystemNetworkErrors = "metric.system.network.errors"; +static constexpr const char *descrMetricSystemNetworkErrors = "Count of network errors detected"; +static constexpr const char *unitMetricSystemNetworkErrors = "{error}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemNetworkErrors(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricSystemNetworkErrors, descrMetricSystemNetworkErrors, + unitMetricSystemNetworkErrors); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricSystemNetworkErrors( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricSystemNetworkErrors, descrMetricSystemNetworkErrors, + unitMetricSystemNetworkErrors); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemNetworkErrors(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter( + kMetricSystemNetworkErrors, descrMetricSystemNetworkErrors, unitMetricSystemNetworkErrors); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemNetworkErrors(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter( + kMetricSystemNetworkErrors, descrMetricSystemNetworkErrors, unitMetricSystemNetworkErrors); +} + +/** + * counter + */ +static constexpr const char *kMetricSystemNetworkIo = "metric.system.network.io"; +static constexpr const char *descrMetricSystemNetworkIo = ""; +static constexpr const char *unitMetricSystemNetworkIo = "By"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricSystemNetworkIo( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricSystemNetworkIo, descrMetricSystemNetworkIo, + unitMetricSystemNetworkIo); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricSystemNetworkIo( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricSystemNetworkIo, descrMetricSystemNetworkIo, + unitMetricSystemNetworkIo); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemNetworkIo(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricSystemNetworkIo, descrMetricSystemNetworkIo, + unitMetricSystemNetworkIo); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemNetworkIo(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricSystemNetworkIo, descrMetricSystemNetworkIo, + unitMetricSystemNetworkIo); +} + +/** + * counter + */ +static constexpr const char *kMetricSystemNetworkPackets = "metric.system.network.packets"; +static constexpr const char *descrMetricSystemNetworkPackets = ""; +static constexpr const char *unitMetricSystemNetworkPackets = "{packet}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemNetworkPackets(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricSystemNetworkPackets, descrMetricSystemNetworkPackets, + unitMetricSystemNetworkPackets); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemNetworkPackets(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricSystemNetworkPackets, descrMetricSystemNetworkPackets, + unitMetricSystemNetworkPackets); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemNetworkPackets(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter( + kMetricSystemNetworkPackets, descrMetricSystemNetworkPackets, unitMetricSystemNetworkPackets); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemNetworkPackets(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter( + kMetricSystemNetworkPackets, descrMetricSystemNetworkPackets, unitMetricSystemNetworkPackets); +} + +/** + * counter + */ +static constexpr const char *kMetricSystemPagingFaults = "metric.system.paging.faults"; +static constexpr const char *descrMetricSystemPagingFaults = ""; +static constexpr const char *unitMetricSystemPagingFaults = "{fault}"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricSystemPagingFaults( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricSystemPagingFaults, descrMetricSystemPagingFaults, + unitMetricSystemPagingFaults); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricSystemPagingFaults( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricSystemPagingFaults, descrMetricSystemPagingFaults, + unitMetricSystemPagingFaults); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemPagingFaults(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter( + kMetricSystemPagingFaults, descrMetricSystemPagingFaults, unitMetricSystemPagingFaults); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemPagingFaults(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter( + kMetricSystemPagingFaults, descrMetricSystemPagingFaults, unitMetricSystemPagingFaults); +} + +/** + * counter + */ +static constexpr const char *kMetricSystemPagingOperations = "metric.system.paging.operations"; +static constexpr const char *descrMetricSystemPagingOperations = ""; +static constexpr const char *unitMetricSystemPagingOperations = "{operation}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemPagingOperations(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricSystemPagingOperations, + descrMetricSystemPagingOperations, + unitMetricSystemPagingOperations); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemPagingOperations(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricSystemPagingOperations, + descrMetricSystemPagingOperations, + unitMetricSystemPagingOperations); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemPagingOperations(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricSystemPagingOperations, + descrMetricSystemPagingOperations, + unitMetricSystemPagingOperations); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemPagingOperations(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricSystemPagingOperations, + descrMetricSystemPagingOperations, + unitMetricSystemPagingOperations); +} + +/** + * Unix swap or windows pagefile usage + *

        + * updowncounter + */ +static constexpr const char *kMetricSystemPagingUsage = "metric.system.paging.usage"; +static constexpr const char *descrMetricSystemPagingUsage = "Unix swap or windows pagefile usage"; +static constexpr const char *unitMetricSystemPagingUsage = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemPagingUsage(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricSystemPagingUsage, descrMetricSystemPagingUsage, + unitMetricSystemPagingUsage); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemPagingUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricSystemPagingUsage, descrMetricSystemPagingUsage, + unitMetricSystemPagingUsage); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemPagingUsage(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter( + kMetricSystemPagingUsage, descrMetricSystemPagingUsage, unitMetricSystemPagingUsage); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemPagingUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter( + kMetricSystemPagingUsage, descrMetricSystemPagingUsage, unitMetricSystemPagingUsage); +} + +/** + * gauge + */ +static constexpr const char *kMetricSystemPagingUtilization = "metric.system.paging.utilization"; +static constexpr const char *descrMetricSystemPagingUtilization = ""; +static constexpr const char *unitMetricSystemPagingUtilization = "1"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemPagingUtilization(metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricSystemPagingUtilization, descrMetricSystemPagingUtilization, + unitMetricSystemPagingUtilization); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemPagingUtilization(metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricSystemPagingUtilization, + descrMetricSystemPagingUtilization, + unitMetricSystemPagingUtilization); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemPagingUtilization(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricSystemPagingUtilization, + descrMetricSystemPagingUtilization, + unitMetricSystemPagingUtilization); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemPagingUtilization(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricSystemPagingUtilization, + descrMetricSystemPagingUtilization, + unitMetricSystemPagingUtilization); +} + +/** + * Total number of processes in each state + *

        + * updowncounter + */ +static constexpr const char *kMetricSystemProcessCount = "metric.system.process.count"; +static constexpr const char *descrMetricSystemProcessCount = + "Total number of processes in each state"; +static constexpr const char *unitMetricSystemProcessCount = "{process}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemProcessCount(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricSystemProcessCount, descrMetricSystemProcessCount, + unitMetricSystemProcessCount); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemProcessCount(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricSystemProcessCount, descrMetricSystemProcessCount, + unitMetricSystemProcessCount); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemProcessCount(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter( + kMetricSystemProcessCount, descrMetricSystemProcessCount, unitMetricSystemProcessCount); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemProcessCount(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter( + kMetricSystemProcessCount, descrMetricSystemProcessCount, unitMetricSystemProcessCount); +} + +/** + * Total number of processes created over uptime of the host + *

        + * counter + */ +static constexpr const char *kMetricSystemProcessCreated = "metric.system.process.created"; +static constexpr const char *descrMetricSystemProcessCreated = + "Total number of processes created over uptime of the host"; +static constexpr const char *unitMetricSystemProcessCreated = "{process}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemProcessCreated(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricSystemProcessCreated, descrMetricSystemProcessCreated, + unitMetricSystemProcessCreated); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemProcessCreated(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricSystemProcessCreated, descrMetricSystemProcessCreated, + unitMetricSystemProcessCreated); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemProcessCreated(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter( + kMetricSystemProcessCreated, descrMetricSystemProcessCreated, unitMetricSystemProcessCreated); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemProcessCreated(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter( + kMetricSystemProcessCreated, descrMetricSystemProcessCreated, unitMetricSystemProcessCreated); +} + +} // namespace system +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/telemetry_attributes.h b/api/include/opentelemetry/semconv/incubating/telemetry_attributes.h new file mode 100644 index 0000000000..5504febaba --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/telemetry_attributes.h @@ -0,0 +1,125 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace telemetry +{ + +/** + * The name of the auto instrumentation agent or distribution, if used. + *

        + * Official auto instrumentation agents and distributions SHOULD set the @code telemetry.distro.name + * @endcode attribute to a string starting with @code opentelemetry- @endcode, e.g. @code + * opentelemetry-java-instrumentation @endcode. + */ +static constexpr const char *kTelemetryDistroName = "telemetry.distro.name"; + +/** + * The version string of the auto instrumentation agent or distribution, if used. + */ +static constexpr const char *kTelemetryDistroVersion = "telemetry.distro.version"; + +/** + * The language of the telemetry SDK. + */ +static constexpr const char *kTelemetrySdkLanguage = "telemetry.sdk.language"; + +/** + * The name of the telemetry SDK as defined above. + *

        + * The OpenTelemetry SDK MUST set the @code telemetry.sdk.name @endcode attribute to @code + * opentelemetry @endcode. If another SDK, like a fork or a vendor-provided implementation, is used, + * this SDK MUST set the + * @code telemetry.sdk.name @endcode attribute to the fully-qualified class or module name of this + * SDK's main entry point or another suitable identifier depending on the language. The identifier + * @code opentelemetry @endcode is reserved and MUST NOT be used in this case. All custom + * identifiers SHOULD be stable across different versions of an implementation. + */ +static constexpr const char *kTelemetrySdkName = "telemetry.sdk.name"; + +/** + * The version string of the telemetry SDK. + */ +static constexpr const char *kTelemetrySdkVersion = "telemetry.sdk.version"; + +namespace TelemetrySdkLanguageValues +{ +/** + * none + */ +static constexpr const char *kCpp = "cpp"; + +/** + * none + */ +static constexpr const char *kDotnet = "dotnet"; + +/** + * none + */ +static constexpr const char *kErlang = "erlang"; + +/** + * none + */ +static constexpr const char *kGo = "go"; + +/** + * none + */ +static constexpr const char *kJava = "java"; + +/** + * none + */ +static constexpr const char *kNodejs = "nodejs"; + +/** + * none + */ +static constexpr const char *kPhp = "php"; + +/** + * none + */ +static constexpr const char *kPython = "python"; + +/** + * none + */ +static constexpr const char *kRuby = "ruby"; + +/** + * none + */ +static constexpr const char *kRust = "rust"; + +/** + * none + */ +static constexpr const char *kSwift = "swift"; + +/** + * none + */ +static constexpr const char *kWebjs = "webjs"; + +} // namespace TelemetrySdkLanguageValues + +} // namespace telemetry +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/test_attributes.h b/api/include/opentelemetry/semconv/incubating/test_attributes.h new file mode 100644 index 0000000000..dce482055c --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/test_attributes.h @@ -0,0 +1,93 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace test +{ + +/** + * The fully qualified human readable name of the test case. + */ +static constexpr const char *kTestCaseName = "test.case.name"; + +/** + * The status of the actual test case result from test execution. + */ +static constexpr const char *kTestCaseResultStatus = "test.case.result.status"; + +/** + * The human readable name of a test suite. + */ +static constexpr const char *kTestSuiteName = "test.suite.name"; + +/** + * The status of the test suite run. + */ +static constexpr const char *kTestSuiteRunStatus = "test.suite.run.status"; + +namespace TestCaseResultStatusValues +{ +/** + * pass + */ +static constexpr const char *kPass = "pass"; + +/** + * fail + */ +static constexpr const char *kFail = "fail"; + +} // namespace TestCaseResultStatusValues + +namespace TestSuiteRunStatusValues +{ +/** + * success + */ +static constexpr const char *kSuccess = "success"; + +/** + * failure + */ +static constexpr const char *kFailure = "failure"; + +/** + * skipped + */ +static constexpr const char *kSkipped = "skipped"; + +/** + * aborted + */ +static constexpr const char *kAborted = "aborted"; + +/** + * timed_out + */ +static constexpr const char *kTimedOut = "timed_out"; + +/** + * in_progress + */ +static constexpr const char *kInProgress = "in_progress"; + +} // namespace TestSuiteRunStatusValues + +} // namespace test +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/thread_attributes.h b/api/include/opentelemetry/semconv/incubating/thread_attributes.h new file mode 100644 index 0000000000..8c053f8408 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/thread_attributes.h @@ -0,0 +1,34 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace thread +{ + +/** + * Current "managed" thread ID (as opposed to OS thread ID). + */ +static constexpr const char *kThreadId = "thread.id"; + +/** + * Current thread name. + */ +static constexpr const char *kThreadName = "thread.name"; + +} // namespace thread +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/tls_attributes.h b/api/include/opentelemetry/semconv/incubating/tls_attributes.h new file mode 100644 index 0000000000..5e14b6d3f0 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/tls_attributes.h @@ -0,0 +1,221 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace tls +{ + +/** + * String indicating the cipher used during the + * current connection.

        The values allowed for @code tls.cipher @endcode MUST be one of the @code + * Descriptions @endcode of the registered + * TLS Cipher Suits. + */ +static constexpr const char *kTlsCipher = "tls.cipher"; + +/** + * PEM-encoded stand-alone certificate offered by the client. This is usually mutually-exclusive of + * @code client.certificate_chain @endcode since this value also exists in that list. + */ +static constexpr const char *kTlsClientCertificate = "tls.client.certificate"; + +/** + * Array of PEM-encoded certificates that make up the certificate chain offered by the client. This + * is usually mutually-exclusive of @code client.certificate @endcode since that value should be the + * first certificate in the chain. + */ +static constexpr const char *kTlsClientCertificateChain = "tls.client.certificate_chain"; + +/** + * Certificate fingerprint using the MD5 digest of DER-encoded version of certificate offered by the + * client. For consistency with other hash values, this value should be formatted as an uppercase + * hash. + */ +static constexpr const char *kTlsClientHashMd5 = "tls.client.hash.md5"; + +/** + * Certificate fingerprint using the SHA1 digest of DER-encoded version of certificate offered by + * the client. For consistency with other hash values, this value should be formatted as an + * uppercase hash. + */ +static constexpr const char *kTlsClientHashSha1 = "tls.client.hash.sha1"; + +/** + * Certificate fingerprint using the SHA256 digest of DER-encoded version of certificate offered by + * the client. For consistency with other hash values, this value should be formatted as an + * uppercase hash. + */ +static constexpr const char *kTlsClientHashSha256 = "tls.client.hash.sha256"; + +/** + * Distinguished name of subject of the issuer of + * the x.509 certificate presented by the client. + */ +static constexpr const char *kTlsClientIssuer = "tls.client.issuer"; + +/** + * A hash that identifies clients based on how they perform an SSL/TLS handshake. + */ +static constexpr const char *kTlsClientJa3 = "tls.client.ja3"; + +/** + * Date/Time indicating when client certificate is no longer considered valid. + */ +static constexpr const char *kTlsClientNotAfter = "tls.client.not_after"; + +/** + * Date/Time indicating when client certificate is first considered valid. + */ +static constexpr const char *kTlsClientNotBefore = "tls.client.not_before"; + +/** + * Deprecated, use @code server.address @endcode instead. + *

        + * @deprecated + * Replaced by `server.address. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kTlsClientServerName = "tls.client.server_name"; + +/** + * Distinguished name of subject of the x.509 certificate presented by the client. + */ +static constexpr const char *kTlsClientSubject = "tls.client.subject"; + +/** + * Array of ciphers offered by the client during the client hello. + */ +static constexpr const char *kTlsClientSupportedCiphers = "tls.client.supported_ciphers"; + +/** + * String indicating the curve used for the given cipher, when applicable + */ +static constexpr const char *kTlsCurve = "tls.curve"; + +/** + * Boolean flag indicating if the TLS negotiation was successful and transitioned to an encrypted + * tunnel. + */ +static constexpr const char *kTlsEstablished = "tls.established"; + +/** + * String indicating the protocol being tunneled. Per the values in the IANA + * registry, this string should be lower case. + */ +static constexpr const char *kTlsNextProtocol = "tls.next_protocol"; + +/** + * Normalized lowercase protocol name parsed from original string of the negotiated SSL/TLS + * protocol version + */ +static constexpr const char *kTlsProtocolName = "tls.protocol.name"; + +/** + * Numeric part of the version parsed from the original string of the negotiated SSL/TLS + * protocol version + */ +static constexpr const char *kTlsProtocolVersion = "tls.protocol.version"; + +/** + * Boolean flag indicating if this TLS connection was resumed from an existing TLS negotiation. + */ +static constexpr const char *kTlsResumed = "tls.resumed"; + +/** + * PEM-encoded stand-alone certificate offered by the server. This is usually mutually-exclusive of + * @code server.certificate_chain @endcode since this value also exists in that list. + */ +static constexpr const char *kTlsServerCertificate = "tls.server.certificate"; + +/** + * Array of PEM-encoded certificates that make up the certificate chain offered by the server. This + * is usually mutually-exclusive of @code server.certificate @endcode since that value should be the + * first certificate in the chain. + */ +static constexpr const char *kTlsServerCertificateChain = "tls.server.certificate_chain"; + +/** + * Certificate fingerprint using the MD5 digest of DER-encoded version of certificate offered by the + * server. For consistency with other hash values, this value should be formatted as an uppercase + * hash. + */ +static constexpr const char *kTlsServerHashMd5 = "tls.server.hash.md5"; + +/** + * Certificate fingerprint using the SHA1 digest of DER-encoded version of certificate offered by + * the server. For consistency with other hash values, this value should be formatted as an + * uppercase hash. + */ +static constexpr const char *kTlsServerHashSha1 = "tls.server.hash.sha1"; + +/** + * Certificate fingerprint using the SHA256 digest of DER-encoded version of certificate offered by + * the server. For consistency with other hash values, this value should be formatted as an + * uppercase hash. + */ +static constexpr const char *kTlsServerHashSha256 = "tls.server.hash.sha256"; + +/** + * Distinguished name of subject of the issuer of + * the x.509 certificate presented by the client. + */ +static constexpr const char *kTlsServerIssuer = "tls.server.issuer"; + +/** + * A hash that identifies servers based on how they perform an SSL/TLS handshake. + */ +static constexpr const char *kTlsServerJa3s = "tls.server.ja3s"; + +/** + * Date/Time indicating when server certificate is no longer considered valid. + */ +static constexpr const char *kTlsServerNotAfter = "tls.server.not_after"; + +/** + * Date/Time indicating when server certificate is first considered valid. + */ +static constexpr const char *kTlsServerNotBefore = "tls.server.not_before"; + +/** + * Distinguished name of subject of the x.509 certificate presented by the server. + */ +static constexpr const char *kTlsServerSubject = "tls.server.subject"; + +namespace TlsProtocolNameValues +{ +/** + * none + */ +static constexpr const char *kSsl = "ssl"; + +/** + * none + */ +static constexpr const char *kTls = "tls"; + +} // namespace TlsProtocolNameValues + +} // namespace tls +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/url_attributes.h b/api/include/opentelemetry/semconv/incubating/url_attributes.h new file mode 100644 index 0000000000..fb3418e26a --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/url_attributes.h @@ -0,0 +1,137 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace url +{ + +/** + * Domain extracted from the @code url.full @endcode, such as "opentelemetry.io". + *

        + * In some cases a URL may refer to an IP and/or port directly, without a domain name. In this case, + * the IP address would go to the domain field. If the URL contains a literal IPv6 address enclosed by + * @code [ @endcode and @code ] @endcode, the @code [ @endcode and @code ] @endcode characters + * should also be captured in the domain field. + */ +static constexpr const char *kUrlDomain = "url.domain"; + +/** + * The file extension extracted from the @code url.full @endcode, excluding the leading dot. + *

        + * The file extension is only set if it exists, as not every url has a file extension. When the file + * name has multiple extensions @code example.tar.gz @endcode, only the last one should be captured + * @code gz @endcode, not @code tar.gz @endcode. + */ +static constexpr const char *kUrlExtension = "url.extension"; + +/** + * The URI fragment component + */ +static constexpr const char *kUrlFragment = "url.fragment"; + +/** + * Absolute URL describing a network resource according to RFC3986

        For network calls, URL usually has + * @code scheme://host[:port][path][?query][#fragment] @endcode format, where the fragment is not + * transmitted over HTTP, but if it is known, it SHOULD be included nevertheless. + * @code url.full @endcode MUST NOT contain credentials passed via URL in form of @code + * https://username:password@www.example.com/ @endcode. In such case username and password SHOULD be + * redacted and attribute's value SHOULD be @code https://REDACTED:REDACTED@www.example.com/ + * @endcode. + * @code url.full @endcode SHOULD capture the absolute URL when it is available (or can be + * reconstructed). Sensitive content provided in @code url.full @endcode SHOULD be scrubbed when + * instrumentations can identify it. + */ +static constexpr const char *kUrlFull = "url.full"; + +/** + * Unmodified original URL as seen in the event source. + *

        + * In network monitoring, the observed URL may be a full URL, whereas in access logs, the URL is + * often just represented as a path. This field is meant to represent the URL as it was observed, + * complete or not. + * @code url.original @endcode might contain credentials passed via URL in form of @code + * https://username:password@www.example.com/ @endcode. In such case password and username SHOULD + * NOT be redacted and attribute's value SHOULD remain the same. + */ +static constexpr const char *kUrlOriginal = "url.original"; + +/** + * The URI path component + *

        + * Sensitive content provided in @code url.path @endcode SHOULD be scrubbed when instrumentations + * can identify it. + */ +static constexpr const char *kUrlPath = "url.path"; + +/** + * Port extracted from the @code url.full @endcode + */ +static constexpr const char *kUrlPort = "url.port"; + +/** + * The URI query component + *

        + * Sensitive content provided in @code url.query @endcode SHOULD be scrubbed when instrumentations + * can identify it. + */ +static constexpr const char *kUrlQuery = "url.query"; + +/** + * The highest registered url domain, stripped of the subdomain. + *

        + * This value can be determined precisely with the public suffix + * list. For example, the registered domain for @code foo.example.com @endcode is @code + * example.com @endcode. Trying to approximate this by simply taking the last two labels will not + * work well for TLDs such as @code co.uk @endcode. + */ +static constexpr const char *kUrlRegisteredDomain = "url.registered_domain"; + +/** + * The URI scheme component + * identifying the used protocol. + */ +static constexpr const char *kUrlScheme = "url.scheme"; + +/** + * The subdomain portion of a fully qualified domain name includes all of the names except the host + * name under the registered_domain. In a partially qualified domain, or if the qualification level + * of the full name cannot be determined, subdomain contains all of the names below the registered + * domain.

        The subdomain portion of @code www.east.mydomain.co.uk @endcode is @code east + * @endcode. If the domain has multiple levels of subdomain, such as @code sub2.sub1.example.com + * @endcode, the subdomain field should contain @code sub2.sub1 @endcode, with no trailing period. + */ +static constexpr const char *kUrlSubdomain = "url.subdomain"; + +/** + * The low-cardinality template of an absolute path reference. + */ +static constexpr const char *kUrlTemplate = "url.template"; + +/** + * The effective top level domain (eTLD), also known as the domain suffix, is the last part of the + * domain name. For example, the top level domain for example.com is @code com @endcode.

        This + * value can be determined precisely with the public suffix + * list. + */ +static constexpr const char *kUrlTopLevelDomain = "url.top_level_domain"; + +} // namespace url +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/user_agent_attributes.h b/api/include/opentelemetry/semconv/incubating/user_agent_attributes.h new file mode 100644 index 0000000000..738bb6de15 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/user_agent_attributes.h @@ -0,0 +1,51 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace user_agent +{ + +/** + * Name of the user-agent extracted from original. Usually refers to the browser's name. + *

        + * Example of extracting browser's name from original + * string. In the case of using a user-agent for non-browser products, such as microservices with + * multiple names/versions inside the @code user_agent.original @endcode, the most significant name + * SHOULD be selected. In such a scenario it should align with @code user_agent.version @endcode + */ +static constexpr const char *kUserAgentName = "user_agent.name"; + +/** + * Value of the HTTP + * User-Agent header sent by the client. + */ +static constexpr const char *kUserAgentOriginal = "user_agent.original"; + +/** + * Version of the user-agent extracted from original. Usually refers to the browser's version + *

        + * Example of extracting browser's version from original + * string. In the case of using a user-agent for non-browser products, such as microservices with + * multiple names/versions inside the @code user_agent.original @endcode, the most significant + * version SHOULD be selected. In such a scenario it should align with @code user_agent.name + * @endcode + */ +static constexpr const char *kUserAgentVersion = "user_agent.version"; + +} // namespace user_agent +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/user_attributes.h b/api/include/opentelemetry/semconv/incubating/user_attributes.h new file mode 100644 index 0000000000..cc5a80d069 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/user_attributes.h @@ -0,0 +1,57 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace user +{ + +/** + * User email address. + */ +static constexpr const char *kUserEmail = "user.email"; + +/** + * User's full name + */ +static constexpr const char *kUserFullName = "user.full_name"; + +/** + * Unique user hash to correlate information for a user in anonymized form. + *

        + * Useful if @code user.id @endcode or @code user.name @endcode contain confidential information and + * cannot be used. + */ +static constexpr const char *kUserHash = "user.hash"; + +/** + * Unique identifier of the user. + */ +static constexpr const char *kUserId = "user.id"; + +/** + * Short name or login/username of the user. + */ +static constexpr const char *kUserName = "user.name"; + +/** + * Array of user roles at the time of the event. + */ +static constexpr const char *kUserRoles = "user.roles"; + +} // namespace user +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/vcs_attributes.h b/api/include/opentelemetry/semconv/incubating/vcs_attributes.h new file mode 100644 index 0000000000..cc38902e88 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/vcs_attributes.h @@ -0,0 +1,86 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace vcs +{ + +/** + * The ID of the change (pull request/merge request) if applicable. This is usually a unique (within + * repository) identifier generated by the VCS system. + */ +static constexpr const char *kVcsRepositoryChangeId = "vcs.repository.change.id"; + +/** + * The human readable title of the change (pull request/merge request). This title is often a brief + * summary of the change and may get merged in to a ref as the commit summary. + */ +static constexpr const char *kVcsRepositoryChangeTitle = "vcs.repository.change.title"; + +/** + * The name of the reference such as + * branch or tag in the repository. + */ +static constexpr const char *kVcsRepositoryRefName = "vcs.repository.ref.name"; + +/** + * The revision, literally revised + * version, The revision most often refers to a commit object in Git, or a revision number in + * SVN.

        The revision can be a full hash value (see glossary), + * of the recorded change to a ref within a repository pointing to a + * commit commit object. It does + * not necessarily have to be a hash; it can simply define a + * revision number + * which is an integer that is monotonically increasing. In cases where + * it is identical to the @code ref.name @endcode, it SHOULD still be included. It is + * up to the implementer to decide which value to set as the revision + * based on the VCS system and situational context. + */ +static constexpr const char *kVcsRepositoryRefRevision = "vcs.repository.ref.revision"; + +/** + * The type of the reference in the + * repository. + */ +static constexpr const char *kVcsRepositoryRefType = "vcs.repository.ref.type"; + +/** + * The URL of the repository providing the complete + * address in order to locate and identify the repository. + */ +static constexpr const char *kVcsRepositoryUrlFull = "vcs.repository.url.full"; + +namespace VcsRepositoryRefTypeValues +{ +/** + * branch + */ +static constexpr const char *kBranch = "branch"; + +/** + * tag + */ +static constexpr const char *kTag = "tag"; + +} // namespace VcsRepositoryRefTypeValues + +} // namespace vcs +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/webengine_attributes.h b/api/include/opentelemetry/semconv/incubating/webengine_attributes.h new file mode 100644 index 0000000000..16283b43cb --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/webengine_attributes.h @@ -0,0 +1,39 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace webengine +{ + +/** + * Additional description of the web engine (e.g. detailed version and edition information). + */ +static constexpr const char *kWebengineDescription = "webengine.description"; + +/** + * The name of the web engine. + */ +static constexpr const char *kWebengineName = "webengine.name"; + +/** + * The version of the web engine. + */ +static constexpr const char *kWebengineVersion = "webengine.version"; + +} // namespace webengine +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/network_attributes.h b/api/include/opentelemetry/semconv/network_attributes.h new file mode 100644 index 0000000000..7e965e6a6e --- /dev/null +++ b/api/include/opentelemetry/semconv/network_attributes.h @@ -0,0 +1,120 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace network +{ + +/** + * Local address of the network connection - IP address or Unix domain socket name. + */ +static constexpr const char *kNetworkLocalAddress = "network.local.address"; + +/** + * Local port number of the network connection. + */ +static constexpr const char *kNetworkLocalPort = "network.local.port"; + +/** + * Peer address of the network connection - IP address or Unix domain socket name. + */ +static constexpr const char *kNetworkPeerAddress = "network.peer.address"; + +/** + * Peer port number of the network connection. + */ +static constexpr const char *kNetworkPeerPort = "network.peer.port"; + +/** + * OSI application layer or non-OSI + * equivalent.

        The value SHOULD be normalized to lowercase. + */ +static constexpr const char *kNetworkProtocolName = "network.protocol.name"; + +/** + * The actual version of the protocol used for network communication. + *

        + * If protocol version is subject to negotiation (for example using ALPN), this attribute SHOULD be set to the + * negotiated version. If the actual protocol version is not known, this attribute SHOULD NOT be + * set. + */ +static constexpr const char *kNetworkProtocolVersion = "network.protocol.version"; + +/** + * OSI transport layer or inter-process communication + * method.

        The value SHOULD be normalized to lowercase.

        Consider always setting the + * transport when setting a port number, since a port number is ambiguous without knowing the + * transport. For example different processes could be listening on TCP port 12345 and UDP port + * 12345. + */ +static constexpr const char *kNetworkTransport = "network.transport"; + +/** + * OSI network layer or non-OSI equivalent. + *

        + * The value SHOULD be normalized to lowercase. + */ +static constexpr const char *kNetworkType = "network.type"; + +namespace NetworkTransportValues +{ +/** + * TCP + */ +static constexpr const char *kTcp = "tcp"; + +/** + * UDP + */ +static constexpr const char *kUdp = "udp"; + +/** + * Named or anonymous pipe. + */ +static constexpr const char *kPipe = "pipe"; + +/** + * Unix domain socket + */ +static constexpr const char *kUnix = "unix"; + +/** + * QUIC + */ +static constexpr const char *kQuic = "quic"; + +} // namespace NetworkTransportValues + +namespace NetworkTypeValues +{ +/** + * IPv4 + */ +static constexpr const char *kIpv4 = "ipv4"; + +/** + * IPv6 + */ +static constexpr const char *kIpv6 = "ipv6"; + +} // namespace NetworkTypeValues + +} // namespace network +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/otel_attributes.h b/api/include/opentelemetry/semconv/otel_attributes.h new file mode 100644 index 0000000000..b92eff1dd4 --- /dev/null +++ b/api/include/opentelemetry/semconv/otel_attributes.h @@ -0,0 +1,59 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace otel +{ + +/** + * The name of the instrumentation scope - (@code InstrumentationScope.Name @endcode in OTLP). + */ +static constexpr const char *kOtelScopeName = "otel.scope.name"; + +/** + * The version of the instrumentation scope - (@code InstrumentationScope.Version @endcode in OTLP). + */ +static constexpr const char *kOtelScopeVersion = "otel.scope.version"; + +/** + * Name of the code, either "OK" or "ERROR". MUST NOT be set if the status code is UNSET. + */ +static constexpr const char *kOtelStatusCode = "otel.status_code"; + +/** + * Description of the Status if it has a value, otherwise not set. + */ +static constexpr const char *kOtelStatusDescription = "otel.status_description"; + +namespace OtelStatusCodeValues +{ +/** + * The operation has been validated by an Application developer or Operator to have completed + * successfully. + */ +static constexpr const char *kOk = "OK"; + +/** + * The operation contains an error. + */ +static constexpr const char *kError = "ERROR"; + +} // namespace OtelStatusCodeValues + +} // namespace otel +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/schema_url.h b/api/include/opentelemetry/semconv/schema_url.h new file mode 100644 index 0000000000..62d040e40b --- /dev/null +++ b/api/include/opentelemetry/semconv/schema_url.h @@ -0,0 +1,24 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/schema_url-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +/** + * The URL of the OpenTelemetry schema for these keys and values. + */ +static constexpr const char *kSchemaUrl = "https://opentelemetry.io/schemas/1.27.0"; +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/server_attributes.h b/api/include/opentelemetry/semconv/server_attributes.h new file mode 100644 index 0000000000..21cb75d729 --- /dev/null +++ b/api/include/opentelemetry/semconv/server_attributes.h @@ -0,0 +1,41 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace server +{ + +/** + * Server domain name if available without reverse DNS lookup; otherwise, IP address or Unix domain + * socket name.

        When observed from the client side, and when communicating through an + * intermediary, @code server.address @endcode SHOULD represent the server address behind any + * intermediaries, for example proxies, if it's available. + */ +static constexpr const char *kServerAddress = "server.address"; + +/** + * Server port number. + *

        + * When observed from the client side, and when communicating through an intermediary, @code + * server.port @endcode SHOULD represent the server port behind any intermediaries, for example + * proxies, if it's available. + */ +static constexpr const char *kServerPort = "server.port"; + +} // namespace server +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/service_attributes.h b/api/include/opentelemetry/semconv/service_attributes.h new file mode 100644 index 0000000000..e4c0dda17a --- /dev/null +++ b/api/include/opentelemetry/semconv/service_attributes.h @@ -0,0 +1,41 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace service +{ + +/** + * Logical name of the service. + *

        + * MUST be the same for all instances of horizontally scaled services. If the value was not + * specified, SDKs MUST fallback to @code unknown_service: @endcode concatenated with @code process.executable.name @endcode, e.g. @code unknown_service:bash + * @endcode. If @code process.executable.name @endcode is not available, the value MUST be set to + * @code unknown_service @endcode. + */ +static constexpr const char *kServiceName = "service.name"; + +/** + * The version string of the service API or implementation. The format is not defined by these + * conventions. + */ +static constexpr const char *kServiceVersion = "service.version"; + +} // namespace service +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/telemetry_attributes.h b/api/include/opentelemetry/semconv/telemetry_attributes.h new file mode 100644 index 0000000000..7aa764cdaa --- /dev/null +++ b/api/include/opentelemetry/semconv/telemetry_attributes.h @@ -0,0 +1,111 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace telemetry +{ + +/** + * The language of the telemetry SDK. + */ +static constexpr const char *kTelemetrySdkLanguage = "telemetry.sdk.language"; + +/** + * The name of the telemetry SDK as defined above. + *

        + * The OpenTelemetry SDK MUST set the @code telemetry.sdk.name @endcode attribute to @code + * opentelemetry @endcode. If another SDK, like a fork or a vendor-provided implementation, is used, + * this SDK MUST set the + * @code telemetry.sdk.name @endcode attribute to the fully-qualified class or module name of this + * SDK's main entry point or another suitable identifier depending on the language. The identifier + * @code opentelemetry @endcode is reserved and MUST NOT be used in this case. All custom + * identifiers SHOULD be stable across different versions of an implementation. + */ +static constexpr const char *kTelemetrySdkName = "telemetry.sdk.name"; + +/** + * The version string of the telemetry SDK. + */ +static constexpr const char *kTelemetrySdkVersion = "telemetry.sdk.version"; + +namespace TelemetrySdkLanguageValues +{ +/** + * none + */ +static constexpr const char *kCpp = "cpp"; + +/** + * none + */ +static constexpr const char *kDotnet = "dotnet"; + +/** + * none + */ +static constexpr const char *kErlang = "erlang"; + +/** + * none + */ +static constexpr const char *kGo = "go"; + +/** + * none + */ +static constexpr const char *kJava = "java"; + +/** + * none + */ +static constexpr const char *kNodejs = "nodejs"; + +/** + * none + */ +static constexpr const char *kPhp = "php"; + +/** + * none + */ +static constexpr const char *kPython = "python"; + +/** + * none + */ +static constexpr const char *kRuby = "ruby"; + +/** + * none + */ +static constexpr const char *kRust = "rust"; + +/** + * none + */ +static constexpr const char *kSwift = "swift"; + +/** + * none + */ +static constexpr const char *kWebjs = "webjs"; + +} // namespace TelemetrySdkLanguageValues + +} // namespace telemetry +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/url_attributes.h b/api/include/opentelemetry/semconv/url_attributes.h new file mode 100644 index 0000000000..25ed5b03ab --- /dev/null +++ b/api/include/opentelemetry/semconv/url_attributes.h @@ -0,0 +1,66 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace url +{ + +/** + * The URI fragment component + */ +static constexpr const char *kUrlFragment = "url.fragment"; + +/** + * Absolute URL describing a network resource according to RFC3986

        For network calls, URL usually has + * @code scheme://host[:port][path][?query][#fragment] @endcode format, where the fragment is not + * transmitted over HTTP, but if it is known, it SHOULD be included nevertheless. + * @code url.full @endcode MUST NOT contain credentials passed via URL in form of @code + * https://username:password@www.example.com/ @endcode. In such case username and password SHOULD be + * redacted and attribute's value SHOULD be @code https://REDACTED:REDACTED@www.example.com/ + * @endcode. + * @code url.full @endcode SHOULD capture the absolute URL when it is available (or can be + * reconstructed). Sensitive content provided in @code url.full @endcode SHOULD be scrubbed when + * instrumentations can identify it. + */ +static constexpr const char *kUrlFull = "url.full"; + +/** + * The URI path component + *

        + * Sensitive content provided in @code url.path @endcode SHOULD be scrubbed when instrumentations + * can identify it. + */ +static constexpr const char *kUrlPath = "url.path"; + +/** + * The URI query component + *

        + * Sensitive content provided in @code url.query @endcode SHOULD be scrubbed when instrumentations + * can identify it. + */ +static constexpr const char *kUrlQuery = "url.query"; + +/** + * The URI scheme component + * identifying the used protocol. + */ +static constexpr const char *kUrlScheme = "url.scheme"; + +} // namespace url +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/user_agent_attributes.h b/api/include/opentelemetry/semconv/user_agent_attributes.h new file mode 100644 index 0000000000..dd1d493278 --- /dev/null +++ b/api/include/opentelemetry/semconv/user_agent_attributes.h @@ -0,0 +1,30 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace user_agent +{ + +/** + * Value of the HTTP + * User-Agent header sent by the client. + */ +static constexpr const char *kUserAgentOriginal = "user_agent.original"; + +} // namespace user_agent +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/trace/semantic_conventions.h b/api/include/opentelemetry/trace/semantic_conventions.h index fb26385fbc..d6d6591149 100644 --- a/api/include/opentelemetry/trace/semantic_conventions.h +++ b/api/include/opentelemetry/trace/semantic_conventions.h @@ -4,9 +4,13 @@ */ /* - DO NOT EDIT, this is an Auto-generated file - from buildscripts/semantic-convention/templates/SemanticAttributes.h.j2 -*/ + * This file is DEPRECATED, and no longer updated. + * See file DEPRECATED.md for details. + */ + +#ifdef OPENTELEMETRY_NO_DEPRECATED_CODE +# error "header is deprecated." +#endif #pragma once diff --git a/buildscripts/semantic-convention/generate.sh b/buildscripts/semantic-convention/generate.sh index cf8aa1d70c..79becfefbd 100755 --- a/buildscripts/semantic-convention/generate.sh +++ b/buildscripts/semantic-convention/generate.sh @@ -13,29 +13,28 @@ set -e SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" ROOT_DIR="${SCRIPT_DIR}/../../" -# freeze the spec & generator tools versions to make SemanticAttributes generation reproducible +# freeze the spec & generator tools versions to make the generation reproducible -# Repository up to 1.20.0: -# https://github.com/open-telemetry/opentelemetry-specification -# Repository from 1.21.0: -# https://github.com/open-telemetry/semantic-conventions +# repository: https://github.com/open-telemetry/semantic-conventions SEMCONV_VERSION=1.27.0 -# repository: https://github.com/open-telemetry/build-tools -GENERATOR_VERSION=0.25.0 +# repository: https://github.com/open-telemetry/weaver +WEAVER_VERSION=0.10.0 -SPEC_VERSION=v$SEMCONV_VERSION -SCHEMA_URL=https://opentelemetry.io/schemas/$SEMCONV_VERSION +SEMCONV_VERSION_TAG=v$SEMCONV_VERSION +WEAVER_VERSION_TAG=v$WEAVER_VERSION +SCHEMA_URL="https://opentelemetry.io/schemas/${SEMCONV_VERSION}" +INCUBATING_DIR=incubating cd ${SCRIPT_DIR} -rm -rf tmp-semconv || true -mkdir tmp-semconv -cd tmp-semconv +rm -rf semantic-conventions || true +mkdir semantic-conventions +cd semantic-conventions git init git remote add origin https://github.com/open-telemetry/semantic-conventions.git -git fetch origin "$SPEC_VERSION" +git fetch origin "$SEMCONV_VERSION_TAG" git reset --hard FETCH_HEAD cd ${SCRIPT_DIR} @@ -52,41 +51,70 @@ if [ -x "$(command -v getenforce)" ]; then fi; fi -# echo "Help ..." - -# docker run --rm otel/semconvgen:$GENERATOR_VERSION -h - -echo "Generating semantic conventions for traces ..." - -docker run --rm \ - -v ${SCRIPT_DIR}/tmp-semconv/model:/source${USE_MOUNT_OPTION} \ - -v ${SCRIPT_DIR}/templates:/templates${USE_MOUNT_OPTION} \ - -v ${ROOT_DIR}/api/include/opentelemetry/trace/:/output${USE_MOUNT_OPTION} \ - otel/semconvgen:$GENERATOR_VERSION \ - --only span,event,attribute_group\ - -f /source code \ - --template /templates/SemanticAttributes.h.j2 \ - --output /output/semantic_conventions.h \ - -Dsemconv=trace \ - -Dclass=SemanticConventions \ - -DschemaUrl=$SCHEMA_URL \ - -Dnamespace_open="namespace trace {" \ - -Dnamespace_close="}" - -echo "Generating semantic conventions for resources ..." - -docker run --rm \ - -v ${SCRIPT_DIR}/tmp-semconv/model:/source${USE_MOUNT_OPTION} \ - -v ${SCRIPT_DIR}/templates:/templates${USE_MOUNT_OPTION} \ - -v ${ROOT_DIR}/sdk/include/opentelemetry/sdk/resource/:/output${USE_MOUNT_OPTION} \ - otel/semconvgen:$GENERATOR_VERSION \ - --only resource,attribute_group \ - -f /source code \ - --template /templates/SemanticAttributes.h.j2 \ - --output /output/semantic_conventions.h \ - -Dsemconv=resource \ - -Dclass=SemanticConventions \ - -DschemaUrl=$SCHEMA_URL \ - -Dnamespace_open="namespace sdk { namespace resource {" \ - -Dnamespace_close="} }" +# DOCKER +# ====== +# +# docker is a root container +# +# MY_UID=$(id -u) +# MY_GID=$(id -g) +# docker --user ${MY_UID}:${MY_GID} +# +# PODMAN +# ====== +# +# podman is a rootless container +# docker is an alias to podman +# +# docker --user 0:0 + +MY_UID=$(id -u) +MY_GID=$(id -g) + +if [ -x "$(command -v docker)" ]; then + PODMANSTATUS=$(docker -v | grep -c podman); + if [ "${PODMANSTATUS}" -ge "1" ]; then + echo "Detected PODMAN" + # podman is a rootless container. + # Execute the docker image as root, + # to avoid creating files as weaver:weaver in the container, + # so files end up created as the local user:group outside the container. + MY_UID="0" + MY_GID="0" + # Possible alternate solution: --userns=keep-id + fi; +fi + +generate() { + TARGET=$1 + OUTPUT=$2 + FILTER=$3 + docker run --rm --user ${MY_UID}:${MY_GID} \ + -v ${SCRIPT_DIR}/semantic-conventions/model:/source${USE_MOUNT_OPTION} \ + -v ${SCRIPT_DIR}/templates:/templates${USE_MOUNT_OPTION} \ + -v ${ROOT_DIR}/tmpgen/:/output${USE_MOUNT_OPTION} \ + otel/weaver:$WEAVER_VERSION_TAG \ + registry \ + generate \ + --registry=/source \ + --templates=/templates \ + ${TARGET} \ + /output/${TARGET} \ + --param output=${OUTPUT} \ + --param filter=${FILTER} \ + --param schema_url=${SCHEMA_URL} +} + +# stable attributes and metrics +mkdir -p ${ROOT_DIR}/tmpgen +generate "./" "./" "stable" + +mkdir -p ${ROOT_DIR}/tmpgen/${INCUBATING_DIR} +generate "./" "./${INCUBATING_DIR}/" "any" + +cp -r ${ROOT_DIR}/tmpgen/*.h \ + ${ROOT_DIR}/api/include/opentelemetry/semconv/ + +cp -r ${ROOT_DIR}/tmpgen/${INCUBATING_DIR}/*.h \ + ${ROOT_DIR}/api/include/opentelemetry/semconv/incubating diff --git a/buildscripts/semantic-convention/templates/SemanticAttributes.h.j2 b/buildscripts/semantic-convention/templates/SemanticAttributes.h.j2 deleted file mode 100644 index 0ed9ce8dab..0000000000 --- a/buildscripts/semantic-convention/templates/SemanticAttributes.h.j2 +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ -{# - Adapted from: - https://github.com/open-telemetry/semantic-conventions-java/blob/main/buildscripts/templates/SemanticAttributes.java.j2 - for opentelemetry-cpp - - For doc on the template syntax: - https://jinja.palletsprojects.com/en/3.0.x/ - - For doc on the semantic convention: - https://github.com/open-telemetry/build-tools/tree/main/semantic-conventions -#} -{%- macro to_cpp_return_type(type) -%} - {%- if type == "string" -%} - char * - {%- elif type == "string[]" -%} - char *[] - {%- elif type == "boolean" -%} - bool - {%- elif type == "int" -%} - int - {%- elif type == "double" -%} - double - {%- else -%} - {{type}} - {%- endif -%} -{%- endmacro %} -{%- macro print_value(type, value) -%} - {{ "\"" if type == "char *"}}{{value}}{{ "\"" if type == "char *"}} -{%- endmacro %} -{%- macro upFirst(text) -%} - {{ text[0]|upper}}{{text[1:] }} -{%- endmacro %} -{%- macro lowerFirst(text) -%} - {{ text[0]|lower}}{{text[1:] }} -{%- endmacro %} - -/* - DO NOT EDIT, this is an Auto-generated file - from buildscripts/semantic-convention{{template}} -*/ - -#pragma once - -#include "opentelemetry/common/macros.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -{{namespace_open}} - -namespace {{class}} -{ -/** - * The URL of the OpenTelemetry schema for these keys and values. - */ -static constexpr const char *kSchemaUrl = "{{schemaUrl}}"; - {%- for attribute in attributes if attribute.is_local and not attribute.ref %} -{# - MAINTAINER: - semconv "messaging.client_id" is deprecated - semconv "messaging.client.id" is to be used instead - - Now, because we use k{{attribute.fqn | to_camelcase(True)}}, - both names collide on C++ symbol kMessagingClientId. - - Do not generate code for semconv "messaging.client_id" -#} -{%- if (attribute.fqn != "messaging.client_id") %} -/** - * {{attribute.brief | render_markdown(code="{{@code {0}}}", paragraph="{0}")}} - {%- if attribute.note %} - * - *

        Notes: -

          {{attribute.note | render_markdown(code="{{@code {0}}}", paragraph="
        • {0}
        • ", list="{0}")}}
        - {%- endif %} -{%- if (attribute.deprecated) %} - * - * @deprecated {{attribute.brief | to_doc_brief}}. - {%- endif %} - */ - {%- if (attribute.deprecated) %} -OPENTELEMETRY_DEPRECATED - {%- endif %} -static constexpr const char *k{{attribute.fqn | to_camelcase(True)}} = "{{attribute.fqn}}"; -{%- endif %} -{%- endfor %} - -// Enum definitions -{%- for attribute in attributes if attribute.is_local and not attribute.ref %} -{%- if attribute.is_enum %} -{%- set enum_name = attribute.fqn | to_camelcase(True) ~ "Values" %} -{%- set type = to_cpp_return_type(attribute.attr_type.enum_type) %} -namespace {{enum_name}} -{ - {%- for member in attribute.attr_type.members %} - /** {% filter escape %}{{member.brief | to_doc_brief}}.{% endfilter %} */ - static constexpr const {{ type }} k{{ member.member_id | to_camelcase(True) }} = {{ print_value(type, member.value) }}; - {%- endfor %} -} -{% endif %} -{%- endfor %} - -{# - {%- if class == "SemanticAttributes" %} - // Manually defined and not YET in the YAML - /** - * The name of an event describing an exception. - * - *

        Typically an event with that name should not be manually created. Instead {@link - * io.opentelemetry.api.trace.Span#recordException(Throwable)} should be used. - */ - static constexpr const char *EXCEPTION_EVENT_NAME = "exception"; - - {% endif %} -#} - -} // namespace {{class}} -{{namespace_close}} -OPENTELEMETRY_END_NAMESPACE - diff --git a/buildscripts/semantic-convention/templates/registry/schema_url-h.j2 b/buildscripts/semantic-convention/templates/registry/schema_url-h.j2 new file mode 100644 index 0000000000..3b80927ed2 --- /dev/null +++ b/buildscripts/semantic-convention/templates/registry/schema_url-h.j2 @@ -0,0 +1,48 @@ +{# + Copyright The OpenTelemetry Authors + SPDX-License-Identifier: Apache-2.0 + + This file is: + - a Jinja template, + - used to generate semantic conventions, + - using weaver. + + For doc on the template syntax: + https://jinja.palletsprojects.com/en/3.0.x/ + + For doc on the semantic conventions: + https://github.com/open-telemetry/semantic-conventions + + For doc on weaver: + https://github.com/open-telemetry/weaver +#} +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/schema_url-h.j2 + */ +{# ========================================================================== #} + +{{ template.set_file_name("schema_url.h") }} + +{# ========================================================================== #} + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +/** + * The URL of the OpenTelemetry schema for these keys and values. + */ +static constexpr const char *kSchemaUrl = {{ params.schema_url | print_member_value }}; +} +OPENTELEMETRY_END_NAMESPACE + diff --git a/buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 b/buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 new file mode 100644 index 0000000000..5e5b4eac7d --- /dev/null +++ b/buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 @@ -0,0 +1,132 @@ +{# + Copyright The OpenTelemetry Authors + SPDX-License-Identifier: Apache-2.0 + + This file is: + - a Jinja template, + - used to generate semantic conventions, + - using weaver. + + For doc on the template syntax: + https://jinja.palletsprojects.com/en/3.0.x/ + + For doc on the semantic conventions: + https://github.com/open-telemetry/semantic-conventions + + For doc on weaver: + https://github.com/open-telemetry/weaver +#} +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ +{# ========================================================================== #} +{# + DESIGN NOTES: + - Use the debug flag to dump the semantic convention data + in the generated output, to inspect it. +#} +{# ========================================================================== #} + +{% set debug = false %} + +{% set file_name = ctx.output + (ctx.root_namespace | snake_case) ~ "_attributes.h" %} +{{ template.set_file_name(file_name) }} + +{% set attributes = ctx.attributes | list %} +{% set enum_attributes = attributes | select("enum") | rejectattr("name", "in", ctx.excluded_attributes) | list %} + +{% macro attribute_namespace(ctx) %} +{{ ctx.root_namespace | snake_case }} +{% endmacro %} + +{% macro attribute_name(attribute) %} +k{{ attribute.name | pascal_case }} +{% endmacro %} + +{% macro attribute_type(attribute) %} +{{ attribute.type | enum_type | map_text("cpp_types") }} +{% endmacro %} + +{% macro enum_namespace_name(attribute) %} +{{ attribute.name | pascal_case ~ "Values"}} +{% endmacro %} + +{% macro enum_name(member) %} +k{{ member.id | pascal_case }} +{% endmacro %} + +{% set cpp_attribute_namespace = attribute_namespace(ctx) %} + +{# ========================================================================== #} + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace {{ cpp_attribute_namespace -}} +{ + +{% for attribute in attributes %} + {% if debug %} +// DEBUG: {{ attribute }} + {% endif %} + {% set cpp_attr_name = attribute_name(attribute) %} + {% set excluded = attribute.name in ctx.excluded_attributes %} + {% if excluded %} +#if 0 +// Excluded attribute: + {% endif %} + {% if attribute is deprecated %} +{{ [attribute.brief, "\n", "@deprecated", attribute.deprecated, "\n", attribute.note] | comment(ident=2) }} +OPENTELEMETRY_DEPRECATED + {% else %} +{{ [attribute.brief, "\n", attribute.note] | comment(ident=2) }} + {% endif %} +static constexpr const char *{{cpp_attr_name}} = "{{attribute.name}}"; + {% if excluded %} +#endif + {% endif %} + +{% endfor %} + +{% for attribute in enum_attributes %} + {% set class_name = attribute.name | pascal_case ~ "Values" %} + {% set cpp_enum_name = enum_namespace_name(attribute) %} + {% set cpp_enum_type = attribute_type(attribute) %} + {% if debug %} +// DEBUG: {{ attribute }} + {% endif %} +namespace {{cpp_enum_name -}} +{ + {% for member in attribute.type.members %} + {% set member_name = enum_name(member) %} + {% if debug %} +// DEBUG: {{ member }} + {% endif %} + {% if member is deprecated %} +{{ [member.brief, "\n", "@deprecated", member.deprecated] | comment(ident=2) }} +OPENTELEMETRY_DEPRECATED + {% else %} +{{ member.brief | comment(ident=2) }} + {% endif %} +static constexpr {{ cpp_enum_type }} {{ member_name }} = {{ member.value | print_member_value }}; + + {% endfor %} +} + +{% endfor %} + +} +} +OPENTELEMETRY_END_NAMESPACE + diff --git a/buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 b/buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 new file mode 100644 index 0000000000..f306367f89 --- /dev/null +++ b/buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 @@ -0,0 +1,228 @@ +{# + Copyright The OpenTelemetry Authors + SPDX-License-Identifier: Apache-2.0 + + This file is: + - a Jinja template, + - used to generate semantic conventions, + - using weaver. + + For doc on the template syntax: + https://jinja.palletsprojects.com/en/3.0.x/ + + For doc on the semantic conventions: + https://github.com/open-telemetry/semantic-conventions + + For doc on weaver: + https://github.com/open-telemetry/weaver +#} +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 + */ +{# ========================================================================== #} +{# + DESIGN NOTES: + - Use the debug flag to dump the semantic convention data + in the generated output, to inspect it. + - Some instruments are not supported in the SDK. + For these, we do not generate the code. +#} +{# ========================================================================== #} + +{% set debug = false %} + +{% set file_name = ctx.output + (ctx.root_namespace | snake_case) ~ "_metrics.h" %} +{{ template.set_file_name(file_name) }} + +{% set metrics = ctx.metrics | list %} + +{% macro metric_namespace(ctx) %} +{{ ctx.root_namespace | snake_case }} +{% endmacro %} + +{% macro func_metric_name(metric) %} +{{ metric.id | pascal_case }} +{% endmacro %} + +{% macro var_metric_name(metric) %} +k{{ metric.id | pascal_case }} +{% endmacro %} + +{% macro descr_metric_name(metric) %} +descr{{ metric.id | pascal_case }} +{% endmacro %} + +{% macro unit_metric_name(metric) %} +unit{{ metric.id | pascal_case }} +{% endmacro %} + +{% macro sync_instrument_min_abi_version(metric) %} +{{ metric.instrument | map_text("cpp_sync_min_abi_version") | trim }} +{% endmacro %} + +{% macro sync_instrument_int64_type(metric) %} +{{ metric.instrument | map_text("cpp_sync_instrument_to_int64_type") | trim }} +{% endmacro %} + +{% macro sync_instrument_double_type(metric) %} +{{ metric.instrument | map_text("cpp_sync_instrument_to_double_type") | trim }} +{% endmacro %} + +{% macro sync_instrument_int64_factory(metric) %} +{{ metric.instrument | map_text("cpp_sync_instrument_to_int64_factory") }} +{% endmacro %} + +{% macro sync_instrument_double_factory(metric) %} +{{ metric.instrument | map_text("cpp_sync_instrument_to_double_factory") }} +{% endmacro %} + +{% macro async_instrument_min_abi_version(metric) %} +{{ metric.instrument | map_text("cpp_async_min_abi_version") | trim }} +{% endmacro %} + +{% macro async_instrument_type(metric) %} +{{ metric.instrument | map_text("cpp_async_instrument_to_type") }} +{% endmacro %} + +{% macro async_instrument_int64_factory(metric) %} +{{ metric.instrument | map_text("cpp_async_instrument_to_int64_factory") }} +{% endmacro %} + +{% macro async_instrument_double_factory(metric) %} +{{ metric.instrument | map_text("cpp_async_instrument_to_double_factory") }} +{% endmacro %} + +{% set cpp_metric_namespace = metric_namespace(ctx) %} + +{# ========================================================================== #} + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace {{ cpp_metric_namespace -}} +{ + +{% for metric in ctx.metrics %} + {% if debug %} +// DEBUG: {{ metric }} + {% endif %} + {% set f_metric_name = func_metric_name(metric) %} + {% set v_metric_name = var_metric_name(metric) %} + {% set descr = descr_metric_name(metric) %} + {% set unit = unit_metric_name(metric) %} + {% set sync_min_abi_version = (sync_instrument_min_abi_version(metric)) %} + {% set async_min_abi_version = (async_instrument_min_abi_version(metric)) %} + {% set sync_int64_type = sync_instrument_int64_type(metric) %} + {% set sync_double_type = sync_instrument_double_type(metric) %} + {% set async_type = async_instrument_type(metric) %} + {% set sync_int64_factory = sync_instrument_int64_factory(metric) %} + {% set sync_double_factory = sync_instrument_double_factory(metric) %} + {% set async_int64_factory = async_instrument_int64_factory(metric) %} + {% set async_double_factory = async_instrument_double_factory(metric) %} + {% set excluded = metric.id in ctx.excluded_attributes %} + {% if excluded %} +#if 0 +// Excluded metric: + {% endif %} + {% if metric is deprecated %} +{{ [metric.brief, "\n", "@deprecated", metric.deprecated, "\n", metric.note, "\n", metric.instrument] | comment(ident=2) }} +OPENTELEMETRY_DEPRECATED + {% else %} +{{ [metric.brief, "\n", metric.note, "\n", metric.instrument] | comment(ident=2) }} + {% endif %} +static constexpr const char *{{v_metric_name}} = "{{metric.id}}"; + {% if metric is deprecated %} +OPENTELEMETRY_DEPRECATED + {% endif %} +static constexpr const char *{{descr}} = "{{metric.brief}}"; + {% if metric is deprecated %} +OPENTELEMETRY_DEPRECATED + {% endif %} +static constexpr const char *{{unit}} = "{{metric.unit}}"; + + {% if sync_min_abi_version|trim != "0" %} + {% if sync_min_abi_version|trim != "1" %} +#if OPENTELEMETRY_ABI_VERSION_NO >= {{sync_min_abi_version}} + {% endif %} + {% if metric is deprecated %} +OPENTELEMETRY_DEPRECATED + {% endif %} +static inline nostd::unique_ptr<{{sync_int64_type-}}> +CreateSyncInt64{{f_metric_name-}}(metrics::Meter *meter) +{ + return meter->{{sync_int64_factory}}( + {{v_metric_name}}, + {{descr}}, + {{unit}}); +} + + {% if metric is deprecated %} +OPENTELEMETRY_DEPRECATED + {% endif %} +static inline nostd::unique_ptr<{{sync_double_type-}}> +CreateSyncDouble{{f_metric_name-}}(metrics::Meter *meter) +{ + return meter->{{sync_double_factory}}( + {{v_metric_name}}, + {{descr}}, + {{unit}}); +} + {% if sync_min_abi_version|trim != "1" %} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + {% endif %} + {% endif %} + + {% if async_min_abi_version|trim != "0" %} + {% if async_min_abi_version|trim != "1" %} +#if OPENTELEMETRY_ABI_VERSION_NO >= {{async_min_abi_version}} + {% endif %} + {% if metric is deprecated %} +OPENTELEMETRY_DEPRECATED + {% endif %} +static inline nostd::shared_ptr<{{async_type-}}> +CreateAsyncInt64{{f_metric_name-}}(metrics::Meter *meter) +{ + return meter->{{async_int64_factory}}( + {{v_metric_name}}, + {{descr}}, + {{unit}}); +} + + {% if metric is deprecated %} +OPENTELEMETRY_DEPRECATED + {% endif %} +static inline nostd::shared_ptr<{{async_type-}}> +CreateAsyncDouble{{f_metric_name-}}(metrics::Meter *meter) +{ + return meter->{{async_double_factory}}( + {{v_metric_name}}, + {{descr}}, + {{unit}}); +} + {% if async_min_abi_version|trim != "1" %} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + {% endif %} + {% endif %} + + {% if excluded %} +#endif /* 0 */ + {% endif %} + +{% endfor %} + +} +} +OPENTELEMETRY_END_NAMESPACE + diff --git a/buildscripts/semantic-convention/templates/registry/weaver.yaml b/buildscripts/semantic-convention/templates/registry/weaver.yaml new file mode 100644 index 0000000000..e0543b2652 --- /dev/null +++ b/buildscripts/semantic-convention/templates/registry/weaver.yaml @@ -0,0 +1,156 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +# This file is the main file for weaver, +# used to generate semantic conventions, +# for opentelemetry-cpp. +# +# For doc on weaver: +# https://github.com/open-telemetry/weaver +# +# For doc on the semantic conventions: +# https://github.com/open-telemetry/semantic-conventions +# + +params: + # excluded namespaces will not be generated + excluded_namespaces: [ios, aspnetcore, signalr, android, dotnet, jvm, kestrel, v8js, veightjs, go, nodejs] + + # excluded attributes will be commented out in the generated code + # this behavior is fully controlled by jinja templates + excluded_attributes: ["messaging.client_id"] + + stable_package_name: opentelemetry.semconv + + # "https://opentelemetry.io/schemas/" + # this is provided from the command line + schema_url: "" + +templates: + - pattern: schema_url-h.j2 + filter: . + application_mode: single + - pattern: semantic_attributes-h.j2 + filter: > + semconv_grouped_attributes({ + "exclude_root_namespace": $excluded_namespaces, + "exclude_stability": if $filter == "any" then [] else ["experimental"] end, + }) + | map({ + root_namespace: .root_namespace, + attributes: .attributes, + output: $output, + stable_package_name: $stable_package_name + ".attributes", + filter: $filter, + excluded_attributes: $excluded_attributes[] + }) + application_mode: each + - pattern: semantic_metrics-h.j2 + filter: > + semconv_grouped_metrics({ + "exclude_root_namespace": $excluded_namespaces, + "exclude_stability": if $filter == "any" then [] else ["experimental"] end, + }) + | map({ + root_namespace: .root_namespace, + metrics: .metrics, + output: $output, + stable_package_name: $stable_package_name + ".metrics", + filter: $filter + }) + application_mode: each + +text_maps: + cpp_types: + int: int + double: double + boolean: bool + string: const char * + string[]: const char *[] + template[string]: const char * + template[string[]]: const char *[] + + # Minimum ABI_VERSION to support the feature: + # 0 - not supported + # 1 - supported in all versions + # 2 - supported in ABI_VERSION >= 2 + cpp_sync_min_abi_version: + counter: 1 + histogram: 1 + updowncounter: 1 + gauge: 2 + + cpp_sync_instrument_to_int64_type: + counter: metrics::Counter + histogram: metrics::Histogram + updowncounter: metrics::UpDownCounter + gauge: metrics::Gauge + + cpp_sync_instrument_to_double_type: + counter: metrics::Counter + histogram: metrics::Histogram + updowncounter: metrics::UpDownCounter + gauge: metrics::Gauge + + cpp_sync_instrument_to_int64_factory: + counter: CreateUInt64Counter + histogram: CreateUInt64Histogram + updowncounter: CreateInt64UpDownCounter + gauge: CreateInt64Gauge + + cpp_sync_instrument_to_double_factory: + counter: CreateDoubleCounter + histogram: CreateDoubleHistogram + updowncounter: CreateDoubleUpDownCounter + gauge: CreateDoubleGauge + + # Minimum ABI_VERSION to support the feature: + # 0 - not supported + # 1 - supported in all versions + # 2 - supported in ABI_VERSION >= 2 + cpp_async_min_abi_version: + counter: 1 + histogram: 0 + updowncounter: 1 + gauge: 1 + + cpp_async_instrument_to_type: + counter: metrics::ObservableInstrument + histogram: UNSUPPORTED + updowncounter: metrics::ObservableInstrument + gauge: metrics::ObservableInstrument + + cpp_async_instrument_to_int64_factory: + counter: CreateInt64ObservableCounter + histogram: UNSUPPORTED + updowncounter: CreateInt64ObservableUpDownCounter + gauge: CreateInt64ObservableGauge + + cpp_async_instrument_to_double_factory: + counter: CreateDoubleObservableCounter + histogram: UNSUPPORTED + updowncounter: CreateDoubleObservableUpDownCounter + gauge: CreateDoubleObservableGauge + + +comment_formats: + cpp: + format: html + header: "/**" + prefix: " * " + footer: " */" + indent_type: Space + trim: true + remove_trailing_dots: false + enforce_trailing_dots: false + old_style_paragraph: true + omit_closing_li: false + inline_code_snippet: "@code {{code}} @endcode" + block_code_snippet: "@verbatim {{code}} @endverbatim" +default_comment_format: cpp + +whitespace_control: + trim_blocks: true + lstrip_blocks: true + keep_trailing_newline: true + diff --git a/examples/common/metrics_foo_library/foo_library.cc b/examples/common/metrics_foo_library/foo_library.cc index e288615293..81cb840718 100644 --- a/examples/common/metrics_foo_library/foo_library.cc +++ b/examples/common/metrics_foo_library/foo_library.cc @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -20,6 +21,9 @@ #include "opentelemetry/metrics/sync_instruments.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/variant.h" +#include "opentelemetry/semconv/http_metrics.h" +#include "opentelemetry/semconv/incubating/container_metrics.h" +#include "opentelemetry/semconv/incubating/system_metrics.h" namespace metrics_api = opentelemetry::metrics; @@ -126,3 +130,49 @@ void foo_library::gauge_example(const std::string &name) } } #endif + +void foo_library::semconv_counter_example() +{ + auto provider = metrics_api::Provider::GetMeterProvider(); + opentelemetry::nostd::shared_ptr meter = provider->GetMeter("demo", "1.2.0"); + auto double_counter = + opentelemetry::semconv::container::CreateSyncDoubleMetricContainerDiskIo(meter.get()); + + for (uint32_t i = 0; i < 20; ++i) + { + double val = (rand() % 700) + 1.1; + double_counter->Add(val); + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + } +} + +void foo_library::semconv_observable_counter_example() +{ + auto provider = metrics_api::Provider::GetMeterProvider(); + opentelemetry::nostd::shared_ptr meter = provider->GetMeter("demo", "1.2.0"); + double_observable_counter = + opentelemetry::semconv::system::CreateAsyncDoubleMetricSystemCpuTime(meter.get()); + double_observable_counter->AddCallback(MeasurementFetcher::Fetcher, nullptr); + for (uint32_t i = 0; i < 20; ++i) + { + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + } +} + +void foo_library::semconv_histogram_example() +{ + auto provider = metrics_api::Provider::GetMeterProvider(); + opentelemetry::nostd::shared_ptr meter = provider->GetMeter("demo", "1.2.0"); + auto histogram_counter = + opentelemetry::semconv::http::CreateSyncInt64MetricHttpClientRequestDuration(meter.get()); + auto context = opentelemetry::context::Context{}; + for (uint32_t i = 0; i < 20; ++i) + { + double val = (rand() % 700) + 1.1; + uint64_t int_val = std::llround(val); + std::map labels = get_random_attr(); + auto labelkv = opentelemetry::common::KeyValueIterableView{labels}; + histogram_counter->Record(int_val, labelkv, context); + std::this_thread::sleep_for(std::chrono::milliseconds(250)); + } +} diff --git a/examples/common/metrics_foo_library/foo_library.h b/examples/common/metrics_foo_library/foo_library.h index 05f0f16c23..65997398a5 100644 --- a/examples/common/metrics_foo_library/foo_library.h +++ b/examples/common/metrics_foo_library/foo_library.h @@ -14,4 +14,7 @@ class foo_library #if OPENTELEMETRY_ABI_VERSION_NO >= 2 static void gauge_example(const std::string &name); #endif + static void semconv_counter_example(); + static void semconv_histogram_example(); + static void semconv_observable_counter_example(); }; diff --git a/examples/grpc/client.cc b/examples/grpc/client.cc index 9ca41c6958..49be22c155 100644 --- a/examples/grpc/client.cc +++ b/examples/grpc/client.cc @@ -15,7 +15,8 @@ #include #include -#include "opentelemetry/trace/semantic_conventions.h" +#include "opentelemetry/semconv/incubating/rpc_attributes.h" +#include "opentelemetry/semconv/network_attributes.h" #include "tracer_common.h" using grpc::Channel; @@ -29,6 +30,7 @@ using grpc_example::GreetResponse; namespace { namespace context = opentelemetry::context; +namespace semconv = opentelemetry::semconv; using namespace opentelemetry::trace; class GreeterClient { @@ -47,14 +49,14 @@ class GreeterClient options.kind = SpanKind::kClient; std::string span_name = "GreeterClient/Greet"; - auto span = get_tracer("grpc")->StartSpan( - span_name, - {{SemanticConventions::kRpcSystem, "grpc"}, - {SemanticConventions::kRpcService, "grpc-example.GreetService"}, - {SemanticConventions::kRpcMethod, "Greet"}, - {SemanticConventions::kNetworkPeerAddress, ip}, - {SemanticConventions::kNetworkPeerPort, port}}, - options); + auto span = + get_tracer("grpc")->StartSpan(span_name, + {{semconv::rpc::kRpcSystem, "grpc"}, + {semconv::rpc::kRpcService, "grpc-example.GreetService"}, + {semconv::rpc::kRpcMethod, "Greet"}, + {semconv::network::kNetworkPeerAddress, ip}, + {semconv::network::kNetworkPeerPort, port}}, + options); auto scope = get_tracer("grpc-client")->WithActiveSpan(span); @@ -69,7 +71,7 @@ class GreeterClient if (status.ok()) { span->SetStatus(StatusCode::kOk); - span->SetAttribute(SemanticConventions::kRpcGrpcStatusCode, status.error_code()); + span->SetAttribute(semconv::rpc::kRpcGrpcStatusCode, status.error_code()); // Make sure to end your spans! span->End(); return response.response(); @@ -78,7 +80,7 @@ class GreeterClient { std::cout << status.error_code() << ": " << status.error_message() << '\n'; span->SetStatus(StatusCode::kError); - span->SetAttribute(SemanticConventions::kRpcGrpcStatusCode, status.error_code()); + span->SetAttribute(semconv::rpc::kRpcGrpcStatusCode, status.error_code()); // Make sure to end your spans! span->End(); return "RPC failed"; diff --git a/examples/grpc/server.cc b/examples/grpc/server.cc index 3c3fcede4f..6aa543a8a1 100644 --- a/examples/grpc/server.cc +++ b/examples/grpc/server.cc @@ -7,8 +7,8 @@ # include "messages.grpc.pb.h" #endif +#include "opentelemetry/semconv/incubating/rpc_attributes.h" #include "opentelemetry/trace/context.h" -#include "opentelemetry/trace/semantic_conventions.h" #include "opentelemetry/trace/span_context_kv_iterable_view.h" #include "tracer_common.h" @@ -38,6 +38,7 @@ using SpanContext = opentelemetry::trace::SpanContext; using namespace opentelemetry::trace; namespace context = opentelemetry::context; +namespace semconv = opentelemetry::semconv; namespace { @@ -67,10 +68,10 @@ class GreeterServer final : public Greeter::Service std::string span_name = "GreeterService/Greet"; auto span = get_tracer("grpc")->StartSpan(span_name, - {{SemanticConventions::kRpcSystem, "grpc"}, - {SemanticConventions::kRpcService, "GreeterService"}, - {SemanticConventions::kRpcMethod, "Greet"}, - {SemanticConventions::kRpcGrpcStatusCode, 0}}, + {{semconv::rpc::kRpcSystem, "grpc"}, + {semconv::rpc::kRpcService, "GreeterService"}, + {semconv::rpc::kRpcMethod, "Greet"}, + {semconv::rpc::kRpcGrpcStatusCode, 0}}, options); auto scope = get_tracer("grpc")->WithActiveSpan(span); diff --git a/examples/http/client.cc b/examples/http/client.cc index 3a8486f55f..54f10b2f95 100644 --- a/examples/http/client.cc +++ b/examples/http/client.cc @@ -3,7 +3,8 @@ #include "opentelemetry/ext/http/client/http_client_factory.h" #include "opentelemetry/ext/http/common/url_parser.h" -#include "opentelemetry/trace/semantic_conventions.h" +#include "opentelemetry/semconv/http_attributes.h" +#include "opentelemetry/semconv/url_attributes.h" #include "tracer_common.h" namespace @@ -13,6 +14,7 @@ using namespace opentelemetry::trace; namespace http_client = opentelemetry::ext::http::client; namespace context = opentelemetry::context; namespace nostd = opentelemetry::nostd; +namespace semconv = opentelemetry::semconv; void sendRequest(const std::string &url) { @@ -26,9 +28,9 @@ void sendRequest(const std::string &url) std::string span_name = url_parser.path_; auto span = get_tracer("http-client") ->StartSpan(span_name, - {{SemanticConventions::kUrlFull, url_parser.url_}, - {SemanticConventions::kUrlScheme, url_parser.scheme_}, - {SemanticConventions::kHttpRequestMethod, "GET"}}, + {{semconv::url::kUrlFull, url_parser.url_}, + {semconv::url::kUrlScheme, url_parser.scheme_}, + {semconv::http::kHttpRequestMethod, "GET"}}, options); auto scope = get_tracer("http-client")->WithActiveSpan(span); @@ -44,7 +46,7 @@ void sendRequest(const std::string &url) { // set span attributes auto status_code = result.GetResponse().GetStatusCode(); - span->SetAttribute(SemanticConventions::kHttpResponseStatusCode, status_code); + span->SetAttribute(semconv::http::kHttpResponseStatusCode, status_code); result.GetResponse().ForEachHeader( [&span](nostd::string_view header_name, nostd::string_view header_value) { span->SetAttribute("http.header." + std::string(header_name.data()), header_value); diff --git a/examples/http/server.cc b/examples/http/server.cc index 85cccc234d..23b37d3ab9 100644 --- a/examples/http/server.cc +++ b/examples/http/server.cc @@ -2,8 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 #include "server.h" +#include "opentelemetry/semconv/client_attributes.h" +#include "opentelemetry/semconv/incubating/http_attributes.h" +#include "opentelemetry/semconv/server_attributes.h" +#include "opentelemetry/semconv/url_attributes.h" #include "opentelemetry/trace/context.h" -#include "opentelemetry/trace/semantic_conventions.h" #include "tracer_common.h" #include @@ -14,6 +17,7 @@ namespace using namespace opentelemetry::trace; namespace context = opentelemetry::context; +namespace semconv = opentelemetry::semconv; uint16_t server_port = 8800; constexpr const char *server_name = "localhost"; @@ -40,13 +44,13 @@ class RequestHandler : public HTTP_SERVER_NS::HttpRequestCallback // start span with parent context extracted from http header auto span = get_tracer("http-server") ->StartSpan(span_name, - {{SemanticConventions::kServerAddress, server_name}, - {SemanticConventions::kServerPort, server_port}, - {SemanticConventions::kHttpRequestMethod, request.method}, - {SemanticConventions::kUrlScheme, "http"}, - {SemanticConventions::kHttpRequestBodySize, + {{semconv::server::kServerAddress, server_name}, + {semconv::server::kServerPort, server_port}, + {semconv::http::kHttpRequestMethod, request.method}, + {semconv::url::kUrlScheme, "http"}, + {semconv::http::kHttpRequestBodySize, static_cast(request.content.length())}, - {SemanticConventions::kClientAddress, request.client}}, + {semconv::client::kClientAddress, request.client}}, options); auto scope = get_tracer("http_server")->WithActiveSpan(span); diff --git a/examples/metrics_simple/metrics_ostream.cc b/examples/metrics_simple/metrics_ostream.cc index 6d8c1ef6e0..53315c033b 100644 --- a/examples/metrics_simple/metrics_ostream.cc +++ b/examples/metrics_simple/metrics_ostream.cc @@ -154,6 +154,18 @@ int main(int argc, char **argv) foo_library::gauge_example(name); } #endif + else if (example_type == "semconv_counter") + { + foo_library::semconv_counter_example(); + } + else if (example_type == "semconv_observable_counter") + { + foo_library::semconv_observable_counter_example(); + } + else if (example_type == "semconv_histogram") + { + foo_library::semconv_histogram_example(); + } else { std::thread counter_example{&foo_library::counter_example, name}; @@ -162,6 +174,10 @@ int main(int argc, char **argv) #if OPENTELEMETRY_ABI_VERSION_NO >= 2 std::thread gauge_example{&foo_library::gauge_example, name}; #endif + std::thread semconv_counter_example{&foo_library::semconv_counter_example}; + std::thread semconv_observable_counter_example{ + &foo_library::semconv_observable_counter_example}; + std::thread semconv_histogram_example{&foo_library::semconv_histogram_example}; counter_example.join(); observable_counter_example.join(); @@ -169,6 +185,9 @@ int main(int argc, char **argv) #if OPENTELEMETRY_ABI_VERSION_NO >= 2 gauge_example.join(); #endif + semconv_counter_example.join(); + semconv_observable_counter_example.join(); + semconv_histogram_example.join(); } CleanupMetrics(); diff --git a/exporters/otlp/test/otlp_log_recordable_test.cc b/exporters/otlp/test/otlp_log_recordable_test.cc index bcecbb8d8f..e5d6701e46 100644 --- a/exporters/otlp/test/otlp_log_recordable_test.cc +++ b/exporters/otlp/test/otlp_log_recordable_test.cc @@ -8,7 +8,6 @@ #include "opentelemetry/exporters/otlp/otlp_log_recordable.h" #include "opentelemetry/sdk/logs/read_write_log_record.h" #include "opentelemetry/sdk/resource/resource.h" -#include "opentelemetry/sdk/resource/semantic_conventions.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/exporters/prometheus/src/exporter_utils.cc b/exporters/prometheus/src/exporter_utils.cc index 27385f3f6f..f54b129ab8 100644 --- a/exporters/prometheus/src/exporter_utils.cc +++ b/exporters/prometheus/src/exporter_utils.cc @@ -16,12 +16,9 @@ #include "opentelemetry/common/macros.h" #include "opentelemetry/exporters/prometheus/exporter_utils.h" +#include "opentelemetry/sdk/common/global_log_handler.h" #include "opentelemetry/sdk/metrics/export/metric_producer.h" #include "opentelemetry/sdk/resource/resource.h" -#include "opentelemetry/sdk/resource/semantic_conventions.h" -#include "opentelemetry/trace/semantic_conventions.h" - -#include "opentelemetry/sdk/common/global_log_handler.h" namespace prometheus_client = ::prometheus; namespace metric_sdk = opentelemetry::sdk::metrics; diff --git a/exporters/zipkin/src/recordable.cc b/exporters/zipkin/src/recordable.cc index 69899e7fad..8b60faef71 100644 --- a/exporters/zipkin/src/recordable.cc +++ b/exporters/zipkin/src/recordable.cc @@ -21,7 +21,7 @@ #include "opentelemetry/sdk/common/attribute_utils.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/resource/resource.h" -#include "opentelemetry/sdk/resource/semantic_conventions.h" +#include "opentelemetry/semconv/service_attributes.h" #include "opentelemetry/trace/span_context.h" #include "opentelemetry/trace/span_id.h" #include "opentelemetry/trace/span_metadata.h" @@ -244,9 +244,9 @@ void Recordable::SetResource(const sdk::resource::Resource &resource) noexcept { // only service.name attribute is supported by specs as of now. auto attributes = resource.GetAttributes(); - if (attributes.find(SemanticConventions::kServiceName) != attributes.end()) + if (attributes.find(semconv::service::kServiceName) != attributes.end()) { - service_name_ = nostd::get(attributes[SemanticConventions::kServiceName]); + service_name_ = nostd::get(attributes[semconv::service::kServiceName]); } } diff --git a/opentracing-shim/include/opentelemetry/opentracingshim/shim_utils.h b/opentracing-shim/include/opentelemetry/opentracingshim/shim_utils.h index 871bed590f..a7feb5efc4 100644 --- a/opentracing-shim/include/opentelemetry/opentracingshim/shim_utils.h +++ b/opentracing-shim/include/opentelemetry/opentracingshim/shim_utils.h @@ -7,7 +7,7 @@ #include "opentelemetry/opentracingshim/span_context_shim.h" -#include "opentelemetry/trace/semantic_conventions.h" +#include "opentelemetry/semconv/incubating/opentracing_attributes.h" #include "opentelemetry/trace/tracer.h" #include "opentracing/tracer.h" @@ -93,7 +93,7 @@ class LinksIterable final : public opentelemetry::trace::SpanContextKeyValueIter callback) const noexcept override { using opentracing::SpanReferenceType; - using namespace opentelemetry::trace::SemanticConventions; + using namespace opentelemetry::semconv; using LinksList = std::initializer_list>; for (const auto &entry : refs_) @@ -102,18 +102,18 @@ class LinksIterable final : public opentelemetry::trace::SpanContextKeyValueIter if (entry.first == SpanReferenceType::ChildOfRef) { - span_kind = OpentracingRefTypeValues::kChildOf; + span_kind = opentracing::OpentracingRefTypeValues::kChildOf; } else if (entry.first == SpanReferenceType::FollowsFromRef) { - span_kind = OpentracingRefTypeValues::kFollowsFrom; + span_kind = opentracing::OpentracingRefTypeValues::kFollowsFrom; } auto context_shim = SpanContextShim::extractFrom(entry.second); if (context_shim && !span_kind.empty() && !callback(context_shim->context(), opentelemetry::common::KeyValueIterableView( - {{kOpentracingRefType, span_kind}}))) + {{opentracing::kOpentracingRefType, span_kind}}))) { return false; } diff --git a/opentracing-shim/src/span_shim.cc b/opentracing-shim/src/span_shim.cc index 7911277f78..1be909f1bd 100644 --- a/opentracing-shim/src/span_shim.cc +++ b/opentracing-shim/src/span_shim.cc @@ -8,7 +8,7 @@ #include "opentelemetry/opentracingshim/span_context_shim.h" #include "opentelemetry/opentracingshim/tracer_shim.h" -#include "opentelemetry/trace/semantic_conventions.h" +#include "opentelemetry/semconv/exception_attributes.h" #include "opentelemetry/trace/span_metadata.h" #include "opentracing/ext/tags.h" @@ -134,15 +134,15 @@ void SpanShim::logImpl(nostd::span fields, { if (key == "error.kind") // - error.kind maps to exception.type. { - key = opentelemetry::trace::SemanticConventions::kExceptionType; + key = opentelemetry::semconv::exception::kExceptionType; } else if (key == "message") // - message maps to exception.message. { - key = opentelemetry::trace::SemanticConventions::kExceptionMessage; + key = opentelemetry::semconv::exception::kExceptionMessage; } else if (key == "stack") // - stack maps to exception.stacktrace. { - key = opentelemetry::trace::SemanticConventions::kExceptionStacktrace; + key = opentelemetry::semconv::exception::kExceptionStacktrace; } } diff --git a/sdk/include/opentelemetry/sdk/resource/semantic_conventions.h b/sdk/include/opentelemetry/sdk/resource/semantic_conventions.h index 9ff985be4d..1c11ba68f9 100644 --- a/sdk/include/opentelemetry/sdk/resource/semantic_conventions.h +++ b/sdk/include/opentelemetry/sdk/resource/semantic_conventions.h @@ -4,9 +4,13 @@ */ /* - DO NOT EDIT, this is an Auto-generated file - from buildscripts/semantic-convention/templates/SemanticAttributes.h.j2 -*/ + * This file is DEPRECATED, and no longer updated. + * See file DEPRECATED.md for details. + */ + +#ifdef OPENTELEMETRY_NO_DEPRECATED_CODE +# error "header is deprecated." +#endif #pragma once diff --git a/sdk/src/resource/resource.cc b/sdk/src/resource/resource.cc index 919624686d..5ae5446e80 100644 --- a/sdk/src/resource/resource.cc +++ b/sdk/src/resource/resource.cc @@ -8,8 +8,10 @@ #include "opentelemetry/nostd/variant.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/sdk/resource/resource_detector.h" -#include "opentelemetry/sdk/resource/semantic_conventions.h" #include "opentelemetry/sdk/version/version.h" +#include "opentelemetry/semconv/incubating/process_attributes.h" +#include "opentelemetry/semconv/service_attributes.h" +#include "opentelemetry/semconv/telemetry_attributes.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -36,16 +38,16 @@ Resource Resource::Create(const ResourceAttributes &attributes, const std::strin auto resource = Resource::GetDefault().Merge(otel_resource).Merge(Resource{attributes, schema_url}); - if (resource.attributes_.find(SemanticConventions::kServiceName) == resource.attributes_.end()) + if (resource.attributes_.find(semconv::service::kServiceName) == resource.attributes_.end()) { std::string default_service_name = "unknown_service"; auto it_process_executable_name = - resource.attributes_.find(SemanticConventions::kProcessExecutableName); + resource.attributes_.find(semconv::process::kProcessExecutableName); if (it_process_executable_name != resource.attributes_.end()) { default_service_name += ":" + nostd::get(it_process_executable_name->second); } - resource.attributes_[SemanticConventions::kServiceName] = default_service_name; + resource.attributes_[semconv::service::kServiceName] = default_service_name; } return resource; } @@ -59,9 +61,9 @@ Resource &Resource::GetEmpty() Resource &Resource::GetDefault() { static Resource default_resource( - {{SemanticConventions::kTelemetrySdkLanguage, "cpp"}, - {SemanticConventions::kTelemetrySdkName, "opentelemetry"}, - {SemanticConventions::kTelemetrySdkVersion, OPENTELEMETRY_SDK_VERSION}}, + {{semconv::telemetry::kTelemetrySdkLanguage, "cpp"}, + {semconv::telemetry::kTelemetrySdkName, "opentelemetry"}, + {semconv::telemetry::kTelemetrySdkVersion, OPENTELEMETRY_SDK_VERSION}}, std::string{}); return default_resource; } diff --git a/sdk/src/resource/resource_detector.cc b/sdk/src/resource/resource_detector.cc index b7c7c7e614..cab8ce748a 100644 --- a/sdk/src/resource/resource_detector.cc +++ b/sdk/src/resource/resource_detector.cc @@ -4,7 +4,7 @@ #include "opentelemetry/sdk/resource/resource_detector.h" #include "opentelemetry/sdk/common/env_variables.h" #include "opentelemetry/sdk/resource/resource.h" -#include "opentelemetry/sdk/resource/semantic_conventions.h" +#include "opentelemetry/semconv/service_attributes.h" #include "opentelemetry/version.h" #include @@ -55,7 +55,7 @@ Resource OTELResourceDetector::Detect() noexcept if (service_name_exists) { - attributes[SemanticConventions::kServiceName] = service_name; + attributes[semconv::service::kServiceName] = service_name; } return Resource(attributes); diff --git a/sdk/test/resource/resource_test.cc b/sdk/test/resource/resource_test.cc index c15087e9b7..a359cb33d4 100644 --- a/sdk/test/resource/resource_test.cc +++ b/sdk/test/resource/resource_test.cc @@ -14,8 +14,9 @@ #include "opentelemetry/sdk/common/attribute_utils.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/sdk/resource/resource_detector.h" -#include "opentelemetry/sdk/resource/semantic_conventions.h" #include "opentelemetry/sdk/version/version.h" +#include "opentelemetry/semconv/service_attributes.h" +#include "opentelemetry/semconv/telemetry_attributes.h" #if defined(_MSC_VER) # include "opentelemetry/sdk/common/env_variables.h" @@ -24,7 +25,8 @@ using opentelemetry::sdk::common::unsetenv; #endif using namespace opentelemetry::sdk::resource; -namespace nostd = opentelemetry::nostd; +namespace nostd = opentelemetry::nostd; +namespace semconv = opentelemetry::semconv; class TestResource : public Resource { @@ -41,10 +43,10 @@ TEST(ResourceTest, create_without_servicename) {"service", "backend"}, {"version", static_cast(1)}, {"cost", 234.23}, - {SemanticConventions::kTelemetrySdkLanguage, "cpp"}, - {SemanticConventions::kTelemetrySdkName, "opentelemetry"}, - {SemanticConventions::kTelemetrySdkVersion, OPENTELEMETRY_SDK_VERSION}, - {SemanticConventions::kServiceName, "unknown_service"}}; + {semconv::telemetry::kTelemetrySdkLanguage, "cpp"}, + {semconv::telemetry::kTelemetrySdkName, "opentelemetry"}, + {semconv::telemetry::kTelemetrySdkVersion, OPENTELEMETRY_SDK_VERSION}, + {semconv::service::kServiceName, "unknown_service"}}; ResourceAttributes attributes = { {"service", "backend"}, {"version", static_cast(1)}, {"cost", 234.23}}; @@ -74,10 +76,10 @@ TEST(ResourceTest, create_with_servicename) ResourceAttributes expected_attributes = { {"version", static_cast(1)}, {"cost", 234.23}, - {SemanticConventions::kTelemetrySdkLanguage, "cpp"}, - {SemanticConventions::kTelemetrySdkName, "opentelemetry"}, - {SemanticConventions::kTelemetrySdkVersion, OPENTELEMETRY_SDK_VERSION}, - {SemanticConventions::kServiceName, "backend"}, + {semconv::telemetry::kTelemetrySdkLanguage, "cpp"}, + {semconv::telemetry::kTelemetrySdkName, "opentelemetry"}, + {semconv::telemetry::kTelemetrySdkVersion, OPENTELEMETRY_SDK_VERSION}, + {semconv::service::kServiceName, "backend"}, }; ResourceAttributes attributes = { {"service.name", "backend"}, {"version", static_cast(1)}, {"cost", 234.23}}; @@ -105,10 +107,10 @@ TEST(ResourceTest, create_with_servicename) TEST(ResourceTest, create_with_emptyatrributes) { ResourceAttributes expected_attributes = { - {SemanticConventions::kTelemetrySdkLanguage, "cpp"}, - {SemanticConventions::kTelemetrySdkName, "opentelemetry"}, - {SemanticConventions::kTelemetrySdkVersion, OPENTELEMETRY_SDK_VERSION}, - {SemanticConventions::kServiceName, "unknown_service"}, + {semconv::telemetry::kTelemetrySdkLanguage, "cpp"}, + {semconv::telemetry::kTelemetrySdkName, "opentelemetry"}, + {semconv::telemetry::kTelemetrySdkVersion, OPENTELEMETRY_SDK_VERSION}, + {semconv::service::kServiceName, "unknown_service"}, }; ResourceAttributes attributes = {}; auto resource = Resource::Create(attributes); From c81a3d4d20282cefd815db499acee539a98eaef1 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Thu, 14 Nov 2024 00:34:37 +0100 Subject: [PATCH 65/89] [SEMANTIC CONVENTIONS] Upgrade to semantic conventions 1.28.0 (#3139) --- .../semconv/incubating/az_attributes.h | 7 + .../semconv/incubating/cloud_attributes.h | 2 +- .../incubating/cloudfoundry_attributes.h | 138 +++++++++ .../semconv/incubating/container_attributes.h | 22 +- .../semconv/incubating/container_metrics.h | 43 +++ .../semconv/incubating/db_attributes.h | 85 ++++-- .../semconv/incubating/db_metrics.h | 4 +- .../semconv/incubating/file_attributes.h | 91 ++++++ .../semconv/incubating/gen_ai_attributes.h | 69 ++++- .../semconv/incubating/http_attributes.h | 8 +- .../semconv/incubating/hw_attributes.h | 148 ++++++++++ .../semconv/incubating/hw_metrics.h | 174 +++++++++++ .../semconv/incubating/k8s_attributes.h | 54 ++++ .../semconv/incubating/k8s_metrics.h | 273 ++++++++++++++++++ .../semconv/incubating/log_attributes.h | 2 +- .../semconv/incubating/messaging_attributes.h | 27 +- .../semconv/incubating/messaging_metrics.h | 59 +++- .../semconv/incubating/otel_attributes.h | 8 +- .../semconv/incubating/process_attributes.h | 38 +++ .../semconv/incubating/process_metrics.h | 38 +++ .../semconv/incubating/profile_attributes.h | 81 ++++++ .../semconv/incubating/system_metrics.h | 90 +++++- .../semconv/incubating/tls_attributes.h | 2 +- .../opentelemetry/semconv/schema_url.h | 2 +- buildscripts/semantic-convention/generate.sh | 2 +- 25 files changed, 1398 insertions(+), 69 deletions(-) create mode 100644 api/include/opentelemetry/semconv/incubating/cloudfoundry_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/hw_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/hw_metrics.h create mode 100644 api/include/opentelemetry/semconv/incubating/k8s_metrics.h create mode 100644 api/include/opentelemetry/semconv/incubating/profile_attributes.h diff --git a/api/include/opentelemetry/semconv/incubating/az_attributes.h b/api/include/opentelemetry/semconv/incubating/az_attributes.h index 5e12c82f7b..2ce360d870 100644 --- a/api/include/opentelemetry/semconv/incubating/az_attributes.h +++ b/api/include/opentelemetry/semconv/incubating/az_attributes.h @@ -19,6 +19,13 @@ namespace semconv namespace az { +/** + * Azure + * Resource Provider Namespace as recognized by the client. + */ +static constexpr const char *kAzNamespace = "az.namespace"; + /** * The unique identifier of the service request. It's generated by the Azure service and returned * with the response. diff --git a/api/include/opentelemetry/semconv/incubating/cloud_attributes.h b/api/include/opentelemetry/semconv/incubating/cloud_attributes.h index cd76489eba..6720eb3edf 100644 --- a/api/include/opentelemetry/semconv/incubating/cloud_attributes.h +++ b/api/include/opentelemetry/semconv/incubating/cloud_attributes.h @@ -77,7 +77,7 @@ static constexpr const char *kCloudRegion = "cloud.region"; * href="https://docs.microsoft.com/rest/api/resources/resources/get-by-id">Fully Qualified Resource * ID of the invoked function, not the function app, having the form * @code - * /subscriptions//resourceGroups//providers/Microsoft.Web/sites//functions/ + * /subscriptions//resourceGroups//providers/Microsoft.Web/sites//functions/ * @endcode. This means that a span attribute MUST be used, as an Azure function app can host * multiple functions that would usually share a TracerProvider.

      • *
      diff --git a/api/include/opentelemetry/semconv/incubating/cloudfoundry_attributes.h b/api/include/opentelemetry/semconv/incubating/cloudfoundry_attributes.h new file mode 100644 index 0000000000..0eda006baa --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/cloudfoundry_attributes.h @@ -0,0 +1,138 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace cloudfoundry +{ + +/** + * The guid of the application. + *

      + * Application instrumentation should use the value from environment + * variable @code VCAP_APPLICATION.application_id @endcode. This is the same value as + * reported by @code cf app --guid @endcode. + */ +static constexpr const char *kCloudfoundryAppId = "cloudfoundry.app.id"; + +/** + * The index of the application instance. 0 when just one instance is active. + *

      + * CloudFoundry defines the @code instance_id @endcode in the Loggegator v2 envelope. It + * is used for logs and metrics emitted by CloudFoundry. It is supposed to contain the application + * instance index for applications deployed on the runtime.

      Application instrumentation should + * use the value from environment variable @code CF_INSTANCE_INDEX @endcode. + */ +static constexpr const char *kCloudfoundryAppInstanceId = "cloudfoundry.app.instance.id"; + +/** + * The name of the application. + *

      + * Application instrumentation should use the value from environment + * variable @code VCAP_APPLICATION.application_name @endcode. This is the same value + * as reported by @code cf apps @endcode. + */ +static constexpr const char *kCloudfoundryAppName = "cloudfoundry.app.name"; + +/** + * The guid of the CloudFoundry org the application is running in. + *

      + * Application instrumentation should use the value from environment + * variable @code VCAP_APPLICATION.org_id @endcode. This is the same value as + * reported by @code cf org --guid @endcode. + */ +static constexpr const char *kCloudfoundryOrgId = "cloudfoundry.org.id"; + +/** + * The name of the CloudFoundry organization the app is running in. + *

      + * Application instrumentation should use the value from environment + * variable @code VCAP_APPLICATION.org_name @endcode. This is the same value as + * reported by @code cf orgs @endcode. + */ +static constexpr const char *kCloudfoundryOrgName = "cloudfoundry.org.name"; + +/** + * The UID identifying the process. + *

      + * Application instrumentation should use the value from environment + * variable @code VCAP_APPLICATION.process_id @endcode. It is supposed to be equal to + * @code VCAP_APPLICATION.app_id @endcode for applications deployed to the runtime. + * For system components, this could be the actual PID. + */ +static constexpr const char *kCloudfoundryProcessId = "cloudfoundry.process.id"; + +/** + * The type of process. + *

      + * CloudFoundry applications can consist of multiple jobs. Usually the + * main process will be of type @code web @endcode. There can be additional background + * tasks or side-cars with different process types. + */ +static constexpr const char *kCloudfoundryProcessType = "cloudfoundry.process.type"; + +/** + * The guid of the CloudFoundry space the application is running in. + *

      + * Application instrumentation should use the value from environment + * variable @code VCAP_APPLICATION.space_id @endcode. This is the same value as + * reported by @code cf space --guid @endcode. + */ +static constexpr const char *kCloudfoundrySpaceId = "cloudfoundry.space.id"; + +/** + * The name of the CloudFoundry space the application is running in. + *

      + * Application instrumentation should use the value from environment + * variable @code VCAP_APPLICATION.space_name @endcode. This is the same value as + * reported by @code cf spaces @endcode. + */ +static constexpr const char *kCloudfoundrySpaceName = "cloudfoundry.space.name"; + +/** + * A guid or another name describing the event source. + *

      + * CloudFoundry defines the @code source_id @endcode in the Loggregator v2 envelope. + * It is used for logs and metrics emitted by CloudFoundry. It is + * supposed to contain the component name, e.g. "gorouter", for + * CloudFoundry components. + *

      + * When system components are instrumented, values from the + * Bosh spec + * should be used. The @code system.id @endcode should be set to + * @code spec.deployment/spec.name @endcode. + */ +static constexpr const char *kCloudfoundrySystemId = "cloudfoundry.system.id"; + +/** + * A guid describing the concrete instance of the event source. + *

      + * CloudFoundry defines the @code instance_id @endcode in the Loggregator v2 envelope. + * It is used for logs and metrics emitted by CloudFoundry. It is + * supposed to contain the vm id for CloudFoundry components. + *

      + * When system components are instrumented, values from the + * Bosh spec + * should be used. The @code system.instance.id @endcode should be set to @code spec.id @endcode. + */ +static constexpr const char *kCloudfoundrySystemInstanceId = "cloudfoundry.system.instance.id"; + +} // namespace cloudfoundry +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/container_attributes.h b/api/include/opentelemetry/semconv/incubating/container_attributes.h index 5bd1118c3b..2ea7810b30 100644 --- a/api/include/opentelemetry/semconv/incubating/container_attributes.h +++ b/api/include/opentelemetry/semconv/incubating/container_attributes.h @@ -28,12 +28,12 @@ namespace container static constexpr const char *kContainerCommand = "container.command"; /** - * All the command arguments (including the command/executable itself) run by the container. [2] + * All the command arguments (including the command/executable itself) run by the container. */ static constexpr const char *kContainerCommandArgs = "container.command_args"; /** - * The full command run by the container as a single string representing the full command. [2] + * The full command run by the container as a single string representing the full command. */ static constexpr const char *kContainerCommandLine = "container.command_line"; @@ -46,9 +46,25 @@ static constexpr const char *kContainerCommandLine = "container.command_line"; OPENTELEMETRY_DEPRECATED static constexpr const char *kContainerCpuState = "container.cpu.state"; +/** + * The name of the CSI (Container + * Storage Interface) plugin used by the volume.

      This can sometimes be referred to as a + * "driver" in CSI implementations. This should represent the @code name @endcode field of the + * GetPluginInfo RPC. + */ +static constexpr const char *kContainerCsiPluginName = "container.csi.plugin.name"; + +/** + * The unique volume ID returned by the CSI (Container Storage Interface) + * plugin.

      This can sometimes be referred to as a "volume handle" in CSI implementations. This + * should represent the @code Volume.volume_id @endcode field in CSI spec. + */ +static constexpr const char *kContainerCsiVolumeId = "container.csi.volume.id"; + /** * Container ID. Usually a UUID, as for example used to identify Docker + * href="https://docs.docker.com/engine/containers/run/#container-identification">identify Docker * containers. The UUID might be abbreviated. */ static constexpr const char *kContainerId = "container.id"; diff --git a/api/include/opentelemetry/semconv/incubating/container_metrics.h b/api/include/opentelemetry/semconv/incubating/container_metrics.h index e670fb3788..8fa2541b32 100644 --- a/api/include/opentelemetry/semconv/incubating/container_metrics.h +++ b/api/include/opentelemetry/semconv/incubating/container_metrics.h @@ -59,6 +59,49 @@ CreateAsyncDoubleMetricContainerCpuTime(metrics::Meter *meter) unitMetricContainerCpuTime); } +/** + * Container's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs + *

      + * CPU usage of the specific container on all available CPU cores, averaged over the sample window + *

      + * gauge + */ +static constexpr const char *kMetricContainerCpuUsage = "metric.container.cpu.usage"; +static constexpr const char *descrMetricContainerCpuUsage = + "Container's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs"; +static constexpr const char *unitMetricContainerCpuUsage = "{cpu}"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricContainerCpuUsage( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricContainerCpuUsage, descrMetricContainerCpuUsage, + unitMetricContainerCpuUsage); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricContainerCpuUsage( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricContainerCpuUsage, descrMetricContainerCpuUsage, + unitMetricContainerCpuUsage); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricContainerCpuUsage(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricContainerCpuUsage, descrMetricContainerCpuUsage, + unitMetricContainerCpuUsage); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricContainerCpuUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricContainerCpuUsage, descrMetricContainerCpuUsage, + unitMetricContainerCpuUsage); +} + /** * Disk bytes for the container. *

      diff --git a/api/include/opentelemetry/semconv/incubating/db_attributes.h b/api/include/opentelemetry/semconv/incubating/db_attributes.h index 940f88b7da..7c5d3304bb 100644 --- a/api/include/opentelemetry/semconv/incubating/db_attributes.h +++ b/api/include/opentelemetry/semconv/incubating/db_attributes.h @@ -102,7 +102,8 @@ static constexpr const char *kDbClientConnectionsState = "db.client.connections. * first collection name found in the query and it SHOULD match the value provided in the query text * including any schema and database name prefix. For batch operations, if the individual operations * are known to have the same collection name then that collection name SHOULD be used, otherwise - * @code db.collection.name @endcode SHOULD NOT be captured. + * @code db.collection.name @endcode SHOULD NOT be captured. This attribute has stability level + * RELEASE CANDIDATE. */ static constexpr const char *kDbCollectionName = "db.collection.name"; @@ -110,7 +111,7 @@ static constexpr const char *kDbCollectionName = "db.collection.name"; * Deprecated, use @code server.address @endcode, @code server.port @endcode attributes instead. *

      * @deprecated - * "Replaced by @code server.address @endcode and @code server.port @endcode." + * Replaced by @code server.address @endcode and @code server.port @endcode. */ OPENTELEMETRY_DEPRECATED static constexpr const char *kDbConnectionString = "db.connection_string"; @@ -135,7 +136,7 @@ OPENTELEMETRY_DEPRECATED static constexpr const char *kDbCosmosdbContainer = "db.cosmosdb.container"; /** - * CosmosDB Operation Type. + * Cosmos DB Operation Type. */ static constexpr const char *kDbCosmosdbOperationType = "db.cosmosdb.operation_type"; @@ -150,8 +151,12 @@ static constexpr const char *kDbCosmosdbRequestCharge = "db.cosmosdb.request_cha static constexpr const char *kDbCosmosdbRequestContentLength = "db.cosmosdb.request_content_length"; /** - * Cosmos DB status code. + * Deprecated, use @code db.response.status_code @endcode instead. + *

      + * @deprecated + * Replaced by @code db.response.status_code @endcode. */ +OPENTELEMETRY_DEPRECATED static constexpr const char *kDbCosmosdbStatusCode = "db.cosmosdb.status_code"; /** @@ -239,7 +244,8 @@ static constexpr const char *kDbName = "db.name"; * namespaces, to ensure that "startswith" queries for the more general namespaces will be valid. * Semantic conventions for individual database systems SHOULD document what @code db.namespace * @endcode means in the context of that system. It is RECOMMENDED to capture the value as provided - * by the application without attempting to do any case normalization. + * by the application without attempting to do any case normalization. This attribute has stability + * level RELEASE CANDIDATE. */ static constexpr const char *kDbNamespace = "db.namespace"; @@ -253,10 +259,11 @@ OPENTELEMETRY_DEPRECATED static constexpr const char *kDbOperation = "db.operation"; /** - * The number of queries included in a batch operation.

      Operations are - * only considered batches when they contain two or more operations, and so @code - * db.operation.batch.size @endcode SHOULD never be @code 1 @endcode. + * The number of queries included in a batch operation. + *

      + * Operations are only considered batches when they contain two or more operations, and so @code + * db.operation.batch.size @endcode SHOULD never be @code 1 @endcode. This attribute has stability + * level RELEASE CANDIDATE. */ static constexpr const char *kDbOperationBatchSize = "db.operation.batch.size"; @@ -268,7 +275,8 @@ static constexpr const char *kDbOperationBatchSize = "db.operation.batch.size"; * first operation name found in the query. For batch operations, if the individual operations are * known to have the same operation name then that operation name SHOULD be used prepended by @code * BATCH @endcode, otherwise @code db.operation.name @endcode SHOULD be @code BATCH @endcode or - * some other database system specific term if more applicable. + * some other database system specific term if more applicable. This attribute has stability level + * RELEASE CANDIDATE. */ static constexpr const char *kDbOperationName = "db.operation.name"; @@ -277,7 +285,7 @@ static constexpr const char *kDbOperationName = "db.operation.name"; * parameter name, and the attribute value being a string representation of the parameter value.

      * Query parameters should only be captured when @code db.query.text @endcode is parameterized with * placeholders. If a parameter has no name and instead is referenced only by index, then @code - * @endcode SHOULD be the 0-based index. + * @endcode SHOULD be the 0-based index. This attribute has stability level RELEASE CANDIDATE. */ static constexpr const char *kDbQueryParameter = "db.query.parameter"; @@ -292,7 +300,8 @@ static constexpr const char *kDbQueryParameter = "db.query.parameter"; * specific separator if more applicable. Even though parameterized query text can potentially have * sensitive data, by using a parameterized query the user is giving a strong signal that any * sensitive data will be passed as parameter values, and the benefit to observability of capturing - * the static part of the query text by default outweighs the risk. + * the static part of the query text by default outweighs the risk. This attribute has stability + * level RELEASE CANDIDATE. */ static constexpr const char *kDbQueryText = "db.query.text"; @@ -305,6 +314,17 @@ static constexpr const char *kDbQueryText = "db.query.text"; OPENTELEMETRY_DEPRECATED static constexpr const char *kDbRedisDatabaseIndex = "db.redis.database_index"; +/** + * Database response status code. + *

      + * The status code returned by the database. Usually it represents an error code, but may also + * represent partial success, warning, or differentiate between various types of successful + * outcomes. Semantic conventions for individual database systems SHOULD document what @code + * db.response.status_code @endcode means in the context of that system. This attribute has + * stability level RELEASE CANDIDATE. + */ +static constexpr const char *kDbResponseStatusCode = "db.response.status_code"; + /** * Deprecated, use @code db.collection.name @endcode instead. *

      @@ -328,7 +348,8 @@ static constexpr const char *kDbStatement = "db.statement"; *

      * The actual DBMS may differ from the one identified by the client. For example, when using * PostgreSQL client libraries to connect to a CockroachDB, the @code db.system @endcode is set to - * @code postgresql @endcode based on the instrumentation's best knowledge. + * @code postgresql @endcode based on the instrumentation's best knowledge. This attribute has + * stability level RELEASE CANDIDATE. */ static constexpr const char *kDbSystem = "db.system"; @@ -447,77 +468,77 @@ namespace DbCosmosdbOperationTypeValues /** * none */ -static constexpr const char *kInvalid = "Invalid"; +static constexpr const char *kBatch = "batch"; /** * none */ -static constexpr const char *kCreate = "Create"; +static constexpr const char *kCreate = "create"; /** * none */ -static constexpr const char *kPatch = "Patch"; +static constexpr const char *kDelete = "delete"; /** * none */ -static constexpr const char *kRead = "Read"; +static constexpr const char *kExecute = "execute"; /** * none */ -static constexpr const char *kReadFeed = "ReadFeed"; +static constexpr const char *kExecuteJavascript = "execute_javascript"; /** * none */ -static constexpr const char *kDelete = "Delete"; +static constexpr const char *kInvalid = "invalid"; /** * none */ -static constexpr const char *kReplace = "Replace"; +static constexpr const char *kHead = "head"; /** * none */ -static constexpr const char *kExecute = "Execute"; +static constexpr const char *kHeadFeed = "head_feed"; /** * none */ -static constexpr const char *kQuery = "Query"; +static constexpr const char *kPatch = "patch"; /** * none */ -static constexpr const char *kHead = "Head"; +static constexpr const char *kQuery = "query"; /** * none */ -static constexpr const char *kHeadFeed = "HeadFeed"; +static constexpr const char *kQueryPlan = "query_plan"; /** * none */ -static constexpr const char *kUpsert = "Upsert"; +static constexpr const char *kRead = "read"; /** * none */ -static constexpr const char *kBatch = "Batch"; +static constexpr const char *kReadFeed = "read_feed"; /** * none */ -static constexpr const char *kQueryPlan = "QueryPlan"; +static constexpr const char *kReplace = "replace"; /** * none */ -static constexpr const char *kExecuteJavascript = "ExecuteJavaScript"; +static constexpr const char *kUpsert = "upsert"; } // namespace DbCosmosdbOperationTypeValues @@ -695,7 +716,7 @@ static constexpr const char *kInstantdb = "instantdb"; static constexpr const char *kInterbase = "interbase"; /** - * MariaDB + * MariaDB (This value has stability level RELEASE CANDIDATE) */ static constexpr const char *kMariadb = "mariadb"; @@ -715,7 +736,7 @@ static constexpr const char *kMemcached = "memcached"; static constexpr const char *kMongodb = "mongodb"; /** - * Microsoft SQL Server + * Microsoft SQL Server (This value has stability level RELEASE CANDIDATE) */ static constexpr const char *kMssql = "mssql"; @@ -729,7 +750,7 @@ OPENTELEMETRY_DEPRECATED static constexpr const char *kMssqlcompact = "mssqlcompact"; /** - * MySQL + * MySQL (This value has stability level RELEASE CANDIDATE) */ static constexpr const char *kMysql = "mysql"; @@ -764,7 +785,7 @@ static constexpr const char *kPervasive = "pervasive"; static constexpr const char *kPointbase = "pointbase"; /** - * PostgreSQL + * PostgreSQL (This value has stability level RELEASE CANDIDATE) */ static constexpr const char *kPostgresql = "postgresql"; diff --git a/api/include/opentelemetry/semconv/incubating/db_metrics.h b/api/include/opentelemetry/semconv/incubating/db_metrics.h index 6ea8e095c7..d3dd52190e 100644 --- a/api/include/opentelemetry/semconv/incubating/db_metrics.h +++ b/api/include/opentelemetry/semconv/incubating/db_metrics.h @@ -217,14 +217,14 @@ CreateAsyncDoubleMetricDbClientConnectionMax(metrics::Meter *meter) } /** - * The number of pending requests for an open connection, cumulative for the entire pool + * The number of current pending requests for an open connection *

      * updowncounter */ static constexpr const char *kMetricDbClientConnectionPendingRequests = "metric.db.client.connection.pending_requests"; static constexpr const char *descrMetricDbClientConnectionPendingRequests = - "The number of pending requests for an open connection, cumulative for the entire pool"; + "The number of current pending requests for an open connection"; static constexpr const char *unitMetricDbClientConnectionPendingRequests = "{request}"; static inline nostd::unique_ptr> diff --git a/api/include/opentelemetry/semconv/incubating/file_attributes.h b/api/include/opentelemetry/semconv/incubating/file_attributes.h index eb65a811ec..2ac4fc4b55 100644 --- a/api/include/opentelemetry/semconv/incubating/file_attributes.h +++ b/api/include/opentelemetry/semconv/incubating/file_attributes.h @@ -19,6 +19,40 @@ namespace semconv namespace file { +/** + * Time when the file was last accessed, in ISO 8601 format. + *

      + * This attribute might not be supported by some file systems — NFS, FAT32, in embedded OS, etc. + */ +static constexpr const char *kFileAccessed = "file.accessed"; + +/** + * Array of file attributes. + *

      + * Attributes names depend on the OS or file system. Here’s a non-exhaustive list of values expected + * for this attribute: @code archive @endcode, @code compressed @endcode, @code directory @endcode, + * @code encrypted @endcode, @code execute @endcode, @code hidden @endcode, @code immutable + * @endcode, @code journaled @endcode, @code read @endcode, @code readonly @endcode, @code symbolic + * link @endcode, @code system @endcode, @code temporary @endcode, @code write @endcode. + */ +static constexpr const char *kFileAttributes = "file.attributes"; + +/** + * Time when the file attributes or metadata was last changed, in ISO 8601 format. + *

      + * @code file.changed @endcode captures the time when any of the file's properties or attributes + * (including the content) are changed, while @code file.modified @endcode captures the timestamp + * when the file content is modified. + */ +static constexpr const char *kFileChanged = "file.changed"; + +/** + * Time when the file was created, in ISO 8601 format. + *

      + * This attribute might not be supported by some file systems — NFS, FAT32, in embedded OS, etc. + */ +static constexpr const char *kFileCreated = "file.created"; + /** * Directory where the file is located. It should include the drive letter, when appropriate. */ @@ -32,11 +66,61 @@ static constexpr const char *kFileDirectory = "file.directory"; */ static constexpr const char *kFileExtension = "file.extension"; +/** + * Name of the fork. A fork is additional data associated with a filesystem object. + *

      + * On Linux, a resource fork is used to store additional data with a filesystem object. A file + * always has at least one fork for the data portion, and additional forks may exist. On NTFS, this + * is analogous to an Alternate Data Stream (ADS), and the default data stream for a file is just + * called $DATA. Zone.Identifier is commonly used by Windows to track contents downloaded from the + * Internet. An ADS is typically of the form: C:\path\to\filename.extension:some_fork_name, and + * some_fork_name is the value that should populate @code fork_name @endcode. @code + * filename.extension @endcode should populate @code file.name @endcode, and @code extension + * @endcode should populate @code file.extension @endcode. The full path, @code file.path @endcode, + * will include the fork name. + */ +static constexpr const char *kFileForkName = "file.fork_name"; + +/** + * Primary Group ID (GID) of the file. + */ +static constexpr const char *kFileGroupId = "file.group.id"; + +/** + * Primary group name of the file. + */ +static constexpr const char *kFileGroupName = "file.group.name"; + +/** + * Inode representing the file in the filesystem. + */ +static constexpr const char *kFileInode = "file.inode"; + +/** + * Mode of the file in octal representation. + */ +static constexpr const char *kFileMode = "file.mode"; + +/** + * Time when the file content was last modified, in ISO 8601 format. + */ +static constexpr const char *kFileModified = "file.modified"; + /** * Name of the file including the extension, without the directory. */ static constexpr const char *kFileName = "file.name"; +/** + * The user ID (UID) or security identifier (SID) of the file owner. + */ +static constexpr const char *kFileOwnerId = "file.owner.id"; + +/** + * Username of the file owner. + */ +static constexpr const char *kFileOwnerName = "file.owner.name"; + /** * Full path to the file, including the file name. It should include the drive letter, when * appropriate. @@ -48,6 +132,13 @@ static constexpr const char *kFilePath = "file.path"; */ static constexpr const char *kFileSize = "file.size"; +/** + * Path to the target of a symbolic link. + *

      + * This attribute is only applicable to symbolic links. + */ +static constexpr const char *kFileSymbolicLinkTargetPath = "file.symbolic_link.target_path"; + } // namespace file } // namespace semconv OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/gen_ai_attributes.h b/api/include/opentelemetry/semconv/incubating/gen_ai_attributes.h index 03f2eebc2c..ce4a939d07 100644 --- a/api/include/opentelemetry/semconv/incubating/gen_ai_attributes.h +++ b/api/include/opentelemetry/semconv/incubating/gen_ai_attributes.h @@ -20,13 +20,36 @@ namespace gen_ai { /** - * The full response received from the GenAI model. + * Deprecated, use Event API to report completions contents. *

      - * It's RECOMMENDED to format completions as JSON string matching OpenAI messages format + * @deprecated + * Removed, no replacement at this time. */ +OPENTELEMETRY_DEPRECATED static constexpr const char *kGenAiCompletion = "gen_ai.completion"; +/** + * The response format that is requested. + */ +static constexpr const char *kGenAiOpenaiRequestResponseFormat = + "gen_ai.openai.request.response_format"; + +/** + * Requests with same seed value more likely to return same result. + */ +static constexpr const char *kGenAiOpenaiRequestSeed = "gen_ai.openai.request.seed"; + +/** + * The service tier requested. May be a specific tier, detault, or auto. + */ +static constexpr const char *kGenAiOpenaiRequestServiceTier = "gen_ai.openai.request.service_tier"; + +/** + * The service tier used for the response. + */ +static constexpr const char *kGenAiOpenaiResponseServiceTier = + "gen_ai.openai.response.service_tier"; + /** * The name of the operation being performed. *

      @@ -38,11 +61,12 @@ static constexpr const char *kGenAiCompletion = "gen_ai.completion"; static constexpr const char *kGenAiOperationName = "gen_ai.operation.name"; /** - * The full prompt sent to the GenAI model. + * Deprecated, use Event API to report prompt contents. *

      - * It's RECOMMENDED to format prompts as JSON string matching OpenAI messages format + * @deprecated + * Removed, no replacement at this time. */ +OPENTELEMETRY_DEPRECATED static constexpr const char *kGenAiPrompt = "gen_ai.prompt"; /** @@ -146,6 +170,39 @@ static constexpr const char *kGenAiUsageOutputTokens = "gen_ai.usage.output_toke OPENTELEMETRY_DEPRECATED static constexpr const char *kGenAiUsagePromptTokens = "gen_ai.usage.prompt_tokens"; +namespace GenAiOpenaiRequestResponseFormatValues +{ +/** + * Text response format + */ +static constexpr const char *kText = "text"; + +/** + * JSON object response format + */ +static constexpr const char *kJsonObject = "json_object"; + +/** + * JSON schema response format + */ +static constexpr const char *kJsonSchema = "json_schema"; + +} // namespace GenAiOpenaiRequestResponseFormatValues + +namespace GenAiOpenaiRequestServiceTierValues +{ +/** + * The system will utilize scale tier credits until they are exhausted. + */ +static constexpr const char *kAuto = "auto"; + +/** + * The system will utilize the default scale tier. + */ +static constexpr const char *kDefault = "default"; + +} // namespace GenAiOpenaiRequestServiceTierValues + namespace GenAiOperationNameValues { /** diff --git a/api/include/opentelemetry/semconv/incubating/http_attributes.h b/api/include/opentelemetry/semconv/incubating/http_attributes.h index 3e06e4e925..8f909f5297 100644 --- a/api/include/opentelemetry/semconv/incubating/http_attributes.h +++ b/api/include/opentelemetry/semconv/incubating/http_attributes.h @@ -126,10 +126,10 @@ static constexpr const char *kHttpRequestResendCount = "http.request.resend_coun static constexpr const char *kHttpRequestSize = "http.request.size"; /** - * Deprecated, use @code http.request.header.content-length @endcode instead. + * Deprecated, use @code http.request.header. @endcode instead. *

      * @deprecated - * Replaced by @code http.request.header.content-length @endcode. + * Replaced by @code http.request.header. @endcode. */ OPENTELEMETRY_DEPRECATED static constexpr const char *kHttpRequestContentLength = "http.request_content_length"; @@ -177,10 +177,10 @@ static constexpr const char *kHttpResponseSize = "http.response.size"; static constexpr const char *kHttpResponseStatusCode = "http.response.status_code"; /** - * Deprecated, use @code http.response.header.content-length @endcode instead. + * Deprecated, use @code http.response.header. @endcode instead. *

      * @deprecated - * Replaced by @code http.response.header.content-length @endcode. + * Replaced by @code http.response.header. @endcode. */ OPENTELEMETRY_DEPRECATED static constexpr const char *kHttpResponseContentLength = "http.response_content_length"; diff --git a/api/include/opentelemetry/semconv/incubating/hw_attributes.h b/api/include/opentelemetry/semconv/incubating/hw_attributes.h new file mode 100644 index 0000000000..d87fe1f3db --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/hw_attributes.h @@ -0,0 +1,148 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace hw +{ + +/** + * An identifier for the hardware component, unique within the monitored host + */ +static constexpr const char *kHwId = "hw.id"; + +/** + * An easily-recognizable name for the hardware component + */ +static constexpr const char *kHwName = "hw.name"; + +/** + * Unique identifier of the parent component (typically the @code hw.id @endcode attribute of the + * enclosure, or disk controller) + */ +static constexpr const char *kHwParent = "hw.parent"; + +/** + * The current state of the component + */ +static constexpr const char *kHwState = "hw.state"; + +/** + * Type of the component + *

      + * Describes the category of the hardware component for which @code hw.state @endcode is being + * reported. For example, @code hw.type=temperature @endcode along with @code hw.state=degraded + * @endcode would indicate that the temperature of the hardware component has been reported as @code + * degraded @endcode. + */ +static constexpr const char *kHwType = "hw.type"; + +namespace HwStateValues +{ +/** + * Ok + */ +static constexpr const char *kOk = "ok"; + +/** + * Degraded + */ +static constexpr const char *kDegraded = "degraded"; + +/** + * Failed + */ +static constexpr const char *kFailed = "failed"; + +} // namespace HwStateValues + +namespace HwTypeValues +{ +/** + * Battery + */ +static constexpr const char *kBattery = "battery"; + +/** + * CPU + */ +static constexpr const char *kCpu = "cpu"; + +/** + * Disk controller + */ +static constexpr const char *kDiskController = "disk_controller"; + +/** + * Enclosure + */ +static constexpr const char *kEnclosure = "enclosure"; + +/** + * Fan + */ +static constexpr const char *kFan = "fan"; + +/** + * GPU + */ +static constexpr const char *kGpu = "gpu"; + +/** + * Logical disk + */ +static constexpr const char *kLogicalDisk = "logical_disk"; + +/** + * Memory + */ +static constexpr const char *kMemory = "memory"; + +/** + * Network + */ +static constexpr const char *kNetwork = "network"; + +/** + * Physical disk + */ +static constexpr const char *kPhysicalDisk = "physical_disk"; + +/** + * Power supply + */ +static constexpr const char *kPowerSupply = "power_supply"; + +/** + * Tape drive + */ +static constexpr const char *kTapeDrive = "tape_drive"; + +/** + * Temperature + */ +static constexpr const char *kTemperature = "temperature"; + +/** + * Voltage + */ +static constexpr const char *kVoltage = "voltage"; + +} // namespace HwTypeValues + +} // namespace hw +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/hw_metrics.h b/api/include/opentelemetry/semconv/incubating/hw_metrics.h new file mode 100644 index 0000000000..3a87fd2506 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/hw_metrics.h @@ -0,0 +1,174 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace hw +{ + +/** + * Energy consumed by the component + *

      + * counter + */ +static constexpr const char *kMetricHwEnergy = "metric.hw.energy"; +static constexpr const char *descrMetricHwEnergy = "Energy consumed by the component"; +static constexpr const char *unitMetricHwEnergy = "J"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricHwEnergy( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricHwEnergy, descrMetricHwEnergy, unitMetricHwEnergy); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwEnergy( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricHwEnergy, descrMetricHwEnergy, unitMetricHwEnergy); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricHwEnergy( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricHwEnergy, descrMetricHwEnergy, + unitMetricHwEnergy); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricHwEnergy( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricHwEnergy, descrMetricHwEnergy, + unitMetricHwEnergy); +} + +/** + * Number of errors encountered by the component + *

      + * counter + */ +static constexpr const char *kMetricHwErrors = "metric.hw.errors"; +static constexpr const char *descrMetricHwErrors = "Number of errors encountered by the component"; +static constexpr const char *unitMetricHwErrors = "{error}"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricHwErrors( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricHwErrors, descrMetricHwErrors, unitMetricHwErrors); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwErrors( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricHwErrors, descrMetricHwErrors, unitMetricHwErrors); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricHwErrors( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricHwErrors, descrMetricHwErrors, + unitMetricHwErrors); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricHwErrors( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricHwErrors, descrMetricHwErrors, + unitMetricHwErrors); +} + +/** + * Instantaneous power consumed by the component + *

      + * It is recommended to report @code hw.energy @endcode instead of @code hw.power @endcode when + * possible.

      gauge + */ +static constexpr const char *kMetricHwPower = "metric.hw.power"; +static constexpr const char *descrMetricHwPower = "Instantaneous power consumed by the component"; +static constexpr const char *unitMetricHwPower = "W"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricHwPower( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricHwPower, descrMetricHwPower, unitMetricHwPower); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwPower( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricHwPower, descrMetricHwPower, unitMetricHwPower); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr CreateAsyncInt64MetricHwPower( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricHwPower, descrMetricHwPower, unitMetricHwPower); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricHwPower( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricHwPower, descrMetricHwPower, unitMetricHwPower); +} + +/** + * Operational status: @code 1 @endcode (true) or @code 0 @endcode (false) for each of the possible + * states

      + * @code hw.status @endcode is currently specified as an UpDownCounter but would ideally be + * represented using a StateSet + * as defined in OpenMetrics. This semantic convention will be updated once StateSet is + * specified in OpenTelemetry. This planned change is not expected to have any consequence on the + * way users query their timeseries backend to retrieve the values of @code hw.status @endcode over + * time.

      updowncounter + */ +static constexpr const char *kMetricHwStatus = "metric.hw.status"; +static constexpr const char *descrMetricHwStatus = + "Operational status: `1` (true) or `0` (false) for each of the possible states"; +static constexpr const char *unitMetricHwStatus = "1"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricHwStatus( + metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricHwStatus, descrMetricHwStatus, unitMetricHwStatus); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwStatus( + metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricHwStatus, descrMetricHwStatus, unitMetricHwStatus); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricHwStatus( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricHwStatus, descrMetricHwStatus, + unitMetricHwStatus); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricHwStatus( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricHwStatus, descrMetricHwStatus, + unitMetricHwStatus); +} + +} // namespace hw +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/k8s_attributes.h b/api/include/opentelemetry/semconv/incubating/k8s_attributes.h index 2d51d057c7..ba40b45409 100644 --- a/api/include/opentelemetry/semconv/incubating/k8s_attributes.h +++ b/api/include/opentelemetry/semconv/incubating/k8s_attributes.h @@ -175,6 +175,60 @@ static constexpr const char *kK8sStatefulsetName = "k8s.statefulset.name"; */ static constexpr const char *kK8sStatefulsetUid = "k8s.statefulset.uid"; +/** + * The name of the K8s volume. + */ +static constexpr const char *kK8sVolumeName = "k8s.volume.name"; + +/** + * The type of the K8s volume. + */ +static constexpr const char *kK8sVolumeType = "k8s.volume.type"; + +namespace K8sVolumeTypeValues +{ +/** + * A persistentVolumeClaim + * volume + */ +static constexpr const char *kPersistentVolumeClaim = "persistentVolumeClaim"; + +/** + * A configMap + * volume + */ +static constexpr const char *kConfigMap = "configMap"; + +/** + * A downwardAPI + * volume + */ +static constexpr const char *kDownwardApi = "downwardAPI"; + +/** + * An emptyDir + * volume + */ +static constexpr const char *kEmptyDir = "emptyDir"; + +/** + * A secret + * volume + */ +static constexpr const char *kSecret = "secret"; + +/** + * A local + * volume + */ +static constexpr const char *kLocal = "local"; + +} // namespace K8sVolumeTypeValues + } // namespace k8s } // namespace semconv OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/k8s_metrics.h b/api/include/opentelemetry/semconv/incubating/k8s_metrics.h new file mode 100644 index 0000000000..2753ba4be1 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/k8s_metrics.h @@ -0,0 +1,273 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace k8s +{ + +/** + * Total CPU time consumed + *

      + * Total CPU time consumed by the specific Node on all available CPU cores + *

      + * counter + */ +static constexpr const char *kMetricK8sNodeCpuTime = "metric.k8s.node.cpu.time"; +static constexpr const char *descrMetricK8sNodeCpuTime = "Total CPU time consumed"; +static constexpr const char *unitMetricK8sNodeCpuTime = "s"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricK8sNodeCpuTime( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricK8sNodeCpuTime, descrMetricK8sNodeCpuTime, + unitMetricK8sNodeCpuTime); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricK8sNodeCpuTime( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricK8sNodeCpuTime, descrMetricK8sNodeCpuTime, + unitMetricK8sNodeCpuTime); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricK8sNodeCpuTime( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricK8sNodeCpuTime, descrMetricK8sNodeCpuTime, + unitMetricK8sNodeCpuTime); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricK8sNodeCpuTime(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricK8sNodeCpuTime, descrMetricK8sNodeCpuTime, + unitMetricK8sNodeCpuTime); +} + +/** + * Node's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs + *

      + * CPU usage of the specific Node on all available CPU cores, averaged over the sample window + *

      + * gauge + */ +static constexpr const char *kMetricK8sNodeCpuUsage = "metric.k8s.node.cpu.usage"; +static constexpr const char *descrMetricK8sNodeCpuUsage = + "Node's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs"; +static constexpr const char *unitMetricK8sNodeCpuUsage = "{cpu}"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricK8sNodeCpuUsage( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricK8sNodeCpuUsage, descrMetricK8sNodeCpuUsage, + unitMetricK8sNodeCpuUsage); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricK8sNodeCpuUsage( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricK8sNodeCpuUsage, descrMetricK8sNodeCpuUsage, + unitMetricK8sNodeCpuUsage); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricK8sNodeCpuUsage(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricK8sNodeCpuUsage, descrMetricK8sNodeCpuUsage, + unitMetricK8sNodeCpuUsage); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricK8sNodeCpuUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricK8sNodeCpuUsage, descrMetricK8sNodeCpuUsage, + unitMetricK8sNodeCpuUsage); +} + +/** + * Memory usage of the Node + *

      + * Total memory usage of the Node + *

      + * gauge + */ +static constexpr const char *kMetricK8sNodeMemoryUsage = "metric.k8s.node.memory.usage"; +static constexpr const char *descrMetricK8sNodeMemoryUsage = "Memory usage of the Node"; +static constexpr const char *unitMetricK8sNodeMemoryUsage = "By"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricK8sNodeMemoryUsage( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricK8sNodeMemoryUsage, descrMetricK8sNodeMemoryUsage, + unitMetricK8sNodeMemoryUsage); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricK8sNodeMemoryUsage( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricK8sNodeMemoryUsage, descrMetricK8sNodeMemoryUsage, + unitMetricK8sNodeMemoryUsage); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricK8sNodeMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricK8sNodeMemoryUsage, descrMetricK8sNodeMemoryUsage, + unitMetricK8sNodeMemoryUsage); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricK8sNodeMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge( + kMetricK8sNodeMemoryUsage, descrMetricK8sNodeMemoryUsage, unitMetricK8sNodeMemoryUsage); +} + +/** + * Total CPU time consumed + *

      + * Total CPU time consumed by the specific Pod on all available CPU cores + *

      + * counter + */ +static constexpr const char *kMetricK8sPodCpuTime = "metric.k8s.pod.cpu.time"; +static constexpr const char *descrMetricK8sPodCpuTime = "Total CPU time consumed"; +static constexpr const char *unitMetricK8sPodCpuTime = "s"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricK8sPodCpuTime( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricK8sPodCpuTime, descrMetricK8sPodCpuTime, + unitMetricK8sPodCpuTime); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricK8sPodCpuTime( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricK8sPodCpuTime, descrMetricK8sPodCpuTime, + unitMetricK8sPodCpuTime); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricK8sPodCpuTime( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricK8sPodCpuTime, descrMetricK8sPodCpuTime, + unitMetricK8sPodCpuTime); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricK8sPodCpuTime( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricK8sPodCpuTime, descrMetricK8sPodCpuTime, + unitMetricK8sPodCpuTime); +} + +/** + * Pod's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs + *

      + * CPU usage of the specific Pod on all available CPU cores, averaged over the sample window + *

      + * gauge + */ +static constexpr const char *kMetricK8sPodCpuUsage = "metric.k8s.pod.cpu.usage"; +static constexpr const char *descrMetricK8sPodCpuUsage = + "Pod's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs"; +static constexpr const char *unitMetricK8sPodCpuUsage = "{cpu}"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricK8sPodCpuUsage( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricK8sPodCpuUsage, descrMetricK8sPodCpuUsage, + unitMetricK8sPodCpuUsage); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricK8sPodCpuUsage( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricK8sPodCpuUsage, descrMetricK8sPodCpuUsage, + unitMetricK8sPodCpuUsage); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr CreateAsyncInt64MetricK8sPodCpuUsage( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricK8sPodCpuUsage, descrMetricK8sPodCpuUsage, + unitMetricK8sPodCpuUsage); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricK8sPodCpuUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricK8sPodCpuUsage, descrMetricK8sPodCpuUsage, + unitMetricK8sPodCpuUsage); +} + +/** + * Memory usage of the Pod + *

      + * Total memory usage of the Pod + *

      + * gauge + */ +static constexpr const char *kMetricK8sPodMemoryUsage = "metric.k8s.pod.memory.usage"; +static constexpr const char *descrMetricK8sPodMemoryUsage = "Memory usage of the Pod"; +static constexpr const char *unitMetricK8sPodMemoryUsage = "By"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricK8sPodMemoryUsage( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricK8sPodMemoryUsage, descrMetricK8sPodMemoryUsage, + unitMetricK8sPodMemoryUsage); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricK8sPodMemoryUsage( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricK8sPodMemoryUsage, descrMetricK8sPodMemoryUsage, + unitMetricK8sPodMemoryUsage); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricK8sPodMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricK8sPodMemoryUsage, descrMetricK8sPodMemoryUsage, + unitMetricK8sPodMemoryUsage); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricK8sPodMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricK8sPodMemoryUsage, descrMetricK8sPodMemoryUsage, + unitMetricK8sPodMemoryUsage); +} + +} // namespace k8s +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/log_attributes.h b/api/include/opentelemetry/semconv/incubating/log_attributes.h index 6bda8a4d31..f9224f1bba 100644 --- a/api/include/opentelemetry/semconv/incubating/log_attributes.h +++ b/api/include/opentelemetry/semconv/incubating/log_attributes.h @@ -45,7 +45,7 @@ static constexpr const char *kLogFilePathResolved = "log.file.path_resolved"; static constexpr const char *kLogIostream = "log.iostream"; /** - * The complete orignal Log Record. + * The complete original Log Record. *

      * This value MAY be added when processing a Log Record which was originally transmitted as a string * or equivalent data type AND the Body field of the Log Record does not contain the same value. diff --git a/api/include/opentelemetry/semconv/incubating/messaging_attributes.h b/api/include/opentelemetry/semconv/incubating/messaging_attributes.h index c5f07fe241..4cf20365ab 100644 --- a/api/include/opentelemetry/semconv/incubating/messaging_attributes.h +++ b/api/include/opentelemetry/semconv/incubating/messaging_attributes.h @@ -328,10 +328,10 @@ static constexpr const char *kMessagingRocketmqMessageType = "messaging.rocketmq static constexpr const char *kMessagingRocketmqNamespace = "messaging.rocketmq.namespace"; /** - * Deprecated, use @code messaging.servicebus.destination.subscription_name @endcode instead. + * Deprecated, use @code messaging.destination.subscription.name @endcode instead. *

      * @deprecated - * Replaced by @code messaging.servicebus.destination.subscription_name @endcode. + * Replaced by @code messaging.destination.subscription.name @endcode. */ OPENTELEMETRY_DEPRECATED static constexpr const char *kMessagingServicebusDestinationSubscriptionName = @@ -369,17 +369,17 @@ static constexpr const char *kMessagingSystem = "messaging.system"; namespace MessagingOperationTypeValues { /** - * One or more messages are provided for publishing to an intermediary. If a single message is - * published, the context of the "Publish" span can be used as the creation context and no "Create" - * span needs to be created. + * A message is created. "Create" spans always refer to a single message and are used to provide a + * unique creation context for messages in batch sending scenarios. */ -static constexpr const char *kPublish = "publish"; +static constexpr const char *kCreate = "create"; /** - * A message is created. "Create" spans always refer to a single message and are used to provide a - * unique creation context for messages in batch publishing scenarios. + * One or more messages are provided for sending to an intermediary. If a single message is sent, + * the context of the "Send" span can be used as the creation context and no "Create" span needs to + * be created. */ -static constexpr const char *kCreate = "create"; +static constexpr const char *kSend = "send"; /** * One or more messages are requested by a consumer. This operation refers to pull-based scenarios, @@ -406,6 +406,15 @@ static constexpr const char *kSettle = "settle"; OPENTELEMETRY_DEPRECATED static constexpr const char *kDeliver = "deliver"; +/** + * Deprecated. Use @code send @endcode instead. + *

      + * @deprecated + * Replaced by @code send @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kPublish = "publish"; + } // namespace MessagingOperationTypeValues namespace MessagingRocketmqConsumptionModelValues diff --git a/api/include/opentelemetry/semconv/incubating/messaging_metrics.h b/api/include/opentelemetry/semconv/incubating/messaging_metrics.h index 5da042da2d..9c29fb86b3 100644 --- a/api/include/opentelemetry/semconv/incubating/messaging_metrics.h +++ b/api/include/opentelemetry/semconv/incubating/messaging_metrics.h @@ -96,18 +96,23 @@ CreateSyncDoubleMetricMessagingClientOperationDuration(metrics::Meter *meter) } /** - * Number of messages producer attempted to publish to the broker. + * Deprecated. Use @code messaging.client.sent.messages @endcode instead. *

      - * This metric MUST NOT count messages that were created haven't yet been attempted to be published. + * @deprecated + * Replaced by @code messaging.client.sent.messages @endcode. *

      * counter */ +OPENTELEMETRY_DEPRECATED static constexpr const char *kMetricMessagingClientPublishedMessages = "metric.messaging.client.published.messages"; +OPENTELEMETRY_DEPRECATED static constexpr const char *descrMetricMessagingClientPublishedMessages = - "Number of messages producer attempted to publish to the broker."; + "Deprecated. Use `messaging.client.sent.messages` instead."; +OPENTELEMETRY_DEPRECATED static constexpr const char *unitMetricMessagingClientPublishedMessages = "{message}"; +OPENTELEMETRY_DEPRECATED static inline nostd::unique_ptr> CreateSyncInt64MetricMessagingClientPublishedMessages(metrics::Meter *meter) { @@ -116,6 +121,7 @@ CreateSyncInt64MetricMessagingClientPublishedMessages(metrics::Meter *meter) unitMetricMessagingClientPublishedMessages); } +OPENTELEMETRY_DEPRECATED static inline nostd::unique_ptr> CreateSyncDoubleMetricMessagingClientPublishedMessages(metrics::Meter *meter) { @@ -124,6 +130,7 @@ CreateSyncDoubleMetricMessagingClientPublishedMessages(metrics::Meter *meter) unitMetricMessagingClientPublishedMessages); } +OPENTELEMETRY_DEPRECATED static inline nostd::shared_ptr CreateAsyncInt64MetricMessagingClientPublishedMessages(metrics::Meter *meter) { @@ -132,6 +139,7 @@ CreateAsyncInt64MetricMessagingClientPublishedMessages(metrics::Meter *meter) unitMetricMessagingClientPublishedMessages); } +OPENTELEMETRY_DEPRECATED static inline nostd::shared_ptr CreateAsyncDoubleMetricMessagingClientPublishedMessages(metrics::Meter *meter) { @@ -140,6 +148,51 @@ CreateAsyncDoubleMetricMessagingClientPublishedMessages(metrics::Meter *meter) unitMetricMessagingClientPublishedMessages); } +/** + * Number of messages producer attempted to send to the broker. + *

      + * This metric MUST NOT count messages that were created but haven't yet been sent. + *

      + * counter + */ +static constexpr const char *kMetricMessagingClientSentMessages = + "metric.messaging.client.sent.messages"; +static constexpr const char *descrMetricMessagingClientSentMessages = + "Number of messages producer attempted to send to the broker."; +static constexpr const char *unitMetricMessagingClientSentMessages = "{message}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricMessagingClientSentMessages(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricMessagingClientSentMessages, + descrMetricMessagingClientSentMessages, + unitMetricMessagingClientSentMessages); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricMessagingClientSentMessages(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricMessagingClientSentMessages, + descrMetricMessagingClientSentMessages, + unitMetricMessagingClientSentMessages); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricMessagingClientSentMessages(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricMessagingClientSentMessages, + descrMetricMessagingClientSentMessages, + unitMetricMessagingClientSentMessages); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricMessagingClientSentMessages(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricMessagingClientSentMessages, + descrMetricMessagingClientSentMessages, + unitMetricMessagingClientSentMessages); +} + /** * Duration of processing operation. *

      diff --git a/api/include/opentelemetry/semconv/incubating/otel_attributes.h b/api/include/opentelemetry/semconv/incubating/otel_attributes.h index 241e07d1aa..e3a3251005 100644 --- a/api/include/opentelemetry/semconv/incubating/otel_attributes.h +++ b/api/include/opentelemetry/semconv/incubating/otel_attributes.h @@ -20,15 +20,19 @@ namespace otel { /** + * Deprecated. Use the @code otel.scope.name @endcode attribute + *

      * @deprecated - * use the @code otel.scope.name @endcode attribute. + * Use the @code otel.scope.name @endcode attribute. */ OPENTELEMETRY_DEPRECATED static constexpr const char *kOtelLibraryName = "otel.library.name"; /** + * Deprecated. Use the @code otel.scope.version @endcode attribute. + *

      * @deprecated - * use the @code otel.scope.version @endcode attribute. + * Use the @code otel.scope.version @endcode attribute. */ OPENTELEMETRY_DEPRECATED static constexpr const char *kOtelLibraryVersion = "otel.library.version"; diff --git a/api/include/opentelemetry/semconv/incubating/process_attributes.h b/api/include/opentelemetry/semconv/incubating/process_attributes.h index 392ef869d1..de81b12c38 100644 --- a/api/include/opentelemetry/semconv/incubating/process_attributes.h +++ b/api/include/opentelemetry/semconv/incubating/process_attributes.h @@ -19,6 +19,14 @@ namespace semconv namespace process { +/** + * Length of the process.command_args array + *

      + * This field can be useful for querying or performing bucket analysis on how many arguments were + * provided to start a process. More arguments may be an indication of suspicious activity. + */ +static constexpr const char *kProcessArgsCount = "process.args_count"; + /** * The command used to launch the process (i.e. the command name). On Linux based systems, can be * set to the zeroth string in @code proc/[pid]/cmdline @endcode. On Windows, can be set to the @@ -60,6 +68,23 @@ static constexpr const char *kProcessCpuState = "process.cpu.state"; */ static constexpr const char *kProcessCreationTime = "process.creation.time"; +/** + * The GNU build ID as found in the @code .note.gnu.build-id @endcode ELF section (hex string). + */ +static constexpr const char *kProcessExecutableBuildIdGnu = "process.executable.build_id.gnu"; + +/** + * The Go build ID as retrieved by @code go tool buildid @endcode. + */ +static constexpr const char *kProcessExecutableBuildIdGo = "process.executable.build_id.go"; + +/** + * Profiling specific build ID for executables. See the OTel specification for Profiles for more + * information. + */ +static constexpr const char *kProcessExecutableBuildIdProfiling = + "process.executable.build_id.profiling"; + /** * The name of the process executable. On Linux based systems, can be set to the @code Name @endcode * in @code proc/[pid]/status @endcode. On Windows, can be set to the base name of @code @@ -156,6 +181,14 @@ static constexpr const char *kProcessSavedUserName = "process.saved_user.name"; */ static constexpr const char *kProcessSessionLeaderPid = "process.session_leader.pid"; +/** + * Process title (proctitle) + *

      + * In many Unix-like systems, process title (proctitle), is the string that represents the name or + * command line of a running process, displayed by system monitoring tools like ps, top, and htop. + */ +static constexpr const char *kProcessTitle = "process.title"; + /** * The effective user ID (EUID) of the process. */ @@ -174,6 +207,11 @@ static constexpr const char *kProcessUserName = "process.user.name"; */ static constexpr const char *kProcessVpid = "process.vpid"; +/** + * The working directory of the process. + */ +static constexpr const char *kProcessWorkingDirectory = "process.working_directory"; + namespace ProcessContextSwitchTypeValues { /** diff --git a/api/include/opentelemetry/semconv/incubating/process_metrics.h b/api/include/opentelemetry/semconv/incubating/process_metrics.h index 95a1853ccb..5f851a2d41 100644 --- a/api/include/opentelemetry/semconv/incubating/process_metrics.h +++ b/api/include/opentelemetry/semconv/incubating/process_metrics.h @@ -411,6 +411,44 @@ CreateAsyncDoubleMetricProcessThreadCount(metrics::Meter *meter) kMetricProcessThreadCount, descrMetricProcessThreadCount, unitMetricProcessThreadCount); } +/** + * The time the process has been running. + *

      + * Instrumentations SHOULD use counter with type @code double @endcode and measure uptime with at + * least millisecond precision

      counter + */ +static constexpr const char *kMetricProcessUptime = "metric.process.uptime"; +static constexpr const char *descrMetricProcessUptime = "The time the process has been running."; +static constexpr const char *unitMetricProcessUptime = "s"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricProcessUptime( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricProcessUptime, descrMetricProcessUptime, + unitMetricProcessUptime); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricProcessUptime( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricProcessUptime, descrMetricProcessUptime, + unitMetricProcessUptime); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricProcessUptime( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricProcessUptime, descrMetricProcessUptime, + unitMetricProcessUptime); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricProcessUptime( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricProcessUptime, descrMetricProcessUptime, + unitMetricProcessUptime); +} + } // namespace process } // namespace semconv OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/profile_attributes.h b/api/include/opentelemetry/semconv/incubating/profile_attributes.h new file mode 100644 index 0000000000..076177904f --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/profile_attributes.h @@ -0,0 +1,81 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace profile +{ + +/** + * Describes the interpreter or compiler of a single frame. + */ +static constexpr const char *kProfileFrameType = "profile.frame.type"; + +namespace ProfileFrameTypeValues +{ +/** + * .NET + */ +static constexpr const char *kDotnet = "dotnet"; + +/** + * JVM + */ +static constexpr const char *kJvm = "jvm"; + +/** + * Kernel + */ +static constexpr const char *kKernel = "kernel"; + +/** + * C, C++, Go, Rust + */ +static constexpr const char *kNative = "native"; + +/** + * Perl + */ +static constexpr const char *kPerl = "perl"; + +/** + * PHP + */ +static constexpr const char *kPhp = "php"; + +/** + * Python + */ +static constexpr const char *kCpython = "cpython"; + +/** + * Ruby + */ +static constexpr const char *kRuby = "ruby"; + +/** + * V8JS + */ +static constexpr const char *kV8js = "v8js"; + +} // namespace ProfileFrameTypeValues + +} // namespace profile +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/system_metrics.h b/api/include/opentelemetry/semconv/incubating/system_metrics.h index b896015372..a23a8ae4d0 100644 --- a/api/include/opentelemetry/semconv/incubating/system_metrics.h +++ b/api/include/opentelemetry/semconv/incubating/system_metrics.h @@ -304,6 +304,43 @@ CreateAsyncDoubleMetricSystemDiskIoTime(metrics::Meter *meter) unitMetricSystemDiskIoTime); } +/** + * The total storage capacity of the disk + *

      + * updowncounter + */ +static constexpr const char *kMetricSystemDiskLimit = "metric.system.disk.limit"; +static constexpr const char *descrMetricSystemDiskLimit = "The total storage capacity of the disk"; +static constexpr const char *unitMetricSystemDiskLimit = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemDiskLimit(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricSystemDiskLimit, descrMetricSystemDiskLimit, + unitMetricSystemDiskLimit); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemDiskLimit(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricSystemDiskLimit, descrMetricSystemDiskLimit, + unitMetricSystemDiskLimit); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemDiskLimit(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter( + kMetricSystemDiskLimit, descrMetricSystemDiskLimit, unitMetricSystemDiskLimit); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemDiskLimit(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter( + kMetricSystemDiskLimit, descrMetricSystemDiskLimit, unitMetricSystemDiskLimit); +} + /** * counter */ @@ -423,11 +460,58 @@ CreateAsyncDoubleMetricSystemDiskOperations(metrics::Meter *meter) } /** + * The total storage capacity of the filesystem + *

      * updowncounter */ -static constexpr const char *kMetricSystemFilesystemUsage = "metric.system.filesystem.usage"; -static constexpr const char *descrMetricSystemFilesystemUsage = ""; -static constexpr const char *unitMetricSystemFilesystemUsage = "By"; +static constexpr const char *kMetricSystemFilesystemLimit = "metric.system.filesystem.limit"; +static constexpr const char *descrMetricSystemFilesystemLimit = + "The total storage capacity of the filesystem"; +static constexpr const char *unitMetricSystemFilesystemLimit = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemFilesystemLimit(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricSystemFilesystemLimit, + descrMetricSystemFilesystemLimit, + unitMetricSystemFilesystemLimit); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemFilesystemLimit(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricSystemFilesystemLimit, + descrMetricSystemFilesystemLimit, + unitMetricSystemFilesystemLimit); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemFilesystemLimit(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricSystemFilesystemLimit, + descrMetricSystemFilesystemLimit, + unitMetricSystemFilesystemLimit); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemFilesystemLimit(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricSystemFilesystemLimit, + descrMetricSystemFilesystemLimit, + unitMetricSystemFilesystemLimit); +} + +/** + * Reports a filesystem's space usage across different states. + *

      + * The sum of all @code system.filesystem.usage @endcode values over the different @code + * system.filesystem.state @endcode attributes SHOULD equal the total storage capacity of the + * filesystem, that is @code system.filesystem.limit @endcode.

      updowncounter + */ +static constexpr const char *kMetricSystemFilesystemUsage = "metric.system.filesystem.usage"; +static constexpr const char *descrMetricSystemFilesystemUsage = + "Reports a filesystem's space usage across different states."; +static constexpr const char *unitMetricSystemFilesystemUsage = "By"; static inline nostd::unique_ptr> CreateSyncInt64MetricSystemFilesystemUsage(metrics::Meter *meter) diff --git a/api/include/opentelemetry/semconv/incubating/tls_attributes.h b/api/include/opentelemetry/semconv/incubating/tls_attributes.h index 5e14b6d3f0..89449453ec 100644 --- a/api/include/opentelemetry/semconv/incubating/tls_attributes.h +++ b/api/include/opentelemetry/semconv/incubating/tls_attributes.h @@ -89,7 +89,7 @@ static constexpr const char *kTlsClientNotBefore = "tls.client.not_before"; * Deprecated, use @code server.address @endcode instead. *

      * @deprecated - * Replaced by `server.address. + * Replaced by @code server.address @endcode. */ OPENTELEMETRY_DEPRECATED static constexpr const char *kTlsClientServerName = "tls.client.server_name"; diff --git a/api/include/opentelemetry/semconv/schema_url.h b/api/include/opentelemetry/semconv/schema_url.h index 62d040e40b..a25e28b5ea 100644 --- a/api/include/opentelemetry/semconv/schema_url.h +++ b/api/include/opentelemetry/semconv/schema_url.h @@ -19,6 +19,6 @@ namespace semconv /** * The URL of the OpenTelemetry schema for these keys and values. */ -static constexpr const char *kSchemaUrl = "https://opentelemetry.io/schemas/1.27.0"; +static constexpr const char *kSchemaUrl = "https://opentelemetry.io/schemas/1.28.0"; } // namespace semconv OPENTELEMETRY_END_NAMESPACE diff --git a/buildscripts/semantic-convention/generate.sh b/buildscripts/semantic-convention/generate.sh index 79becfefbd..b6fecb4459 100755 --- a/buildscripts/semantic-convention/generate.sh +++ b/buildscripts/semantic-convention/generate.sh @@ -16,7 +16,7 @@ ROOT_DIR="${SCRIPT_DIR}/../../" # freeze the spec & generator tools versions to make the generation reproducible # repository: https://github.com/open-telemetry/semantic-conventions -SEMCONV_VERSION=1.27.0 +SEMCONV_VERSION=1.28.0 # repository: https://github.com/open-telemetry/weaver WEAVER_VERSION=0.10.0 From 149d29ca78e183480dd179c6a7663169bb5760a6 Mon Sep 17 00:00:00 2001 From: Volodymyr Kolesnykov Date: Thu, 14 Nov 2024 20:06:39 +0200 Subject: [PATCH 66/89] [EXPORTER] handling of invalid ports in UrlParser (#3142) --- .../ext/http/common/url_parser.h | 29 ++++++++++++--- ext/test/http/url_parser_test.cc | 35 +++++++++++++++++++ 2 files changed, 59 insertions(+), 5 deletions(-) diff --git a/ext/include/opentelemetry/ext/http/common/url_parser.h b/ext/include/opentelemetry/ext/http/common/url_parser.h index 75f53ce943..bec9f06c0d 100644 --- a/ext/include/opentelemetry/ext/http/common/url_parser.h +++ b/ext/include/opentelemetry/ext/http/common/url_parser.h @@ -3,8 +3,9 @@ #pragma once -#include +#include #include +#include #include #include "opentelemetry/version.h" @@ -88,8 +89,11 @@ class UrlParser path_ = std::string("/"); // use default path if (is_port) { - port_ = static_cast( - std::stoi(std::string(url_.begin() + cpos, url_.begin() + url_.length()))); + std::string port_str( + url_.begin() + static_cast(cpos), + url_.begin() + static_cast(url_.length())); + + port_ = GetPort(port_str); } else { @@ -99,8 +103,9 @@ class UrlParser } if (is_port) { - port_ = - static_cast(std::stoi(std::string(url_.begin() + cpos, url_.begin() + pos))); + std::string port_str(url_.begin() + static_cast(cpos), + url_.begin() + static_cast(pos)); + port_ = GetPort(port_str); } else { @@ -164,6 +169,20 @@ class UrlParser return std::string::npos; } + + std::uint16_t GetPort(const std::string &s) + { + char *e = nullptr; + errno = 0; + auto port = std::strtol(s.c_str(), &e, 10); + if (e == s.c_str() || e != s.c_str() + s.size() || errno == ERANGE || port < 0 || port > 65535) + { + success_ = false; + return 0; + } + + return static_cast(port); + } }; class UrlDecoder diff --git a/ext/test/http/url_parser_test.cc b/ext/test/http/url_parser_test.cc index aceb43966a..4314735a6f 100644 --- a/ext/test/http/url_parser_test.cc +++ b/ext/test/http/url_parser_test.cc @@ -179,6 +179,41 @@ TEST(UrlParserTests, BasicTests) {"path", "/path1@bbb/path2"}, {"query", "q1=a1&q2=a2"}, {"success", "true"}}}, + {"https://https://example.com/some/path", + {{"host", "https"}, + {"port", "0"}, + {"scheme", "https"}, + {"path", "//example.com/some/path"}, + {"query", ""}, + {"success", "false"}}}, + {"https://example.com:-1/some/path", + {{"host", "example.com"}, + {"port", "0"}, + {"scheme", "https"}, + {"path", "/some/path"}, + {"query", ""}, + {"success", "false"}}}, + {"https://example.com:65536/some/path", + {{"host", "example.com"}, + {"port", "0"}, + {"scheme", "https"}, + {"path", "/some/path"}, + {"query", ""}, + {"success", "false"}}}, + {"https://example.com:80a/some/path", + {{"host", "example.com"}, + {"port", "0"}, + {"scheme", "https"}, + {"path", "/some/path"}, + {"query", ""}, + {"success", "false"}}}, + {"https://example.com:18446744073709551616/some/path", + {{"host", "example.com"}, + {"port", "0"}, + {"scheme", "https"}, + {"path", "/some/path"}, + {"query", ""}, + {"success", "false"}}}, }; for (auto &url_map : urls_map) { From a388e87d72b8321c189c8d41edb746ffa687ce3c Mon Sep 17 00:00:00 2001 From: Volodymyr Kolesnykov Date: Fri, 15 Nov 2024 17:46:25 +0200 Subject: [PATCH 67/89] [CI] speed up `clang-tidy` workflow (#3148) --- .github/workflows/clang-tidy.yaml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/clang-tidy.yaml b/.github/workflows/clang-tidy.yaml index 612ff05270..b467c56d44 100644 --- a/.github/workflows/clang-tidy.yaml +++ b/.github/workflows/clang-tidy.yaml @@ -46,9 +46,8 @@ jobs: CC: clang CXX: clang++ run: | - mkdir -p build && cd build echo "Running cmake..." - cmake .. \ + cmake -B build \ -DCMAKE_CXX_STANDARD=14 \ -DWITH_STL=CXX14 \ -DWITH_OTLP_HTTP=ON \ @@ -62,23 +61,21 @@ jobs: -DBUILD_W3CTRACECONTEXT_TEST=ON \ -DWITH_METRICS_EXEMPLAR_PREVIEW=ON \ -DWITH_ASYNC_EXPORT_PREVIEW=ON \ - -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ - -DCMAKE_CXX_CLANG_TIDY="clang-tidy" + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON - name: Run clang-tidy run: | - cd build - make 2>&1 | tee -a clang-tidy.log || exit 1 + cmake --build build --target opentelemetry_proto + jq -r .[].file build/compile_commands.json | grep -vE '/(generated|third_party)/' | xargs -P $(nproc) -n 1 clang-tidy --quiet -p build 2>&1 | tee -a clang-tidy.log - uses: actions/upload-artifact@v4 with: name: Logs (clang-tidy) - path: ./build/clang-tidy.log + path: ./clang-tidy.log - name: Count warnings run: | - cd build COUNT=$(grep -c "warning:" clang-tidy.log) echo "clang-tidy reported ${COUNT} warning(s)" -# TODO: include WITH_OTLP_GRPC and WITH_ABSEIL flags. \ No newline at end of file +# TODO: include WITH_OTLP_GRPC and WITH_ABSEIL flags. From a5db7e593548fd0718241ba57e62c62bbca77357 Mon Sep 17 00:00:00 2001 From: WenTao Ou Date: Tue, 19 Nov 2024 06:32:36 +0800 Subject: [PATCH 68/89] [EXPORTER] Allow to share gRPC clients between OTLP exporters (#3041) --- CHANGELOG.md | 3 + CMakeLists.txt | 10 +- .../nostd/internal/absl/README.md | 4 +- .../nostd/internal/absl/base/config.h | 43 +-- .../absl/base/internal/inline_variable.h | 10 +- .../internal/absl/base/internal/invoke.h | 10 +- .../nostd/internal/absl/base/macros.h | 8 +- .../nostd/internal/absl/base/options.h | 50 ++-- .../nostd/internal/absl/meta/type_traits.h | 28 +- .../internal/absl/types/bad_variant_access.h | 14 +- .../internal/absl/types/internal/variant.h | 258 +++++++++--------- .../nostd/internal/absl/types/variant.h | 222 +++++++-------- .../nostd/internal/absl/utility/utility.h | 68 ++--- api/include/opentelemetry/nostd/variant.h | 11 +- cmake/opentelemetry-cpp-config.cmake.in | 9 +- cmake/opentelemetry-proto.cmake | 32 ++- cmake/patch-imported-config.cmake | 2 +- examples/grpc/CMakeLists.txt | 2 +- exporters/otlp/BUILD | 2 + exporters/otlp/CMakeLists.txt | 8 +- .../exporters/otlp/otlp_grpc_client.h | 55 +++- .../exporters/otlp/otlp_grpc_client_factory.h | 36 +++ .../exporters/otlp/otlp_grpc_exporter.h | 40 ++- .../otlp/otlp_grpc_exporter_factory.h | 10 + .../otlp/otlp_grpc_log_record_exporter.h | 43 ++- .../otlp_grpc_log_record_exporter_factory.h | 12 +- .../otlp/otlp_grpc_metric_exporter.h | 42 ++- .../otlp/otlp_grpc_metric_exporter_factory.h | 12 +- exporters/otlp/src/otlp_grpc_client.cc | 161 +++++++++-- .../otlp/src/otlp_grpc_client_factory.cc | 27 ++ exporters/otlp/src/otlp_grpc_exporter.cc | 108 ++++++-- .../otlp/src/otlp_grpc_exporter_factory.cc | 9 + .../otlp/src/otlp_grpc_log_record_exporter.cc | 113 ++++++-- .../otlp_grpc_log_record_exporter_factory.cc | 9 + .../otlp/src/otlp_grpc_metric_exporter.cc | 110 ++++++-- .../src/otlp_grpc_metric_exporter_factory.cc | 9 + .../test/otlp_grpc_exporter_factory_test.cc | 22 ++ ...p_grpc_log_record_exporter_factory_test.cc | 24 ++ .../otlp_grpc_log_record_exporter_test.cc | 132 +++++++++ .../otlp_grpc_metric_exporter_factory_test.cc | 24 ++ sdk/src/common/CMakeLists.txt | 2 +- 41 files changed, 1256 insertions(+), 538 deletions(-) create mode 100644 exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client_factory.h create mode 100644 exporters/otlp/src/otlp_grpc_client_factory.cc diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e3521797d..050dfa7551 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,9 @@ Increment the: * [SEMANTIC CONVENTIONS] Migration to weaver [#3105](https://github.com/open-telemetry/opentelemetry-cpp/pull/3105) +* [EXPORTER] Allow to share gRPC clients between OTLP exporters. + [#3041](https://github.com/open-telemetry/opentelemetry-cpp/pull/3041) + Important changes: * [API] Jaeger Propagator should not be deprecated diff --git a/CMakeLists.txt b/CMakeLists.txt index aa0ae9ef43..f9e017eed2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -389,14 +389,8 @@ if(WITH_OTLP_GRPC OR WITH_OTLP_HTTP OR WITH_OTLP_FILE) find_package(Protobuf) - if(Protobuf_VERSION AND Protobuf_VERSION VERSION_GREATER_EQUAL "3.22.0") - if(NOT WITH_ABSEIL) - message( - FATAL_ERROR - "Protobuf 3.22 or upper require abseil-cpp(Recommended version: 20230125 or upper)" - ) - endif() - endif() + # Protobuf 3.22 or upper require abseil-cpp, we can find it in + # opentelemetry-cpp-config.cmake if(WITH_OTLP_GRPC) find_package(gRPC) diff --git a/api/include/opentelemetry/nostd/internal/absl/README.md b/api/include/opentelemetry/nostd/internal/absl/README.md index 6a40855704..5dd661971f 100644 --- a/api/include/opentelemetry/nostd/internal/absl/README.md +++ b/api/include/opentelemetry/nostd/internal/absl/README.md @@ -1,4 +1,4 @@ # Notes on Abseil Variant implementation -This is a snapshot of Abseil Variant `absl::variant` from Abseil -`v2020-03-03#8`. +This is a snapshot of Abseil Variant +`absl::OTABSL_OPTION_NAMESPACE_NAME::variant` from Abseil `v2020-03-03#8`. diff --git a/api/include/opentelemetry/nostd/internal/absl/base/config.h b/api/include/opentelemetry/nostd/internal/absl/base/config.h index 3f78df3d98..e0836b9b3f 100644 --- a/api/include/opentelemetry/nostd/internal/absl/base/config.h +++ b/api/include/opentelemetry/nostd/internal/absl/base/config.h @@ -84,7 +84,7 @@ // namespace absl { // OTABSL_NAMESPACE_BEGIN // -// void Foo(); // absl::Foo(). +// void Foo(); // absl::OTABSL_OPTION_NAMESPACE_NAME::Foo(). // // OTABSL_NAMESPACE_END // } // namespace absl @@ -94,40 +94,32 @@ // not support forward declarations of its own types, nor does it support // user-provided specialization of Abseil templates. Code that violates these // rules may be broken without warning.) -#if !defined(OTABSL_OPTION_USE_INLINE_NAMESPACE) || \ - !defined(OTABSL_OPTION_INLINE_NAMESPACE_NAME) +#if !defined(OTABSL_OPTION_NAMESPACE_NAME) #error options.h is misconfigured. #endif -// Check that OTABSL_OPTION_INLINE_NAMESPACE_NAME is neither "head" nor "" -#if defined(__cplusplus) && OTABSL_OPTION_USE_INLINE_NAMESPACE == 1 +// Check that OTABSL_OPTION_NAMESPACE_NAME is neither "head" nor "" +#if defined(__cplusplus) #define OTABSL_INTERNAL_INLINE_NAMESPACE_STR \ - OTABSL_INTERNAL_TOKEN_STR(OTABSL_OPTION_INLINE_NAMESPACE_NAME) + OTABSL_INTERNAL_TOKEN_STR(OTABSL_OPTION_NAMESPACE_NAME) static_assert(OTABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != '\0', - "options.h misconfigured: OTABSL_OPTION_INLINE_NAMESPACE_NAME must " + "options.h misconfigured: OTABSL_OPTION_NAMESPACE_NAME must " "not be empty."); static_assert(OTABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || OTABSL_INTERNAL_INLINE_NAMESPACE_STR[1] != 'e' || OTABSL_INTERNAL_INLINE_NAMESPACE_STR[2] != 'a' || OTABSL_INTERNAL_INLINE_NAMESPACE_STR[3] != 'd' || OTABSL_INTERNAL_INLINE_NAMESPACE_STR[4] != '\0', - "options.h misconfigured: OTABSL_OPTION_INLINE_NAMESPACE_NAME must " + "options.h misconfigured: OTABSL_OPTION_NAMESPACE_NAME must " "be changed to a new, unique identifier name."); #endif -#if OTABSL_OPTION_USE_INLINE_NAMESPACE == 0 -#define OTABSL_NAMESPACE_BEGIN -#define OTABSL_NAMESPACE_END -#elif OTABSL_OPTION_USE_INLINE_NAMESPACE == 1 -#define OTABSL_NAMESPACE_BEGIN \ - inline namespace OTABSL_OPTION_INLINE_NAMESPACE_NAME { + +#define OTABSL_NAMESPACE_BEGIN namespace OTABSL_OPTION_NAMESPACE_NAME { #define OTABSL_NAMESPACE_END } -#else -#error options.h is misconfigured. -#endif // ----------------------------------------------------------------------------- // Compiler Feature Checks @@ -217,7 +209,7 @@ static_assert(OTABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || // OTABSL_HAVE_SOURCE_LOCATION_CURRENT // -// Indicates whether `absl::SourceLocation::current()` will return useful +// Indicates whether `absl::OTABSL_OPTION_NAMESPACE_NAME::SourceLocation::current()` will return useful // information in some contexts. #ifndef OTABSL_HAVE_SOURCE_LOCATION_CURRENT #if OTABSL_INTERNAL_HAS_KEYWORD(__builtin_LINE) && \ @@ -570,7 +562,7 @@ static_assert(OTABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || // OTABSL_USES_STD_ANY // -// Indicates whether absl::any is an alias for std::any. +// Indicates whether absl::OTABSL_OPTION_NAMESPACE_NAME::any is an alias for std::any. #if !defined(OTABSL_OPTION_USE_STD_ANY) #error options.h is misconfigured. #elif OTABSL_OPTION_USE_STD_ANY == 0 || \ @@ -585,7 +577,7 @@ static_assert(OTABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || // OTABSL_USES_STD_OPTIONAL // -// Indicates whether absl::optional is an alias for std::optional. +// Indicates whether absl::OTABSL_OPTION_NAMESPACE_NAME::optional is an alias for std::optional. #if !defined(OTABSL_OPTION_USE_STD_OPTIONAL) #error options.h is misconfigured. #elif OTABSL_OPTION_USE_STD_OPTIONAL == 0 || \ @@ -600,7 +592,7 @@ static_assert(OTABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || // OTABSL_USES_STD_VARIANT // -// Indicates whether absl::variant is an alias for std::variant. +// Indicates whether absl::OTABSL_OPTION_NAMESPACE_NAME::variant is an alias for std::variant. #if !defined(OTABSL_OPTION_USE_STD_VARIANT) #error options.h is misconfigured. #elif OTABSL_OPTION_USE_STD_VARIANT == 0 || \ @@ -615,7 +607,7 @@ static_assert(OTABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || // OTABSL_USES_STD_STRING_VIEW // -// Indicates whether absl::string_view is an alias for std::string_view. +// Indicates whether absl::OTABSL_OPTION_NAMESPACE_NAME::string_view is an alias for std::string_view. #if !defined(OTABSL_OPTION_USE_STD_STRING_VIEW) #error options.h is misconfigured. #elif OTABSL_OPTION_USE_STD_STRING_VIEW == 0 || \ @@ -650,15 +642,10 @@ static_assert(OTABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || // the proper count to skip past the CCTZ fork namespace names. (This number // is one larger when there is an inline namespace name to skip.) #if defined(_MSC_VER) -#if OTABSL_OPTION_USE_INLINE_NAMESPACE == 0 -#define OTABSL_INTERNAL_MANGLED_NS "absl" -#define OTABSL_INTERNAL_MANGLED_BACKREFERENCE "5" -#else #define OTABSL_INTERNAL_MANGLED_NS \ - OTABSL_INTERNAL_TOKEN_STR(OTABSL_OPTION_INLINE_NAMESPACE_NAME) "@absl" + OTABSL_INTERNAL_TOKEN_STR(OTABSL_OPTION_NAMESPACE_NAME) "@absl" #define OTABSL_INTERNAL_MANGLED_BACKREFERENCE "6" #endif -#endif #undef OTABSL_INTERNAL_HAS_KEYWORD diff --git a/api/include/opentelemetry/nostd/internal/absl/base/internal/inline_variable.h b/api/include/opentelemetry/nostd/internal/absl/base/internal/inline_variable.h index 9d024a2d91..dd66e9f223 100644 --- a/api/include/opentelemetry/nostd/internal/absl/base/internal/inline_variable.h +++ b/api/include/opentelemetry/nostd/internal/absl/base/internal/inline_variable.h @@ -68,7 +68,7 @@ // types, etc.. #if defined(__clang__) #define OTABSL_INTERNAL_EXTERN_DECL(type, name) \ - extern const ::absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::internal::identity_t name; + extern const ::absl::OTABSL_OPTION_NAMESPACE_NAME::internal::identity_t name; #else // Otherwise, just define the macro to do nothing. #define OTABSL_INTERNAL_EXTERN_DECL(type, name) #endif // defined(__clang__) @@ -76,7 +76,7 @@ // See above comment at top of file for details. #define OTABSL_INTERNAL_INLINE_CONSTEXPR(type, name, init) \ OTABSL_INTERNAL_EXTERN_DECL(type, name) \ - inline constexpr ::absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::internal::identity_t name = init + inline constexpr ::absl::OTABSL_OPTION_NAMESPACE_NAME::internal::identity_t name = init #else @@ -89,14 +89,14 @@ #define OTABSL_INTERNAL_INLINE_CONSTEXPR(var_type, name, init) \ template \ struct AbslInternalInlineVariableHolder##name { \ - static constexpr ::absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::internal::identity_t kInstance = init; \ + static constexpr ::absl::OTABSL_OPTION_NAMESPACE_NAME::internal::identity_t kInstance = init; \ }; \ \ template \ - constexpr ::absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::internal::identity_t \ + constexpr ::absl::OTABSL_OPTION_NAMESPACE_NAME::internal::identity_t \ AbslInternalInlineVariableHolder##name::kInstance; \ \ - static constexpr const ::absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::internal::identity_t& \ + static constexpr const ::absl::OTABSL_OPTION_NAMESPACE_NAME::internal::identity_t& \ name = /* NOLINT */ \ AbslInternalInlineVariableHolder##name<>::kInstance; \ static_assert(sizeof(void (*)(decltype(name))) != 0, \ diff --git a/api/include/opentelemetry/nostd/internal/absl/base/internal/invoke.h b/api/include/opentelemetry/nostd/internal/absl/base/internal/invoke.h index 99c37ba24a..c37f43cfc8 100644 --- a/api/include/opentelemetry/nostd/internal/absl/base/internal/invoke.h +++ b/api/include/opentelemetry/nostd/internal/absl/base/internal/invoke.h @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. // -// absl::base_internal::Invoke(f, args...) is an implementation of +// absl::OTABSL_OPTION_NAMESPACE_NAME::base_internal::Invoke(f, args...) is an implementation of // INVOKE(f, args...) from section [func.require] of the C++ standard. // // [func.require] @@ -73,7 +73,7 @@ struct MemFunAndRef : StrippedAccept { template struct AcceptImpl : std::integral_constant::value && - absl::is_function::value> { + absl::OTABSL_OPTION_NAMESPACE_NAME::is_function::value> { }; template @@ -94,7 +94,7 @@ struct MemFunAndPtr : StrippedAccept { template struct AcceptImpl : std::integral_constant::value && - absl::is_function::value> { + absl::OTABSL_OPTION_NAMESPACE_NAME::is_function::value> { }; template @@ -116,7 +116,7 @@ struct DataMemAndRef : StrippedAccept { template struct AcceptImpl : std::integral_constant::value && - !absl::is_function::value> {}; + !absl::OTABSL_OPTION_NAMESPACE_NAME::is_function::value> {}; template static decltype(std::declval().*std::declval()) Invoke( @@ -134,7 +134,7 @@ struct DataMemAndPtr : StrippedAccept { template struct AcceptImpl : std::integral_constant::value && - !absl::is_function::value> {}; + !absl::OTABSL_OPTION_NAMESPACE_NAME::is_function::value> {}; template static decltype((*std::declval()).*std::declval()) Invoke( diff --git a/api/include/opentelemetry/nostd/internal/absl/base/macros.h b/api/include/opentelemetry/nostd/internal/absl/base/macros.h index 7b4f427d30..707c375ed1 100644 --- a/api/include/opentelemetry/nostd/internal/absl/base/macros.h +++ b/api/include/opentelemetry/nostd/internal/absl/base/macros.h @@ -41,7 +41,7 @@ // can be used in defining new arrays. If you use this macro on a pointer by // mistake, you will get a compile-time error. #define OTABSL_ARRAYSIZE(array) \ - (sizeof(::absl::macros_internal::ArraySizeHelper(array))) + (sizeof(::absl::OTABSL_OPTION_NAMESPACE_NAME::macros_internal::ArraySizeHelper(array))) namespace absl { OTABSL_NAMESPACE_BEGIN @@ -60,7 +60,7 @@ OTABSL_NAMESPACE_END // static storage duration, and that the constructor should do nothing to its // state. Use of this macro indicates to the reader that it is legal to // declare a static instance of the class, provided the constructor is given -// the absl::base_internal::kLinkerInitialized argument. +// the absl::OTABSL_OPTION_NAMESPACE_NAME::base_internal::kLinkerInitialized argument. // // Normally, it is unsafe to declare a static variable that has a constructor or // a destructor because invocation order is undefined. However, if the type can @@ -70,10 +70,10 @@ OTABSL_NAMESPACE_END // // Example: // // Declaration -// explicit MyClass(absl::base_internal:LinkerInitialized x) {} +// explicit MyClass(absl::OTABSL_OPTION_NAMESPACE_NAME::base_internal:LinkerInitialized x) {} // // // Invocation -// static MyClass my_global(absl::base_internal::kLinkerInitialized); +// static MyClass my_global(absl::OTABSL_OPTION_NAMESPACE_NAME::base_internal::kLinkerInitialized); namespace absl { OTABSL_NAMESPACE_BEGIN namespace base_internal { diff --git a/api/include/opentelemetry/nostd/internal/absl/base/options.h b/api/include/opentelemetry/nostd/internal/absl/base/options.h index 3632b74f64..26665b151e 100644 --- a/api/include/opentelemetry/nostd/internal/absl/base/options.h +++ b/api/include/opentelemetry/nostd/internal/absl/base/options.h @@ -79,7 +79,7 @@ // // OTABSL_OPTION_USE_STD_ANY // -// This option controls whether absl::any is implemented as an alias to +// This option controls whether absl::OTABSL_OPTION_NAMESPACE_NAME::any is implemented as an alias to // std::any, or as an independent implementation. // // A value of 0 means to use Abseil's implementation. This requires only C++11 @@ -93,19 +93,19 @@ // useful when you are building your entire program, including all of its // dependencies, from source. It should not be used otherwise -- for example, // if you are distributing Abseil in a binary package manager -- since in -// mode 2, absl::any will name a different type, with a different mangled name +// mode 2, absl::OTABSL_OPTION_NAMESPACE_NAME::any will name a different type, with a different mangled name // and binary layout, depending on the compiler flags passed by the end user. // For more info, see https://abseil.io/about/design/dropin-types. // // User code should not inspect this macro. To check in the preprocessor if -// absl::any is a typedef of std::any, use the feature macro OTABSL_USES_STD_ANY. +// absl::OTABSL_OPTION_NAMESPACE_NAME::any is a typedef of std::any, use the feature macro OTABSL_USES_STD_ANY. #define OTABSL_OPTION_USE_STD_ANY 0 // OTABSL_OPTION_USE_STD_OPTIONAL // -// This option controls whether absl::optional is implemented as an alias to +// This option controls whether absl::OTABSL_OPTION_NAMESPACE_NAME::optional is implemented as an alias to // std::optional, or as an independent implementation. // // A value of 0 means to use Abseil's implementation. This requires only C++11 @@ -118,13 +118,13 @@ // and use an alias only if a working std::optional is available. This option // is useful when you are building your program from source. It should not be // used otherwise -- for example, if you are distributing Abseil in a binary -// package manager -- since in mode 2, absl::optional will name a different +// package manager -- since in mode 2, absl::OTABSL_OPTION_NAMESPACE_NAME::optional will name a different // type, with a different mangled name and binary layout, depending on the // compiler flags passed by the end user. For more info, see // https://abseil.io/about/design/dropin-types. // User code should not inspect this macro. To check in the preprocessor if -// absl::optional is a typedef of std::optional, use the feature macro +// absl::OTABSL_OPTION_NAMESPACE_NAME::optional is a typedef of std::optional, use the feature macro // OTABSL_USES_STD_OPTIONAL. #define OTABSL_OPTION_USE_STD_OPTIONAL 0 @@ -132,7 +132,7 @@ // OTABSL_OPTION_USE_STD_STRING_VIEW // -// This option controls whether absl::string_view is implemented as an alias to +// This option controls whether absl::OTABSL_OPTION_NAMESPACE_NAME::string_view is implemented as an alias to // std::string_view, or as an independent implementation. // // A value of 0 means to use Abseil's implementation. This requires only C++11 @@ -145,20 +145,20 @@ // and use an alias only if a working std::string_view is available. This // option is useful when you are building your program from source. It should // not be used otherwise -- for example, if you are distributing Abseil in a -// binary package manager -- since in mode 2, absl::string_view will name a +// binary package manager -- since in mode 2, absl::OTABSL_OPTION_NAMESPACE_NAME::string_view will name a // different type, with a different mangled name and binary layout, depending on // the compiler flags passed by the end user. For more info, see // https://abseil.io/about/design/dropin-types. // // User code should not inspect this macro. To check in the preprocessor if -// absl::string_view is a typedef of std::string_view, use the feature macro +// absl::OTABSL_OPTION_NAMESPACE_NAME::string_view is a typedef of std::string_view, use the feature macro // OTABSL_USES_STD_STRING_VIEW. #define OTABSL_OPTION_USE_STD_STRING_VIEW 0 // OTABSL_OPTION_USE_STD_VARIANT // -// This option controls whether absl::variant is implemented as an alias to +// This option controls whether absl::OTABSL_OPTION_NAMESPACE_NAME::variant is implemented as an alias to // std::variant, or as an independent implementation. // // A value of 0 means to use Abseil's implementation. This requires only C++11 @@ -171,41 +171,23 @@ // and use an alias only if a working std::variant is available. This option // is useful when you are building your program from source. It should not be // used otherwise -- for example, if you are distributing Abseil in a binary -// package manager -- since in mode 2, absl::variant will name a different +// package manager -- since in mode 2, absl::OTABSL_OPTION_NAMESPACE_NAME::variant will name a different // type, with a different mangled name and binary layout, depending on the // compiler flags passed by the end user. For more info, see // https://abseil.io/about/design/dropin-types. // // User code should not inspect this macro. To check in the preprocessor if -// absl::variant is a typedef of std::variant, use the feature macro +// absl::OTABSL_OPTION_NAMESPACE_NAME::variant is a typedef of std::variant, use the feature macro // OTABSL_USES_STD_VARIANT. #define OTABSL_OPTION_USE_STD_VARIANT 0 -// OTABSL_OPTION_USE_INLINE_NAMESPACE -// OTABSL_OPTION_INLINE_NAMESPACE_NAME +// OTABSL_OPTION_NAMESPACE_NAME // -// These options controls whether all entities in the absl namespace are -// contained within an inner inline namespace. This does not affect the -// user-visible API of Abseil, but it changes the mangled names of all symbols. -// -// This can be useful as a version tag if you are distributing Abseil in -// precompiled form. This will prevent a binary library build of Abseil with -// one inline namespace being used with headers configured with a different -// inline namespace name. Binary packagers are reminded that Abseil does not -// guarantee any ABI stability in Abseil, so any update of Abseil or -// configuration change in such a binary package should be combined with a -// new, unique value for the inline namespace name. -// -// A value of 0 means not to use inline namespaces. -// -// A value of 1 means to use an inline namespace with the given name inside -// namespace absl. If this is set, OTABSL_OPTION_INLINE_NAMESPACE_NAME must also -// be changed to a new, unique identifier name. In particular "head" is not -// allowed. +// All codes in otabsl are under OTABSL_OPTION_NAMESPACE_NAME, we do not use inline namespace to avoid +// conlict with external Abseil. -#define OTABSL_OPTION_USE_INLINE_NAMESPACE 1 -#define OTABSL_OPTION_INLINE_NAMESPACE_NAME otel_v1 +#define OTABSL_OPTION_NAMESPACE_NAME otel_v1 #endif // OTABSL_BASE_OPTIONS_H_ diff --git a/api/include/opentelemetry/nostd/internal/absl/meta/type_traits.h b/api/include/opentelemetry/nostd/internal/absl/meta/type_traits.h index 7fba912312..dbd0348871 100644 --- a/api/include/opentelemetry/nostd/internal/absl/meta/type_traits.h +++ b/api/include/opentelemetry/nostd/internal/absl/meta/type_traits.h @@ -81,25 +81,25 @@ struct IsTriviallyMoveConstructibleObject : std::integral_constant< bool, std::is_move_constructible< type_traits_internal::SingleMemberUnion>::value && - absl::is_trivially_destructible::value> {}; + absl::OTABSL_OPTION_NAMESPACE_NAME::is_trivially_destructible::value> {}; template struct IsTriviallyCopyConstructibleObject : std::integral_constant< bool, std::is_copy_constructible< type_traits_internal::SingleMemberUnion>::value && - absl::is_trivially_destructible::value> {}; + absl::OTABSL_OPTION_NAMESPACE_NAME::is_trivially_destructible::value> {}; template struct IsTriviallyMoveAssignableReference : std::false_type {}; template struct IsTriviallyMoveAssignableReference - : absl::is_trivially_move_assignable::type {}; + : absl::OTABSL_OPTION_NAMESPACE_NAME::is_trivially_move_assignable::type {}; template struct IsTriviallyMoveAssignableReference - : absl::is_trivially_move_assignable::type {}; + : absl::OTABSL_OPTION_NAMESPACE_NAME::is_trivially_move_assignable::type {}; template struct VoidTImpl { @@ -191,7 +191,7 @@ struct is_move_assignable : type_traits_internal::is_detected< // This metafunction is designed to be a drop-in replacement for the C++17 // `std::void_t` metafunction. // -// NOTE: `absl::void_t` does not use the standard-specified implementation so +// NOTE: `absl::OTABSL_OPTION_NAMESPACE_NAME::void_t` does not use the standard-specified implementation so // that it can remain compatible with gcc < 5.1. This can introduce slightly // different behavior, such as when ordering partial specializations. template @@ -493,7 +493,7 @@ struct is_trivially_copy_assignable #else : std::integral_constant< bool, __has_trivial_assign(typename std::remove_reference::type) && - absl::is_copy_assignable::value> { + absl::OTABSL_OPTION_NAMESPACE_NAME::is_copy_assignable::value> { #endif #ifdef OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE private: @@ -537,8 +537,8 @@ class is_trivially_copyable_impl { std::is_copy_constructible::value || std::is_move_constructible::value; static constexpr bool kIsCopyOrMoveAssignable = - absl::is_copy_assignable::value || - absl::is_move_assignable::value; + absl::OTABSL_OPTION_NAMESPACE_NAME::is_copy_assignable::value || + absl::OTABSL_OPTION_NAMESPACE_NAME::is_move_assignable::value; public: static constexpr bool kValue = @@ -661,7 +661,7 @@ struct IsHashable : std::false_type {}; template struct IsHashable< Key, - absl::enable_if_t&>()(std::declval())), std::size_t>::value>> : std::true_type {}; #endif // !OTABSL_META_INTERNAL_STD_HASH_SFINAE_FRIENDLY_ @@ -687,7 +687,7 @@ struct AssertHashEnabledHelper { static_assert( std::is_copy_constructible>::value, "std::hash must be copy constructible when it is enabled"); - static_assert(absl::is_copy_assignable>::value, + static_assert(absl::OTABSL_OPTION_NAMESPACE_NAME::is_copy_assignable>::value, "std::hash must be copy assignable when it is enabled"); // is_destructible is unchecked as it's implied by each of the // is_constructible checks. @@ -717,7 +717,7 @@ namespace swap_internal { // Necessary for the traits. using std::swap; -// This declaration prevents global `swap` and `absl::swap` overloads from being +// This declaration prevents global `swap` and `absl::OTABSL_OPTION_NAMESPACE_NAME::swap` overloads from being // considered unless ADL picks them up. void swap(); @@ -736,7 +736,7 @@ using IsNothrowSwappableImpl = typename std::enable_if::type; // arguments of type `T`. template struct IsSwappable - : absl::type_traits_internal::is_detected {}; + : absl::OTABSL_OPTION_NAMESPACE_NAME::type_traits_internal::is_detected {}; // IsNothrowSwappable // @@ -744,13 +744,13 @@ struct IsSwappable // arguments of type `T` and is noexcept. template struct IsNothrowSwappable - : absl::type_traits_internal::is_detected {}; + : absl::OTABSL_OPTION_NAMESPACE_NAME::type_traits_internal::is_detected {}; // Swap() // // Performs the swap idiom from a namespace where valid candidates may only be // found in `std` or via ADL. -template ::value, int> = 0> +template ::value, int> = 0> void Swap(T& lhs, T& rhs) noexcept(IsNothrowSwappable::value) { swap(lhs, rhs); } diff --git a/api/include/opentelemetry/nostd/internal/absl/types/bad_variant_access.h b/api/include/opentelemetry/nostd/internal/absl/types/bad_variant_access.h index 81caa0d75c..89fe750dbd 100644 --- a/api/include/opentelemetry/nostd/internal/absl/types/bad_variant_access.h +++ b/api/include/opentelemetry/nostd/internal/absl/types/bad_variant_access.h @@ -16,7 +16,7 @@ // bad_variant_access.h // ----------------------------------------------------------------------------- // -// This header file defines the `absl::bad_variant_access` type. +// This header file defines the `absl::OTABSL_OPTION_NAMESPACE_NAME::bad_variant_access` type. #ifndef OTABSL_TYPES_BAD_VARIANT_ACCESS_H_ #define OTABSL_TYPES_BAD_VARIANT_ACCESS_H_ @@ -44,21 +44,21 @@ OTABSL_NAMESPACE_BEGIN // bad_variant_access // ----------------------------------------------------------------------------- // -// An `absl::bad_variant_access` type is an exception type that is thrown in +// An `absl::OTABSL_OPTION_NAMESPACE_NAME::bad_variant_access` type is an exception type that is thrown in // the following cases: // -// * Calling `absl::get(absl::variant) with an index or type that does not +// * Calling `absl::OTABSL_OPTION_NAMESPACE_NAME::get(absl::OTABSL_OPTION_NAMESPACE_NAME::variant) with an index or type that does not // match the currently selected alternative type -// * Calling `absl::visit on an `absl::variant` that is in the +// * Calling `absl::OTABSL_OPTION_NAMESPACE_NAME::visit on an `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` that is in the // `variant::valueless_by_exception` state. // // Example: // -// absl::variant v; +// absl::OTABSL_OPTION_NAMESPACE_NAME::variant v; // v = 1; // try { -// absl::get(v); -// } catch(const absl::bad_variant_access& e) { +// absl::OTABSL_OPTION_NAMESPACE_NAME::get(v); +// } catch(const absl::OTABSL_OPTION_NAMESPACE_NAME::bad_variant_access& e) { // std::cout << "Bad variant access: " << e.what() << '\n'; // } class bad_variant_access : public std::exception { diff --git a/api/include/opentelemetry/nostd/internal/absl/types/internal/variant.h b/api/include/opentelemetry/nostd/internal/absl/types/internal/variant.h index ee42da7c93..fc73cf5328 100644 --- a/api/include/opentelemetry/nostd/internal/absl/types/internal/variant.h +++ b/api/include/opentelemetry/nostd/internal/absl/types/internal/variant.h @@ -136,24 +136,24 @@ struct VariantAccessResultImpl; template class Variantemplate, class... T> struct VariantAccessResultImpl&> { - using type = typename absl::variant_alternative>::type&; + using type = typename absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative>::type&; }; template class Variantemplate, class... T> struct VariantAccessResultImpl&> { using type = - const typename absl::variant_alternative>::type&; + const typename absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative>::type&; }; template class Variantemplate, class... T> struct VariantAccessResultImpl&&> { - using type = typename absl::variant_alternative>::type&&; + using type = typename absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative>::type&&; }; template class Variantemplate, class... T> struct VariantAccessResultImpl&&> { using type = - const typename absl::variant_alternative>::type&&; + const typename absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative>::type&&; }; template @@ -198,7 +198,7 @@ using AlwaysZero = SizeT<0>; template struct VisitIndicesResultImpl { - using type = absl::result_of_t...)>; + using type = absl::OTABSL_OPTION_NAMESPACE_NAME::result_of_t...)>; }; template @@ -214,7 +214,7 @@ constexpr ReturnType call_with_indices(FunctionObject&& function) { std::is_same()( SizeT()...))>::value, "Not all visitation overloads have the same return type."); - return absl::forward(function)(SizeT()...); + return absl::OTABSL_OPTION_NAMESPACE_NAME::forward(function)(SizeT()...); } template @@ -265,7 +265,7 @@ struct MakeVisitationMatrix> : MakeVisitationMatrixImpl, - absl::make_index_sequence, + absl::OTABSL_OPTION_NAMESPACE_NAME::make_index_sequence, index_sequence> {}; struct UnreachableSwitchCase { @@ -284,7 +284,7 @@ struct UnreachableSwitchCase { assert(false); // NOLINT // Hack to silence potential no return warning -- cause an infinite loop. - return Run(absl::forward(op)); + return Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); #endif // Checks for __builtin_unreachable } }; @@ -292,7 +292,7 @@ struct UnreachableSwitchCase { template struct ReachableSwitchCase { static VisitIndicesResultT Run(Op&& op) { - return absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::base_internal::Invoke(absl::forward(op), SizeT()); + return absl::OTABSL_OPTION_NAMESPACE_NAME::base_internal::Invoke(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op), SizeT()); } }; @@ -326,7 +326,7 @@ using PickCase = typename PickCaseImpl<(I < EndIndex)>::template Apply; template [[noreturn]] ReturnType TypedThrowBadVariantAccess() { - absl::variant_internal::ThrowBadVariantAccess(); + absl::OTABSL_OPTION_NAMESPACE_NAME::variant_internal::ThrowBadVariantAccess(); } // Given N variant sizes, determine the number of cases there would need to be @@ -357,74 +357,74 @@ struct VisitIndicesSwitch { static VisitIndicesResultT Run(Op&& op, std::size_t i) { switch (i) { case 0: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 1: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 2: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 3: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 4: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 5: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 6: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 7: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 8: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 9: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 10: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 11: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 12: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 13: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 14: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 15: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 16: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 17: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 18: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 19: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 20: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 21: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 22: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 23: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 24: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 25: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 26: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 27: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 28: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 29: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 30: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 31: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 32: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); default: OTABSL_ASSERT(i == variant_npos); - return absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::base_internal::Invoke(absl::forward(op), NPos()); + return absl::OTABSL_OPTION_NAMESPACE_NAME::base_internal::Invoke(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op), NPos()); } } }; @@ -437,7 +437,7 @@ struct VisitIndicesFallback { MakeVisitationMatrix, Op, index_sequence<(EndIndices + 1)...>, index_sequence<>>::Run(), - (indices + 1)...)(absl::forward(op)); + (indices + 1)...)(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); } }; @@ -479,7 +479,7 @@ template struct VisitIndicesVariadicImpl; template -struct VisitIndicesVariadicImpl, EndIndices...> { +struct VisitIndicesVariadicImpl, EndIndices...> { // A type that can take an N-ary function object and converts it to a unary // function object that takes a single, flattened index, and "unflattens" it // into its individual dimensions when forwarding to the wrapped object. @@ -488,8 +488,8 @@ struct VisitIndicesVariadicImpl, EndIndices...> { template VisitIndicesResultT operator()( SizeT /*index*/) && { - return OTABSL_OPTION_INLINE_NAMESPACE_NAME::base_internal::Invoke( - absl::forward(op), + return absl::OTABSL_OPTION_NAMESPACE_NAME::base_internal::Invoke( + absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op), SizeT::value - std::size_t{1}>()...); } @@ -501,7 +501,7 @@ struct VisitIndicesVariadicImpl, EndIndices...> { static VisitIndicesResultT Run( Op&& op, SizeType... i) { return VisitIndicesSwitch::value>::Run( - FlattenedOp{absl::forward(op)}, + FlattenedOp{absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)}, FlattenIndices<(EndIndices + std::size_t{1})...>::Run( (i + std::size_t{1})...)); } @@ -509,7 +509,7 @@ struct VisitIndicesVariadicImpl, EndIndices...> { template struct VisitIndicesVariadic - : VisitIndicesVariadicImpl, + : VisitIndicesVariadicImpl, EndIndices...> {}; // This implementation will flatten N-ary visit operations into a single switch @@ -522,14 +522,14 @@ struct VisitIndicesVariadic // size. template struct VisitIndices - : absl::conditional_t<(NumCasesOfSwitch::value <= + : absl::OTABSL_OPTION_NAMESPACE_NAME::conditional_t<(NumCasesOfSwitch::value <= MaxUnrolledVisitCases), VisitIndicesVariadic, VisitIndicesFallback> {}; template struct VisitIndices - : absl::conditional_t<(EndIndex <= MaxUnrolledVisitCases), + : absl::OTABSL_OPTION_NAMESPACE_NAME::conditional_t<(EndIndex <= MaxUnrolledVisitCases), VisitIndicesSwitch, VisitIndicesFallback> {}; @@ -577,7 +577,7 @@ struct VariantCoreAccess { template static void Destroy(VariantType& self) { // NOLINT Derived(self).destroy(); - self.index_ = absl::variant_npos; + self.index_ = absl::OTABSL_OPTION_NAMESPACE_NAME::variant_npos; } template @@ -587,7 +587,7 @@ struct VariantCoreAccess { template static void InitFrom(Variant& self, Variant&& other) { // NOLINT - VisitIndices::value>::Run( + VisitIndices::value>::Run( InitFromVisitor{&self, std::forward(other)}, other.index()); @@ -612,7 +612,7 @@ struct VariantCoreAccess { TypedThrowBadVariantAccess>(); } - return Access(absl::forward(self)); + return Access(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(self)); } // The implementation of the move-assignment operation for a variant. @@ -629,7 +629,7 @@ struct VariantCoreAccess { } } - void operator()(SizeT /*new_i*/) const { + void operator()(SizeT /*new_i*/) const { Destroy(*left); } @@ -650,7 +650,7 @@ struct VariantCoreAccess { template void operator()(SizeT /*new_i*/) const { using New = - typename absl::variant_alternative::type; + typename absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative::type; if (left->index_ == NewIndex) { Access(*left) = Access(*right); @@ -662,7 +662,7 @@ struct VariantCoreAccess { } } - void operator()(SizeT /*new_i*/) const { + void operator()(SizeT /*new_i*/) const { Destroy(*left); } @@ -684,24 +684,24 @@ struct VariantCoreAccess { void operator()(SizeT /*old_i*/ ) const { - Access(*left) = absl::forward(other); + Access(*left) = absl::OTABSL_OPTION_NAMESPACE_NAME::forward(other); } template void operator()(SizeT /*old_i*/ ) const { using New = - typename absl::variant_alternative::type; + typename absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative::type; if (std::is_nothrow_constructible::value || !std::is_nothrow_move_constructible::value) { left->template emplace( - absl::forward(other)); + absl::OTABSL_OPTION_NAMESPACE_NAME::forward(other)); } else { // the standard says "equivalent to // operator=(variant(std::forward(t)))", but we use `emplace` here // because the variant's move assignment operator could be deleted. left->template emplace( - New(absl::forward(other))); + New(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(other))); } } @@ -712,18 +712,18 @@ struct VariantCoreAccess { template static ConversionAssignVisitor MakeConversionAssignVisitor(Left* left, QualifiedNew&& qual) { - return {left, absl::forward(qual)}; + return {left, absl::OTABSL_OPTION_NAMESPACE_NAME::forward(qual)}; } // Backend for operations for `emplace()` which destructs `*self` then // construct a new alternative with `Args...`. template - static typename absl::variant_alternative::type& Replace( + static typename absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative::type& Replace( Self* self, Args&&... args) { Destroy(*self); - using New = typename absl::variant_alternative::type; + using New = typename absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative::type; New* const result = ::new (static_cast(&self->state_)) - New(absl::forward(args)...); + New(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(args)...); self->index_ = NewIndex; return *result; } @@ -738,7 +738,7 @@ struct VariantCoreAccess { Access(std::forward(right))); } - void operator()(SizeT /*new_i*/) const { + void operator()(SizeT /*new_i*/) const { // This space intentionally left blank. } LeftVariant* left; @@ -888,13 +888,13 @@ struct IndexOfConstructedType< template struct ContainsVariantNPos - : absl::negation, - absl::integer_sequence>> {}; + : absl::OTABSL_OPTION_NAMESPACE_NAME::negation, + absl::OTABSL_OPTION_NAMESPACE_NAME::integer_sequence>> {}; template using RawVisitResult = - absl::result_of_t...)>; + absl::OTABSL_OPTION_NAMESPACE_NAME::result_of_t...)>; // NOTE: The spec requires that all return-paths yield the same type and is not // SFINAE-friendly, so we can deduce the return type by examining the first @@ -905,7 +905,7 @@ using RawVisitResult = template struct VisitResultImpl { using type = - absl::result_of_t...)>; + absl::OTABSL_OPTION_NAMESPACE_NAME::result_of_t...)>; }; // Done in two steps intentionally so that we don't cause substitution to fail. @@ -919,7 +919,7 @@ struct PerformVisitation { template constexpr ReturnType operator()(SizeT... indices) const { return Run(typename ContainsVariantNPos::type{}, - absl::index_sequence_for(), indices...); + absl::OTABSL_OPTION_NAMESPACE_NAME::index_sequence_for(), indices...); } template @@ -927,19 +927,19 @@ struct PerformVisitation { index_sequence, SizeT...) const { static_assert( std::is_same...)>>::value, "All visitation overloads must have the same return type."); - return absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::base_internal::Invoke( - absl::forward(op), + return absl::OTABSL_OPTION_NAMESPACE_NAME::base_internal::Invoke( + absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op), VariantCoreAccess::Access( - absl::forward(std::get(variant_tup)))...); + absl::OTABSL_OPTION_NAMESPACE_NAME::forward(std::get(variant_tup)))...); } template [[noreturn]] ReturnType Run(std::true_type /*has_valueless*/, index_sequence, SizeT...) const { - absl::variant_internal::ThrowBadVariantAccess(); + absl::OTABSL_OPTION_NAMESPACE_NAME::variant_internal::ThrowBadVariantAccess(); } // TODO(calabrese) Avoid using a tuple, which causes lots of instantiations @@ -981,11 +981,11 @@ union Union { template explicit constexpr Union(EmplaceTag<0>, P&&... args) - : head(absl::forward

      (args)...) {} + : head(absl::OTABSL_OPTION_NAMESPACE_NAME::forward

      (args)...) {} template explicit constexpr Union(EmplaceTag, P&&... args) - : tail(EmplaceTag{}, absl::forward

      (args)...) {} + : tail(EmplaceTag{}, absl::OTABSL_OPTION_NAMESPACE_NAME::forward

      (args)...) {} Head head; TailUnion tail; @@ -1013,11 +1013,11 @@ union DestructibleUnionImpl { template explicit constexpr DestructibleUnionImpl(EmplaceTag<0>, P&&... args) - : head(absl::forward

      (args)...) {} + : head(absl::OTABSL_OPTION_NAMESPACE_NAME::forward

      (args)...) {} template explicit constexpr DestructibleUnionImpl(EmplaceTag, P&&... args) - : tail(EmplaceTag{}, absl::forward

      (args)...) {} + : tail(EmplaceTag{}, absl::OTABSL_OPTION_NAMESPACE_NAME::forward

      (args)...) {} ~DestructibleUnionImpl() {} @@ -1030,7 +1030,7 @@ union DestructibleUnionImpl { // this resultant type. template using DestructibleUnion = - absl::conditional_t>::value, Union, + absl::OTABSL_OPTION_NAMESPACE_NAME::conditional_t>::value, Union, DestructibleUnionImpl>; // Deepest base, containing the actual union and the discriminator @@ -1040,7 +1040,7 @@ class VariantStateBase { using Variant = variant; template ::value, LazyH>> constexpr VariantStateBase() noexcept( std::is_nothrow_default_constructible::value) @@ -1048,7 +1048,7 @@ class VariantStateBase { template explicit constexpr VariantStateBase(EmplaceTag tag, P&&... args) - : state_(tag, absl::forward

      (args)...), index_(I) {} + : state_(tag, absl::OTABSL_OPTION_NAMESPACE_NAME::forward

      (args)...), index_(I) {} explicit constexpr VariantStateBase(NoopConstructorTag) : state_(NoopConstructorTag()), index_(variant_npos) {} @@ -1059,7 +1059,7 @@ class VariantStateBase { std::size_t index_; }; -using absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::internal::identity; +using absl::OTABSL_OPTION_NAMESPACE_NAME::internal::identity; // OverloadSet::Overload() is a unary function which is overloaded to // take any of the element types of the variant, by reference-to-const. @@ -1106,37 +1106,37 @@ using NotEqualResult = decltype(std::declval() != std::declval()); using type_traits_internal::is_detected_convertible; template -using RequireAllHaveEqualT = absl::enable_if_t< - absl::conjunction...>::value, +using RequireAllHaveEqualT = absl::OTABSL_OPTION_NAMESPACE_NAME::enable_if_t< + absl::OTABSL_OPTION_NAMESPACE_NAME::conjunction...>::value, bool>; template using RequireAllHaveNotEqualT = - absl::enable_if_t...>::value, bool>; template using RequireAllHaveLessThanT = - absl::enable_if_t...>::value, bool>; template using RequireAllHaveLessThanOrEqualT = - absl::enable_if_t...>::value, bool>; template using RequireAllHaveGreaterThanOrEqualT = - absl::enable_if_t...>::value, bool>; template using RequireAllHaveGreaterThanT = - absl::enable_if_t...>::value, bool>; @@ -1171,7 +1171,7 @@ struct VariantHelper> { template struct CanConvertFrom> - : public absl::conjunction...> {}; + : public absl::OTABSL_OPTION_NAMESPACE_NAME::conjunction...> {}; }; // A type with nontrivial copy ctor and trivial move ctor. @@ -1220,7 +1220,7 @@ class VariantCopyAssignBaseNontrivial; // Base that is dependent on whether or not the destructor can be trivial. template using VariantStateBaseDestructor = - absl::conditional_t>::value, + absl::OTABSL_OPTION_NAMESPACE_NAME::conditional_t>::value, VariantStateBase, VariantStateBaseDestructorNontrivial>; @@ -1232,44 +1232,44 @@ using VariantStateBaseDestructor = // So we have to use a different approach (i.e. `HasTrivialMoveConstructor`) to // work around the bug. template -using VariantMoveBase = absl::conditional_t< - absl::disjunction< - absl::negation...>>, - absl::conjunction...>>::value, +using VariantMoveBase = absl::OTABSL_OPTION_NAMESPACE_NAME::conditional_t< + absl::OTABSL_OPTION_NAMESPACE_NAME::disjunction< + absl::OTABSL_OPTION_NAMESPACE_NAME::negation...>>, + absl::OTABSL_OPTION_NAMESPACE_NAME::conjunction...>>::value, VariantStateBaseDestructor, VariantMoveBaseNontrivial>; // Base that is dependent on whether or not the copy-constructor can be trivial. template -using VariantCopyBase = absl::conditional_t< - absl::disjunction< - absl::negation...>>, +using VariantCopyBase = absl::OTABSL_OPTION_NAMESPACE_NAME::conditional_t< + absl::OTABSL_OPTION_NAMESPACE_NAME::disjunction< + absl::OTABSL_OPTION_NAMESPACE_NAME::negation...>>, std::is_copy_constructible>>::value, VariantMoveBase, VariantCopyBaseNontrivial>; // Base that is dependent on whether or not the move-assign can be trivial. template -using VariantMoveAssignBase = absl::conditional_t< - absl::disjunction< - absl::conjunction>, +using VariantMoveAssignBase = absl::OTABSL_OPTION_NAMESPACE_NAME::conditional_t< + absl::OTABSL_OPTION_NAMESPACE_NAME::disjunction< + absl::OTABSL_OPTION_NAMESPACE_NAME::conjunction>, std::is_move_constructible>, std::is_destructible>>, - absl::negation..., + absl::OTABSL_OPTION_NAMESPACE_NAME::negation..., // Note: We're not qualifying this with - // absl:: because it doesn't compile + // absl::OTABSL_OPTION_NAMESPACE_NAME:: because it doesn't compile // under MSVC. is_move_assignable...>>>::value, VariantCopyBase, VariantMoveAssignBaseNontrivial>; // Base that is dependent on whether or not the copy-assign can be trivial. template -using VariantCopyAssignBase = absl::conditional_t< - absl::disjunction< - absl::conjunction>, +using VariantCopyAssignBase = absl::OTABSL_OPTION_NAMESPACE_NAME::conditional_t< + absl::OTABSL_OPTION_NAMESPACE_NAME::disjunction< + absl::OTABSL_OPTION_NAMESPACE_NAME::conjunction>, std::is_copy_constructible>, std::is_destructible>>, - absl::negation..., + absl::OTABSL_OPTION_NAMESPACE_NAME::negation..., // Note: We're not qualifying this with - // absl:: because it doesn't compile + // absl::OTABSL_OPTION_NAMESPACE_NAME:: because it doesn't compile // under MSVC. is_copy_assignable...>>>::value, VariantMoveAssignBase, VariantCopyAssignBaseNontrivial>; @@ -1299,11 +1299,11 @@ class VariantStateBaseDestructorNontrivial : protected VariantStateBase { template void operator()(SizeT i) const { using Alternative = - typename absl::variant_alternative>::type; + typename absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative>::type; variant_internal::AccessUnion(self->state_, i).~Alternative(); } - void operator()(SizeT /*i*/) const { + void operator()(SizeT /*i*/) const { // This space intentionally left blank } @@ -1331,12 +1331,12 @@ class VariantMoveBaseNontrivial : protected VariantStateBaseDestructor { template void operator()(SizeT i) const { using Alternative = - typename absl::variant_alternative>::type; + typename absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative>::type; ::new (static_cast(&self->state_)) Alternative( - variant_internal::AccessUnion(absl::move(other->state_), i)); + variant_internal::AccessUnion(absl::OTABSL_OPTION_NAMESPACE_NAME::move(other->state_), i)); } - void operator()(SizeT /*i*/) const {} + void operator()(SizeT /*i*/) const {} VariantMoveBaseNontrivial* self; VariantMoveBaseNontrivial* other; @@ -1344,7 +1344,7 @@ class VariantMoveBaseNontrivial : protected VariantStateBaseDestructor { VariantMoveBaseNontrivial() = default; VariantMoveBaseNontrivial(VariantMoveBaseNontrivial&& other) noexcept( - absl::conjunction...>::value) + absl::OTABSL_OPTION_NAMESPACE_NAME::conjunction...>::value) : Base(NoopConstructorTag()) { VisitIndices::Run(Construct{this, &other}, other.index_); index_ = other.index_; @@ -1376,12 +1376,12 @@ class VariantCopyBaseNontrivial : protected VariantMoveBase { template void operator()(SizeT i) const { using Alternative = - typename absl::variant_alternative>::type; + typename absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative>::type; ::new (static_cast(&self->state_)) Alternative(variant_internal::AccessUnion(other->state_, i)); } - void operator()(SizeT /*i*/) const {} + void operator()(SizeT /*i*/) const {} VariantCopyBaseNontrivial* self; const VariantCopyBaseNontrivial* other; @@ -1421,7 +1421,7 @@ class VariantMoveAssignBaseNontrivial : protected VariantCopyBase { VariantMoveAssignBaseNontrivial& operator=(VariantMoveAssignBaseNontrivial&& other) noexcept( - absl::conjunction..., + absl::OTABSL_OPTION_NAMESPACE_NAME::conjunction..., std::is_nothrow_move_assignable...>::value) { VisitIndices::Run( VariantCoreAccess::MakeMoveAssignVisitor(this, &other), other.index_); @@ -1471,7 +1471,7 @@ struct EqualsOp { const variant* v; const variant* w; - constexpr bool operator()(SizeT /*v_i*/) const { + constexpr bool operator()(SizeT /*v_i*/) const { return true; } @@ -1486,7 +1486,7 @@ struct NotEqualsOp { const variant* v; const variant* w; - constexpr bool operator()(SizeT /*v_i*/) const { + constexpr bool operator()(SizeT /*v_i*/) const { return false; } @@ -1501,7 +1501,7 @@ struct LessThanOp { const variant* v; const variant* w; - constexpr bool operator()(SizeT /*v_i*/) const { + constexpr bool operator()(SizeT /*v_i*/) const { return false; } @@ -1516,7 +1516,7 @@ struct GreaterThanOp { const variant* v; const variant* w; - constexpr bool operator()(SizeT /*v_i*/) const { + constexpr bool operator()(SizeT /*v_i*/) const { return false; } @@ -1531,7 +1531,7 @@ struct LessThanOrEqualsOp { const variant* v; const variant* w; - constexpr bool operator()(SizeT /*v_i*/) const { + constexpr bool operator()(SizeT /*v_i*/) const { return true; } @@ -1546,7 +1546,7 @@ struct GreaterThanOrEqualsOp { const variant* v; const variant* w; - constexpr bool operator()(SizeT /*v_i*/) const { + constexpr bool operator()(SizeT /*v_i*/) const { return true; } @@ -1584,7 +1584,7 @@ struct Swap { VariantCoreAccess::InitFrom(*v, std::move(tmp)); } - void operator()(SizeT /*w_i*/) const { + void operator()(SizeT /*w_i*/) const { if (!v->valueless_by_exception()) { generic_swap(); } @@ -1618,7 +1618,7 @@ struct VariantHashVisitor { template struct VariantHashBase...>::value>, Ts...> { using argument_type = Variant; diff --git a/api/include/opentelemetry/nostd/internal/absl/types/variant.h b/api/include/opentelemetry/nostd/internal/absl/types/variant.h index 2649a29ce3..cbce326c26 100644 --- a/api/include/opentelemetry/nostd/internal/absl/types/variant.h +++ b/api/include/opentelemetry/nostd/internal/absl/types/variant.h @@ -16,26 +16,26 @@ // variant.h // ----------------------------------------------------------------------------- // -// This header file defines an `absl::variant` type for holding a type-safe +// This header file defines an `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` type for holding a type-safe // value of some prescribed set of types (noted as alternative types), and // associated functions for managing variants. // -// The `absl::variant` type is a form of type-safe union. An `absl::variant` +// The `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` type is a form of type-safe union. An `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` // should always hold a value of one of its alternative types (except in the // "valueless by exception state" -- see below). A default-constructed -// `absl::variant` will hold the value of its first alternative type, provided +// `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` will hold the value of its first alternative type, provided // it is default-constructible. // -// In exceptional cases due to error, an `absl::variant` can hold no +// In exceptional cases due to error, an `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` can hold no // value (known as a "valueless by exception" state), though this is not the // norm. // -// As with `absl::optional`, an `absl::variant` -- when it holds a value -- +// As with `absl::OTABSL_OPTION_NAMESPACE_NAME::optional`, an `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` -- when it holds a value -- // allocates a value of that type directly within the `variant` itself; it // cannot hold a reference, array, or the type `void`; it can, however, hold a // pointer to externally managed memory. // -// `absl::variant` is a C++11 compatible version of the C++17 `std::variant` +// `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` is a C++11 compatible version of the C++17 `std::variant` // abstraction and is designed to be a drop-in replacement for code compliant // with C++17. @@ -82,10 +82,10 @@ namespace absl { OTABSL_NAMESPACE_BEGIN // ----------------------------------------------------------------------------- -// absl::variant +// absl::OTABSL_OPTION_NAMESPACE_NAME::variant // ----------------------------------------------------------------------------- // -// An `absl::variant` type is a form of type-safe union. An `absl::variant` -- +// An `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` type is a form of type-safe union. An `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` -- // except in exceptional cases -- always holds a value of one of its alternative // types. // @@ -93,29 +93,29 @@ OTABSL_NAMESPACE_BEGIN // // // Construct a variant that holds either an integer or a std::string and // // assign it to a std::string. -// absl::variant v = std::string("abc"); +// absl::OTABSL_OPTION_NAMESPACE_NAME::variant v = std::string("abc"); // // // A default-constructed variant will hold a value-initialized value of // // the first alternative type. -// auto a = absl::variant(); // Holds an int of value '0'. +// auto a = absl::OTABSL_OPTION_NAMESPACE_NAME::variant(); // Holds an int of value '0'. // // // variants are assignable. // // // copy assignment -// auto v1 = absl::variant("abc"); -// auto v2 = absl::variant(10); +// auto v1 = absl::OTABSL_OPTION_NAMESPACE_NAME::variant("abc"); +// auto v2 = absl::OTABSL_OPTION_NAMESPACE_NAME::variant(10); // v2 = v1; // copy assign // // // move assignment -// auto v1 = absl::variant("abc"); -// v1 = absl::variant(10); +// auto v1 = absl::OTABSL_OPTION_NAMESPACE_NAME::variant("abc"); +// v1 = absl::OTABSL_OPTION_NAMESPACE_NAME::variant(10); // // // assignment through type conversion // a = 128; // variant contains int // a = "128"; // variant contains std::string // -// An `absl::variant` holding a value of one of its alternative types `T` holds -// an allocation of `T` directly within the variant itself. An `absl::variant` +// An `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` holding a value of one of its alternative types `T` holds +// an allocation of `T` directly within the variant itself. An `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` // is not allowed to allocate additional storage, such as dynamic memory, to // allocate the contained value. The contained value shall be allocated in a // region of the variant storage suitably aligned for all alternative types. @@ -124,8 +124,8 @@ class variant; // swap() // -// Swaps two `absl::variant` values. This function is equivalent to `v.swap(w)` -// where `v` and `w` are `absl::variant` types. +// Swaps two `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` values. This function is equivalent to `v.swap(w)` +// where `v` and `w` are `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` types. // // Note that this function requires all alternative types to be both swappable // and move-constructible, because any two variants may refer to either the same @@ -134,8 +134,8 @@ class variant; // template < typename... Ts, - absl::enable_if_t< - absl::conjunction..., + absl::OTABSL_OPTION_NAMESPACE_NAME::enable_if_t< + absl::OTABSL_OPTION_NAMESPACE_NAME::conjunction..., type_traits_internal::IsSwappable...>::value, int> = 0> void swap(variant& v, variant& w) noexcept(noexcept(v.swap(w))) { @@ -144,25 +144,25 @@ void swap(variant& v, variant& w) noexcept(noexcept(v.swap(w))) { // variant_size // -// Returns the number of alternative types available for a given `absl::variant` +// Returns the number of alternative types available for a given `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` // type as a compile-time constant expression. As this is a class template, it // is not generally useful for accessing the number of alternative types of -// any given `absl::variant` instance. +// any given `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` instance. // // Example: // -// auto a = absl::variant; +// auto a = absl::OTABSL_OPTION_NAMESPACE_NAME::variant; // constexpr int num_types = -// absl::variant_size>(); +// absl::OTABSL_OPTION_NAMESPACE_NAME::variant_size>(); // // // You can also use the member constant `value`. // constexpr int num_types = -// absl::variant_size>::value; +// absl::OTABSL_OPTION_NAMESPACE_NAME::variant_size>::value; // -// // `absl::variant_size` is more valuable for use in generic code: +// // `absl::OTABSL_OPTION_NAMESPACE_NAME::variant_size` is more valuable for use in generic code: // template // constexpr bool IsVariantMultivalue() { -// return absl::variant_size() > 1; +// return absl::OTABSL_OPTION_NAMESPACE_NAME::variant_size() > 1; // } // // Note that the set of cv-qualified specializations of `variant_size` are @@ -189,20 +189,20 @@ struct variant_size : variant_size::type {}; // variant_alternative // -// Returns the alternative type for a given `absl::variant` at the passed +// Returns the alternative type for a given `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` at the passed // index value as a compile-time constant expression. As this is a class // template resulting in a type, it is not useful for access of the run-time -// value of any given `absl::variant` variable. +// value of any given `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` variable. // // Example: // // // The type of the 0th alternative is "int". // using alternative_type_0 -// = absl::variant_alternative<0, absl::variant>::type; +// = absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative<0, absl::OTABSL_OPTION_NAMESPACE_NAME::variant>::type; // // static_assert(std::is_same::value, ""); // -// // `absl::variant_alternative` is more valuable for use in generic code: +// // `absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative` is more valuable for use in generic code: // template // constexpr bool IsFirstElementTrivial() { // return std::is_trivial_v::type>; @@ -244,7 +244,7 @@ struct variant_alternative { // Example: // // using alternative_type_0 -// = absl::variant_alternative_t<0, absl::variant>; +// = absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative_t<0, absl::OTABSL_OPTION_NAMESPACE_NAME::variant>; // static_assert(std::is_same::value, ""); template using variant_alternative_t = typename variant_alternative::type; @@ -256,8 +256,8 @@ using variant_alternative_t = typename variant_alternative::type; // // Example: // -// absl::variant foo = 42; -// if (absl::holds_alternative(foo)) { +// absl::OTABSL_OPTION_NAMESPACE_NAME::variant foo = 42; +// if (absl::OTABSL_OPTION_NAMESPACE_NAME::holds_alternative(foo)) { // std::cout << "The variant holds an integer"; // } template @@ -278,22 +278,22 @@ constexpr bool holds_alternative(const variant& v) noexcept { // using a type that is not unique within the variant's set of alternative types // is a compile-time error. If the index of the alternative being specified is // different from the index of the alternative that is currently stored, throws -// `absl::bad_variant_access`. +// `absl::OTABSL_OPTION_NAMESPACE_NAME::bad_variant_access`. // // Example: // -// auto a = absl::variant; +// auto a = absl::OTABSL_OPTION_NAMESPACE_NAME::variant; // // // Get the value by type (if unique). -// int i = absl::get(a); +// int i = absl::OTABSL_OPTION_NAMESPACE_NAME::get(a); // -// auto b = absl::variant; +// auto b = absl::OTABSL_OPTION_NAMESPACE_NAME::variant; // // // Getting the value by a type that is not unique is ill-formed. -// int j = absl::get(b); // Compile Error! +// int j = absl::OTABSL_OPTION_NAMESPACE_NAME::get(b); // Compile Error! // // // Getting value by index not ambiguous and allowed. -// int k = absl::get<1>(b); +// int k = absl::OTABSL_OPTION_NAMESPACE_NAME::get<1>(b); // Overload for getting a variant's lvalue by type. template @@ -303,11 +303,11 @@ constexpr T& get(variant& v) { // NOLINT } // Overload for getting a variant's rvalue by type. -// Note: `absl::move()` is required to allow use of constexpr in C++11. +// Note: `absl::OTABSL_OPTION_NAMESPACE_NAME::move()` is required to allow use of constexpr in C++11. template constexpr T&& get(variant&& v) { return variant_internal::VariantCoreAccess::CheckedAccess< - variant_internal::IndexOf::value>(absl::move(v)); + variant_internal::IndexOf::value>(absl::OTABSL_OPTION_NAMESPACE_NAME::move(v)); } // Overload for getting a variant's const lvalue by type. @@ -318,11 +318,11 @@ constexpr const T& get(const variant& v) { } // Overload for getting a variant's const rvalue by type. -// Note: `absl::move()` is required to allow use of constexpr in C++11. +// Note: `absl::OTABSL_OPTION_NAMESPACE_NAME::move()` is required to allow use of constexpr in C++11. template constexpr const T&& get(const variant&& v) { return variant_internal::VariantCoreAccess::CheckedAccess< - variant_internal::IndexOf::value>(absl::move(v)); + variant_internal::IndexOf::value>(absl::OTABSL_OPTION_NAMESPACE_NAME::move(v)); } // Overload for getting a variant's lvalue by index. @@ -333,11 +333,11 @@ constexpr variant_alternative_t>& get( } // Overload for getting a variant's rvalue by index. -// Note: `absl::move()` is required to allow use of constexpr in C++11. +// Note: `absl::OTABSL_OPTION_NAMESPACE_NAME::move()` is required to allow use of constexpr in C++11. template constexpr variant_alternative_t>&& get( variant&& v) { - return variant_internal::VariantCoreAccess::CheckedAccess(absl::move(v)); + return variant_internal::VariantCoreAccess::CheckedAccess(absl::OTABSL_OPTION_NAMESPACE_NAME::move(v)); } // Overload for getting a variant's const lvalue by index. @@ -348,11 +348,11 @@ constexpr const variant_alternative_t>& get( } // Overload for getting a variant's const rvalue by index. -// Note: `absl::move()` is required to allow use of constexpr in C++11. +// Note: `absl::OTABSL_OPTION_NAMESPACE_NAME::move()` is required to allow use of constexpr in C++11. template constexpr const variant_alternative_t>&& get( const variant&& v) { - return variant_internal::VariantCoreAccess::CheckedAccess(absl::move(v)); + return variant_internal::VariantCoreAccess::CheckedAccess(absl::OTABSL_OPTION_NAMESPACE_NAME::move(v)); } // get_if() @@ -368,7 +368,7 @@ constexpr const variant_alternative_t>&& get( // Overload for getting a pointer to the value stored in the given variant by // index. template -constexpr absl::add_pointer_t>> +constexpr absl::OTABSL_OPTION_NAMESPACE_NAME::add_pointer_t>> get_if(variant* v) noexcept { return (v != nullptr && v->index() == I) ? std::addressof( @@ -379,7 +379,7 @@ get_if(variant* v) noexcept { // Overload for getting a pointer to the const value stored in the given // variant by index. template -constexpr absl::add_pointer_t>> +constexpr absl::OTABSL_OPTION_NAMESPACE_NAME::add_pointer_t>> get_if(const variant* v) noexcept { return (v != nullptr && v->index() == I) ? std::addressof( @@ -390,21 +390,21 @@ get_if(const variant* v) noexcept { // Overload for getting a pointer to the value stored in the given variant by // type. template -constexpr absl::add_pointer_t get_if(variant* v) noexcept { - return absl::get_if::value>(v); +constexpr absl::OTABSL_OPTION_NAMESPACE_NAME::add_pointer_t get_if(variant* v) noexcept { + return absl::OTABSL_OPTION_NAMESPACE_NAME::get_if::value>(v); } // Overload for getting a pointer to the const value stored in the given variant // by type. template -constexpr absl::add_pointer_t get_if( +constexpr absl::OTABSL_OPTION_NAMESPACE_NAME::add_pointer_t get_if( const variant* v) noexcept { - return absl::get_if::value>(v); + return absl::OTABSL_OPTION_NAMESPACE_NAME::get_if::value>(v); } // visit() // -// Calls a provided functor on a given set of variants. `absl::visit()` is +// Calls a provided functor on a given set of variants. `absl::OTABSL_OPTION_NAMESPACE_NAME::visit()` is // commonly used to conditionally inspect the state of a given variant (or set // of variants). // @@ -421,19 +421,19 @@ constexpr absl::add_pointer_t get_if( // } // }; // -// // Declare our variant, and call `absl::visit()` on it. +// // Declare our variant, and call `absl::OTABSL_OPTION_NAMESPACE_NAME::visit()` on it. // // Note that `GetVariant()` returns void in either case. -// absl::variant foo = std::string("foo"); +// absl::OTABSL_OPTION_NAMESPACE_NAME::variant foo = std::string("foo"); // GetVariant visitor; -// absl::visit(visitor, foo); // Prints `The variant's value is: foo' +// absl::OTABSL_OPTION_NAMESPACE_NAME::visit(visitor, foo); // Prints `The variant's value is: foo' template variant_internal::VisitResult visit(Visitor&& vis, Variants&&... vars) { return variant_internal:: - VisitIndices >::value...>::Run( + VisitIndices >::value...>::Run( variant_internal::PerformVisitation{ - std::forward_as_tuple(absl::forward(vars)...), - absl::forward(vis)}, + std::forward_as_tuple(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(vars)...), + absl::OTABSL_OPTION_NAMESPACE_NAME::forward(vis)}, vars.index()...); } @@ -443,7 +443,7 @@ variant_internal::VisitResult visit(Visitor&& vis, // which the first variant type is otherwise not default-constructible. struct monostate {}; -// `absl::monostate` Relational Operators +// `absl::OTABSL_OPTION_NAMESPACE_NAME::monostate` Relational Operators constexpr bool operator<(monostate, monostate) noexcept { return false; } constexpr bool operator>(monostate, monostate) noexcept { return false; } @@ -454,20 +454,20 @@ constexpr bool operator!=(monostate, monostate) noexcept { return false; } //------------------------------------------------------------------------------ -// `absl::variant` Template Definition +// `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` Template Definition //------------------------------------------------------------------------------ template class variant : private variant_internal::VariantBase { - static_assert(absl::conjunction, + static_assert(absl::OTABSL_OPTION_NAMESPACE_NAME::conjunction, std::is_object...>::value, "Attempted to instantiate a variant containing a non-object " "type."); - // Intentionally not qualifying `negation` with `absl::` to work around a bug + // Intentionally not qualifying `negation` with `absl::OTABSL_OPTION_NAMESPACE_NAME::` to work around a bug // in MSVC 2015 with inline namespace and variadic template. - static_assert(absl::conjunction >, + static_assert(absl::OTABSL_OPTION_NAMESPACE_NAME::conjunction >, negation >...>::value, "Attempted to instantiate a variant containing an array type."); - static_assert(absl::conjunction, + static_assert(absl::OTABSL_OPTION_NAMESPACE_NAME::conjunction, std::is_nothrow_destructible...>::value, "Attempted to instantiate a variant containing a non-nothrow " "destructible type."); @@ -499,18 +499,18 @@ class variant : private variant_internal::VariantBase { // // NOTE: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0608r1.html // has been voted passed the design phase in the C++ standard meeting in Mar - // 2018. It will be implemented and integrated into `absl::variant`. + // 2018. It will be implemented and integrated into `absl::OTABSL_OPTION_NAMESPACE_NAME::variant`. template < class T, std::size_t I = std::enable_if< variant_internal::IsNeitherSelfNorInPlace>::value, + absl::OTABSL_OPTION_NAMESPACE_NAME::decay_t>::value, variant_internal::IndexOfConstructedType>::type::value, - class Tj = absl::variant_alternative_t, - absl::enable_if_t::value>* = + class Tj = absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative_t, + absl::OTABSL_OPTION_NAMESPACE_NAME::enable_if_t::value>* = nullptr> constexpr variant(T&& t) noexcept(std::is_nothrow_constructible::value) - : Base(variant_internal::EmplaceTag(), absl::forward(t)) {} + : Base(variant_internal::EmplaceTag(), absl::OTABSL_OPTION_NAMESPACE_NAME::forward(t)) {} // Constructs a variant of an alternative type from the arguments through // direct-initialization. @@ -524,7 +524,7 @@ class variant : private variant_internal::VariantBase { constexpr explicit variant(in_place_type_t, Args&&... args) : Base(variant_internal::EmplaceTag< variant_internal::UnambiguousIndexOf::value>(), - absl::forward(args)...) {} + absl::OTABSL_OPTION_NAMESPACE_NAME::forward(args)...) {} // Constructs a variant of an alternative type from an initializer list // and other arguments through direct-initialization. @@ -539,7 +539,7 @@ class variant : private variant_internal::VariantBase { Args&&... args) : Base(variant_internal::EmplaceTag< variant_internal::UnambiguousIndexOf::value>(), - il, absl::forward(args)...) {} + il, absl::OTABSL_OPTION_NAMESPACE_NAME::forward(args)...) {} // Constructs a variant of an alternative type from a provided index, // through value-initialization using the provided forwarded arguments. @@ -548,7 +548,7 @@ class variant : private variant_internal::VariantBase { variant_internal::VariantAlternativeSfinaeT, Args...>::value>::type* = nullptr> constexpr explicit variant(in_place_index_t, Args&&... args) - : Base(variant_internal::EmplaceTag(), absl::forward(args)...) {} + : Base(variant_internal::EmplaceTag(), absl::OTABSL_OPTION_NAMESPACE_NAME::forward(args)...) {} // Constructs a variant of an alternative type from a provided index, // through value-initialization of an initializer list and the provided @@ -560,12 +560,12 @@ class variant : private variant_internal::VariantBase { constexpr explicit variant(in_place_index_t, std::initializer_list il, Args&&... args) : Base(variant_internal::EmplaceTag(), il, - absl::forward(args)...) {} + absl::OTABSL_OPTION_NAMESPACE_NAME::forward(args)...) {} // Destructors // Destroys the variant's currently contained value, provided that - // `absl::valueless_by_exception()` is false. + // `absl::OTABSL_OPTION_NAMESPACE_NAME::valueless_by_exception()` is false. ~variant() = default; // Assignment Operators @@ -580,13 +580,13 @@ class variant : private variant_internal::VariantBase { // // NOTE: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0608r1.html // has been voted passed the design phase in the C++ standard meeting in Mar - // 2018. It will be implemented and integrated into `absl::variant`. + // 2018. It will be implemented and integrated into `absl::OTABSL_OPTION_NAMESPACE_NAME::variant`. template < class T, std::size_t I = std::enable_if< - !std::is_same, variant>::value, + !std::is_same, variant>::value, variant_internal::IndexOfConstructedType>::type::value, - class Tj = absl::variant_alternative_t, + class Tj = absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative_t, typename std::enable_if::value && std::is_constructible::value>::type* = nullptr> @@ -595,7 +595,7 @@ class variant : private variant_internal::VariantBase { std::is_nothrow_constructible::value) { variant_internal::VisitIndices::Run( variant_internal::VariantCoreAccess::MakeConversionAssignVisitor( - this, absl::forward(t)), + this, absl::OTABSL_OPTION_NAMESPACE_NAME::forward(t)), index()); return *this; @@ -606,89 +606,89 @@ class variant : private variant_internal::VariantBase { // Constructs a value of the given alternative type T within the variant. The // existing value of the variant is destroyed first (provided that - // `absl::valueless_by_exception()` is false). Requires that T is unambiguous + // `absl::OTABSL_OPTION_NAMESPACE_NAME::valueless_by_exception()` is false). Requires that T is unambiguous // in the variant. // // Example: // - // absl::variant, int, std::string> v; + // absl::OTABSL_OPTION_NAMESPACE_NAME::variant, int, std::string> v; // v.emplace(99); // v.emplace("abc"); template < class T, class... Args, typename std::enable_if::value, variant>, Args...>::value>::type* = nullptr> T& emplace(Args&&... args) { return variant_internal::VariantCoreAccess::Replace< variant_internal::UnambiguousIndexOf::value>( - this, absl::forward(args)...); + this, absl::OTABSL_OPTION_NAMESPACE_NAME::forward(args)...); } // Constructs a value of the given alternative type T within the variant using // an initializer list. The existing value of the variant is destroyed first - // (provided that `absl::valueless_by_exception()` is false). Requires that T + // (provided that `absl::OTABSL_OPTION_NAMESPACE_NAME::valueless_by_exception()` is false). Requires that T // is unambiguous in the variant. // // Example: // - // absl::variant, int, std::string> v; + // absl::OTABSL_OPTION_NAMESPACE_NAME::variant, int, std::string> v; // v.emplace>({0, 1, 2}); template < class T, class U, class... Args, typename std::enable_if::value, variant>, std::initializer_list&, Args...>::value>::type* = nullptr> T& emplace(std::initializer_list il, Args&&... args) { return variant_internal::VariantCoreAccess::Replace< variant_internal::UnambiguousIndexOf::value>( - this, il, absl::forward(args)...); + this, il, absl::OTABSL_OPTION_NAMESPACE_NAME::forward(args)...); } // Destroys the current value of the variant (provided that - // `absl::valueless_by_exception()` is false) and constructs a new value at + // `absl::OTABSL_OPTION_NAMESPACE_NAME::valueless_by_exception()` is false) and constructs a new value at // the given index. // // Example: // - // absl::variant, int, int> v; + // absl::OTABSL_OPTION_NAMESPACE_NAME::variant, int, int> v; // v.emplace<1>(99); // v.emplace<2>(98); // v.emplace(99); // Won't compile. 'int' isn't a unique type. template , + std::is_constructible, Args...>::value>::type* = nullptr> - absl::variant_alternative_t& emplace(Args&&... args) { + absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative_t& emplace(Args&&... args) { return variant_internal::VariantCoreAccess::Replace( - this, absl::forward(args)...); + this, absl::OTABSL_OPTION_NAMESPACE_NAME::forward(args)...); } // Destroys the current value of the variant (provided that - // `absl::valueless_by_exception()` is false) and constructs a new value at + // `absl::OTABSL_OPTION_NAMESPACE_NAME::valueless_by_exception()` is false) and constructs a new value at // the given index using an initializer list and the provided arguments. // // Example: // - // absl::variant, int, int> v; + // absl::OTABSL_OPTION_NAMESPACE_NAME::variant, int, int> v; // v.emplace<0>({0, 1, 2}); template , + absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative_t, std::initializer_list&, Args...>::value>::type* = nullptr> - absl::variant_alternative_t& emplace(std::initializer_list il, + absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative_t& emplace(std::initializer_list il, Args&&... args) { return variant_internal::VariantCoreAccess::Replace( - this, il, absl::forward(args)...); + this, il, absl::OTABSL_OPTION_NAMESPACE_NAME::forward(args)...); } // variant::valueless_by_exception() // // Returns false if and only if the variant currently holds a valid value. constexpr bool valueless_by_exception() const noexcept { - return this->index_ == absl::variant_npos; + return this->index_ == absl::OTABSL_OPTION_NAMESPACE_NAME::variant_npos; } // variant::index() @@ -702,7 +702,7 @@ class variant : private variant_internal::VariantBase { // Swaps the values of two variant objects. // void swap(variant& rhs) noexcept( - absl::conjunction< + absl::OTABSL_OPTION_NAMESPACE_NAME::conjunction< std::is_nothrow_move_constructible, std::is_nothrow_move_constructible..., type_traits_internal::IsNothrowSwappable, @@ -810,14 +810,14 @@ namespace std { // hash() template <> // NOLINT -struct hash { - std::size_t operator()(absl::monostate) const { return 0; } +struct hash { + std::size_t operator()(absl::OTABSL_OPTION_NAMESPACE_NAME::monostate) const { return 0; } }; template // NOLINT -struct hash> - : absl::variant_internal::VariantHashBase, void, - absl::remove_const_t...> {}; +struct hash> + : absl::OTABSL_OPTION_NAMESPACE_NAME::variant_internal::VariantHashBase, void, + absl::OTABSL_OPTION_NAMESPACE_NAME::remove_const_t...> {}; } // namespace std @@ -841,22 +841,22 @@ struct ConversionVisitor { // ConvertVariantTo() // -// Helper functions to convert an `absl::variant` to a variant of another set of +// Helper functions to convert an `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` to a variant of another set of // types, provided that the alternative type of the new variant type can be // converted from any type in the source variant. // // Example: // -// absl::variant InternalReq(const Req&); +// absl::OTABSL_OPTION_NAMESPACE_NAME::variant InternalReq(const Req&); // // // name1 and name2 are convertible to name -// absl::variant ExternalReq(const Req& req) { -// return absl::ConvertVariantTo>( +// absl::OTABSL_OPTION_NAMESPACE_NAME::variant ExternalReq(const Req& req) { +// return absl::OTABSL_OPTION_NAMESPACE_NAME::ConvertVariantTo>( // InternalReq(req)); // } template To ConvertVariantTo(Variant&& variant) { - return absl::visit(variant_internal::ConversionVisitor{}, + return absl::OTABSL_OPTION_NAMESPACE_NAME::visit(variant_internal::ConversionVisitor{}, std::forward(variant)); } diff --git a/api/include/opentelemetry/nostd/internal/absl/utility/utility.h b/api/include/opentelemetry/nostd/internal/absl/utility/utility.h index 8c15e2b8c1..62580cc5af 100644 --- a/api/include/opentelemetry/nostd/internal/absl/utility/utility.h +++ b/api/include/opentelemetry/nostd/internal/absl/utility/utility.h @@ -58,7 +58,7 @@ OTABSL_NAMESPACE_BEGIN // Class template representing a compile-time integer sequence. An instantiation // of `integer_sequence` has a sequence of integers encoded in its // type through its template arguments (which is a common need when -// working with C++11 variadic templates). `absl::integer_sequence` is designed +// working with C++11 variadic templates). `absl::OTABSL_OPTION_NAMESPACE_NAME::integer_sequence` is designed // to be a drop-in replacement for C++14's `std::integer_sequence`. // // Example: @@ -81,7 +81,7 @@ struct integer_sequence { // index_sequence // // A helper template for an `integer_sequence` of `size_t`, -// `absl::index_sequence` is designed to be a drop-in replacement for C++14's +// `absl::OTABSL_OPTION_NAMESPACE_NAME::index_sequence` is designed to be a drop-in replacement for C++14's // `std::index_sequence`. template using index_sequence = integer_sequence; @@ -169,7 +169,7 @@ using std::in_place; // in_place_t // // Tag type used to specify in-place construction, such as with -// `absl::optional`, designed to be a drop-in replacement for C++17's +// `absl::OTABSL_OPTION_NAMESPACE_NAME::optional`, designed to be a drop-in replacement for C++17's // `std::in_place_t`. struct in_place_t {}; @@ -185,7 +185,7 @@ using std::in_place_type_t; // in_place_type_t // // Tag type used for in-place construction when the type to construct needs to -// be specified, such as with `absl::any`, designed to be a drop-in replacement +// be specified, such as with `absl::OTABSL_OPTION_NAMESPACE_NAME::any`, designed to be a drop-in replacement // for C++17's `std::in_place_type_t`. template using in_place_type_t = void (*)(utility_internal::InPlaceTypeTag); @@ -202,7 +202,7 @@ using std::in_place_index_t; // in_place_index_t // // Tag type used for in-place construction when the type to construct needs to -// be specified, such as with `absl::any`, designed to be a drop-in replacement +// be specified, such as with `absl::OTABSL_OPTION_NAMESPACE_NAME::any`, designed to be a drop-in replacement // for C++17's `std::in_place_index_t`. template using in_place_index_t = void (*)(utility_internal::InPlaceIndexTag); @@ -218,8 +218,8 @@ void in_place_index(utility_internal::InPlaceIndexTag) {} // A constexpr version of `std::move()`, designed to be a drop-in replacement // for C++14's `std::move()`. template -constexpr absl::remove_reference_t&& move(T&& t) noexcept { - return static_cast&&>(t); +constexpr absl::OTABSL_OPTION_NAMESPACE_NAME::remove_reference_t&& move(T&& t) noexcept { + return static_cast&&>(t); } // forward() @@ -228,7 +228,7 @@ constexpr absl::remove_reference_t&& move(T&& t) noexcept { // for C++14's `std::forward()`. template constexpr T&& forward( - absl::remove_reference_t& t) noexcept { // NOLINT(runtime/references) + absl::OTABSL_OPTION_NAMESPACE_NAME::remove_reference_t& t) noexcept { // NOLINT(runtime/references) return static_cast(t); } @@ -236,12 +236,12 @@ namespace utility_internal { // Helper method for expanding tuple into a called method. template auto apply_helper(Functor&& functor, Tuple&& t, index_sequence) - -> decltype(absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::base_internal::Invoke( - absl::forward(functor), - std::get(absl::forward(t))...)) { - return absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::base_internal::Invoke( - absl::forward(functor), - std::get(absl::forward(t))...); + -> decltype(absl::OTABSL_OPTION_NAMESPACE_NAME::base_internal::Invoke( + absl::OTABSL_OPTION_NAMESPACE_NAME::forward(functor), + std::get(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(t))...)) { + return absl::OTABSL_OPTION_NAMESPACE_NAME::base_internal::Invoke( + absl::OTABSL_OPTION_NAMESPACE_NAME::forward(functor), + std::get(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(t))...); } } // namespace utility_internal @@ -252,7 +252,7 @@ auto apply_helper(Functor&& functor, Tuple&& t, index_sequence) // Each element of the tuple corresponds to an argument of the call (in order). // Both the Callable argument and the tuple argument are perfect-forwarded. // For member-function Callables, the first tuple element acts as the `this` -// pointer. `absl::apply` is designed to be a drop-in replacement for C++17's +// pointer. `absl::OTABSL_OPTION_NAMESPACE_NAME::apply` is designed to be a drop-in replacement for C++17's // `std::apply`. Unlike C++17's `std::apply`, this is not currently `constexpr`. // // Example: @@ -269,57 +269,57 @@ auto apply_helper(Functor&& functor, Tuple&& t, index_sequence) // { // std::tuple tuple1(42, "bar"); // // Invokes the first user function on int, std::string. -// absl::apply(&user_function1, tuple1); +// absl::OTABSL_OPTION_NAMESPACE_NAME::apply(&user_function1, tuple1); // -// std::tuple> tuple2(absl::make_unique()); +// std::tuple> tuple2(absl::OTABSL_OPTION_NAMESPACE_NAME::make_unique()); // // Invokes the user function that takes ownership of the unique // // pointer. -// absl::apply(&user_function2, std::move(tuple2)); +// absl::OTABSL_OPTION_NAMESPACE_NAME::apply(&user_function2, std::move(tuple2)); // -// auto foo = absl::make_unique(); +// auto foo = absl::OTABSL_OPTION_NAMESPACE_NAME::make_unique(); // std::tuple tuple3(foo.get(), 42); // // Invokes the method Bar on foo with one argument, 42. -// absl::apply(&Foo::Bar, tuple3); +// absl::OTABSL_OPTION_NAMESPACE_NAME::apply(&Foo::Bar, tuple3); // // std::tuple tuple4(8, 9); // // Invokes a lambda. -// absl::apply(user_lambda, tuple4); +// absl::OTABSL_OPTION_NAMESPACE_NAME::apply(user_lambda, tuple4); // } template auto apply(Functor&& functor, Tuple&& t) -> decltype(utility_internal::apply_helper( - absl::forward(functor), absl::forward(t), - absl::make_index_sequence(functor), absl::OTABSL_OPTION_NAMESPACE_NAME::forward(t), + absl::OTABSL_OPTION_NAMESPACE_NAME::make_index_sequence::type>::value>{})) { return utility_internal::apply_helper( - absl::forward(functor), absl::forward(t), - absl::make_index_sequence(functor), absl::OTABSL_OPTION_NAMESPACE_NAME::forward(t), + absl::OTABSL_OPTION_NAMESPACE_NAME::make_index_sequence::type>::value>{}); } // exchange // // Replaces the value of `obj` with `new_value` and returns the old value of -// `obj`. `absl::exchange` is designed to be a drop-in replacement for C++14's +// `obj`. `absl::OTABSL_OPTION_NAMESPACE_NAME::exchange` is designed to be a drop-in replacement for C++14's // `std::exchange`. // // Example: // // Foo& operator=(Foo&& other) { -// ptr1_ = absl::exchange(other.ptr1_, nullptr); -// int1_ = absl::exchange(other.int1_, -1); +// ptr1_ = absl::OTABSL_OPTION_NAMESPACE_NAME::exchange(other.ptr1_, nullptr); +// int1_ = absl::OTABSL_OPTION_NAMESPACE_NAME::exchange(other.int1_, -1); // return *this; // } template T exchange(T& obj, U&& new_value) { - T old_value = absl::move(obj); - obj = absl::forward(new_value); + T old_value = absl::OTABSL_OPTION_NAMESPACE_NAME::move(obj); + obj = absl::OTABSL_OPTION_NAMESPACE_NAME::forward(new_value); return old_value; } namespace utility_internal { template -T make_from_tuple_impl(Tuple&& tup, absl::index_sequence) { +T make_from_tuple_impl(Tuple&& tup, absl::OTABSL_OPTION_NAMESPACE_NAME::index_sequence) { return T(std::get(std::forward(tup))...); } } // namespace utility_internal @@ -333,15 +333,15 @@ T make_from_tuple_impl(Tuple&& tup, absl::index_sequence) { // Example: // // std::tuple args("hello world", 5); -// auto s = absl::make_from_tuple(args); +// auto s = absl::OTABSL_OPTION_NAMESPACE_NAME::make_from_tuple(args); // assert(s == "hello"); // template constexpr T make_from_tuple(Tuple&& tup) { return utility_internal::make_from_tuple_impl( std::forward(tup), - absl::make_index_sequence< - std::tuple_size>::value>{}); + absl::OTABSL_OPTION_NAMESPACE_NAME::make_index_sequence< + std::tuple_size>::value>{}); } OTABSL_NAMESPACE_END diff --git a/api/include/opentelemetry/nostd/variant.h b/api/include/opentelemetry/nostd/variant.h index 6f3837c588..02df092d0f 100644 --- a/api/include/opentelemetry/nostd/variant.h +++ b/api/include/opentelemetry/nostd/variant.h @@ -66,7 +66,6 @@ namespace nostd { # ifdef HAVE_ABSEIL using absl::bad_variant_access; -# endif using absl::get; using absl::get_if; using absl::holds_alternative; @@ -75,6 +74,16 @@ using absl::variant; using absl::variant_alternative_t; using absl::variant_size; using absl::visit; +# else +using absl::OTABSL_OPTION_NAMESPACE_NAME::get; +using absl::OTABSL_OPTION_NAMESPACE_NAME::get_if; +using absl::OTABSL_OPTION_NAMESPACE_NAME::holds_alternative; +using absl::OTABSL_OPTION_NAMESPACE_NAME::monostate; +using absl::OTABSL_OPTION_NAMESPACE_NAME::variant; +using absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative_t; +using absl::OTABSL_OPTION_NAMESPACE_NAME::variant_size; +using absl::OTABSL_OPTION_NAMESPACE_NAME::visit; +# endif } // namespace nostd OPENTELEMETRY_END_NAMESPACE diff --git a/cmake/opentelemetry-cpp-config.cmake.in b/cmake/opentelemetry-cpp-config.cmake.in index f5c6e5e722..6eead53d28 100644 --- a/cmake/opentelemetry-cpp-config.cmake.in +++ b/cmake/opentelemetry-cpp-config.cmake.in @@ -7,7 +7,6 @@ # # Find the native opentelemetry-cpp includes and library. # -# # Result Variables # ^^^^^^^^^^^^^^^^ # @@ -104,6 +103,14 @@ if (@WITH_HTTP_CLIENT_CURL@ AND NOT @BUILD_SHARED_LIBS@) endif() endif() +if(@WITH_ABSEIL@ OR @WITH_OTLP_GRPC@) + find_package(absl CONFIG) +elseif(OR @WITH_OTLP_HTTP@ OR @WITH_OTLP_FILE@) + if("@Protobuf_VERSION@" VERSION_GREATER_EQUAL "3.22.0") + find_package(absl CONFIG) + endif() +endif() + set_and_check(OPENTELEMETRY_CPP_INCLUDE_DIRS "@PACKAGE_INCLUDE_INSTALL_DIR@") set_and_check(OPENTELEMETRY_CPP_LIBRARY_DIRS "@PACKAGE_CMAKE_INSTALL_LIBDIR@") diff --git a/cmake/opentelemetry-proto.cmake b/cmake/opentelemetry-proto.cmake index fa6e185c13..7831075a27 100644 --- a/cmake/opentelemetry-proto.cmake +++ b/cmake/opentelemetry-proto.cmake @@ -328,15 +328,23 @@ add_library( set_target_version(opentelemetry_proto) # Disable include-what-you-use on generated code. -set_target_properties( - opentelemetry_proto - PROPERTIES CXX_INCLUDE_WHAT_YOU_USE "" -) +set_target_properties(opentelemetry_proto PROPERTIES CXX_INCLUDE_WHAT_YOU_USE + "") -if(WITH_ABSEIL) +if(TARGET absl::bad_variant_access) target_link_libraries(opentelemetry_proto PUBLIC absl::bad_variant_access) endif() +if(NOT Protobuf_INCLUDE_DIRS AND TARGET protobuf::libprotobuf) + get_target_property(Protobuf_INCLUDE_DIRS protobuf::libprotobuf + INTERFACE_INCLUDE_DIRECTORIES) +endif() +if(Protobuf_INCLUDE_DIRS) + target_include_directories( + opentelemetry_proto BEFORE + PUBLIC "$") +endif() + if(WITH_OTLP_GRPC) add_library( opentelemetry_proto_grpc @@ -358,7 +366,7 @@ if(WITH_OTLP_GRPC) INTERFACE_INCLUDE_DIRECTORIES) if(GRPC_INCLUDE_DIRECTORY) target_include_directories( - opentelemetry_proto_grpc + opentelemetry_proto_grpc BEFORE PUBLIC "$") endif() endif() @@ -387,18 +395,14 @@ endif() if(TARGET protobuf::libprotobuf) target_link_libraries(opentelemetry_proto PUBLIC protobuf::libprotobuf) else() # cmake 3.8 or lower - target_include_directories(opentelemetry_proto - PUBLIC ${Protobuf_INCLUDE_DIRS}) target_link_libraries(opentelemetry_proto PUBLIC ${Protobuf_LIBRARIES}) endif() if(WITH_OTLP_GRPC) - if(WITH_ABSEIL) - find_package(absl CONFIG) - if(TARGET absl::synchronization) - target_link_libraries(opentelemetry_proto_grpc - PRIVATE absl::synchronization) - endif() + find_package(absl CONFIG) + if(TARGET absl::synchronization) + target_link_libraries(opentelemetry_proto_grpc + PRIVATE absl::synchronization) endif() endif() diff --git a/cmake/patch-imported-config.cmake b/cmake/patch-imported-config.cmake index a2d22ed398..25d6b2f78f 100644 --- a/cmake/patch-imported-config.cmake +++ b/cmake/patch-imported-config.cmake @@ -29,7 +29,7 @@ if(TARGET CURL::libcurl endif() # abseil targets -if(WITH_ABSEIL) +if(WITH_ABSEIL OR WITH_OTLP_GRPC) project_build_tools_patch_default_imported_config( absl::bad_variant_access absl::raw_logging_internal diff --git a/examples/grpc/CMakeLists.txt b/examples/grpc/CMakeLists.txt index 447f138a0f..21325663ab 100644 --- a/examples/grpc/CMakeLists.txt +++ b/examples/grpc/CMakeLists.txt @@ -39,7 +39,7 @@ else() target_link_libraries(example_grpc_proto PUBLIC gRPC::grpc++ ${Protobuf_LIBRARIES}) endif() -if(WITH_ABSEIL) +if(WITH_ABSEIL OR WITH_OTLP_GRPC) target_link_libraries(example_grpc_proto PUBLIC absl::bad_variant_access) endif() diff --git a/exporters/otlp/BUILD b/exporters/otlp/BUILD index a2dd8f8c65..eb3d23d579 100644 --- a/exporters/otlp/BUILD +++ b/exporters/otlp/BUILD @@ -42,11 +42,13 @@ cc_library( name = "otlp_grpc_client", srcs = [ "src/otlp_grpc_client.cc", + "src/otlp_grpc_client_factory.cc", "src/otlp_grpc_utils.cc", ], hdrs = [ "include/opentelemetry/exporters/otlp/otlp_environment.h", "include/opentelemetry/exporters/otlp/otlp_grpc_client.h", + "include/opentelemetry/exporters/otlp/otlp_grpc_client_factory.h", "include/opentelemetry/exporters/otlp/otlp_grpc_client_options.h", "include/opentelemetry/exporters/otlp/otlp_grpc_utils.h", "include/opentelemetry/exporters/otlp/protobuf_include_prefix.h", diff --git a/exporters/otlp/CMakeLists.txt b/exporters/otlp/CMakeLists.txt index 83b35f16a7..34da75b563 100644 --- a/exporters/otlp/CMakeLists.txt +++ b/exporters/otlp/CMakeLists.txt @@ -23,8 +23,10 @@ target_link_libraries(opentelemetry_otlp_recordable if(WITH_OTLP_GRPC) find_package(gRPC REQUIRED) - add_library(opentelemetry_exporter_otlp_grpc_client src/otlp_grpc_client.cc - src/otlp_grpc_utils.cc) + add_library( + opentelemetry_exporter_otlp_grpc_client + src/otlp_grpc_client.cc src/otlp_grpc_client_factory.cc + src/otlp_grpc_utils.cc) set_target_properties(opentelemetry_exporter_otlp_grpc_client PROPERTIES EXPORT_NAME otlp_grpc_client) set_target_version(opentelemetry_exporter_otlp_grpc_client) @@ -45,7 +47,7 @@ if(WITH_OTLP_GRPC) INTERFACE_INCLUDE_DIRECTORIES) if(GRPC_INCLUDE_DIRECTORY) target_include_directories( - opentelemetry_exporter_otlp_grpc_client + opentelemetry_exporter_otlp_grpc_client BEFORE PUBLIC "$") endif() target_include_directories( diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client.h index 89224403a4..3ded3a16eb 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client.h @@ -13,14 +13,18 @@ #include "opentelemetry/exporters/otlp/otlp_grpc_client_options.h" +// clang-format off #include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" +// clang-format on #include "google/protobuf/arena.h" #include "opentelemetry/proto/collector/logs/v1/logs_service.grpc.pb.h" #include "opentelemetry/proto/collector/metrics/v1/metrics_service.grpc.pb.h" #include "opentelemetry/proto/collector/trace/v1/trace_service.grpc.pb.h" +// clang-format off #include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" +// clang-format on OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter @@ -28,11 +32,25 @@ namespace exporter namespace otlp { +class OtlpGrpcClient; struct OtlpGrpcClientOptions; - -#ifdef ENABLE_ASYNC_EXPORT struct OtlpGrpcClientAsyncData; -#endif + +class OtlpGrpcClientReferenceGuard +{ +public: + OtlpGrpcClientReferenceGuard() noexcept; + ~OtlpGrpcClientReferenceGuard() noexcept; + + OtlpGrpcClientReferenceGuard(const OtlpGrpcClientReferenceGuard &) = delete; + OtlpGrpcClientReferenceGuard(OtlpGrpcClientReferenceGuard &&) = delete; + OtlpGrpcClientReferenceGuard &operator=(const OtlpGrpcClientReferenceGuard &) = delete; + OtlpGrpcClientReferenceGuard &operator=(OtlpGrpcClientReferenceGuard &&) = delete; + +private: + friend class OtlpGrpcClient; + std::atomic has_value_; +}; /** * The OTLP gRPC client contains utility functions of gRPC. @@ -40,7 +58,7 @@ struct OtlpGrpcClientAsyncData; class OtlpGrpcClient { public: - OtlpGrpcClient(); + OtlpGrpcClient(const OtlpGrpcClientOptions &options); ~OtlpGrpcClient(); @@ -58,20 +76,18 @@ class OtlpGrpcClient /** * Create trace service stub to communicate with the OpenTelemetry Collector. */ - static std::unique_ptr - MakeTraceServiceStub(const OtlpGrpcClientOptions &options); + std::unique_ptr MakeTraceServiceStub(); /** * Create metrics service stub to communicate with the OpenTelemetry Collector. */ - static std::unique_ptr - MakeMetricsServiceStub(const OtlpGrpcClientOptions &options); + std::unique_ptr + MakeMetricsServiceStub(); /** * Create logs service stub to communicate with the OpenTelemetry Collector. */ - static std::unique_ptr - MakeLogsServiceStub(const OtlpGrpcClientOptions &options); + std::unique_ptr MakeLogsServiceStub(); static grpc::Status DelegateExport( proto::collector::trace::v1::TraceService::StubInterface *stub, @@ -94,8 +110,18 @@ class OtlpGrpcClient proto::collector::logs::v1::ExportLogsServiceRequest &&request, proto::collector::logs::v1::ExportLogsServiceResponse *response); -#ifdef ENABLE_ASYNC_EXPORT + void AddReference(OtlpGrpcClientReferenceGuard &guard, + const OtlpGrpcClientOptions &options) noexcept; + /** + * Reomve reference fro a guard object + * + * @param guard guard object to remove reference from + * @return true if there is no more reference to this gRPC client + */ + bool RemoveReference(OtlpGrpcClientReferenceGuard &guard) noexcept; + +#ifdef ENABLE_ASYNC_EXPORT /** * Async export * @param options Options used to message to create gRPC context and stub(if necessary) @@ -155,6 +181,7 @@ class OtlpGrpcClient const proto::collector::logs::v1::ExportLogsServiceRequest &, proto::collector::logs::v1::ExportLogsServiceResponse *)> &&result_callback) noexcept; +#endif /** * Force flush the gRPC client. @@ -167,17 +194,19 @@ class OtlpGrpcClient * timeout is applied. * @return return the status of this operation */ - bool Shutdown(std::chrono::microseconds timeout = std::chrono::microseconds(0)) noexcept; + bool Shutdown(OtlpGrpcClientReferenceGuard &guard, + std::chrono::microseconds timeout = std::chrono::microseconds(0)) noexcept; std::shared_ptr MutableAsyncData(const OtlpGrpcClientOptions &options); + bool IsShutdown() const noexcept; + private: // Stores if this gRPC client had its Shutdown() method called std::atomic is_shutdown_; // Stores shared data between threads of this gRPC client std::shared_ptr async_data_; -#endif }; } // namespace otlp } // namespace exporter diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client_factory.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client_factory.h new file mode 100644 index 0000000000..ded0eadd8e --- /dev/null +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client_factory.h @@ -0,0 +1,36 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/exporters/otlp/otlp_grpc_client_options.h" +#include "opentelemetry/nostd/shared_ptr.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +class OtlpGrpcClientReferenceGuard; +class OtlpGrpcClient; + +/** + * Factory class for OtlpGrpcClient. + */ +class OPENTELEMETRY_EXPORT OtlpGrpcClientFactory +{ +public: + /** + * Create an OtlpGrpcClient using all default options. + */ + static std::shared_ptr Create(const OtlpGrpcClientOptions &options); + + static std::shared_ptr CreateReferenceGuard(); +}; + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter.h index 80346a253d..1022b0dc8f 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter.h @@ -6,12 +6,17 @@ #include #include +// clang-format off #include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" +// clang-format on #include "opentelemetry/proto/collector/trace/v1/trace_service.grpc.pb.h" +// clang-format off #include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" +// clang-format on +#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/sdk/trace/exporter.h" #include "opentelemetry/exporters/otlp/otlp_environment.h" @@ -23,6 +28,8 @@ namespace exporter namespace otlp { +class OtlpGrpcClientReferenceGuard; + class OtlpGrpcClient; /** @@ -36,11 +43,22 @@ class OtlpGrpcExporter final : public opentelemetry::sdk::trace::SpanExporter */ OtlpGrpcExporter(); + /** + * Create an OtlpGrpcExporter using specified OtlpGrpcClient. + * + * @param options options to create exporter + * @param client the gRPC client to use + */ + OtlpGrpcExporter(const OtlpGrpcExporterOptions &options, + const std::shared_ptr &client); + /** * Create an OtlpGrpcExporter using the given options. */ explicit OtlpGrpcExporter(const OtlpGrpcExporterOptions &options); + ~OtlpGrpcExporter() override; + /** * Create a span recordable. * @return a newly initialized Recordable object @@ -71,20 +89,26 @@ class OtlpGrpcExporter final : public opentelemetry::sdk::trace::SpanExporter bool Shutdown( std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept override; + /** + * Get the Client object + * + * @return return binded gRPC client + */ + const std::shared_ptr &GetClient() const noexcept; + private: // The configuration options associated with this exporter. const OtlpGrpcExporterOptions options_; -#ifdef ENABLE_ASYNC_EXPORT std::shared_ptr client_; -#endif + std::shared_ptr client_reference_guard_; // For testing friend class OtlpGrpcExporterTestPeer; friend class OtlpGrpcLogRecordExporterTestPeer; // Store service stub internally. Useful for testing. - std::unique_ptr trace_service_stub_; + std::shared_ptr trace_service_stub_; /** * Create an OtlpGrpcExporter using the specified service stub. @@ -92,6 +116,16 @@ class OtlpGrpcExporter final : public opentelemetry::sdk::trace::SpanExporter * @param stub the service stub to be used for exporting */ OtlpGrpcExporter(std::unique_ptr stub); + + /** + * Create an OtlpGrpcExporter using the specified service stub and gRPC client. + * Only tests can call this constructor directly. + * @param stub the service stub to be used for exporting + * @param client the gRPC client to use + */ + OtlpGrpcExporter(std::unique_ptr stub, + const std::shared_ptr &client); + std::atomic is_shutdown_{false}; bool isShutdown() const noexcept; }; diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter_factory.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter_factory.h index 518cf8b82c..24d19d5ced 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter_factory.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter_factory.h @@ -6,6 +6,7 @@ #include #include "opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h" +#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/sdk/trace/exporter.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -14,6 +15,8 @@ namespace exporter namespace otlp { +class OtlpGrpcClient; + /** * Factory class for OtlpGrpcExporter. */ @@ -30,6 +33,13 @@ class OPENTELEMETRY_EXPORT OtlpGrpcExporterFactory */ static std::unique_ptr Create( const OtlpGrpcExporterOptions &options); + + /** + * Create an OtlpGrpcExporter using the given options and gRPC client. + */ + static std::unique_ptr Create( + const OtlpGrpcExporterOptions &options, + const std::shared_ptr &client); }; } // namespace otlp diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h index 72af90701f..da278ccd28 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h @@ -4,15 +4,18 @@ #pragma once // clang-format off - #include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" +// clang-format on + #include "opentelemetry/proto/collector/logs/v1/logs_service.grpc.pb.h" -#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" +// clang-format off +#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // clang-format on #include "opentelemetry/exporters/otlp/otlp_environment.h" #include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_options.h" +#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/sdk/logs/exporter.h" #include @@ -23,6 +26,8 @@ namespace exporter namespace otlp { +class OtlpGrpcClientReferenceGuard; + class OtlpGrpcClient; /** @@ -36,12 +41,23 @@ class OtlpGrpcLogRecordExporter : public opentelemetry::sdk::logs::LogRecordExpo */ OtlpGrpcLogRecordExporter(); + /** + * Create an OtlpGrpcLogRecordExporter using specified OtlpGrpcClient. + * + * @param options options to create exporter + * @param client the gRPC client to use + */ + OtlpGrpcLogRecordExporter(const OtlpGrpcLogRecordExporterOptions &options, + const std::shared_ptr &client); + /** * Create an OtlpGrpcLogRecordExporter with user specified options. * @param options An object containing the user's configuration options. */ OtlpGrpcLogRecordExporter(const OtlpGrpcLogRecordExporterOptions &options); + ~OtlpGrpcLogRecordExporter() override; + /** * Creates a recordable that stores the data in protobuf. * @return a newly initialized Recordable object. @@ -72,19 +88,25 @@ class OtlpGrpcLogRecordExporter : public opentelemetry::sdk::logs::LogRecordExpo bool Shutdown( std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept override; + /** + * Get the Client object + * + * @return return binded gRPC client + */ + const std::shared_ptr &GetClient() const noexcept; + private: // Configuration options for the exporter const OtlpGrpcLogRecordExporterOptions options_; -#ifdef ENABLE_ASYNC_EXPORT std::shared_ptr client_; -#endif + std::shared_ptr client_reference_guard_; // For testing friend class OtlpGrpcLogRecordExporterTestPeer; // Store service stub internally. Useful for testing. - std::unique_ptr log_service_stub_; + std::shared_ptr log_service_stub_; /** * Create an OtlpGrpcLogRecordExporter using the specified service stub. @@ -93,6 +115,17 @@ class OtlpGrpcLogRecordExporter : public opentelemetry::sdk::logs::LogRecordExpo */ OtlpGrpcLogRecordExporter( std::unique_ptr stub); + + /** + * Create an OtlpGrpcLogRecordExporter using the specified service stub and gRPC client. + * Only tests can call this constructor directly. + * @param stub the service stub to be used for exporting + * @param client the gRPC client to use + */ + OtlpGrpcLogRecordExporter( + std::unique_ptr stub, + const std::shared_ptr &client); + std::atomic is_shutdown_{false}; bool isShutdown() const noexcept; }; diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_factory.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_factory.h index 7a88615959..e69a20b452 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_factory.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_factory.h @@ -4,6 +4,7 @@ #pragma once #include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_options.h" +#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/sdk/logs/exporter.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -12,6 +13,8 @@ namespace exporter namespace otlp { +class OtlpGrpcClient; + /** * Factory class for OtlpGrpcLogRecordExporter. */ @@ -24,10 +27,17 @@ class OPENTELEMETRY_EXPORT OtlpGrpcLogRecordExporterFactory static std::unique_ptr Create(); /** - * Create a OtlpGrpcLogRecordExporter. + * Create a OtlpGrpcLogRecordExporter using the given options. */ static std::unique_ptr Create( const OtlpGrpcLogRecordExporterOptions &options); + + /** + * Create a OtlpGrpcLogRecordExporter using the given options and gRPC client. + */ + static std::unique_ptr Create( + const OtlpGrpcLogRecordExporterOptions &options, + const std::shared_ptr &client); }; } // namespace otlp diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter.h index 3899e926f6..d3d857b3f0 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter.h @@ -4,15 +4,18 @@ #pragma once // clang-format off - #include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" +// clang-format on + #include "opentelemetry/proto/collector/metrics/v1/metrics_service.grpc.pb.h" -#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" +// clang-format off +#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // clang-format on #include "opentelemetry/exporters/otlp/otlp_environment.h" #include "opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_options.h" +#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" #include @@ -23,6 +26,7 @@ namespace exporter namespace otlp { +class OtlpGrpcClientReferenceGuard; class OtlpGrpcClient; /** @@ -36,11 +40,22 @@ class OtlpGrpcMetricExporter : public opentelemetry::sdk::metrics::PushMetricExp */ OtlpGrpcMetricExporter(); + /** + * Create an OtlpGrpcMetricExporter using specified OtlpGrpcClient. + * + * @param options options to create exporter + * @param client the gRPC client to use + */ + OtlpGrpcMetricExporter(const OtlpGrpcMetricExporterOptions &options, + const std::shared_ptr &client); + /** * Create an OtlpGrpcMetricExporter using the given options. */ explicit OtlpGrpcMetricExporter(const OtlpGrpcMetricExporterOptions &options); + ~OtlpGrpcMetricExporter() override; + /** * Get the AggregationTemporality for exporter * @@ -58,13 +73,19 @@ class OtlpGrpcMetricExporter : public opentelemetry::sdk::metrics::PushMetricExp bool Shutdown( std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept override; + /** + * Get the Client object + * + * @return return binded gRPC client + */ + const std::shared_ptr &GetClient() const noexcept; + private: // The configuration options associated with this exporter. const OtlpGrpcMetricExporterOptions options_; -#ifdef ENABLE_ASYNC_EXPORT std::shared_ptr client_; -#endif + std::shared_ptr client_reference_guard_; // Aggregation Temporality selector const sdk::metrics::AggregationTemporalitySelector aggregation_temporality_selector_; @@ -73,7 +94,7 @@ class OtlpGrpcMetricExporter : public opentelemetry::sdk::metrics::PushMetricExp friend class OtlpGrpcMetricExporterTestPeer; // Store service stub internally. Useful for testing. - std::unique_ptr + std::shared_ptr metrics_service_stub_; /** @@ -83,6 +104,17 @@ class OtlpGrpcMetricExporter : public opentelemetry::sdk::metrics::PushMetricExp */ OtlpGrpcMetricExporter( std::unique_ptr stub); + + /** + * Create an OtlpGrpcMetricExporter using the specified service stub and gRPC client. + * Only tests can call this constructor directly. + * @param stub the service stub to be used for exporting + * @param client the gRPC client to use + */ + OtlpGrpcMetricExporter( + std::unique_ptr stub, + const std::shared_ptr &client); + std::atomic is_shutdown_{false}; bool isShutdown() const noexcept; }; diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h index 11b185a384..5d405609b0 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h @@ -6,6 +6,7 @@ #include #include "opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_options.h" +#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -14,6 +15,8 @@ namespace exporter namespace otlp { +class OtlpGrpcClient; + /** * Factory class for OtlpGrpcMetricExporter. */ @@ -26,10 +29,17 @@ class OPENTELEMETRY_EXPORT OtlpGrpcMetricExporterFactory static std::unique_ptr Create(); /** - * Create a OtlpGrpcMetricExporter. + * Create a OtlpGrpcMetricExporter using the given options. */ static std::unique_ptr Create( const OtlpGrpcMetricExporterOptions &options); + + /** + * Create a OtlpGrpcMetricExporter using the given options and gRPC client. + */ + static std::unique_ptr Create( + const OtlpGrpcMetricExporterOptions &options, + const std::shared_ptr &client); }; } // namespace otlp diff --git a/exporters/otlp/src/otlp_grpc_client.cc b/exporters/otlp/src/otlp_grpc_client.cc index 44d86004a9..04382c65e5 100644 --- a/exporters/otlp/src/otlp_grpc_client.cc +++ b/exporters/otlp/src/otlp_grpc_client.cc @@ -78,16 +78,20 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpGrpcAsyncCallData : public OtlpGrpcAsyncCal virtual ~OtlpGrpcAsyncCallData() {} }; } // namespace +#endif struct OtlpGrpcClientAsyncData { + std::chrono::system_clock::duration export_timeout = std::chrono::seconds{10}; // The best performance trade-off of gRPC is having numcpu's threads and one completion queue // per thread, but this exporter should not cost a lot resource and we don't want to create - // too many threads in the process. So we use one completion queue. - grpc::CompletionQueue cq; - + // too many threads in the process. So we use one completion queue and shared context. + std::shared_ptr channel; +#ifdef ENABLE_ASYNC_EXPORT + std::mutex running_calls_lock; + std::unordered_set> running_calls; // Running requests, this is used to limit the number of concurrent requests. std::atomic running_requests{0}; // Request counter is used to record ForceFlush. @@ -98,13 +102,16 @@ struct OtlpGrpcClientAsyncData // Condition variable and mutex to control the concurrency count of running requests. std::mutex session_waker_lock; std::condition_variable session_waker; +#endif + + // Reference count of OtlpGrpcClient + std::atomic reference_count{0}; // Do not use OtlpGrpcClientAsyncData() = default; here, some versions of GCC&Clang have BUGs // and may not initialize the member correctly. See also // https://stackoverflow.com/questions/53408962/try-to-understand-compiler-error-message-default-member-initializer-required-be OtlpGrpcClientAsyncData() {} }; -#endif namespace { @@ -199,6 +206,11 @@ static sdk::common::ExportResult InternalDelegateAsyncExport( ++async_data->start_request_counter; ++async_data->running_requests; + { + std::lock_guard lock{async_data->running_calls_lock}; + async_data->running_calls.insert( + std::static_pointer_cast(call_data)); + } // Some old toolchains can only use gRPC 1.33 and it's experimental. # if defined(GRPC_CPP_VERSION_MAJOR) && \ (GRPC_CPP_VERSION_MAJOR * 1000 + GRPC_CPP_VERSION_MINOR) >= 1039 @@ -208,6 +220,12 @@ static sdk::common::ExportResult InternalDelegateAsyncExport( # endif ->Export(call_data->grpc_context.get(), call_data->request, call_data->response, [call_data, async_data, export_data_name](::grpc::Status grpc_status) { + { + std::lock_guard lock{async_data->running_calls_lock}; + async_data->running_calls.erase( + std::static_pointer_cast(call_data)); + } + --async_data->running_requests; ++async_data->finished_request_counter; @@ -247,18 +265,38 @@ static sdk::common::ExportResult InternalDelegateAsyncExport( #endif } // namespace -OtlpGrpcClient::OtlpGrpcClient() -#ifdef ENABLE_ASYNC_EXPORT - : is_shutdown_(false) -#endif -{} +OtlpGrpcClientReferenceGuard::OtlpGrpcClientReferenceGuard() noexcept : has_value_{false} {} + +OtlpGrpcClientReferenceGuard::~OtlpGrpcClientReferenceGuard() noexcept {} + +OtlpGrpcClient::OtlpGrpcClient(const OtlpGrpcClientOptions &options) : is_shutdown_(false) +{ + std::shared_ptr async_data = MutableAsyncData(options); + async_data->channel = MakeChannel(options); +} OtlpGrpcClient::~OtlpGrpcClient() { -#ifdef ENABLE_ASYNC_EXPORT std::shared_ptr async_data; async_data.swap(async_data_); +#ifdef ENABLE_ASYNC_EXPORT + if (async_data) + { + std::unordered_set> running_calls; + { + std::lock_guard lock(async_data->running_calls_lock); + running_calls = async_data->running_calls; + } + for (auto &call_data : running_calls) + { + if (call_data && call_data->grpc_context) + { + call_data->grpc_context->TryCancel(); + } + } + } + while (async_data && async_data->running_requests.load(std::memory_order_acquire) > 0) { std::unique_lock lock{async_data->session_waker_lock}; @@ -357,21 +395,33 @@ std::unique_ptr OtlpGrpcClient::MakeClientContext( } std::unique_ptr -OtlpGrpcClient::MakeTraceServiceStub(const OtlpGrpcClientOptions &options) +OtlpGrpcClient::MakeTraceServiceStub() { - return proto::collector::trace::v1::TraceService::NewStub(MakeChannel(options)); + if (!async_data_ || !async_data_->channel) + { + return nullptr; + } + return proto::collector::trace::v1::TraceService::NewStub(async_data_->channel); } std::unique_ptr -OtlpGrpcClient::MakeMetricsServiceStub(const OtlpGrpcClientOptions &options) +OtlpGrpcClient::MakeMetricsServiceStub() { - return proto::collector::metrics::v1::MetricsService::NewStub(MakeChannel(options)); + if (!async_data_ || !async_data_->channel) + { + return nullptr; + } + return proto::collector::metrics::v1::MetricsService::NewStub(async_data_->channel); } std::unique_ptr -OtlpGrpcClient::MakeLogsServiceStub(const OtlpGrpcClientOptions &options) +OtlpGrpcClient::MakeLogsServiceStub() { - return proto::collector::logs::v1::LogsService::NewStub(MakeChannel(options)); + if (!async_data_ || !async_data_->channel) + { + return nullptr; + } + return proto::collector::logs::v1::LogsService::NewStub(async_data_->channel); } grpc::Status OtlpGrpcClient::DelegateExport( @@ -404,6 +454,35 @@ grpc::Status OtlpGrpcClient::DelegateExport( return stub->Export(context.get(), request, response); } +void OtlpGrpcClient::AddReference(OtlpGrpcClientReferenceGuard &guard, + const OtlpGrpcClientOptions &options) noexcept +{ + if (false == guard.has_value_.exchange(true, std::memory_order_acq_rel)) + { + MutableAsyncData(options)->reference_count.fetch_add(1, std::memory_order_acq_rel); + } +} + +bool OtlpGrpcClient::RemoveReference(OtlpGrpcClientReferenceGuard &guard) noexcept +{ + auto async_data = async_data_; + if (true == guard.has_value_.exchange(false, std::memory_order_acq_rel)) + { + if (async_data) + { + int64_t left = async_data->reference_count.fetch_sub(1, std::memory_order_acq_rel); + return left <= 1; + } + } + + if (async_data) + { + return async_data->reference_count.load(std::memory_order_acquire) <= 0; + } + + return true; +} + #ifdef ENABLE_ASYNC_EXPORT /** @@ -507,26 +586,37 @@ sdk::common::ExportResult OtlpGrpcClient::DelegateAsyncExport( "log(s)"); } +#endif + std::shared_ptr OtlpGrpcClient::MutableAsyncData( const OtlpGrpcClientOptions &options) { if (!async_data_) { - async_data_ = std::make_shared(); - async_data_->export_timeout = options.timeout; + async_data_ = std::make_shared(); + async_data_->export_timeout = options.timeout; +#ifdef ENABLE_ASYNC_EXPORT async_data_->max_concurrent_requests = options.max_concurrent_requests; +#endif } return async_data_; } -bool OtlpGrpcClient::ForceFlush(std::chrono::microseconds timeout) noexcept +bool OtlpGrpcClient::IsShutdown() const noexcept +{ + return is_shutdown_.load(std::memory_order_acquire); +} + +bool OtlpGrpcClient::ForceFlush( + OPENTELEMETRY_MAYBE_UNUSED std::chrono::microseconds timeout) noexcept { if (!async_data_) { return true; } +#ifdef ENABLE_ASYNC_EXPORT std::size_t request_counter = async_data_->start_request_counter.load(std::memory_order_acquire); if (request_counter <= async_data_->finished_request_counter.load(std::memory_order_acquire)) { @@ -565,21 +655,46 @@ bool OtlpGrpcClient::ForceFlush(std::chrono::microseconds timeout) noexcept } return timeout_steady > std::chrono::steady_clock::duration::zero(); +#else + return true; +#endif } -bool OtlpGrpcClient::Shutdown(std::chrono::microseconds timeout) noexcept +bool OtlpGrpcClient::Shutdown(OtlpGrpcClientReferenceGuard &guard, + OPENTELEMETRY_MAYBE_UNUSED std::chrono::microseconds timeout) noexcept { if (!async_data_) { return true; } + bool last_reference_removed = RemoveReference(guard); bool force_flush_result; - if (false == is_shutdown_.exchange(true, std::memory_order_acq_rel)) + if (last_reference_removed && false == is_shutdown_.exchange(true, std::memory_order_acq_rel)) { + OTEL_INTERNAL_LOG_DEBUG("[OTLP GRPC Client] DEBUG: OtlpGrpcClient start to shitdown"); force_flush_result = ForceFlush(timeout); - async_data_->cq.Shutdown(); +#ifdef ENABLE_ASYNC_EXPORT + std::unordered_set> running_calls; + { + std::lock_guard lock(async_data_->running_calls_lock); + running_calls = async_data_->running_calls; + } + if (!running_calls.empty()) + { + OTEL_INTERNAL_LOG_WARN( + "[OTLP GRPC Client] WARN: OtlpGrpcClient shutdown timeout, try to cancel " + << running_calls.size() << " running calls."); + } + for (auto &call_data : running_calls) + { + if (call_data && call_data->grpc_context) + { + call_data->grpc_context->TryCancel(); + } + } +#endif } else { @@ -589,8 +704,6 @@ bool OtlpGrpcClient::Shutdown(std::chrono::microseconds timeout) noexcept return force_flush_result; } -#endif - } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/otlp/src/otlp_grpc_client_factory.cc b/exporters/otlp/src/otlp_grpc_client_factory.cc new file mode 100644 index 0000000000..310593a77a --- /dev/null +++ b/exporters/otlp/src/otlp_grpc_client_factory.cc @@ -0,0 +1,27 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include "opentelemetry/exporters/otlp/otlp_grpc_client_factory.h" +#include + +#include "opentelemetry/exporters/otlp/otlp_grpc_client.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +std::shared_ptr OtlpGrpcClientFactory::Create(const OtlpGrpcClientOptions &options) +{ + return std::make_shared(options); +} + +std::shared_ptr OtlpGrpcClientFactory::CreateReferenceGuard() +{ + return std::make_shared(); +} + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/otlp/src/otlp_grpc_exporter.cc b/exporters/otlp/src/otlp_grpc_exporter.cc index ed0fc74518..e4012c2ebf 100644 --- a/exporters/otlp/src/otlp_grpc_exporter.cc +++ b/exporters/otlp/src/otlp_grpc_exporter.cc @@ -12,6 +12,7 @@ #include "opentelemetry/exporters/otlp/otlp_recordable_utils.h" #include "opentelemetry/sdk_config.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_client_factory.h" #include "opentelemetry/exporters/otlp/otlp_grpc_utils.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -23,22 +24,53 @@ namespace otlp OtlpGrpcExporter::OtlpGrpcExporter() : OtlpGrpcExporter(OtlpGrpcExporterOptions()) {} -OtlpGrpcExporter::OtlpGrpcExporter(const OtlpGrpcExporterOptions &options) - : options_(options), -#ifdef ENABLE_ASYNC_EXPORT - client_(std::make_shared()), -#endif - trace_service_stub_(OtlpGrpcClient::MakeTraceServiceStub(options)) -{} +OtlpGrpcExporter::OtlpGrpcExporter(const OtlpGrpcExporterOptions &options) : options_(options) +{ + client_ = OtlpGrpcClientFactory::Create(options_); + client_reference_guard_ = OtlpGrpcClientFactory::CreateReferenceGuard(); + client_->AddReference(*client_reference_guard_, options_); + + trace_service_stub_ = client_->MakeTraceServiceStub(); +} OtlpGrpcExporter::OtlpGrpcExporter( std::unique_ptr stub) + : options_(OtlpGrpcExporterOptions()), trace_service_stub_(std::move(stub)) +{ + client_ = OtlpGrpcClientFactory::Create(options_); + client_reference_guard_ = OtlpGrpcClientFactory::CreateReferenceGuard(); + client_->AddReference(*client_reference_guard_, options_); +} + +OtlpGrpcExporter::OtlpGrpcExporter(const OtlpGrpcExporterOptions &options, + const std::shared_ptr &client) + : options_(options), + client_(client), + client_reference_guard_(OtlpGrpcClientFactory::CreateReferenceGuard()) +{ + client_->AddReference(*client_reference_guard_, options_); + + trace_service_stub_ = client_->MakeTraceServiceStub(); +} + +OtlpGrpcExporter::OtlpGrpcExporter( + std::unique_ptr stub, + const std::shared_ptr &client) : options_(OtlpGrpcExporterOptions()), -#ifdef ENABLE_ASYNC_EXPORT - client_(std::make_shared()), -#endif + client_(client), + client_reference_guard_(OtlpGrpcClientFactory::CreateReferenceGuard()), trace_service_stub_(std::move(stub)) -{} +{ + client_->AddReference(*client_reference_guard_, options_); +} + +OtlpGrpcExporter::~OtlpGrpcExporter() +{ + if (client_) + { + client_->RemoveReference(*client_reference_guard_); + } +} // ----------------------------- Exporter methods ------------------------------ @@ -50,12 +82,21 @@ std::unique_ptr OtlpGrpcExporter::MakeRecordable() noexc sdk::common::ExportResult OtlpGrpcExporter::Export( const nostd::span> &spans) noexcept { - if (isShutdown()) + std::shared_ptr client = client_; + if (isShutdown() || !client) { OTEL_INTERNAL_LOG_ERROR("[OTLP gRPC] Exporting " << spans.size() << " span(s) failed, exporter is shutdown"); return sdk::common::ExportResult::kFailure; } + + if (!trace_service_stub_) + { + OTEL_INTERNAL_LOG_ERROR("[OTLP gRPC] Exporting " + << spans.size() << " span(s) failed, service stub unavailable"); + return sdk::common::ExportResult::kFailure; + } + if (spans.empty()) { return sdk::common::ExportResult::kSuccess; @@ -82,13 +123,16 @@ sdk::common::ExportResult OtlpGrpcExporter::Export( #ifdef ENABLE_ASYNC_EXPORT if (options_.max_concurrent_requests > 1) { - return client_->DelegateAsyncExport( + return client->DelegateAsyncExport( options_, trace_service_stub_.get(), std::move(context), std::move(arena), std::move(*request), - [](opentelemetry::sdk::common::ExportResult result, - std::unique_ptr &&, - const proto::collector::trace::v1::ExportTraceServiceRequest &request, - proto::collector::trace::v1::ExportTraceServiceResponse *) { + // Capture the trace_service_stub_ to ensure it is not destroyed before the callback is + // called. + [trace_service_stub = trace_service_stub_]( + opentelemetry::sdk::common::ExportResult result, + std::unique_ptr &&, + const proto::collector::trace::v1::ExportTraceServiceRequest &request, + proto::collector::trace::v1::ExportTraceServiceResponse *) { if (result != opentelemetry::sdk::common::ExportResult::kSuccess) { OTEL_INTERNAL_LOG_ERROR("[OTLP TRACE GRPC Exporter] ERROR: Export " @@ -125,22 +169,27 @@ sdk::common::ExportResult OtlpGrpcExporter::Export( bool OtlpGrpcExporter::ForceFlush( OPENTELEMETRY_MAYBE_UNUSED std::chrono::microseconds timeout) noexcept { -#ifdef ENABLE_ASYNC_EXPORT - return client_->ForceFlush(timeout); -#else - return true; -#endif + // Maybe already shutdown, we need to keep thread-safety here. + std::shared_ptr client = client_; + if (!client) + { + return true; + } + return client->ForceFlush(timeout); } bool OtlpGrpcExporter::Shutdown( OPENTELEMETRY_MAYBE_UNUSED std::chrono::microseconds timeout) noexcept { is_shutdown_ = true; -#ifdef ENABLE_ASYNC_EXPORT - return client_->Shutdown(timeout); -#else - return true; -#endif + // Maybe already shutdown, we need to keep thread-safety here. + std::shared_ptr client; + client.swap(client_); + if (!client) + { + return true; + } + return client->Shutdown(*client_reference_guard_, timeout); } bool OtlpGrpcExporter::isShutdown() const noexcept @@ -148,6 +197,11 @@ bool OtlpGrpcExporter::isShutdown() const noexcept return is_shutdown_; } +const std::shared_ptr &OtlpGrpcExporter::GetClient() const noexcept +{ + return client_; +} + } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/otlp/src/otlp_grpc_exporter_factory.cc b/exporters/otlp/src/otlp_grpc_exporter_factory.cc index f8ee7e3594..5ed832a3cd 100644 --- a/exporters/otlp/src/otlp_grpc_exporter_factory.cc +++ b/exporters/otlp/src/otlp_grpc_exporter_factory.cc @@ -27,6 +27,15 @@ std::unique_ptr OtlpGrpcExporterFactory return exporter; } +std::unique_ptr OtlpGrpcExporterFactory::Create( + const OtlpGrpcExporterOptions &options, + const std::shared_ptr &client) +{ + std::unique_ptr exporter( + new OtlpGrpcExporter(options, client)); + return exporter; +} + } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/otlp/src/otlp_grpc_log_record_exporter.cc b/exporters/otlp/src/otlp_grpc_log_record_exporter.cc index 1069703f96..fe05be7b30 100644 --- a/exporters/otlp/src/otlp_grpc_log_record_exporter.cc +++ b/exporters/otlp/src/otlp_grpc_log_record_exporter.cc @@ -6,19 +6,20 @@ #include "opentelemetry/common/macros.h" #include "opentelemetry/exporters/otlp/otlp_grpc_client.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_client_factory.h" #include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h" #include "opentelemetry/exporters/otlp/otlp_log_recordable.h" #include "opentelemetry/exporters/otlp/otlp_recordable_utils.h" // clang-format off - #include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" +// clang-format on -#include "opentelemetry/proto/collector/logs/v1/logs_service.pb.h" #include "opentelemetry/proto/collector/logs/v1/logs_service.grpc.pb.h" +#include "opentelemetry/proto/collector/logs/v1/logs_service.pb.h" +// clang-format off #include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" - // clang-format on #include "opentelemetry/sdk/common/global_log_handler.h" @@ -36,21 +37,54 @@ OtlpGrpcLogRecordExporter::OtlpGrpcLogRecordExporter() OtlpGrpcLogRecordExporter::OtlpGrpcLogRecordExporter( const OtlpGrpcLogRecordExporterOptions &options) - : options_(options), -#ifdef ENABLE_ASYNC_EXPORT - client_(std::make_shared()), -#endif - log_service_stub_(OtlpGrpcClient::MakeLogsServiceStub(options)) -{} + : options_(options) +{ + client_ = OtlpGrpcClientFactory::Create(options_); + client_reference_guard_ = OtlpGrpcClientFactory::CreateReferenceGuard(); + client_->AddReference(*client_reference_guard_, options_); + + log_service_stub_ = client_->MakeLogsServiceStub(); +} OtlpGrpcLogRecordExporter::OtlpGrpcLogRecordExporter( std::unique_ptr stub) + : options_(OtlpGrpcLogRecordExporterOptions()), log_service_stub_(std::move(stub)) +{ + client_ = OtlpGrpcClientFactory::Create(options_); + client_reference_guard_ = OtlpGrpcClientFactory::CreateReferenceGuard(); + client_->AddReference(*client_reference_guard_, options_); +} + +OtlpGrpcLogRecordExporter::OtlpGrpcLogRecordExporter( + const OtlpGrpcLogRecordExporterOptions &options, + const std::shared_ptr &client) + : options_(options), + client_(client), + client_reference_guard_(OtlpGrpcClientFactory::CreateReferenceGuard()) +{ + client_->AddReference(*client_reference_guard_, options_); + + log_service_stub_ = client_->MakeLogsServiceStub(); +} + +OtlpGrpcLogRecordExporter::OtlpGrpcLogRecordExporter( + std::unique_ptr stub, + const std::shared_ptr &client) : options_(OtlpGrpcLogRecordExporterOptions()), -#ifdef ENABLE_ASYNC_EXPORT - client_(std::make_shared()), -#endif + client_(client), + client_reference_guard_(OtlpGrpcClientFactory::CreateReferenceGuard()), log_service_stub_(std::move(stub)) -{} +{ + client_->AddReference(*client_reference_guard_, options_); +} + +OtlpGrpcLogRecordExporter::~OtlpGrpcLogRecordExporter() +{ + if (client_) + { + client_->RemoveReference(*client_reference_guard_); + } +} // ----------------------------- Exporter methods ------------------------------ @@ -63,12 +97,20 @@ OtlpGrpcLogRecordExporter::MakeRecordable() noexcept opentelemetry::sdk::common::ExportResult OtlpGrpcLogRecordExporter::Export( const nostd::span> &logs) noexcept { - if (isShutdown()) + std::shared_ptr client = client_; + if (isShutdown() || !client) { OTEL_INTERNAL_LOG_ERROR("[OTLP gRPC log] Exporting " << logs.size() << " log(s) failed, exporter is shutdown"); return sdk::common::ExportResult::kFailure; } + if (!log_service_stub_) + { + OTEL_INTERNAL_LOG_ERROR("[OTLP gRPC] Exporting " << logs.size() + << " log(s) failed, service stub unavailable"); + return sdk::common::ExportResult::kFailure; + } + if (logs.empty()) { return sdk::common::ExportResult::kSuccess; @@ -95,13 +137,16 @@ opentelemetry::sdk::common::ExportResult OtlpGrpcLogRecordExporter::Export( #ifdef ENABLE_ASYNC_EXPORT if (options_.max_concurrent_requests > 1) { - return client_->DelegateAsyncExport( + return client->DelegateAsyncExport( options_, log_service_stub_.get(), std::move(context), std::move(arena), std::move(*request), - [](opentelemetry::sdk::common::ExportResult result, - std::unique_ptr &&, - const proto::collector::logs::v1::ExportLogsServiceRequest &request, - proto::collector::logs::v1::ExportLogsServiceResponse *) { + // Capture log_service_stub by value to ensure it is not destroyed before the callback is + // called. + [log_service_stub = log_service_stub_]( + opentelemetry::sdk::common::ExportResult result, + std::unique_ptr &&, + const proto::collector::logs::v1::ExportLogsServiceRequest &request, + proto::collector::logs::v1::ExportLogsServiceResponse *) { if (result != opentelemetry::sdk::common::ExportResult::kSuccess) { OTEL_INTERNAL_LOG_ERROR("[OTLP LOG GRPC Exporter] ERROR: Export " @@ -139,21 +184,26 @@ bool OtlpGrpcLogRecordExporter::Shutdown( OPENTELEMETRY_MAYBE_UNUSED std::chrono::microseconds timeout) noexcept { is_shutdown_ = true; -#ifdef ENABLE_ASYNC_EXPORT - return client_->Shutdown(timeout); -#else - return true; -#endif + // Maybe already shutdown, we need to keep thread-safety here. + std::shared_ptr client; + client.swap(client_); + if (!client) + { + return true; + } + return client->Shutdown(*client_reference_guard_, timeout); } bool OtlpGrpcLogRecordExporter::ForceFlush( OPENTELEMETRY_MAYBE_UNUSED std::chrono::microseconds timeout) noexcept { -#ifdef ENABLE_ASYNC_EXPORT - return client_->ForceFlush(timeout); -#else - return true; -#endif + // Maybe already shutdown, we need to keep thread-safety here. + std::shared_ptr client = client_; + if (!client) + { + return true; + } + return client->ForceFlush(timeout); } bool OtlpGrpcLogRecordExporter::isShutdown() const noexcept @@ -161,6 +211,11 @@ bool OtlpGrpcLogRecordExporter::isShutdown() const noexcept return is_shutdown_; } +const std::shared_ptr &OtlpGrpcLogRecordExporter::GetClient() const noexcept +{ + return client_; +} + } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/otlp/src/otlp_grpc_log_record_exporter_factory.cc b/exporters/otlp/src/otlp_grpc_log_record_exporter_factory.cc index 7229de569a..4b519e37e8 100644 --- a/exporters/otlp/src/otlp_grpc_log_record_exporter_factory.cc +++ b/exporters/otlp/src/otlp_grpc_log_record_exporter_factory.cc @@ -28,6 +28,15 @@ OtlpGrpcLogRecordExporterFactory::Create(const OtlpGrpcLogRecordExporterOptions return exporter; } +std::unique_ptr +OtlpGrpcLogRecordExporterFactory::Create(const OtlpGrpcLogRecordExporterOptions &options, + const std::shared_ptr &client) +{ + std::unique_ptr exporter( + new OtlpGrpcLogRecordExporter(options, client)); + return exporter; +} + } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/otlp/src/otlp_grpc_metric_exporter.cc b/exporters/otlp/src/otlp_grpc_metric_exporter.cc index 6a78149eaa..1723dd557a 100644 --- a/exporters/otlp/src/otlp_grpc_metric_exporter.cc +++ b/exporters/otlp/src/otlp_grpc_metric_exporter.cc @@ -6,6 +6,7 @@ #include "opentelemetry/common/macros.h" #include "opentelemetry/exporters/otlp/otlp_grpc_client.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_client_factory.h" #include "opentelemetry/exporters/otlp/otlp_grpc_metric_exporter.h" #include "opentelemetry/exporters/otlp/otlp_metric_utils.h" @@ -24,24 +25,57 @@ OtlpGrpcMetricExporter::OtlpGrpcMetricExporter() OtlpGrpcMetricExporter::OtlpGrpcMetricExporter(const OtlpGrpcMetricExporterOptions &options) : options_(options), -#ifdef ENABLE_ASYNC_EXPORT - client_(std::make_shared()), -#endif aggregation_temporality_selector_{ - OtlpMetricUtils::ChooseTemporalitySelector(options_.aggregation_temporality)}, - metrics_service_stub_(OtlpGrpcClient::MakeMetricsServiceStub(options)) -{} + OtlpMetricUtils::ChooseTemporalitySelector(options_.aggregation_temporality)} +{ + client_ = OtlpGrpcClientFactory::Create(options_); + client_reference_guard_ = OtlpGrpcClientFactory::CreateReferenceGuard(); + client_->AddReference(*client_reference_guard_, options_); + + metrics_service_stub_ = client_->MakeMetricsServiceStub(); +} OtlpGrpcMetricExporter::OtlpGrpcMetricExporter( std::unique_ptr stub) : options_(OtlpGrpcMetricExporterOptions()), -#ifdef ENABLE_ASYNC_EXPORT - client_(std::make_shared()), -#endif aggregation_temporality_selector_{ OtlpMetricUtils::ChooseTemporalitySelector(options_.aggregation_temporality)}, metrics_service_stub_(std::move(stub)) -{} +{ + client_ = OtlpGrpcClientFactory::Create(options_); + client_reference_guard_ = OtlpGrpcClientFactory::CreateReferenceGuard(); + client_->AddReference(*client_reference_guard_, options_); +} + +OtlpGrpcMetricExporter::OtlpGrpcMetricExporter(const OtlpGrpcMetricExporterOptions &options, + const std::shared_ptr &client) + : options_(options), + client_(client), + client_reference_guard_(OtlpGrpcClientFactory::CreateReferenceGuard()) +{ + client_->AddReference(*client_reference_guard_, options_); + + metrics_service_stub_ = client_->MakeMetricsServiceStub(); +} + +OtlpGrpcMetricExporter::OtlpGrpcMetricExporter( + std::unique_ptr stub, + const std::shared_ptr &client) + : options_(OtlpGrpcMetricExporterOptions()), + client_(client), + client_reference_guard_(OtlpGrpcClientFactory::CreateReferenceGuard()), + metrics_service_stub_(std::move(stub)) +{ + client_->AddReference(*client_reference_guard_, options_); +} + +OtlpGrpcMetricExporter::~OtlpGrpcMetricExporter() +{ + if (client_) + { + client_->RemoveReference(*client_reference_guard_); + } +} // ----------------------------- Exporter methods ------------------------------ @@ -54,14 +88,23 @@ sdk::metrics::AggregationTemporality OtlpGrpcMetricExporter::GetAggregationTempo opentelemetry::sdk::common::ExportResult OtlpGrpcMetricExporter::Export( const opentelemetry::sdk::metrics::ResourceMetrics &data) noexcept { - - if (isShutdown()) + std::shared_ptr client = client_; + if (isShutdown() || !client) { OTEL_INTERNAL_LOG_ERROR("[OTLP METRICS gRPC] Exporting " << data.scope_metric_data_.size() << " metric(s) failed, exporter is shutdown"); return sdk::common::ExportResult::kFailure; } + + if (!metrics_service_stub_) + { + OTEL_INTERNAL_LOG_ERROR("[OTLP gRPC] Exporting " + << data.scope_metric_data_.size() + << " metric(s) failed, service stub unavailable"); + return sdk::common::ExportResult::kFailure; + } + if (data.scope_metric_data_.empty()) { return sdk::common::ExportResult::kSuccess; @@ -88,13 +131,16 @@ opentelemetry::sdk::common::ExportResult OtlpGrpcMetricExporter::Export( #ifdef ENABLE_ASYNC_EXPORT if (options_.max_concurrent_requests > 1) { - return client_->DelegateAsyncExport( + return client->DelegateAsyncExport( options_, metrics_service_stub_.get(), std::move(context), std::move(arena), std::move(*request), - [](opentelemetry::sdk::common::ExportResult result, - std::unique_ptr &&, - const proto::collector::metrics::v1::ExportMetricsServiceRequest &request, - proto::collector::metrics::v1::ExportMetricsServiceResponse *) { + // Capture the metrics_service_stub_ to ensure it is not destroyed before the callback is + // called. + [metrics_service_stub = metrics_service_stub_]( + opentelemetry::sdk::common::ExportResult result, + std::unique_ptr &&, + const proto::collector::metrics::v1::ExportMetricsServiceRequest &request, + proto::collector::metrics::v1::ExportMetricsServiceResponse *) { if (result != opentelemetry::sdk::common::ExportResult::kSuccess) { OTEL_INTERNAL_LOG_ERROR("[OTLP METRIC GRPC Exporter] ERROR: Export " @@ -131,22 +177,27 @@ opentelemetry::sdk::common::ExportResult OtlpGrpcMetricExporter::Export( bool OtlpGrpcMetricExporter::ForceFlush( OPENTELEMETRY_MAYBE_UNUSED std::chrono::microseconds timeout) noexcept { -#ifdef ENABLE_ASYNC_EXPORT - return client_->ForceFlush(timeout); -#else - return true; -#endif + // Maybe already shutdown, we need to keep thread-safety here. + std::shared_ptr client = client_; + if (!client) + { + return true; + } + return client->ForceFlush(timeout); } bool OtlpGrpcMetricExporter::Shutdown( OPENTELEMETRY_MAYBE_UNUSED std::chrono::microseconds timeout) noexcept { is_shutdown_ = true; -#ifdef ENABLE_ASYNC_EXPORT - return client_->Shutdown(timeout); -#else - return true; -#endif + // Maybe already shutdown, we need to keep thread-safety here. + std::shared_ptr client; + client.swap(client_); + if (!client) + { + return true; + } + return client->Shutdown(*client_reference_guard_, timeout); } bool OtlpGrpcMetricExporter::isShutdown() const noexcept @@ -154,6 +205,11 @@ bool OtlpGrpcMetricExporter::isShutdown() const noexcept return is_shutdown_; } +const std::shared_ptr &OtlpGrpcMetricExporter::GetClient() const noexcept +{ + return client_; +} + } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/otlp/src/otlp_grpc_metric_exporter_factory.cc b/exporters/otlp/src/otlp_grpc_metric_exporter_factory.cc index c26035a8df..244d275722 100644 --- a/exporters/otlp/src/otlp_grpc_metric_exporter_factory.cc +++ b/exporters/otlp/src/otlp_grpc_metric_exporter_factory.cc @@ -28,6 +28,15 @@ OtlpGrpcMetricExporterFactory::Create(const OtlpGrpcMetricExporterOptions &optio return exporter; } +std::unique_ptr +OtlpGrpcMetricExporterFactory::Create(const OtlpGrpcMetricExporterOptions &options, + const std::shared_ptr &client) +{ + std::unique_ptr exporter( + new OtlpGrpcMetricExporter(options, client)); + return exporter; +} + } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/otlp/test/otlp_grpc_exporter_factory_test.cc b/exporters/otlp/test/otlp_grpc_exporter_factory_test.cc index c383cc85ed..a2fb62dab0 100644 --- a/exporters/otlp/test/otlp_grpc_exporter_factory_test.cc +++ b/exporters/otlp/test/otlp_grpc_exporter_factory_test.cc @@ -3,6 +3,7 @@ #include +#include "opentelemetry/exporters/otlp/otlp_grpc_client_factory.h" #include "opentelemetry/exporters/otlp/otlp_grpc_exporter_factory.h" #include "opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h" @@ -14,6 +15,8 @@ # error "protobuf should not be included" #endif +#include "opentelemetry/exporters/otlp/otlp_grpc_exporter.h" + OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter { @@ -31,6 +34,25 @@ TEST(OtlpGrpcExporterFactoryTest, BuildTest) EXPECT_TRUE(exporter != nullptr); } +TEST(OtlpGrpcExporterFactoryTest, ShareClient) +{ + OtlpGrpcExporterOptions opts; + opts.endpoint = "localhost:45454"; + + std::shared_ptr client = OtlpGrpcClientFactory::Create(opts); + std::unique_ptr exporter1 = + OtlpGrpcExporterFactory::Create(opts, client); + + std::unique_ptr exporter2 = + OtlpGrpcExporterFactory::Create(opts, client); + + EXPECT_TRUE(exporter1 != nullptr); + EXPECT_TRUE(exporter2 != nullptr); + + EXPECT_TRUE(static_cast(exporter1.get())->GetClient().get() == client.get()); + EXPECT_TRUE(static_cast(exporter2.get())->GetClient().get() == client.get()); +} + } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/otlp/test/otlp_grpc_log_record_exporter_factory_test.cc b/exporters/otlp/test/otlp_grpc_log_record_exporter_factory_test.cc index cb1d1849aa..0d0ab17d62 100644 --- a/exporters/otlp/test/otlp_grpc_log_record_exporter_factory_test.cc +++ b/exporters/otlp/test/otlp_grpc_log_record_exporter_factory_test.cc @@ -3,6 +3,7 @@ #include +#include "opentelemetry/exporters/otlp/otlp_grpc_client_factory.h" #include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_factory.h" #include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_options.h" @@ -14,6 +15,8 @@ # error "protobuf should not be included" #endif +#include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h" + OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter { @@ -31,6 +34,27 @@ TEST(OtlpGrpcLogRecordExporterFactoryTest, BuildTest) EXPECT_TRUE(exporter != nullptr); } +TEST(OtlpGrpcLogRecordExporterFactoryTest, ShareClient) +{ + OtlpGrpcLogRecordExporterOptions opts; + opts.endpoint = "localhost:45454"; + + std::shared_ptr client = OtlpGrpcClientFactory::Create(opts); + std::unique_ptr exporter1 = + OtlpGrpcLogRecordExporterFactory::Create(opts, client); + + std::unique_ptr exporter2 = + OtlpGrpcLogRecordExporterFactory::Create(opts, client); + + EXPECT_TRUE(exporter1 != nullptr); + EXPECT_TRUE(exporter2 != nullptr); + + EXPECT_TRUE(static_cast(exporter1.get())->GetClient().get() == + client.get()); + EXPECT_TRUE(static_cast(exporter2.get())->GetClient().get() == + client.get()); +} + } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/otlp/test/otlp_grpc_log_record_exporter_test.cc b/exporters/otlp/test/otlp_grpc_log_record_exporter_test.cc index 90827f576f..a2604de096 100644 --- a/exporters/otlp/test/otlp_grpc_log_record_exporter_test.cc +++ b/exporters/otlp/test/otlp_grpc_log_record_exporter_test.cc @@ -3,15 +3,21 @@ #include +#include "opentelemetry/exporters/otlp/otlp_grpc_client.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_client_factory.h" #include "opentelemetry/exporters/otlp/otlp_grpc_exporter.h" #include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h" +// clang-format off #include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" +// clang-format on #include "opentelemetry/proto/collector/logs/v1/logs_service_mock.grpc.pb.h" #include "opentelemetry/proto/collector/trace/v1/trace_service_mock.grpc.pb.h" +// clang-format off #include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" +// clang-format on #include "opentelemetry/logs/provider.h" #include "opentelemetry/sdk/logs/batch_log_record_processor.h" @@ -188,6 +194,22 @@ class OtlpGrpcLogRecordExporterTestPeer : public ::testing::Test new OtlpGrpcExporter(std::move(stub_interface))); } + std::unique_ptr GetExporter( + std::unique_ptr &stub_interface, + const std::shared_ptr &client) + { + return std::unique_ptr( + new OtlpGrpcLogRecordExporter(std::move(stub_interface), std::move(client))); + } + + std::unique_ptr GetExporter( + std::unique_ptr &stub_interface, + const std::shared_ptr &client) + { + return std::unique_ptr( + new OtlpGrpcExporter(std::move(stub_interface), std::move(client))); + } + // Get the options associated with the given exporter. const OtlpGrpcLogRecordExporterOptions &GetOptions( std::unique_ptr &exporter) @@ -334,6 +356,116 @@ TEST_F(OtlpGrpcLogRecordExporterTestPeer, ExportIntegrationTest) trace_provider = opentelemetry::nostd::shared_ptr(); } +// Create spans, let processor call Export() and share client object between trace and logs +TEST_F(OtlpGrpcLogRecordExporterTestPeer, ShareClientTest) +{ + std::shared_ptr shared_client = + OtlpGrpcClientFactory::Create(OtlpGrpcLogRecordExporterOptions()); + + auto mock_stub = new OtlpMockLogsServiceStub(); + std::unique_ptr stub_interface(mock_stub); + + auto exporter = GetExporter(stub_interface, shared_client); + + bool attribute_storage_bool_value[] = {true, false, true}; + int32_t attribute_storage_int32_value[] = {1, 2}; + uint32_t attribute_storage_uint32_value[] = {3, 4}; + int64_t attribute_storage_int64_value[] = {5, 6}; + uint64_t attribute_storage_uint64_value[] = {7, 8}; + double attribute_storage_double_value[] = {3.2, 3.3}; + opentelemetry::nostd::string_view attribute_storage_string_value[] = {"vector", "string"}; + + auto provider = nostd::shared_ptr(new sdk::logs::LoggerProvider()); + provider->AddProcessor( + std::unique_ptr(new sdk::logs::BatchLogRecordProcessor( + std::move(exporter), 5, std::chrono::milliseconds(256), 1))); + + EXPECT_CALL(*mock_stub, Export(_, _, _)) + .Times(Exactly(1)) + .WillRepeatedly(Return(grpc::Status::OK)); + + uint8_t trace_id_bin[opentelemetry::trace::TraceId::kSize] = { + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; + opentelemetry::trace::TraceId trace_id{trace_id_bin}; + uint8_t span_id_bin[opentelemetry::trace::SpanId::kSize] = {'7', '6', '5', '4', + '3', '2', '1', '0'}; + opentelemetry::trace::SpanId span_id{span_id_bin}; + + auto trace_mock_stub = new OtlpMockTraceServiceStub(); + std::unique_ptr trace_stub_interface( + trace_mock_stub); + + auto trace_provider = opentelemetry::nostd::shared_ptr( + opentelemetry::sdk::trace::TracerProviderFactory::Create( + opentelemetry::sdk::trace::SimpleSpanProcessorFactory::Create( + GetExporter(trace_stub_interface, shared_client)))); + + // Trace and Logs should both receive datas when links static gRPC on ELF ABI. + EXPECT_CALL(*trace_mock_stub, Export(_, _, _)) + .Times(AtLeast(2)) + .WillRepeatedly(Return(grpc::Status::OK)); + + { + const std::string schema_url{"https://opentelemetry.io/schemas/1.11.0"}; + + auto tracer = trace_provider->GetTracer("opentelelemtry_library", "", schema_url); + auto copy_trace_provider = trace_provider; + opentelemetry::trace::Provider::SetTracerProvider(std::move(copy_trace_provider)); + auto trace_span = tracer->StartSpan("test_log"); + opentelemetry::trace::Scope trace_scope{trace_span}; + + auto logger = provider->GetLogger("test", "opentelelemtry_library", "", schema_url, + {{"scope_key1", "scope_value"}, {"scope_key2", 2}}); + std::unordered_map attributes; + attributes["service.name"] = "unit_test_service"; + attributes["tenant.id"] = "test_user"; + attributes["bool_value"] = true; + attributes["int32_value"] = static_cast(1); + attributes["uint32_value"] = static_cast(2); + attributes["int64_value"] = static_cast(0x1100000000LL); + attributes["uint64_value"] = static_cast(0x1200000000ULL); + attributes["double_value"] = static_cast(3.1); + attributes["vec_bool_value"] = attribute_storage_bool_value; + attributes["vec_int32_value"] = attribute_storage_int32_value; + attributes["vec_uint32_value"] = attribute_storage_uint32_value; + attributes["vec_int64_value"] = attribute_storage_int64_value; + attributes["vec_uint64_value"] = attribute_storage_uint64_value; + attributes["vec_double_value"] = attribute_storage_double_value; + attributes["vec_string_value"] = attribute_storage_string_value; + logger->EmitLogRecord(opentelemetry::logs::Severity::kInfo, "Log message", attributes, + trace_span->GetContext(), std::chrono::system_clock::now()); + } + + // Shudown logs, but tracer still works + provider->Shutdown(); + EXPECT_FALSE(shared_client->IsShutdown()); + + { + const std::string schema_url{"https://opentelemetry.io/schemas/1.11.0"}; + + auto tracer = trace_provider->GetTracer("opentelelemtry_library", "", schema_url); + auto trace_span = tracer->StartSpan("test_log"); + opentelemetry::trace::Scope trace_scope{trace_span}; + + auto logger = provider->GetLogger("test", "opentelelemtry_library", "", schema_url, + {{"scope_key1", "scope_value"}, {"scope_key2", 2}}); + std::unordered_map attributes; + attributes["service.name"] = "unit_test_service"; + attributes["tenant.id"] = "test_user"; + logger->EmitLogRecord(opentelemetry::logs::Severity::kInfo, "Log message", attributes, + trace_span->GetContext(), std::chrono::system_clock::now()); + } + + // All references are released, client should also be shutdown + trace_provider->Shutdown(); + EXPECT_TRUE(shared_client->IsShutdown()); + + opentelemetry::trace::Provider::SetTracerProvider( + opentelemetry::nostd::shared_ptr( + new opentelemetry::trace::NoopTracerProvider())); + trace_provider = opentelemetry::nostd::shared_ptr(); +} + } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/otlp/test/otlp_grpc_metric_exporter_factory_test.cc b/exporters/otlp/test/otlp_grpc_metric_exporter_factory_test.cc index b1d473e8da..ecad49bee1 100644 --- a/exporters/otlp/test/otlp_grpc_metric_exporter_factory_test.cc +++ b/exporters/otlp/test/otlp_grpc_metric_exporter_factory_test.cc @@ -3,6 +3,7 @@ #include +#include "opentelemetry/exporters/otlp/otlp_grpc_client_factory.h" #include "opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h" #include "opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_options.h" @@ -14,6 +15,8 @@ # error "protobuf should not be included" #endif +#include "opentelemetry/exporters/otlp/otlp_grpc_metric_exporter.h" + OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter { @@ -31,6 +34,27 @@ TEST(OtlpGrpcMetricExporterFactory, BuildTest) EXPECT_TRUE(exporter != nullptr); } +TEST(OtlpGrpcMetricExporterFactory, ShareClient) +{ + OtlpGrpcMetricExporterOptions opts; + opts.endpoint = "localhost:45454"; + + std::shared_ptr client = OtlpGrpcClientFactory::Create(opts); + std::unique_ptr exporter1 = + OtlpGrpcMetricExporterFactory::Create(opts, client); + + std::unique_ptr exporter2 = + OtlpGrpcMetricExporterFactory::Create(opts, client); + + EXPECT_TRUE(exporter1 != nullptr); + EXPECT_TRUE(exporter2 != nullptr); + + EXPECT_TRUE(static_cast(exporter1.get())->GetClient().get() == + client.get()); + EXPECT_TRUE(static_cast(exporter2.get())->GetClient().get() == + client.get()); +} + } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/src/common/CMakeLists.txt b/sdk/src/common/CMakeLists.txt index 664db38e17..16229e0820 100644 --- a/sdk/src/common/CMakeLists.txt +++ b/sdk/src/common/CMakeLists.txt @@ -17,7 +17,7 @@ target_link_libraries( opentelemetry_common PUBLIC opentelemetry_api opentelemetry_sdk Threads::Threads) -if(WITH_ABSEIL) +if(WITH_ABSEIL OR WITH_OTLP_GRPC) target_link_libraries(opentelemetry_common PUBLIC absl::strings) endif() From 169525328ad96613c9a1cf886da5bea30968272d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Nov 2024 01:04:53 +0100 Subject: [PATCH 69/89] Bump codecov/codecov-action from 4 to 5 (#3143) * Bump codecov/codecov-action from 4 to 5 Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4 to 5. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v4...v5) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * Update .github/workflows/ci.yml --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Marc Alff --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f3a214ecde..2cb354d5db 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -876,9 +876,9 @@ jobs: CXX: /usr/bin/g++-10 run: ./ci/do_ci.sh code.coverage - name: upload report - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v5 with: - file: /home/runner/build/coverage.info + files: /home/runner/build/coverage.info markdown-lint: runs-on: ubuntu-latest From 8691248fddcab67b9968458037eec89e65b89af9 Mon Sep 17 00:00:00 2001 From: "Alex E." <36134278+chusitoo@users.noreply.github.com> Date: Mon, 18 Nov 2024 19:37:22 -0500 Subject: [PATCH 70/89] [CI] Add cppcheck in the build (#3151) --- .github/workflows/cppcheck.yml | 62 ++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/cppcheck.yml diff --git a/.github/workflows/cppcheck.yml b/.github/workflows/cppcheck.yml new file mode 100644 index 0000000000..a6581634bc --- /dev/null +++ b/.github/workflows/cppcheck.yml @@ -0,0 +1,62 @@ + +name: cppcheck + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + cppcheck: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - name: Set up dependencies + run: | + sudo apt update -y + sudo apt install -y cppcheck + + - name: Run cppcheck + run: | + cppcheck --version | tee cppcheck.log + cppcheck \ + --force \ + --enable=warning,performance,portability \ + --inline-suppr \ + --suppress=unknownMacro:exporters/etw/include/opentelemetry/exporters/etw/TraceLoggingDynamic.h \ + --language=c++ \ + --std=c++14 \ + -I api/include \ + -I exporters/elasticsearch/include \ + -I exporters/etw/include \ + -I exporters/memory/include \ + -I exporters/ostream/include \ + -I exporters/otlp/include \ + -I exporters/prometheus/include \ + -I exporters/zipkin/include \ + -I ext/include \ + -I opentracing-shim/include \ + -I sdk/include \ + -i build \ + -i test \ + -i third_party \ + -j $(nproc) \ + . 2>&1 | tee --append cppcheck.log + + - uses: actions/upload-artifact@v4 + if: success() || failure() + with: + name: Logs (cppcheck) + path: ./cppcheck.log + + - name: Count warnings + run: | + set +e + COUNT=`grep -c -E "\[.+\]" cppcheck.log` + echo "cppcheck reported ${COUNT} warning(s)" + # TODO: uncomment to enforce failing the build + # if [ $COUNT -ne 0 ] ; then exit 1 ; fi From 8e7a192f3ec496297de718fb60f874fa4c40fc57 Mon Sep 17 00:00:00 2001 From: Tom Tan Date: Tue, 19 Nov 2024 10:12:36 -0800 Subject: [PATCH 71/89] [BUILD] Fix error message (#3152) --- exporters/otlp/src/otlp_grpc_client.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporters/otlp/src/otlp_grpc_client.cc b/exporters/otlp/src/otlp_grpc_client.cc index 04382c65e5..fe38f16e2b 100644 --- a/exporters/otlp/src/otlp_grpc_client.cc +++ b/exporters/otlp/src/otlp_grpc_client.cc @@ -672,7 +672,7 @@ bool OtlpGrpcClient::Shutdown(OtlpGrpcClientReferenceGuard &guard, bool force_flush_result; if (last_reference_removed && false == is_shutdown_.exchange(true, std::memory_order_acq_rel)) { - OTEL_INTERNAL_LOG_DEBUG("[OTLP GRPC Client] DEBUG: OtlpGrpcClient start to shitdown"); + OTEL_INTERNAL_LOG_DEBUG("[OTLP GRPC Client] DEBUG: OtlpGrpcClient start to shutdown"); force_flush_result = ForceFlush(timeout); #ifdef ENABLE_ASYNC_EXPORT From 4d9cc288d5a37df33260023287f376e345024570 Mon Sep 17 00:00:00 2001 From: Volodymyr Kolesnykov Date: Tue, 19 Nov 2024 23:13:08 +0200 Subject: [PATCH 72/89] [EXPORTER] fix clang-tidy warnings in UrlParser (#3146) --- .../ext/http/common/url_parser.h | 79 ++++++++++--------- ext/test/http/url_parser_test.cc | 3 +- 2 files changed, 43 insertions(+), 39 deletions(-) diff --git a/ext/include/opentelemetry/ext/http/common/url_parser.h b/ext/include/opentelemetry/ext/http/common/url_parser.h index bec9f06c0d..c5fe156aa6 100644 --- a/ext/include/opentelemetry/ext/http/common/url_parser.h +++ b/ext/include/opentelemetry/ext/http/common/url_parser.h @@ -7,6 +7,7 @@ #include #include #include +#include #include "opentelemetry/version.h" @@ -34,7 +35,7 @@ class UrlParser std::string query_; bool success_; - UrlParser(std::string url) : url_(url), success_(true) + UrlParser(std::string url) : url_(std::move(url)), success_(true) { if (url_.length() == 0) { @@ -50,15 +51,15 @@ class UrlParser } else { - scheme_ = std::string(url_.begin() + cpos, url_.begin() + pos); + scheme_ = url_.substr(cpos, pos - cpos); cpos = pos + 3; } // credentials - size_t pos1 = url_.find_first_of("@", cpos); - size_t pos2 = url_.find_first_of("/", cpos); + size_t pos1 = url_.find_first_of('@', cpos); if (pos1 != std::string::npos) { + size_t pos2 = url_.find_first_of('/', cpos); // TODO - handle credentials if (pos2 == std::string::npos || pos1 < pos2) { @@ -72,15 +73,19 @@ class UrlParser { // port missing. Used default 80 / 443 if (scheme_ == "http") + { port_ = 80; - if (scheme_ == "https") + } + else if (scheme_ == "https") + { port_ = 443; + } } else { // port present is_port = true; - host_ = std::string(url_.begin() + cpos, url_.begin() + pos); + host_ = url_.substr(cpos, pos - cpos); cpos = pos + 1; } pos = url_.find_first_of("/?", cpos); @@ -89,27 +94,23 @@ class UrlParser path_ = std::string("/"); // use default path if (is_port) { - std::string port_str( - url_.begin() + static_cast(cpos), - url_.begin() + static_cast(url_.length())); - - port_ = GetPort(port_str); + auto port_str = url_.substr(cpos); + port_ = GetPort(port_str); } else { - host_ = std::string(url_.begin() + cpos, url_.begin() + url_.length()); + host_ = url_.substr(cpos); } return; } if (is_port) { - std::string port_str(url_.begin() + static_cast(cpos), - url_.begin() + static_cast(pos)); - port_ = GetPort(port_str); + auto port_str = url_.substr(cpos, pos - cpos); + port_ = GetPort(port_str); } else { - host_ = std::string(url_.begin() + cpos, url_.begin() + pos); + host_ = url_.substr(cpos, pos - cpos); } cpos = pos; @@ -118,21 +119,20 @@ class UrlParser pos = url_.find('?', cpos); if (pos == std::string::npos) { - path_ = std::string(url_.begin() + cpos, url_.begin() + url_.length()); - query_ = ""; + path_ = url_.substr(cpos); } else { - path_ = std::string(url_.begin() + cpos, url_.begin() + pos); + path_ = url_.substr(cpos, pos - cpos); cpos = pos + 1; - query_ = std::string(url_.begin() + cpos, url_.begin() + url_.length()); + query_ = url_.substr(cpos); } return; } path_ = std::string("/"); if (url_[cpos] == '?') { - query_ = std::string(url_.begin() + cpos, url_.begin() + url_.length()); + query_ = url_.substr(cpos); } } @@ -193,36 +193,39 @@ class UrlDecoder std::string result; result.reserve(encoded.size()); + auto hex_to_int = [](int ch) -> int { + if (ch >= '0' && ch <= '9') + return ch - '0'; + if (ch >= 'a' && ch <= 'f') + return ch - 'a' + 10; + if (ch >= 'A' && ch <= 'F') + return ch - 'A' + 10; + return -1; + }; + for (size_t pos = 0; pos < encoded.size(); pos++) { - if (encoded[pos] == '%') + auto c = encoded[pos]; + if (c == '%') { - - // Invalid input: less than two characters left after '%' - if (encoded.size() < pos + 3) + if (pos + 2 >= encoded.size()) { return encoded; } - char hex[3] = {0}; - hex[0] = encoded[++pos]; - hex[1] = encoded[++pos]; - - char *endptr; - long value = strtol(hex, &endptr, 16); + int hi = hex_to_int(encoded[pos + 1]); + int lo = hex_to_int(encoded[pos + 2]); - // Invalid input: no valid hex characters after '%' - if (endptr != &hex[2]) + if (hi == -1 || lo == -1) { return encoded; } - result.push_back(static_cast(value)); - } - else - { - result.push_back(encoded[pos]); + c = static_cast((hi << 4) | lo); + pos += 2; } + + result.push_back(c); } return result; diff --git a/ext/test/http/url_parser_test.cc b/ext/test/http/url_parser_test.cc index 4314735a6f..f62e29259d 100644 --- a/ext/test/http/url_parser_test.cc +++ b/ext/test/http/url_parser_test.cc @@ -238,7 +238,8 @@ TEST(UrlDecoderTests, BasicTests) {"%2x", "%2x"}, {"%20", " "}, {"text%2", "text%2"}, - }; + {"%20test%zztest", "%20test%zztest"}, + {"%20test%2", "%20test%2"}}; for (auto &testsample : testdata) { From fe68d51efe6a8a463bac957b5aea40dbaaa81856 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Thu, 21 Nov 2024 08:43:52 +0100 Subject: [PATCH 73/89] [EXPORTER] Upgrade to opentelemetry-proto 1.4.0 (#3157) --- bazel/repository.bzl | 6 +++--- cmake/opentelemetry-proto.cmake | 32 ++++++++++---------------------- third_party/opentelemetry-proto | 2 +- third_party_release | 2 +- 4 files changed, 15 insertions(+), 27 deletions(-) diff --git a/bazel/repository.bzl b/bazel/repository.bzl index 4827cffba3..b4f6b5fb1f 100644 --- a/bazel/repository.bzl +++ b/bazel/repository.bzl @@ -88,10 +88,10 @@ def opentelemetry_cpp_deps(): http_archive, name = "com_github_opentelemetry_proto", build_file = "@io_opentelemetry_cpp//bazel:opentelemetry_proto.BUILD", - sha256 = "c069c0d96137cf005d34411fa67dd3b6f1f8c64af1e7fb2fe0089a41c425acd7", - strip_prefix = "opentelemetry-proto-1.3.2", + sha256 = "53cd32cedb27762ea2060a9c8d83e4b822de13d73b5d5d37a2db3cf55018d694", + strip_prefix = "opentelemetry-proto-1.4.0", urls = [ - "https://github.com/open-telemetry/opentelemetry-proto/archive/v1.3.2.tar.gz", + "https://github.com/open-telemetry/opentelemetry-proto/archive/v1.4.0.tar.gz", ], ) diff --git a/cmake/opentelemetry-proto.cmake b/cmake/opentelemetry-proto.cmake index 7831075a27..62b2174957 100644 --- a/cmake/opentelemetry-proto.cmake +++ b/cmake/opentelemetry-proto.cmake @@ -49,7 +49,7 @@ else() "opentelemetry-proto=[ \\t]*([A-Za-z0-9_\\.\\-]+)") set(opentelemetry-proto "${CMAKE_MATCH_1}") else() - set(opentelemetry-proto "v1.3.2") + set(opentelemetry-proto "v1.4.0") endif() unset(OTELCPP_THIRD_PARTY_RELEASE_CONTENT) endif() @@ -81,10 +81,7 @@ set(LOGS_PROTO "${PROTO_PATH}/opentelemetry/proto/logs/v1/logs.proto") set(METRICS_PROTO "${PROTO_PATH}/opentelemetry/proto/metrics/v1/metrics.proto") set(PROFILES_PROTO - "${PROTO_PATH}/opentelemetry/proto/profiles/v1experimental/profiles.proto") -set(PROFILES_EXT_PROTO - "${PROTO_PATH}/opentelemetry/proto/profiles/v1experimental/pprofextended.proto" -) + "${PROTO_PATH}/opentelemetry/proto/profiles/v1development/profiles.proto") set(TRACE_SERVICE_PROTO "${PROTO_PATH}/opentelemetry/proto/collector/trace/v1/trace_service.proto") @@ -95,7 +92,7 @@ set(METRICS_SERVICE_PROTO ) set(PROFILES_SERVICE_PROTO - "${PROTO_PATH}/opentelemetry/proto/collector/profiles/v1experimental/profiles_service.proto" + "${PROTO_PATH}/opentelemetry/proto/collector/profiles/v1development/profiles_service.proto" ) set(GENERATED_PROTOBUF_PATH @@ -138,30 +135,24 @@ set(TRACE_SERVICE_PB_H_FILE # set(PROFILES_CPP_FILE - "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/profiles/v1experimental/profiles.pb.cc" + "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/profiles/v1development/profiles.pb.cc" ) set(PROFILES_H_FILE - "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/profiles/v1experimental/profiles.pb.h" -) -set(PROFILES_EXT_CPP_FILE - "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/profiles/v1experimental/pprofextended.pb.cc" -) -set(PROFILES_EXT_H_FILE - "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/profiles/v1experimental/pprofextended.pb.h" + "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/profiles/v1development/profiles.pb.h" ) set(PROFILES_SERVICE_PB_H_FILE - "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/profiles/v1experimental/profiles_service.pb.h" + "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/profiles/v1development/profiles_service.pb.h" ) set(PROFILES_SERVICE_PB_CPP_FILE - "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/profiles/v1experimental/profiles_service.pb.cc" + "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/profiles/v1development/profiles_service.pb.cc" ) if(WITH_OTLP_GRPC) set(PROFILES_SERVICE_GRPC_PB_H_FILE - "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/profiles/v1experimental/profiles_service.grpc.pb.h" + "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/profiles/v1development/profiles_service.grpc.pb.h" ) set(PROFILES_SERVICE_GRPC_PB_CPP_FILE - "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/profiles/v1experimental/profiles_service.grpc.pb.cc" + "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/profiles/v1development/profiles_service.grpc.pb.cc" ) endif() @@ -243,8 +234,6 @@ set(PROTOBUF_GENERATED_FILES ${METRICS_PB_CPP_FILE} ${PROFILES_H_FILE} ${PROFILES_CPP_FILE} - ${PROFILES_EXT_H_FILE} - ${PROFILES_EXT_CPP_FILE} ${TRACE_SERVICE_PB_H_FILE} ${TRACE_SERVICE_PB_CPP_FILE} ${LOGS_SERVICE_PB_H_FILE} @@ -283,7 +272,6 @@ foreach( ${LOGS_PROTO} ${METRICS_PROTO} ${PROFILES_PROTO} - ${PROFILES_EXT_PROTO} ${TRACE_SERVICE_PROTO} ${LOGS_SERVICE_PROTO} ${METRICS_SERVICE_PROTO} @@ -298,7 +286,7 @@ add_custom_command( ${PROTOBUF_PROTOC_EXECUTABLE} ${PROTOBUF_COMMON_FLAGS} ${PROTOBUF_INCLUDE_FLAGS} ${COMMON_PROTO} ${RESOURCE_PROTO} ${TRACE_PROTO} ${LOGS_PROTO} ${METRICS_PROTO} ${TRACE_SERVICE_PROTO} ${LOGS_SERVICE_PROTO} - ${METRICS_SERVICE_PROTO} ${PROFILES_PROTO} ${PROFILES_EXT_PROTO} + ${METRICS_SERVICE_PROTO} ${PROFILES_PROTO} ${PROFILES_SERVICE_PROTO} COMMENT "[Run]: ${PROTOBUF_RUN_PROTOC_COMMAND}") diff --git a/third_party/opentelemetry-proto b/third_party/opentelemetry-proto index 40b3c1b746..0adf6aac00 160000 --- a/third_party/opentelemetry-proto +++ b/third_party/opentelemetry-proto @@ -1 +1 @@ -Subproject commit 40b3c1b746767cbc13c2e39da3eaf1a23e54ffdd +Subproject commit 0adf6aac004578b28267394514b2e55ee9cc012f diff --git a/third_party_release b/third_party_release index 2a57541bf0..75646fa6c9 100644 --- a/third_party_release +++ b/third_party_release @@ -19,7 +19,7 @@ benchmark=v1.8.3 googletest=1.14.0 ms-gsl=v3.1.0-67-g6f45293 nlohmann-json=v3.11.3 -opentelemetry-proto=v1.3.2 +opentelemetry-proto=v1.4.0 opentracing-cpp=v1.6.0 prometheus-cpp=v1.3.0 vcpkg=2024.02.14 From 4341e1237ee6ce5bd87c60948c1d848b101de586 Mon Sep 17 00:00:00 2001 From: Volodymyr Kolesnykov Date: Fri, 22 Nov 2024 23:50:10 +0200 Subject: [PATCH 74/89] [TEST] refactor UrlParser tests to use value-paramterized tests (#3153) --- ext/test/http/url_parser_test.cc | 348 +++++++++++-------------------- 1 file changed, 118 insertions(+), 230 deletions(-) diff --git a/ext/test/http/url_parser_test.cc b/ext/test/http/url_parser_test.cc index f62e29259d..680e73670f 100644 --- a/ext/test/http/url_parser_test.cc +++ b/ext/test/http/url_parser_test.cc @@ -2,248 +2,136 @@ // SPDX-License-Identifier: Apache-2.0 #include -#include #include -#include +#include #include "opentelemetry/ext/http/common/url_parser.h" namespace http_common = opentelemetry::ext::http::common; -inline const char *BoolToString(bool b) +struct ParsedUrl { - return b ? "true" : "false"; -} + std::string scheme; + std::string host; + std::uint16_t port; + std::string path; + std::string query; + bool success; -TEST(UrlParserTests, BasicTests) -{ - std::map> urls_map{ - {"www.abc.com", - {{"host", "www.abc.com"}, - {"port", "80"}, - {"scheme", "http"}, - {"path", "/"}, - {"query", ""}, - {"success", "true"}}}, - {"http://www.abc.com", - {{"host", "www.abc.com"}, - {"port", "80"}, - {"scheme", "http"}, - {"path", "/"}, - {"query", ""}, - {"success", "true"}}}, - {"https://www.abc.com", - {{"host", "www.abc.com"}, - {"port", "443"}, - {"scheme", "https"}, - {"path", "/"}, - {"query", ""}, - {"success", "true"}}}, - {"https://www.abc.com:4431", - {{"host", "www.abc.com"}, - {"port", "4431"}, - {"scheme", "https"}, - {"path", "/"}, - {"query", ""}, - {"success", "true"}}}, - {"https://www.abc.com:4431", - {{"host", "www.abc.com"}, - {"port", "4431"}, - {"scheme", "https"}, - {"path", "/"}, - {"query", ""}, - {"success", "true"}}}, - {"https://www.abc.com:4431/path1", - {{"host", "www.abc.com"}, - {"port", "4431"}, - {"scheme", "https"}, - {"path", "/path1"}, - {"query", ""}, - {"success", "true"}}}, - {"https://www.abc.com:4431/path1/path2", - {{"host", "www.abc.com"}, - {"port", "4431"}, - {"scheme", "https"}, - {"path", "/path1/path2"}, - {"query", ""}, - {"success", "true"}}}, - {"https://www.abc.com/path1/path2", - {{"host", "www.abc.com"}, - {"port", "443"}, - {"scheme", "https"}, - {"path", "/path1/path2"}, - {"query", ""}, - {"success", "true"}}}, - {"http://www.abc.com/path1/path2?q1=a1&q2=a2", - {{"host", "www.abc.com"}, - {"port", "80"}, - {"scheme", "http"}, - {"path", "/path1/path2"}, - {"query", "q1=a1&q2=a2"}, - {"success", "true"}}}, - {"http://www.abc.com:8080/path1/path2?q1=a1&q2=a2", - {{"host", "www.abc.com"}, - {"port", "8080"}, - {"scheme", "http"}, - {"path", "/path1/path2"}, - {"query", "q1=a1&q2=a2"}, - {"success", "true"}}}, - {"www.abc.com:8080/path1/path2?q1=a1&q2=a2", - {{"host", "www.abc.com"}, - {"port", "8080"}, - {"scheme", "http"}, - {"path", "/path1/path2"}, - {"query", "q1=a1&q2=a2"}, - {"success", "true"}}}, - {"http://user:password@www.abc.com:8080/path1/path2?q1=a1&q2=a2", - {{"host", "www.abc.com"}, - {"port", "8080"}, - {"scheme", "http"}, - {"path", "/path1/path2"}, - {"query", "q1=a1&q2=a2"}, - {"success", "true"}}}, - {"user:password@www.abc.com:8080/path1/path2?q1=a1&q2=a2", - {{"host", "www.abc.com"}, - {"port", "8080"}, - {"scheme", "http"}, - {"path", "/path1/path2"}, - {"query", "q1=a1&q2=a2"}, - {"success", "true"}}}, - {"https://user@www.abc.com/path1/path2?q1=a1&q2=a2", - {{"host", "www.abc.com"}, - {"port", "443"}, - {"scheme", "https"}, - {"path", "/path1/path2"}, - {"query", "q1=a1&q2=a2"}, - {"success", "true"}}}, - {"http://www.abc.com/path1@bbb/path2?q1=a1&q2=a2", - {{"host", "www.abc.com"}, - {"port", "80"}, - {"scheme", "http"}, - {"path", "/path1@bbb/path2"}, - {"query", "q1=a1&q2=a2"}, - {"success", "true"}}}, - {"http://1.2.3.4/path1/path2?q1=a1&q2=a2", - {{"host", "1.2.3.4"}, - {"port", "80"}, - {"scheme", "http"}, - {"path", "/path1/path2"}, - {"query", "q1=a1&q2=a2"}, - {"success", "true"}}}, - {"user:password@1.2.3.4:8080/path1/path2?q1=a1&q2=a2", - {{"host", "1.2.3.4"}, - {"port", "8080"}, - {"scheme", "http"}, - {"path", "/path1/path2"}, - {"query", "q1=a1&q2=a2"}, - {"success", "true"}}}, - {"https://user@1.2.3.4/path1/path2?q1=a1&q2=a2", - {{"host", "1.2.3.4"}, - {"port", "443"}, - {"scheme", "https"}, - {"path", "/path1/path2"}, - {"query", "q1=a1&q2=a2"}, - {"success", "true"}}}, - {"http://1.2.3.4/path1@bbb/path2?q1=a1&q2=a2", - {{"host", "1.2.3.4"}, - {"port", "80"}, - {"scheme", "http"}, - {"path", "/path1@bbb/path2"}, - {"query", "q1=a1&q2=a2"}, - {"success", "true"}}}, - {"http://[fe80::225:93da:bfde:b5f5]/path1/path2?q1=a1&q2=a2", - {{"host", "[fe80::225:93da:bfde:b5f5]"}, - {"port", "80"}, - {"scheme", "http"}, - {"path", "/path1/path2"}, - {"query", "q1=a1&q2=a2"}, - {"success", "true"}}}, - {"user:password@[fe80::225:93da:bfde:b5f5]:8080/path1/path2?q1=a1&q2=a2", - {{"host", "[fe80::225:93da:bfde:b5f5]"}, - {"port", "8080"}, - {"scheme", "http"}, - {"path", "/path1/path2"}, - {"query", "q1=a1&q2=a2"}, - {"success", "true"}}}, - {"https://user@[fe80::225:93da:bfde:b5f5]/path1/path2?q1=a1&q2=a2", - {{"host", "[fe80::225:93da:bfde:b5f5]"}, - {"port", "443"}, - {"scheme", "https"}, - {"path", "/path1/path2"}, - {"query", "q1=a1&q2=a2"}, - {"success", "true"}}}, - {"http://[fe80::225:93da:bfde:b5f5]/path1@bbb/path2?q1=a1&q2=a2", - {{"host", "[fe80::225:93da:bfde:b5f5]"}, - {"port", "80"}, - {"scheme", "http"}, - {"path", "/path1@bbb/path2"}, - {"query", "q1=a1&q2=a2"}, - {"success", "true"}}}, - {"https://https://example.com/some/path", - {{"host", "https"}, - {"port", "0"}, - {"scheme", "https"}, - {"path", "//example.com/some/path"}, - {"query", ""}, - {"success", "false"}}}, - {"https://example.com:-1/some/path", - {{"host", "example.com"}, - {"port", "0"}, - {"scheme", "https"}, - {"path", "/some/path"}, - {"query", ""}, - {"success", "false"}}}, - {"https://example.com:65536/some/path", - {{"host", "example.com"}, - {"port", "0"}, - {"scheme", "https"}, - {"path", "/some/path"}, - {"query", ""}, - {"success", "false"}}}, - {"https://example.com:80a/some/path", - {{"host", "example.com"}, - {"port", "0"}, - {"scheme", "https"}, - {"path", "/some/path"}, - {"query", ""}, - {"success", "false"}}}, - {"https://example.com:18446744073709551616/some/path", - {{"host", "example.com"}, - {"port", "0"}, - {"scheme", "https"}, - {"path", "/some/path"}, - {"query", ""}, - {"success", "false"}}}, - }; - for (auto &url_map : urls_map) + friend void PrintTo(const ParsedUrl &p, std::ostream *os) { - http_common::UrlParser url(url_map.first); - auto url_properties = url_map.second; - ASSERT_EQ(BoolToString(url.success_), url_properties["success"]); - ASSERT_EQ(url.host_, url_properties["host"]); - ASSERT_EQ(std::to_string(url.port_), url_properties["port"]); - ASSERT_EQ(url.scheme_, url_properties["scheme"]); - ASSERT_EQ(url.path_, url_properties["path"]); - ASSERT_EQ(url.query_, url_properties["query"]); + *os << "(valid: " << (p.success ? "yes" : "no") << ", scheme: " << p.scheme + << ", host: " << p.host << ", port: " << p.port << ", path: " << p.path + << ", query: " << p.query << ")"; } +}; + +class UrlParserTests : public testing::TestWithParam> +{}; + +INSTANTIATE_TEST_SUITE_P( + SampleValues, + UrlParserTests, + testing::Values( + std::make_tuple("www.abc.com", ParsedUrl{"http", "www.abc.com", 80, "/", "", true}), + std::make_tuple("http://www.abc.com", ParsedUrl{"http", "www.abc.com", 80, "/", "", true}), + std::make_tuple("https://www.abc.com", + ParsedUrl{"https", "www.abc.com", 443, "/", "", true}), + std::make_tuple("https://www.abc.com:4431", + ParsedUrl{"https", "www.abc.com", 4431, "/", "", true}), + std::make_tuple("https://www.abc.com:4431/path1", + ParsedUrl{"https", "www.abc.com", 4431, "/path1", "", true}), + std::make_tuple("https://www.abc.com:4431/path1/path2", + ParsedUrl{"https", "www.abc.com", 4431, "/path1/path2", "", true}), + std::make_tuple("https://www.abc.com/path1/path2", + ParsedUrl{"https", "www.abc.com", 443, "/path1/path2", "", true}), + std::make_tuple("http://www.abc.com/path1/path2?q1=a1&q2=a2", + ParsedUrl{"http", "www.abc.com", 80, "/path1/path2", "q1=a1&q2=a2", true}), + std::make_tuple("http://www.abc.com:8080/path1/path2?q1=a1&q2=a2", + ParsedUrl{"http", "www.abc.com", 8080, "/path1/path2", "q1=a1&q2=a2", + true}), + std::make_tuple("www.abc.com:8080/path1/path2?q1=a1&q2=a2", + ParsedUrl{"http", "www.abc.com", 8080, "/path1/path2", "q1=a1&q2=a2", + true}), + std::make_tuple("http://user:password@www.abc.com:8080/path1/path2?q1=a1&q2=a2", + ParsedUrl{"http", "www.abc.com", 8080, "/path1/path2", "q1=a1&q2=a2", + true}), + std::make_tuple("user:password@www.abc.com:8080/path1/path2?q1=a1&q2=a2", + ParsedUrl{"http", "www.abc.com", 8080, "/path1/path2", "q1=a1&q2=a2", + true}), + std::make_tuple("https://user@www.abc.com/path1/path2?q1=a1&q2=a2", + ParsedUrl{"https", "www.abc.com", 443, "/path1/path2", "q1=a1&q2=a2", + true}), + std::make_tuple("http://www.abc.com/path1@bbb/path2?q1=a1&q2=a2", + ParsedUrl{"http", "www.abc.com", 80, "/path1@bbb/path2", "q1=a1&q2=a2", + true}), + std::make_tuple("http://1.2.3.4/path1/path2?q1=a1&q2=a2", + ParsedUrl{"http", "1.2.3.4", 80, "/path1/path2", "q1=a1&q2=a2", true}), + std::make_tuple("user:password@1.2.3.4:8080/path1/path2?q1=a1&q2=a2", + ParsedUrl{"http", "1.2.3.4", 8080, "/path1/path2", "q1=a1&q2=a2", true}), + std::make_tuple("https://user@1.2.3.4/path1/path2?q1=a1&q2=a2", + ParsedUrl{"https", "1.2.3.4", 443, "/path1/path2", "q1=a1&q2=a2", true}), + std::make_tuple("http://1.2.3.4/path1@bbb/path2?q1=a1&q2=a2", + ParsedUrl{"http", "1.2.3.4", 80, "/path1@bbb/path2", "q1=a1&q2=a2", true}), + std::make_tuple("http://[fe80::225:93da:bfde:b5f5]/path1/path2?q1=a1&q2=a2", + ParsedUrl{"http", "[fe80::225:93da:bfde:b5f5]", 80, "/path1/path2", + "q1=a1&q2=a2", true}), + std::make_tuple("user:password@[fe80::225:93da:bfde:b5f5]:8080/path1/path2?q1=a1&q2=a2", + ParsedUrl{"http", "[fe80::225:93da:bfde:b5f5]", 8080, "/path1/path2", + "q1=a1&q2=a2", true}), + std::make_tuple("https://user@[fe80::225:93da:bfde:b5f5]/path1/path2?q1=a1&q2=a2", + ParsedUrl{"https", "[fe80::225:93da:bfde:b5f5]", 443, "/path1/path2", + "q1=a1&q2=a2", true}), + std::make_tuple("http://[fe80::225:93da:bfde:b5f5]/path1@bbb/path2?q1=a1&q2=a2", + ParsedUrl{"http", "[fe80::225:93da:bfde:b5f5]", 80, "/path1@bbb/path2", + "q1=a1&q2=a2", true}), + std::make_tuple("https://https://example.com/some/path", + ParsedUrl{"https", "https", 0, "//example.com/some/path", "", false}), + std::make_tuple("https://example.com:-1/some/path", + ParsedUrl{"https", "example.com", 0, "/some/path", "", false}), + std::make_tuple("https://example.com:65536/some/path", + ParsedUrl{"https", "example.com", 0, "/some/path", "", false}), + std::make_tuple("https://example.com:80a/some/path", + ParsedUrl{"https", "example.com", 0, "/some/path", "", false}), + std::make_tuple("https://example.com:18446744073709551616/some/path", + ParsedUrl{"https", "example.com", 0, "/some/path", "", false}))); + +TEST_P(UrlParserTests, BasicTests) +{ + const auto &url = std::get<0>(GetParam()); + const auto &expected = std::get<1>(GetParam()); + + const auto actual = http_common::UrlParser(url); + + EXPECT_EQ(actual.success_, expected.success); + EXPECT_EQ(actual.host_, expected.host); + EXPECT_EQ(actual.port_, expected.port); + EXPECT_EQ(actual.scheme_, expected.scheme); + EXPECT_EQ(actual.path_, expected.path); + EXPECT_EQ(actual.query_, expected.query); } -TEST(UrlDecoderTests, BasicTests) +class UrlDecoderTests : public ::testing::TestWithParam> +{}; + +INSTANTIATE_TEST_SUITE_P( + SampleValues, + UrlDecoderTests, + testing::Values(std::make_tuple("Authentication=Basic xxx", "Authentication=Basic xxx"), + std::make_tuple("Authentication=Basic%20xxx", "Authentication=Basic xxx"), + std::make_tuple("%C3%B6%C3%A0%C2%A7%C3%96abcd%C3%84", + "\xc3\xb6\xc3\xa0\xc2\xa7\xc3\x96\x61\x62\x63\x64\xc3\x84"), + std::make_tuple("%2x", "%2x"), + std::make_tuple("%20", " "), + std::make_tuple("text%2", "text%2"), + std::make_tuple("%20test%zztest", "%20test%zztest"), + std::make_tuple("%20test%2", "%20test%2"))); + +TEST_P(UrlDecoderTests, BasicTests) { - std::map testdata{ - {"Authentication=Basic xxx", "Authentication=Basic xxx"}, - {"Authentication=Basic%20xxx", "Authentication=Basic xxx"}, - {"%C3%B6%C3%A0%C2%A7%C3%96abcd%C3%84", - "\xc3\xb6\xc3\xa0\xc2\xa7\xc3\x96\x61\x62\x63\x64\xc3\x84"}, - {"%2x", "%2x"}, - {"%20", " "}, - {"text%2", "text%2"}, - {"%20test%zztest", "%20test%zztest"}, - {"%20test%2", "%20test%2"}}; + const auto &encoded = std::get<0>(GetParam()); + const auto &expected = std::get<1>(GetParam()); + const auto actual = http_common::UrlDecoder::Decode(encoded); - for (auto &testsample : testdata) - { - ASSERT_EQ(http_common::UrlDecoder::Decode(testsample.first), testsample.second); - ASSERT_TRUE(http_common::UrlDecoder::Decode(testsample.first) == testsample.second); - } + EXPECT_EQ(actual, expected); } From f1b5fbdedd5beb7e7ca6aacfb3f430686d694d9c Mon Sep 17 00:00:00 2001 From: Volodymyr Kolesnykov Date: Sat, 23 Nov 2024 00:33:45 +0200 Subject: [PATCH 75/89] [TEST] add a test for ElasticSearchRecordable (#3154) --- .../test/es_log_record_exporter_test.cc | 92 ++++++++++++++----- 1 file changed, 69 insertions(+), 23 deletions(-) diff --git a/exporters/elasticsearch/test/es_log_record_exporter_test.cc b/exporters/elasticsearch/test/es_log_record_exporter_test.cc index 8a1c81da48..6bdd5248a5 100644 --- a/exporters/elasticsearch/test/es_log_record_exporter_test.cc +++ b/exporters/elasticsearch/test/es_log_record_exporter_test.cc @@ -2,50 +2,48 @@ // SPDX-License-Identifier: Apache-2.0 #include "opentelemetry/exporters/elasticsearch/es_log_record_exporter.h" -#include "opentelemetry/ext/http/server/http_server.h" -#include "opentelemetry/logs/provider.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/exporters/elasticsearch/es_log_recordable.h" +#include "opentelemetry/logs/severity.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/logs/exporter.h" -#include "opentelemetry/sdk/logs/logger_provider.h" -#include "opentelemetry/sdk/logs/simple_log_record_processor.h" +#include "opentelemetry/sdk/resource/resource.h" #include -#include +#include +#include namespace sdklogs = opentelemetry::sdk::logs; namespace logs_api = opentelemetry::logs; namespace nostd = opentelemetry::nostd; namespace logs_exporter = opentelemetry::exporter::logs; -TEST(ElasticsearchLogsExporterTests, Dummy) -{ - // to enable linking -} - -#if 0 // Attempt to write a log to an invalid host/port, test that the Export() returns failure -TEST(ElasticsearchLogsExporterTests, InvalidEndpoint) +TEST(DISABLED_ElasticsearchLogsExporterTests, InvalidEndpoint) { // Create invalid connection options for the elasticsearch exporter logs_exporter::ElasticsearchExporterOptions options("localhost", -1); // Create an elasticsearch exporter - auto exporter = - std::unique_ptr(new logs_exporter::ElasticsearchLogRecordExporter(options)); + auto exporter = std::unique_ptr( + new logs_exporter::ElasticsearchLogRecordExporter(options)); // Create a log record and send to the exporter auto record = exporter->MakeRecordable(); auto result = exporter->Export(nostd::span>(&record, 1)); // Ensure the return value is failure - ASSERT_EQ(result, sdk::common::ExportResult::kFailure); + ASSERT_EQ(result, opentelemetry::sdk::common::ExportResult::kFailure); } // Test that when the exporter is shutdown, any call to Export should return failure -TEST(ElasticsearchLogsExporterTests, Shutdown) +TEST(DISABLED_ElasticsearchLogsExporterTests, Shutdown) { // Create an elasticsearch exporter and immediately shut it down - auto exporter = - std::unique_ptr(new logs_exporter::ElasticsearchLogRecordExporter); + auto exporter = std::unique_ptr( + new logs_exporter::ElasticsearchLogRecordExporter); bool shutdownResult = exporter->Shutdown(); ASSERT_TRUE(shutdownResult); @@ -54,15 +52,15 @@ TEST(ElasticsearchLogsExporterTests, Shutdown) auto result = exporter->Export(nostd::span>(&record, 1)); // Ensure the return value is failure - ASSERT_EQ(result, sdk::common::ExportResult::kFailure); + ASSERT_EQ(result, opentelemetry::sdk::common::ExportResult::kFailure); } // Test the elasticsearch recordable object -TEST(ElasticsearchLogsExporterTests, RecordableCreation) +TEST(DISABLED_ElasticsearchLogsExporterTests, RecordableCreation) { // Create an elasticsearch exporter - auto exporter = - std::unique_ptr(new logs_exporter::ElasticsearchLogRecordExporter); + auto exporter = std::unique_ptr( + new logs_exporter::ElasticsearchLogRecordExporter); // Create a recordable auto record = exporter->MakeRecordable(); @@ -79,4 +77,52 @@ TEST(ElasticsearchLogsExporterTests, RecordableCreation) exporter->Export(nostd::span>(&record, 1)); } -#endif + +TEST(ElasticsearchLogRecordableTests, BasicTests) +{ + const auto severity = logs_api::Severity::kFatal; + const std::array stringlist{ + {nostd::string_view("string1"), nostd::string_view("string2")}}; + + const std::int64_t expected_observed_ts = 1732063944999647774LL; + const std::string expected_timestamp("2024-11-20T00:52:24.999647Z"); + const std::string expected_severity( + opentelemetry::logs::SeverityNumToText[static_cast(severity)]); + const std::string expected_body("Body of the log message"); + const std::string expected_scope_name("scope_name"); + const bool expected_boolean = false; + const int expected_int = 1; + const double expected_double = 2.0; + + const nlohmann::json expected{ + {"@timestamp", expected_timestamp}, + {"boolean", expected_boolean}, + {"double", expected_double}, + {"ecs", {{"version", "8.11.0"}}}, + {"int", expected_int}, + {"log", {{"level", expected_severity}, {"logger", expected_scope_name}}}, + {"message", expected_body}, + {"observedtimestamp", expected_observed_ts}, + {"stringlist", {stringlist[0], stringlist[1]}}}; + + const opentelemetry::common::SystemTimestamp now{std::chrono::nanoseconds(expected_observed_ts)}; + + const auto scope = + opentelemetry::sdk::instrumentationscope::InstrumentationScope::Create(expected_scope_name); + + opentelemetry::exporter::logs::ElasticSearchRecordable recordable; + recordable.SetTimestamp(now); + recordable.SetObservedTimestamp(now); + recordable.SetSeverity(severity); + recordable.SetBody(expected_body); + recordable.SetInstrumentationScope(*scope); + + recordable.SetAttribute("boolean", expected_boolean); + recordable.SetAttribute("int", expected_int); + recordable.SetAttribute("double", expected_double); + recordable.SetAttribute("stringlist", stringlist); + + const auto actual = recordable.GetJSON(); + + EXPECT_EQ(actual, expected); +} From 09c0616971c85315090f3dec549bd7dad70fe7ee Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Sat, 23 Nov 2024 00:19:24 +0100 Subject: [PATCH 76/89] [BUILD] Fix missing dependency on protoc compiler (#3159) --- cmake/opentelemetry-proto.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmake/opentelemetry-proto.cmake b/cmake/opentelemetry-proto.cmake index 62b2174957..0ff346d249 100644 --- a/cmake/opentelemetry-proto.cmake +++ b/cmake/opentelemetry-proto.cmake @@ -288,7 +288,9 @@ add_custom_command( ${LOGS_PROTO} ${METRICS_PROTO} ${TRACE_SERVICE_PROTO} ${LOGS_SERVICE_PROTO} ${METRICS_SERVICE_PROTO} ${PROFILES_PROTO} ${PROFILES_SERVICE_PROTO} - COMMENT "[Run]: ${PROTOBUF_RUN_PROTOC_COMMAND}") + COMMENT "[Run]: ${PROTOBUF_RUN_PROTOC_COMMAND}" + DEPENDS ${PROTOBUF_PROTOC_EXECUTABLE} + ) include_directories("${GENERATED_PROTOBUF_PATH}") From 6a77bcdd5fa39e9b76b3a9f2cbae02ca14bd1fe8 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Fri, 22 Nov 2024 16:36:36 -0800 Subject: [PATCH 77/89] [bazel] Update prometheus-cpp in MODULE.bazel (#3162) --- MODULE.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MODULE.bazel b/MODULE.bazel index a9171d7424..d5e0384c8d 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -16,7 +16,7 @@ bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "github_nlohma bazel_dep(name = "opentelemetry-proto", version = "1.3.2", repo_name = "com_github_opentelemetry_proto") bazel_dep(name = "opentracing-cpp", version = "1.6.0", repo_name = "com_github_opentracing") bazel_dep(name = "platforms", version = "0.0.8") -bazel_dep(name = "prometheus-cpp", version = "1.2.4", repo_name = "com_github_jupp0r_prometheus_cpp") +bazel_dep(name = "prometheus-cpp", version = "1.3.0", repo_name = "com_github_jupp0r_prometheus_cpp") bazel_dep(name = "protobuf", version = "26.0", repo_name = "com_google_protobuf") bazel_dep(name = "rules_proto", version = "5.3.0-21.7") bazel_dep(name = "zlib", version = "1.3.1.bcr.1") From 9d998e33412bbff3c227fdf1a2d1403527345d0e Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Sat, 23 Nov 2024 02:10:48 -0800 Subject: [PATCH 78/89] [bazel] Enable --incompatible_disallow_empty_glob (#2642) --- .bazelrc | 3 +++ sdk/src/logs/BUILD | 1 - sdk/src/metrics/BUILD | 1 - sdk/src/resource/BUILD | 1 - 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.bazelrc b/.bazelrc index f169347647..57cd0a2fa0 100644 --- a/.bazelrc +++ b/.bazelrc @@ -7,6 +7,9 @@ # Enable automatic configs based on platform common --enable_platform_specific_config +# Make globs that don't match anything fail +common --incompatible_disallow_empty_glob + # Needed by gRPC to build on some platforms. build --copt -DGRPC_BAZEL_BUILD diff --git a/sdk/src/logs/BUILD b/sdk/src/logs/BUILD index f1a0828527..93642e99b6 100644 --- a/sdk/src/logs/BUILD +++ b/sdk/src/logs/BUILD @@ -6,7 +6,6 @@ package(default_visibility = ["//visibility:public"]) cc_library( name = "logs", srcs = glob(["**/*.cc"]), - hdrs = glob(["**/*.h"]), include_prefix = "src/logs", deps = [ "//api", diff --git a/sdk/src/metrics/BUILD b/sdk/src/metrics/BUILD index ff8d244da1..78f224b5ab 100644 --- a/sdk/src/metrics/BUILD +++ b/sdk/src/metrics/BUILD @@ -6,7 +6,6 @@ package(default_visibility = ["//visibility:public"]) cc_library( name = "metrics", srcs = glob(["**/*.cc"]), - hdrs = glob(["**/*.h"]), include_prefix = "src/metrics", deps = [ "//api", diff --git a/sdk/src/resource/BUILD b/sdk/src/resource/BUILD index 6cff52723a..8845629990 100644 --- a/sdk/src/resource/BUILD +++ b/sdk/src/resource/BUILD @@ -6,7 +6,6 @@ package(default_visibility = ["//visibility:public"]) cc_library( name = "resource", srcs = glob(["**/*.cc"]), - hdrs = glob(["**/*.h"]), include_prefix = "src/resource", deps = [ "//api", From fcdd52672f8fe84d4345c4d4707bbd819de590c0 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Sun, 24 Nov 2024 14:24:16 +0100 Subject: [PATCH 79/89] [INSTALL] Fix cmake/opentelemetry-cpp-config.cmake.in (#3165) --- cmake/opentelemetry-cpp-config.cmake.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/opentelemetry-cpp-config.cmake.in b/cmake/opentelemetry-cpp-config.cmake.in index 6eead53d28..254bcc662b 100644 --- a/cmake/opentelemetry-cpp-config.cmake.in +++ b/cmake/opentelemetry-cpp-config.cmake.in @@ -105,7 +105,7 @@ endif() if(@WITH_ABSEIL@ OR @WITH_OTLP_GRPC@) find_package(absl CONFIG) -elseif(OR @WITH_OTLP_HTTP@ OR @WITH_OTLP_FILE@) +elseif(@WITH_OTLP_HTTP@ OR @WITH_OTLP_FILE@) if("@Protobuf_VERSION@" VERSION_GREATER_EQUAL "3.22.0") find_package(absl CONFIG) endif() From c1ef416c54fb8572492ed9b86cf418eef1aac379 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Sun, 24 Nov 2024 20:39:35 +0100 Subject: [PATCH 80/89] [BUILD] Do not set OTELCPP_PROTO_PATH in the CMake cache (#3160) --- CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f9e017eed2..177296d81c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -260,10 +260,6 @@ if(OTELCPP_VERSIONED_LIBS AND NOT BUILD_SHARED_LIBS) message(FATAL_ERROR "OTELCPP_VERSIONED_LIBS=ON requires BUILD_SHARED_LIBS=ON") endif() -set(OTELCPP_PROTO_PATH - "" - CACHE PATH "Path to opentelemetry-proto") - if(WIN32) option(WITH_ETW "Whether to include the ETW Exporter in the SDK" ON) else() From 31956f82ff990a870d2953c722666a782f672c35 Mon Sep 17 00:00:00 2001 From: Albert Kharisov Date: Mon, 25 Nov 2024 00:50:40 +0400 Subject: [PATCH 81/89] [BUILD] Fix build for esp32 (#3155) --- sdk/include/opentelemetry/sdk/common/empty_attributes.h | 6 +++--- sdk/include/opentelemetry/sdk/trace/span_data.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/common/empty_attributes.h b/sdk/include/opentelemetry/sdk/common/empty_attributes.h index 0afe439ee6..4a699e7d32 100644 --- a/sdk/include/opentelemetry/sdk/common/empty_attributes.h +++ b/sdk/include/opentelemetry/sdk/common/empty_attributes.h @@ -21,12 +21,12 @@ namespace sdk * with default attributes. */ static const opentelemetry::common::KeyValueIterableView< - std::array, 0>> & + std::array, 0>> & GetEmptyAttributes() noexcept { - static const std::array, 0> array{}; + static const std::array, 0> array{}; static const opentelemetry::common::KeyValueIterableView< - std::array, 0>> + std::array, 0>> kEmptyAttributes(array); return kEmptyAttributes; diff --git a/sdk/include/opentelemetry/sdk/trace/span_data.h b/sdk/include/opentelemetry/sdk/trace/span_data.h index 2bd8b2112b..96b8e5deee 100644 --- a/sdk/include/opentelemetry/sdk/trace/span_data.h +++ b/sdk/include/opentelemetry/sdk/trace/span_data.h @@ -257,7 +257,7 @@ class SpanData final : public Recordable opentelemetry::common::SystemTimestamp timestamp = opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now()), const opentelemetry::common::KeyValueIterable &attributes = - opentelemetry::common::KeyValueIterableView>( + opentelemetry::common::KeyValueIterableView>( {})) noexcept override { SpanDataEvent event(std::string(name), timestamp, attributes); From 2a8c8bc3de1f932d781ecdda3cf6941bc26b1b25 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Mon, 25 Nov 2024 12:09:05 -0800 Subject: [PATCH 82/89] [bazel] Update opentelemetry-proto in MODULE.bazel (#3163) Mirrors fe68d51efe6a8a463bac957b5aea40dbaaa81856 --- MODULE.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MODULE.bazel b/MODULE.bazel index d5e0384c8d..b3c7077108 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -13,7 +13,7 @@ bazel_dep(name = "bazel_skylib", version = "1.5.0") bazel_dep(name = "curl", version = "8.8.0") bazel_dep(name = "grpc", version = "1.63.1.bcr.1", repo_name = "com_github_grpc_grpc") bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "github_nlohmann_json") -bazel_dep(name = "opentelemetry-proto", version = "1.3.2", repo_name = "com_github_opentelemetry_proto") +bazel_dep(name = "opentelemetry-proto", version = "1.4.0", repo_name = "com_github_opentelemetry_proto") bazel_dep(name = "opentracing-cpp", version = "1.6.0", repo_name = "com_github_opentracing") bazel_dep(name = "platforms", version = "0.0.8") bazel_dep(name = "prometheus-cpp", version = "1.3.0", repo_name = "com_github_jupp0r_prometheus_cpp") From 955a807c0461544560429c2414b8967f6023e590 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Tue, 26 Nov 2024 00:19:04 +0100 Subject: [PATCH 83/89] [RELEASE] Release opentelemetry-cpp 1.18.0 (#3168) Fixes #3145 --- CHANGELOG.md | 131 +++++++++++++++++- api/include/opentelemetry/version.h | 4 +- docs/public/conf.py | 2 +- .../opentelemetry/sdk/version/version.h | 2 +- sdk/src/version/version.cc | 8 +- 5 files changed, 135 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 050dfa7551..2025c36b59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,21 +15,140 @@ Increment the: ## [Unreleased] -* [API] Comply with W3C Trace Context - [#3115](https://github.com/open-telemetry/opentelemetry-cpp/pull/3115) +## [1.18 2024-11-25] + +* [EXPORTER] Fix crash in ElasticsearchLogRecordExporter + [#3082](https://github.com/open-telemetry/opentelemetry-cpp/pull/3082) + +* [BUILD] Avoid buggy warning with gcc <= 8 + [#3087](https://github.com/open-telemetry/opentelemetry-cpp/pull/3087) * [API] Jaeger Propagator should not be deprecated [#3086](https://github.com/open-telemetry/opentelemetry-cpp/pull/3086) -* Upgrade to prometheus 1.3.0 +* Update bzlmod version + [#3093](https://github.com/open-telemetry/opentelemetry-cpp/pull/3093) + +* [BUILD] Remove std::make_unique + [#3098](https://github.com/open-telemetry/opentelemetry-cpp/pull/3098) + +* [BUILD] Fix compiling problems for gcc 4.8 + [#3100](https://github.com/open-telemetry/opentelemetry-cpp/pull/3100) + +* [TEST] Fix linking order and gmock linking + [#3106](https://github.com/open-telemetry/opentelemetry-cpp/pull/3106) + +* [EXPORTER] Add config options to prometheus exporter + [#3104](https://github.com/open-telemetry/opentelemetry-cpp/pull/3104) + +* [BUILD] Add a CMake option to disable shared libs + [#3095](https://github.com/open-telemetry/opentelemetry-cpp/pull/3095) + +* [EXPORTER] Remove out of date ETW exporter doc + [#3103](https://github.com/open-telemetry/opentelemetry-cpp/pull/3103) + +* [EXPORTER] Add logging for async gRPC errors + [#3108](https://github.com/open-telemetry/opentelemetry-cpp/pull/3108) + +* [BUILD] Remove aligned_storage from nostd + [#3112](https://github.com/open-telemetry/opentelemetry-cpp/pull/3112) + +* [EXPORTER] Elastic Search exporter follow ECS guidelines + [#3107](https://github.com/open-telemetry/opentelemetry-cpp/pull/3107) + +* [INSTALL] Resolve dependencies in opentelemetry-cpp-config.cmake + [#3094](https://github.com/open-telemetry/opentelemetry-cpp/pull/3094) + +* [API] Add synchronous gauge + [#3029](https://github.com/open-telemetry/opentelemetry-cpp/pull/3029) + +* [BUILD] allow building with -DWITH_OTLP_HTTP_COMPRESSION=OFF without zlib + [#3120](https://github.com/open-telemetry/opentelemetry-cpp/pull/3120) + +* [CI] Comment the arm64 CI + [#3125](https://github.com/open-telemetry/opentelemetry-cpp/pull/3125) + +* [API] Comply with W3C Trace Context + [#3115](https://github.com/open-telemetry/opentelemetry-cpp/pull/3115) + +* [EXPORTER] bump prometheus to v1.3.0 [#3122](https://github.com/open-telemetry/opentelemetry-cpp/pull/3122) +* [EXPORTER] Log SSL Connection Information + [#3113](https://github.com/open-telemetry/opentelemetry-cpp/pull/3113) + +* [BUILD] Improve how to handle yield() in ARM + [#3129](https://github.com/open-telemetry/opentelemetry-cpp/pull/3129) + +* [BUILD] Fix -Wmissing-template-arg-list-after-template-kw warning + [#3133](https://github.com/open-telemetry/opentelemetry-cpp/pull/3133) + +* [EXPORTER]: Elasticsearch exporter put log resource in root instead of under 'resources' + [#3131](https://github.com/open-telemetry/opentelemetry-cpp/pull/3131) + +* [TEST] Rename w3c_tracecontext_test to w3c_tracecontext_http_test_server + [#3132](https://github.com/open-telemetry/opentelemetry-cpp/pull/3132) + +* [BUILD] Patches for building on AIX + [#3127](https://github.com/open-telemetry/opentelemetry-cpp/pull/3127) + * [SEMANTIC CONVENTIONS] Migration to weaver [#3105](https://github.com/open-telemetry/opentelemetry-cpp/pull/3105) -* [EXPORTER] Allow to share gRPC clients between OTLP exporters. +* [SEMANTIC CONVENTIONS] Upgrade to semantic conventions 1.28.0 + [#3139](https://github.com/open-telemetry/opentelemetry-cpp/pull/3139) + +* [EXPORTER] handling of invalid ports in UrlParser + [#3142](https://github.com/open-telemetry/opentelemetry-cpp/pull/3142) + +* [CI] speed up clang-tidy workflow + [#3148](https://github.com/open-telemetry/opentelemetry-cpp/pull/3148) + +* [EXPORTER] Allow to share gRPC clients between OTLP exporters [#3041](https://github.com/open-telemetry/opentelemetry-cpp/pull/3041) +* Bump codecov/codecov-action from 4 to 5 + [#3143](https://github.com/open-telemetry/opentelemetry-cpp/pull/3143) + +* [CI] Add cppcheck in the build + [#3151](https://github.com/open-telemetry/opentelemetry-cpp/pull/3151) + +* [BUILD] Fix error message + [#3152](https://github.com/open-telemetry/opentelemetry-cpp/pull/3152) + +* [EXPORTER] fix clang-tidy warnings in UrlParser + [#3146](https://github.com/open-telemetry/opentelemetry-cpp/pull/3146) + +* [EXPORTER] Upgrade to opentelemetry-proto 1.4.0 + [#3157](https://github.com/open-telemetry/opentelemetry-cpp/pull/3157) + +* [TEST] refactor UrlParser tests to use value-paramterized tests + [#3153](https://github.com/open-telemetry/opentelemetry-cpp/pull/3153) + +* [TEST] add a test for ElasticSearchRecordable + [#3154](https://github.com/open-telemetry/opentelemetry-cpp/pull/3154) + +* [BUILD] Fix missing dependency on protoc compiler + [#3159](https://github.com/open-telemetry/opentelemetry-cpp/pull/3159) + +* [bazel] Update prometheus-cpp in MODULE.bazel + [#3162](https://github.com/open-telemetry/opentelemetry-cpp/pull/3162) + +* [bazel] Enable --incompatible_disallow_empty_glob + [#2642](https://github.com/open-telemetry/opentelemetry-cpp/pull/2642) + +* [INSTALL] Fix cmake/opentelemetry-cpp-config.cmake.in + [#3165](https://github.com/open-telemetry/opentelemetry-cpp/pull/3165) + +* [BUILD] Do not set OTELCPP_PROTO_PATH in the CMake cache + [#3160](https://github.com/open-telemetry/opentelemetry-cpp/pull/3160) + +* [BUILD] Fix build for esp32 + [#3155](https://github.com/open-telemetry/opentelemetry-cpp/pull/3155) + +* [bazel] Update opentelemetry-proto in MODULE.bazel + [#3163](https://github.com/open-telemetry/opentelemetry-cpp/pull/3163) + Important changes: * [API] Jaeger Propagator should not be deprecated @@ -54,6 +173,10 @@ Important changes: for each `xxx` semantic attribute group. * See file DEPRECATED.md for details. +Deprecations: + +* This release contains deprecations, see file DEPRECATED.md for details. + ## [1.17 2024-10-07] * [CI] Add a clang-tidy build diff --git a/api/include/opentelemetry/version.h b/api/include/opentelemetry/version.h index d3e18ce1d8..a26b8b4e88 100644 --- a/api/include/opentelemetry/version.h +++ b/api/include/opentelemetry/version.h @@ -10,9 +10,9 @@ # define OPENTELEMETRY_ABI_VERSION_NO 1 #endif -#define OPENTELEMETRY_VERSION "1.17.0" +#define OPENTELEMETRY_VERSION "1.18.0" #define OPENTELEMETRY_VERSION_MAJOR 1 -#define OPENTELEMETRY_VERSION_MINOR 17 +#define OPENTELEMETRY_VERSION_MINOR 18 #define OPENTELEMETRY_VERSION_PATCH 0 #define OPENTELEMETRY_ABI_VERSION OPENTELEMETRY_STRINGIFY(OPENTELEMETRY_ABI_VERSION_NO) diff --git a/docs/public/conf.py b/docs/public/conf.py index 96b70cb6fa..d1b51d7a39 100644 --- a/docs/public/conf.py +++ b/docs/public/conf.py @@ -24,7 +24,7 @@ author = 'OpenTelemetry authors' # The full version, including alpha/beta/rc tags -release = "1.17.0" +release = "1.18.0" # Run sphinx on subprojects and copy output # ----------------------------------------- diff --git a/sdk/include/opentelemetry/sdk/version/version.h b/sdk/include/opentelemetry/sdk/version/version.h index b8f4c076f1..387eb64fab 100644 --- a/sdk/include/opentelemetry/sdk/version/version.h +++ b/sdk/include/opentelemetry/sdk/version/version.h @@ -3,7 +3,7 @@ #pragma once -#define OPENTELEMETRY_SDK_VERSION "1.17.0" +#define OPENTELEMETRY_SDK_VERSION "1.18.0" #include "opentelemetry/version.h" diff --git a/sdk/src/version/version.cc b/sdk/src/version/version.cc index 97e7f15549..078bafe2ea 100644 --- a/sdk/src/version/version.cc +++ b/sdk/src/version/version.cc @@ -12,13 +12,13 @@ namespace sdk namespace version { const int major_version = 1; -const int minor_version = 17; +const int minor_version = 18; const int patch_version = 0; const char *pre_release = "NONE"; const char *build_metadata = "NONE"; -const char *short_version = "1.17.0"; -const char *full_version = "1.17.0-NONE-NONE"; -const char *build_date = "Mon Oct 7 08:55:12 PM UTC 2024"; +const char *short_version = "1.18.0"; +const char *full_version = "1.18.0-NONE-NONE"; +const char *build_date = "Mon Nov 25 08:46:03 PM UTC 2024"; } // namespace version } // namespace sdk OPENTELEMETRY_END_NAMESPACE From 8d45dec7eeaedcdc823a040c56e60720abfb9119 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Tue, 26 Nov 2024 00:22:18 -0800 Subject: [PATCH 84/89] [PROMETHEUS_EXPORTER] Fix default for emitting otel_scope attributes (#3171) --- exporters/prometheus/src/exporter_options.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporters/prometheus/src/exporter_options.cc b/exporters/prometheus/src/exporter_options.cc index a9de8f4eb4..2ac24b635d 100644 --- a/exporters/prometheus/src/exporter_options.cc +++ b/exporters/prometheus/src/exporter_options.cc @@ -33,7 +33,7 @@ inline bool GetPrometheusWithoutOtelScope() auto exists = opentelemetry::sdk::common::GetBoolEnvironmentVariable(kPrometheusWithoutOtelScope, setting); - return exists ? setting : true; + return exists ? setting : false; } inline bool GetPrometheusPopulateTargetInfo() From d15da3b2568beb50f34098afbab8892232ec8bde Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Wed, 27 Nov 2024 11:57:47 +0100 Subject: [PATCH 85/89] [Code health] Include what you use cleanup, part 5 (#3140) --- .github/workflows/iwyu.yml | 15 +++- .iwyu.imp | 5 ++ api/include/opentelemetry/nostd/variant.h | 13 ++++ .../trace/propagation/detail/string_test.cc | 6 +- .../exporters/memory/in_memory_metric_data.h | 10 +-- .../in_memory_metric_exporter_factory.h | 10 +-- exporters/memory/src/in_memory_metric_data.cc | 13 ++++ .../src/in_memory_metric_exporter_factory.cc | 9 ++- .../memory/test/in_memory_metric_data_test.cc | 16 +++- .../test/in_memory_metric_exporter_test.cc | 7 +- .../memory/test/in_memory_span_data_test.cc | 8 +- .../test/in_memory_span_exporter_test.cc | 8 +- exporters/ostream/test/ostream_log_test.cc | 32 ++++++-- exporters/ostream/test/ostream_metric_test.cc | 19 +++-- exporters/ostream/test/ostream_span_test.cc | 36 ++++++--- exporters/otlp/src/otlp_file_client.cc | 73 ++++++++++--------- exporters/otlp/src/otlp_log_recordable.cc | 7 +- exporters/otlp/test/otlp_file_client_test.cc | 56 +++++++++----- .../test/otlp_file_exporter_factory_test.cc | 3 + .../otlp/test/otlp_file_exporter_test.cc | 57 +++++++++------ ...p_file_log_record_exporter_factory_test.cc | 3 + .../otlp_file_log_record_exporter_test.cc | 51 ++++++++----- .../otlp_file_metric_exporter_factory_test.cc | 3 + .../test/otlp_file_metric_exporter_test.cc | 42 ++++++----- .../test/otlp_http_exporter_factory_test.cc | 4 + ...p_http_log_record_exporter_factory_test.cc | 4 + .../otlp_http_metric_exporter_factory_test.cc | 4 + .../test/otlp_http_metric_exporter_test.cc | 51 ++++++++----- .../otlp/test/otlp_log_recordable_test.cc | 24 +++++- .../test/otlp_metrics_serialization_test.cc | 24 +++++- exporters/otlp/test/otlp_recordable_test.cc | 30 +++++++- .../zipkin/test/zipkin_recordable_test.cc | 33 ++++++--- ext/test/http/url_parser_test.cc | 2 + .../w3c_tracecontext_http_test_server/main.cc | 9 +++ sdk/src/metrics/state/metric_collector.cc | 2 +- sdk/test/logs/log_record_test.cc | 2 +- sdk/test/metrics/histogram_test.cc | 4 - sdk/test/metrics/meter_test.cc | 2 +- sdk/test/metrics/multi_metric_storage_test.cc | 1 + .../sync_metric_storage_counter_test.cc | 2 +- .../metrics/sync_metric_storage_gauge_test.cc | 22 ++++-- sdk/test/metrics/view_registry_test.cc | 4 - sdk/test/trace/sampler_benchmark.cc | 1 + 43 files changed, 502 insertions(+), 225 deletions(-) diff --git a/.github/workflows/iwyu.yml b/.github/workflows/iwyu.yml index c675193cdb..573af3a803 100644 --- a/.github/workflows/iwyu.yml +++ b/.github/workflows/iwyu.yml @@ -62,7 +62,16 @@ jobs: - name: count warnings run: | + set +e cd build - COUNT=`grep -c "Warning:" iwyu.log` - echo "include-what-you-use reported ${COUNT} warning(s)" - + readonly WARNING_COUNT=`grep -c "include-what-you-use reported diagnostics:" iwyu.log` + echo "include-what-you-use reported ${WARNING_COUNT} warning(s)" + # Acceptable limit, to decrease over time down to 0 + readonly WARNING_LIMIT=10 + # FAIL the build if WARNING_COUNT > WARNING_LIMIT + if [ $WARNING_COUNT -gt $WARNING_LIMIT ] ; then + exit 1 + # WARN in annotations if WARNING_COUNT > 0 + elif [ $WARNING_COUNT -gt 0 ] ; then + echo "::warning::include-what-you-use reported ${WARNING_COUNT} warning(s)" + fi diff --git a/.iwyu.imp b/.iwyu.imp index 6529a92458..a9d2c03058 100644 --- a/.iwyu.imp +++ b/.iwyu.imp @@ -6,6 +6,10 @@ [ # Work around for C++ STL { "include": ["", "private", "", "public"] }, + { "include": ["", "private", "", "public"] }, + { "include": ["", "private", "", "public"] }, + { "include": ["", "private", "", "public"] }, + { "include": ["", "private", "", "public"] }, # Local opentelemetry-cpp style @@ -14,6 +18,7 @@ { "include": ["", "private", "", "public"] }, { "include": ["", "private", "", "public"] }, { "include": ["", "private", "", "public"] }, + { "include": ["", "private", "", "public"] }, # We prefer to include for simplicity { "include": ["", "private", "", "public"] }, diff --git a/api/include/opentelemetry/nostd/variant.h b/api/include/opentelemetry/nostd/variant.h index 02df092d0f..b03a9b844b 100644 --- a/api/include/opentelemetry/nostd/variant.h +++ b/api/include/opentelemetry/nostd/variant.h @@ -54,6 +54,19 @@ OPENTELEMETRY_END_NAMESPACE # ifdef HAVE_ABSEIL # include "absl/types/variant.h" # else +# include "opentelemetry/nostd/internal/absl/base/options.h" + +namespace absl +{ +namespace OTABSL_OPTION_NAMESPACE_NAME +{ +template +struct variant_size; +template +class variant; +} // namespace OTABSL_OPTION_NAMESPACE_NAME +} // namespace absl + # include "opentelemetry/nostd/internal/absl/types/variant.h" # endif diff --git a/api/test/trace/propagation/detail/string_test.cc b/api/test/trace/propagation/detail/string_test.cc index 67a48a354c..184434b528 100644 --- a/api/test/trace/propagation/detail/string_test.cc +++ b/api/test/trace/propagation/detail/string_test.cc @@ -2,10 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 #include -#include -#include +#include +#include +#include #include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/trace/propagation/detail/string.h" using namespace opentelemetry; diff --git a/exporters/memory/include/opentelemetry/exporters/memory/in_memory_metric_data.h b/exporters/memory/include/opentelemetry/exporters/memory/in_memory_metric_data.h index 8d24c586b2..077f5ec699 100644 --- a/exporters/memory/include/opentelemetry/exporters/memory/in_memory_metric_data.h +++ b/exporters/memory/include/opentelemetry/exporters/memory/in_memory_metric_data.h @@ -3,6 +3,7 @@ #pragma once +#include #include #include #include @@ -10,15 +11,10 @@ #include "opentelemetry/exporters/memory/in_memory_data.h" #include "opentelemetry/sdk/metrics/data/metric_data.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE -namespace sdk -{ -namespace metrics -{ -struct ResourceMetrics; -} -} // namespace sdk namespace exporter { namespace memory diff --git a/exporters/memory/include/opentelemetry/exporters/memory/in_memory_metric_exporter_factory.h b/exporters/memory/include/opentelemetry/exporters/memory/in_memory_metric_exporter_factory.h index f6934df727..ae1c2b8579 100644 --- a/exporters/memory/include/opentelemetry/exporters/memory/in_memory_metric_exporter_factory.h +++ b/exporters/memory/include/opentelemetry/exporters/memory/in_memory_metric_exporter_factory.h @@ -5,22 +5,16 @@ #include +#include "opentelemetry/exporters/memory/in_memory_metric_data.h" #include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE -namespace sdk -{ -namespace metrics -{ -class PushMetricExporter; -} // namespace metrics -} // namespace sdk namespace exporter { namespace memory { -class InMemoryMetricData; /// A factory for InMemoryMetricExporter class InMemoryMetricExporterFactory diff --git a/exporters/memory/src/in_memory_metric_data.cc b/exporters/memory/src/in_memory_metric_data.cc index 90f1c1450f..be950b238f 100644 --- a/exporters/memory/src/in_memory_metric_data.cc +++ b/exporters/memory/src/in_memory_metric_data.cc @@ -1,9 +1,22 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/exporters/memory/in_memory_data.h" #include "opentelemetry/exporters/memory/in_memory_metric_data.h" +#include "opentelemetry/nostd/variant.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" #include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/exporters/memory/src/in_memory_metric_exporter_factory.cc b/exporters/memory/src/in_memory_metric_exporter_factory.cc index 0deff73dcd..227d846fbb 100644 --- a/exporters/memory/src/in_memory_metric_exporter_factory.cc +++ b/exporters/memory/src/in_memory_metric_exporter_factory.cc @@ -1,11 +1,18 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/exporters/memory/in_memory_metric_exporter_factory.h" +#include +#include +#include + #include "opentelemetry/exporters/memory/in_memory_metric_data.h" +#include "opentelemetry/exporters/memory/in_memory_metric_exporter_factory.h" +#include "opentelemetry/sdk/common/exporter_utils.h" #include "opentelemetry/sdk/common/global_log_handler.h" #include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/exporters/memory/test/in_memory_metric_data_test.cc b/exporters/memory/test/in_memory_metric_data_test.cc index 3f2d661759..45d42ea064 100644 --- a/exporters/memory/test/in_memory_metric_data_test.cc +++ b/exporters/memory/test/in_memory_metric_data_test.cc @@ -1,15 +1,23 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include + #include "opentelemetry/exporters/memory/in_memory_metric_data.h" +#include "opentelemetry/nostd/variant.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" #include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/resource/resource.h" -#include - -#include - using opentelemetry::exporter::memory::CircularBufferInMemoryMetricData; using opentelemetry::exporter::memory::SimpleAggregateInMemoryMetricData; using opentelemetry::sdk::metrics::MetricData; diff --git a/exporters/memory/test/in_memory_metric_exporter_test.cc b/exporters/memory/test/in_memory_metric_exporter_test.cc index adaa322f71..64e939f774 100644 --- a/exporters/memory/test/in_memory_metric_exporter_test.cc +++ b/exporters/memory/test/in_memory_metric_exporter_test.cc @@ -1,15 +1,18 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include + #include "opentelemetry/exporters/memory/in_memory_metric_data.h" #include "opentelemetry/exporters/memory/in_memory_metric_exporter_factory.h" +#include "opentelemetry/sdk/common/exporter_utils.h" #include "opentelemetry/sdk/metrics/export/metric_producer.h" #include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" #include "opentelemetry/sdk/resource/resource.h" -#include - using opentelemetry::exporter::memory::CircularBufferInMemoryMetricData; using opentelemetry::exporter::memory::InMemoryMetricExporterFactory; using opentelemetry::sdk::common::ExportResult; diff --git a/exporters/memory/test/in_memory_span_data_test.cc b/exporters/memory/test/in_memory_span_data_test.cc index be013734ef..83a907f324 100644 --- a/exporters/memory/test/in_memory_span_data_test.cc +++ b/exporters/memory/test/in_memory_span_data_test.cc @@ -1,12 +1,14 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include + #include "opentelemetry/exporters/memory/in_memory_span_data.h" -#include "opentelemetry/nostd/span.h" #include "opentelemetry/sdk/trace/span_data.h" -#include - using opentelemetry::exporter::memory::InMemorySpanData; using opentelemetry::sdk::trace::SpanData; diff --git a/exporters/memory/test/in_memory_span_exporter_test.cc b/exporters/memory/test/in_memory_span_exporter_test.cc index 56a0ef7790..175942a409 100644 --- a/exporters/memory/test/in_memory_span_exporter_test.cc +++ b/exporters/memory/test/in_memory_span_exporter_test.cc @@ -1,12 +1,16 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include + #include "opentelemetry/exporters/memory/in_memory_span_exporter.h" #include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/trace/recordable.h" #include "opentelemetry/sdk/trace/span_data.h" -#include - using opentelemetry::exporter::memory::InMemorySpanExporter; using opentelemetry::sdk::trace::Recordable; using opentelemetry::sdk::trace::SpanData; diff --git a/exporters/ostream/test/ostream_log_test.cc b/exporters/ostream/test/ostream_log_test.cc index b7708f3153..552b7d1983 100644 --- a/exporters/ostream/test/ostream_log_test.cc +++ b/exporters/ostream/test/ostream_log_test.cc @@ -1,20 +1,42 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/common/timestamp.h" #include "opentelemetry/exporters/ostream/log_record_exporter.h" #include "opentelemetry/exporters/ostream/log_record_exporter_factory.h" +#include "opentelemetry/logs/event_id.h" +#include "opentelemetry/logs/log_record.h" +#include "opentelemetry/logs/logger.h" +#include "opentelemetry/logs/logger_provider.h" #include "opentelemetry/logs/provider.h" +#include "opentelemetry/logs/severity.h" +#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/utility.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" +#include "opentelemetry/sdk/logs/exporter.h" #include "opentelemetry/sdk/logs/logger_provider.h" +#include "opentelemetry/sdk/logs/processor.h" #include "opentelemetry/sdk/logs/read_write_log_record.h" +#include "opentelemetry/sdk/logs/readable_log_record.h" +#include "opentelemetry/sdk/logs/recordable.h" #include "opentelemetry/sdk/logs/simple_log_record_processor.h" +#include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/sdk/version/version.h" - -#include -#include - -#include +#include "opentelemetry/version.h" namespace sdklogs = opentelemetry::sdk::logs; namespace logs_api = opentelemetry::logs; diff --git a/exporters/ostream/test/ostream_metric_test.cc b/exporters/ostream/test/ostream_metric_test.cc index bd221fa1b7..ebd4f451f0 100644 --- a/exporters/ostream/test/ostream_metric_test.cc +++ b/exporters/ostream/test/ostream_metric_test.cc @@ -2,21 +2,26 @@ // SPDX-License-Identifier: Apache-2.0 #include +#include +#include +#include +#include +#include +#include +#include "opentelemetry/common/timestamp.h" #include "opentelemetry/exporters/ostream/metric_exporter.h" +#include "opentelemetry/nostd/utility.h" +#include "opentelemetry/sdk/common/exporter_utils.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" -#include "opentelemetry/sdk/metrics/aggregation/default_aggregation.h" -#include "opentelemetry/sdk/metrics/aggregation/histogram_aggregation.h" #include "opentelemetry/sdk/metrics/data/metric_data.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" #include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" #include "opentelemetry/sdk/resource/resource.h" -#include "opentelemetry/sdk/resource/resource_detector.h" #include "opentelemetry/sdk/version/version.h" -#include -#include -#include - namespace metric_sdk = opentelemetry::sdk::metrics; namespace nostd = opentelemetry::nostd; namespace exportermetrics = opentelemetry::exporter::metrics; diff --git a/exporters/ostream/test/ostream_span_test.cc b/exporters/ostream/test/ostream_span_test.cc index cadc1b9d38..5cf4bcb510 100644 --- a/exporters/ostream/test/ostream_span_test.cc +++ b/exporters/ostream/test/ostream_span_test.cc @@ -1,22 +1,36 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/exporters/ostream/span_exporter.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/utility.h" +#include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/sdk/trace/processor.h" #include "opentelemetry/sdk/trace/recordable.h" #include "opentelemetry/sdk/trace/simple_processor.h" -#include "opentelemetry/sdk/trace/span_data.h" -#include "opentelemetry/sdk/trace/tracer_provider.h" -#include "opentelemetry/trace/provider.h" - -#include "opentelemetry/sdk/trace/exporter.h" - -#include "opentelemetry/exporters/ostream/span_exporter.h" - +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_flags.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/trace/trace_state.h" #include "ostream_capture.h" -#include -#include - using namespace opentelemetry::exporter::ostream::test; namespace trace = opentelemetry::trace; diff --git a/exporters/otlp/src/otlp_file_client.cc b/exporters/otlp/src/otlp_file_client.cc index bdd6eac27d..ddf2ff1f11 100644 --- a/exporters/otlp/src/otlp_file_client.cc +++ b/exporters/otlp/src/otlp_file_client.cc @@ -1,40 +1,10 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/exporters/otlp/otlp_file_client.h" - -#if defined(HAVE_GSL) -# include -#else -# include -#endif - -// clang-format off -#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep -// clang-format on - -#include "google/protobuf/message.h" -#include "nlohmann/json.hpp" - -// clang-format off -#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep -// clang-format on - -#include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/nostd/variant.h" -#include "opentelemetry/sdk/common/base64.h" -#include "opentelemetry/sdk/common/global_log_handler.h" -#include "opentelemetry/version.h" - -#ifdef _MSC_VER -# include -# define strcasecmp _stricmp -#else -# include -#endif - #include +#include #include +#include #include #include #include @@ -43,12 +13,24 @@ #include #include #include +#include +#include #include #include #include #include -#if OPENTELEMETRY_HAVE_EXCEPTIONS -# include + +#if defined(HAVE_GSL) +# include +#else +# include +#endif + +#ifdef _MSC_VER +# include +# define strcasecmp _stricmp +#else +# include #endif #if !defined(__CYGWIN__) && defined(_WIN32) @@ -120,6 +102,29 @@ # define OTLP_FILE_OPEN(f, path, mode) f = fopen(path, mode) #endif +#include "opentelemetry/exporters/otlp/otlp_file_client.h" +#include "opentelemetry/exporters/otlp/otlp_file_client_options.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/base64.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/common/global_log_handler.h" +#include "opentelemetry/version.h" + +// clang-format off +#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep +#include "google/protobuf/descriptor.h" +#include "google/protobuf/message.h" +#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep +// clang-format on + +// Must be included after opentelemetry/version.h, +// which exports opentelemetry/common/macros.h +#if OPENTELEMETRY_HAVE_EXCEPTIONS +# include +#endif + OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter { diff --git a/exporters/otlp/src/otlp_log_recordable.cc b/exporters/otlp/src/otlp_log_recordable.cc index 03c89626f2..e45e2b9c11 100644 --- a/exporters/otlp/src/otlp_log_recordable.cc +++ b/exporters/otlp/src/otlp_log_recordable.cc @@ -10,7 +10,6 @@ #include "opentelemetry/logs/severity.h" #include "opentelemetry/nostd/span.h" #include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/proto/logs/v1/logs.pb.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/logs/readable_log_record.h" #include "opentelemetry/sdk/resource/resource.h" @@ -19,6 +18,12 @@ #include "opentelemetry/trace/trace_id.h" #include "opentelemetry/version.h" +// clang-format off +#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep +#include "opentelemetry/proto/logs/v1/logs.pb.h" +#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep +// clang-format on + OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter { diff --git a/exporters/otlp/test/otlp_file_client_test.cc b/exporters/otlp/test/otlp_file_client_test.cc index f38a682de0..cd4ffb5bc9 100644 --- a/exporters/otlp/test/otlp_file_client_test.cc +++ b/exporters/otlp/test/otlp_file_client_test.cc @@ -1,34 +1,50 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/common/key_value_iterable_view.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "opentelemetry/common/timestamp.h" #include "opentelemetry/exporters/otlp/otlp_file_client.h" -#include "opentelemetry/exporters/otlp/otlp_file_exporter_options.h" +#include "opentelemetry/exporters/otlp/otlp_file_client_options.h" #include "opentelemetry/exporters/otlp/otlp_recordable.h" #include "opentelemetry/exporters/otlp/otlp_recordable_utils.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/span.h" #include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/resource/resource.h" - -#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" - +#include "opentelemetry/sdk/trace/recordable.h" +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_flags.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/trace/trace_state.h" +#include "opentelemetry/version.h" + +// clang-format off +#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep +#include #include "opentelemetry/proto/collector/trace/v1/trace_service.pb.h" - -#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" - -#include "gmock/gmock.h" -#include "gtest/gtest.h" - -#include "nlohmann/json.hpp" - -#include -#include -#include -#include -#include -#include -#include +#include "opentelemetry/proto/trace/v1/trace.pb.h" +#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep +// clang-format on using namespace testing; diff --git a/exporters/otlp/test/otlp_file_exporter_factory_test.cc b/exporters/otlp/test/otlp_file_exporter_factory_test.cc index 2d671c6e8f..fbb42c8e0c 100644 --- a/exporters/otlp/test/otlp_file_exporter_factory_test.cc +++ b/exporters/otlp/test/otlp_file_exporter_factory_test.cc @@ -2,9 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 #include +#include #include "opentelemetry/exporters/otlp/otlp_file_exporter_factory.h" #include "opentelemetry/exporters/otlp/otlp_file_exporter_options.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/version.h" /* Make sure OtlpFileExporterFactory does not require, diff --git a/exporters/otlp/test/otlp_file_exporter_test.cc b/exporters/otlp/test/otlp_file_exporter_test.cc index 81e1baab44..575339c621 100644 --- a/exporters/otlp/test/otlp_file_exporter_test.cc +++ b/exporters/otlp/test/otlp_file_exporter_test.cc @@ -1,32 +1,47 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/exporters/otlp/otlp_file_exporter_factory.h" -#include "opentelemetry/exporters/otlp/otlp_file_exporter_options.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "opentelemetry/exporters/otlp/otlp_file_client_options.h" #include "opentelemetry/exporters/otlp/otlp_file_exporter.h" - -#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" - -#include "google/protobuf/message_lite.h" -#include "opentelemetry/proto/collector/trace/v1/trace_service.pb.h" - -#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" - +#include "opentelemetry/exporters/otlp/otlp_file_exporter_factory.h" +#include "opentelemetry/exporters/otlp/otlp_file_exporter_options.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/sdk/trace/batch_span_processor.h" #include "opentelemetry/sdk/trace/batch_span_processor_options.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/recordable.h" #include "opentelemetry/sdk/trace/tracer_provider.h" - -#include "opentelemetry/trace/provider.h" - -#include "gmock/gmock.h" -#include "gtest/gtest.h" - -#include "nlohmann/json.hpp" - -#include -#include -#include +#include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/span_startoptions.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/trace/tracer.h" +#include "opentelemetry/version.h" + +// clang-format off +#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep +#include "google/protobuf/message_lite.h" +#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep +// clang-format on using namespace testing; diff --git a/exporters/otlp/test/otlp_file_log_record_exporter_factory_test.cc b/exporters/otlp/test/otlp_file_log_record_exporter_factory_test.cc index ec4ced5f33..48b8570fc6 100644 --- a/exporters/otlp/test/otlp_file_log_record_exporter_factory_test.cc +++ b/exporters/otlp/test/otlp_file_log_record_exporter_factory_test.cc @@ -2,9 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 #include +#include #include "opentelemetry/exporters/otlp/otlp_file_log_record_exporter_factory.h" #include "opentelemetry/exporters/otlp/otlp_file_log_record_exporter_options.h" +#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/version.h" /* Make sure OtlpFileExporterFactory does not require, diff --git a/exporters/otlp/test/otlp_file_log_record_exporter_test.cc b/exporters/otlp/test/otlp_file_log_record_exporter_test.cc index 5bc1e4a473..4bfd649069 100644 --- a/exporters/otlp/test/otlp_file_log_record_exporter_test.cc +++ b/exporters/otlp/test/otlp_file_log_record_exporter_test.cc @@ -1,33 +1,44 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include #include -#include +#include +#include +#include +#include +#include +#include +#include +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/exporters/otlp/otlp_file_client_options.h" #include "opentelemetry/exporters/otlp/otlp_file_log_record_exporter.h" #include "opentelemetry/exporters/otlp/otlp_file_log_record_exporter_factory.h" - -#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" - -#include "opentelemetry/proto/collector/logs/v1/logs_service.pb.h" - -#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" - -#include "opentelemetry/common/key_value_iterable_view.h" - -#include "opentelemetry/logs/provider.h" +#include "opentelemetry/exporters/otlp/otlp_file_log_record_exporter_options.h" +#include "opentelemetry/logs/logger.h" +#include "opentelemetry/logs/severity.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/common/exporter_utils.h" #include "opentelemetry/sdk/logs/batch_log_record_processor.h" #include "opentelemetry/sdk/logs/exporter.h" #include "opentelemetry/sdk/logs/logger_provider.h" -#include "opentelemetry/sdk/resource/resource.h" - -#include "gmock/gmock.h" -#include "gtest/gtest.h" - -#include "nlohmann/json.hpp" - -#include -#include +#include "opentelemetry/sdk/logs/processor.h" +#include "opentelemetry/sdk/logs/recordable.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/trace_flags.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/version.h" + +// clang-format off +#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep +#include +#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep +// clang-format on using namespace testing; diff --git a/exporters/otlp/test/otlp_file_metric_exporter_factory_test.cc b/exporters/otlp/test/otlp_file_metric_exporter_factory_test.cc index d14dc3056a..415f425633 100644 --- a/exporters/otlp/test/otlp_file_metric_exporter_factory_test.cc +++ b/exporters/otlp/test/otlp_file_metric_exporter_factory_test.cc @@ -2,9 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 #include +#include #include "opentelemetry/exporters/otlp/otlp_file_metric_exporter_factory.h" #include "opentelemetry/exporters/otlp/otlp_file_metric_exporter_options.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/version.h" /* Make sure OtlpFileExporterFactory does not require, diff --git a/exporters/otlp/test/otlp_file_metric_exporter_test.cc b/exporters/otlp/test/otlp_file_metric_exporter_test.cc index 50f60e15b7..f79e2280b6 100644 --- a/exporters/otlp/test/otlp_file_metric_exporter_test.cc +++ b/exporters/otlp/test/otlp_file_metric_exporter_test.cc @@ -1,37 +1,39 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include +#include +#include #include -#include +#include +#include +#include +#include +#include +#include +#include +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/exporters/otlp/otlp_file_client_options.h" #include "opentelemetry/exporters/otlp/otlp_file_metric_exporter.h" #include "opentelemetry/exporters/otlp/otlp_file_metric_exporter_factory.h" - -#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" - -#include "google/protobuf/message_lite.h" -#include "opentelemetry/proto/collector/metrics/v1/metrics_service.pb.h" - +#include "opentelemetry/exporters/otlp/otlp_file_metric_exporter_options.h" #include "opentelemetry/exporters/otlp/otlp_metric_utils.h" -#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" - -#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/exporters/otlp/otlp_preferred_temporality.h" +#include "opentelemetry/sdk/common/exporter_utils.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" -#include "opentelemetry/sdk/metrics/aggregation/default_aggregation.h" -#include "opentelemetry/sdk/metrics/aggregation/histogram_aggregation.h" #include "opentelemetry/sdk/metrics/data/metric_data.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" #include "opentelemetry/sdk/metrics/export/metric_producer.h" #include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" #include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/version.h" -#include "gmock/gmock.h" -#include "gtest/gtest.h" - -#include "nlohmann/json.hpp" - -#include -#include +// clang-format off +#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep +#include "google/protobuf/message_lite.h" +#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep +// clang-format on using namespace testing; diff --git a/exporters/otlp/test/otlp_http_exporter_factory_test.cc b/exporters/otlp/test/otlp_http_exporter_factory_test.cc index fd578a65c1..77bf230f70 100644 --- a/exporters/otlp/test/otlp_http_exporter_factory_test.cc +++ b/exporters/otlp/test/otlp_http_exporter_factory_test.cc @@ -2,9 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 #include +#include +#include #include "opentelemetry/exporters/otlp/otlp_http_exporter_factory.h" #include "opentelemetry/exporters/otlp/otlp_http_exporter_options.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/version.h" /* Make sure OtlpHttpExporterFactory does not require, diff --git a/exporters/otlp/test/otlp_http_log_record_exporter_factory_test.cc b/exporters/otlp/test/otlp_http_log_record_exporter_factory_test.cc index 1f3275e1c3..93f2fede12 100644 --- a/exporters/otlp/test/otlp_http_log_record_exporter_factory_test.cc +++ b/exporters/otlp/test/otlp_http_log_record_exporter_factory_test.cc @@ -2,9 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 #include +#include +#include #include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter_factory.h" #include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h" +#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/version.h" /* Make sure OtlpHttpExporterFactory does not require, diff --git a/exporters/otlp/test/otlp_http_metric_exporter_factory_test.cc b/exporters/otlp/test/otlp_http_metric_exporter_factory_test.cc index 3158300548..2f042b8f66 100644 --- a/exporters/otlp/test/otlp_http_metric_exporter_factory_test.cc +++ b/exporters/otlp/test/otlp_http_metric_exporter_factory_test.cc @@ -2,9 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 #include +#include +#include #include "opentelemetry/exporters/otlp/otlp_http_metric_exporter_factory.h" #include "opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/version.h" /* Make sure OtlpHttpExporterFactory does not require, diff --git a/exporters/otlp/test/otlp_http_metric_exporter_test.cc b/exporters/otlp/test/otlp_http_metric_exporter_test.cc index 174597248b..0b44d98379 100644 --- a/exporters/otlp/test/otlp_http_metric_exporter_test.cc +++ b/exporters/otlp/test/otlp_http_metric_exporter_test.cc @@ -1,37 +1,52 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include #include +#include #include -#include - +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/exporters/otlp/otlp_environment.h" +#include "opentelemetry/exporters/otlp/otlp_http.h" +#include "opentelemetry/exporters/otlp/otlp_http_client.h" #include "opentelemetry/exporters/otlp/otlp_http_metric_exporter.h" - -#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" - -#include "opentelemetry/proto/collector/metrics/v1/metrics_service.pb.h" - +#include "opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h" #include "opentelemetry/exporters/otlp/otlp_metric_utils.h" -#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" - -#include "opentelemetry/common/key_value_iterable_view.h" -#include "opentelemetry/ext/http/client/http_client_factory.h" -#include "opentelemetry/ext/http/server/http_server.h" +#include "opentelemetry/exporters/otlp/otlp_preferred_temporality.h" +#include "opentelemetry/ext/http/client/http_client.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/common/exporter_utils.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" -#include "opentelemetry/sdk/metrics/aggregation/default_aggregation.h" -#include "opentelemetry/sdk/metrics/aggregation/histogram_aggregation.h" #include "opentelemetry/sdk/metrics/data/metric_data.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" #include "opentelemetry/sdk/metrics/export/metric_producer.h" #include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/test_common/ext/http/client/http_client_test_factory.h" #include "opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h" +#include "opentelemetry/version.h" +// clang-format off +#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep #include -#include -#include "gmock/gmock.h" - -#include "nlohmann/json.hpp" +#include "opentelemetry/proto/collector/metrics/v1/metrics_service.pb.h" +#include "opentelemetry/proto/common/v1/common.pb.h" +#include "opentelemetry/proto/metrics/v1/metrics.pb.h" +#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep +// clang-format on #if defined(_MSC_VER) # include "opentelemetry/sdk/common/env_variables.h" diff --git a/exporters/otlp/test/otlp_log_recordable_test.cc b/exporters/otlp/test/otlp_log_recordable_test.cc index e5d6701e46..3e13a66bd9 100644 --- a/exporters/otlp/test/otlp_log_recordable_test.cc +++ b/exporters/otlp/test/otlp_log_recordable_test.cc @@ -2,12 +2,32 @@ // SPDX-License-Identifier: Apache-2.0 #include - +#include #include +#include +#include +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/timestamp.h" #include "opentelemetry/exporters/otlp/otlp_log_recordable.h" -#include "opentelemetry/sdk/logs/read_write_log_record.h" +#include "opentelemetry/logs/severity.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" +#include "opentelemetry/sdk/logs/readable_log_record.h" +#include "opentelemetry/sdk/logs/recordable.h" #include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/version.h" + +// clang-format off +#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep +#include "opentelemetry/proto/common/v1/common.pb.h" +#include "opentelemetry/proto/logs/v1/logs.pb.h" +#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep +// clang-format on OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/exporters/otlp/test/otlp_metrics_serialization_test.cc b/exporters/otlp/test/otlp_metrics_serialization_test.cc index 2ad76dfd1d..9f266e5e5f 100644 --- a/exporters/otlp/test/otlp_metrics_serialization_test.cc +++ b/exporters/otlp/test/otlp_metrics_serialization_test.cc @@ -1,10 +1,30 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/timestamp.h" #include "opentelemetry/exporters/otlp/otlp_metric_utils.h" +#include "opentelemetry/exporters/otlp/otlp_preferred_temporality.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/version.h" + +// clang-format off +#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep +#include "opentelemetry/proto/common/v1/common.pb.h" #include "opentelemetry/proto/metrics/v1/metrics.pb.h" - -#include +#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep +// clang-format on OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/exporters/otlp/test/otlp_recordable_test.cc b/exporters/otlp/test/otlp_recordable_test.cc index 537f10340d..9e148e60ee 100644 --- a/exporters/otlp/test/otlp_recordable_test.cc +++ b/exporters/otlp/test/otlp_recordable_test.cc @@ -1,9 +1,34 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/common/timestamp.h" #include "opentelemetry/exporters/otlp/otlp_recordable.h" #include "opentelemetry/exporters/otlp/otlp_recordable_utils.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/sdk/trace/recordable.h" +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_flags.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/trace/trace_state.h" +#include "opentelemetry/version.h" #if defined(__GNUC__) // GCC raises -Wsuggest-override warnings on GTest, @@ -11,11 +36,12 @@ # pragma GCC diagnostic ignored "-Wsuggest-override" #endif -#include - // clang-format off #include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep #include "opentelemetry/proto/collector/trace/v1/trace_service.pb.h" +#include "opentelemetry/proto/common/v1/common.pb.h" +#include "opentelemetry/proto/resource/v1/resource.pb.h" +#include "opentelemetry/proto/trace/v1/trace.pb.h" #include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep // clang-format on diff --git a/exporters/zipkin/test/zipkin_recordable_test.cc b/exporters/zipkin/test/zipkin_recordable_test.cc index 630ca332f0..2d875ff702 100644 --- a/exporters/zipkin/test/zipkin_recordable_test.cc +++ b/exporters/zipkin/test/zipkin_recordable_test.cc @@ -1,16 +1,31 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/trace/recordable.h" -#include "opentelemetry/sdk/trace/simple_processor.h" -#include "opentelemetry/sdk/trace/span_data.h" -#include "opentelemetry/sdk/trace/tracer_provider.h" -#include "opentelemetry/trace/provider.h" - -#include "opentelemetry/sdk/trace/exporter.h" - +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/key_value_iterable_view.h" #include "opentelemetry/common/timestamp.h" #include "opentelemetry/exporters/zipkin/recordable.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/utility.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" +#include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/sdk/trace/recordable.h" +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_flags.h" +#include "opentelemetry/trace/trace_id.h" #if defined(__GNUC__) // GCC raises -Wsuggest-override warnings on GTest, @@ -18,8 +33,6 @@ # pragma GCC diagnostic ignored "-Wsuggest-override" #endif -#include - namespace trace = opentelemetry::trace; namespace nostd = opentelemetry::nostd; namespace sdktrace = opentelemetry::sdk::trace; diff --git a/ext/test/http/url_parser_test.cc b/ext/test/http/url_parser_test.cc index 680e73670f..89e4a3efe3 100644 --- a/ext/test/http/url_parser_test.cc +++ b/ext/test/http/url_parser_test.cc @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 #include +#include +#include #include #include diff --git a/ext/test/w3c_tracecontext_http_test_server/main.cc b/ext/test/w3c_tracecontext_http_test_server/main.cc index 5af8c141de..68128da137 100644 --- a/ext/test/w3c_tracecontext_http_test_server/main.cc +++ b/ext/test/w3c_tracecontext_http_test_server/main.cc @@ -1,25 +1,34 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include #include #include +#include +#include +#include +#include #include #include #include #include +#include #include #include +#include "opentelemetry/context/context_value.h" #include "opentelemetry/context/propagation/text_map_propagator.h" #include "opentelemetry/context/runtime_context.h" #include "opentelemetry/exporters/ostream/span_exporter.h" #include "opentelemetry/ext/http/client/curl/http_client_curl.h" +#include "opentelemetry/ext/http/client/curl/http_operation_curl.h" #include "opentelemetry/ext/http/client/http_client.h" #include "opentelemetry/ext/http/server/http_server.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/trace/exporter.h" #include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/recordable.h" #include "opentelemetry/sdk/trace/simple_processor.h" #include "opentelemetry/sdk/trace/tracer_context.h" #include "opentelemetry/sdk/trace/tracer_provider.h" diff --git a/sdk/src/metrics/state/metric_collector.cc b/sdk/src/metrics/state/metric_collector.cc index 35d5e53939..e0c61e66e6 100644 --- a/sdk/src/metrics/state/metric_collector.cc +++ b/sdk/src/metrics/state/metric_collector.cc @@ -8,7 +8,6 @@ #include #include -#include "opentelemetry/nostd/function_ref.h" #include "opentelemetry/sdk/common/global_log_handler.h" #include "opentelemetry/sdk/metrics/data/metric_data.h" #include "opentelemetry/sdk/metrics/export/metric_producer.h" @@ -17,6 +16,7 @@ #include "opentelemetry/sdk/metrics/meter_context.h" #include "opentelemetry/sdk/metrics/metric_reader.h" #include "opentelemetry/sdk/metrics/state/metric_collector.h" +#include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/sdk/test/logs/log_record_test.cc b/sdk/test/logs/log_record_test.cc index 99ba9f296d..74af102e10 100644 --- a/sdk/test/logs/log_record_test.cc +++ b/sdk/test/logs/log_record_test.cc @@ -3,8 +3,8 @@ #include #include -#include #include +#include #include #include diff --git a/sdk/test/metrics/histogram_test.cc b/sdk/test/metrics/histogram_test.cc index 8e0f3c1c1c..0b13664a32 100644 --- a/sdk/test/metrics/histogram_test.cc +++ b/sdk/test/metrics/histogram_test.cc @@ -27,10 +27,6 @@ #include "opentelemetry/sdk/metrics/view/meter_selector.h" #include "opentelemetry/sdk/metrics/view/view.h" -#if OPENTELEMETRY_HAVE_WORKING_REGEX -# include -#endif - using namespace opentelemetry; using namespace opentelemetry::sdk::instrumentationscope; using namespace opentelemetry::sdk::metrics; diff --git a/sdk/test/metrics/meter_test.cc b/sdk/test/metrics/meter_test.cc index 196be7b105..e8dc605e65 100644 --- a/sdk/test/metrics/meter_test.cc +++ b/sdk/test/metrics/meter_test.cc @@ -17,7 +17,7 @@ #include "opentelemetry/metrics/meter.h" #include "opentelemetry/metrics/meter_provider.h" #include "opentelemetry/metrics/observer_result.h" -#include "opentelemetry/metrics/sync_instruments.h" +#include "opentelemetry/metrics/sync_instruments.h" // IWYU pragma: keep #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/variant.h" #include "opentelemetry/sdk/common/exporter_utils.h" diff --git a/sdk/test/metrics/multi_metric_storage_test.cc b/sdk/test/metrics/multi_metric_storage_test.cc index e2449db9d5..3eaf91ee33 100644 --- a/sdk/test/metrics/multi_metric_storage_test.cc +++ b/sdk/test/metrics/multi_metric_storage_test.cc @@ -8,6 +8,7 @@ #include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/context/context.h" #include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/utility.h" #include "opentelemetry/sdk/metrics/data/point_data.h" #include "opentelemetry/sdk/metrics/state/metric_storage.h" #include "opentelemetry/sdk/metrics/state/multi_metric_storage.h" diff --git a/sdk/test/metrics/sync_metric_storage_counter_test.cc b/sdk/test/metrics/sync_metric_storage_counter_test.cc index c67b9d499a..ee6c2ed57b 100644 --- a/sdk/test/metrics/sync_metric_storage_counter_test.cc +++ b/sdk/test/metrics/sync_metric_storage_counter_test.cc @@ -25,7 +25,7 @@ #include "opentelemetry/sdk/metrics/state/sync_metric_storage.h" #include "opentelemetry/sdk/metrics/view/attributes_processor.h" -#if ENABLE_METRICS_EXEMPLAR_PREVIEW +#ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW # include "opentelemetry/sdk/metrics/exemplar/filter_type.h" # include "opentelemetry/sdk/metrics/exemplar/reservoir.h" #endif diff --git a/sdk/test/metrics/sync_metric_storage_gauge_test.cc b/sdk/test/metrics/sync_metric_storage_gauge_test.cc index f826755af3..db20637e82 100644 --- a/sdk/test/metrics/sync_metric_storage_gauge_test.cc +++ b/sdk/test/metrics/sync_metric_storage_gauge_test.cc @@ -1,17 +1,23 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "common.h" +#include -#include "opentelemetry/common/key_value_iterable_view.h" -#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/nostd/utility.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" #include "opentelemetry/sdk/metrics/instruments.h" -#include "opentelemetry/sdk/metrics/state/sync_metric_storage.h" -#include "opentelemetry/sdk/metrics/view/attributes_processor.h" -#include -#include -#include +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 +# include +# include +# include "common.h" + +# include "opentelemetry/common/key_value_iterable_view.h" +# include "opentelemetry/nostd/shared_ptr.h" +# include "opentelemetry/sdk/metrics/state/sync_metric_storage.h" +# include "opentelemetry/sdk/metrics/view/attributes_processor.h" +#endif using namespace opentelemetry::sdk::metrics; using namespace opentelemetry::common; diff --git a/sdk/test/metrics/view_registry_test.cc b/sdk/test/metrics/view_registry_test.cc index 0135227e16..fd86168d77 100644 --- a/sdk/test/metrics/view_registry_test.cc +++ b/sdk/test/metrics/view_registry_test.cc @@ -15,10 +15,6 @@ #include "opentelemetry/sdk/metrics/view/view.h" #include "opentelemetry/sdk/metrics/view/view_registry.h" -#if OPENTELEMETRY_HAVE_WORKING_REGEX -# include -#endif - using namespace opentelemetry::sdk::metrics; using namespace opentelemetry::sdk::instrumentationscope; diff --git a/sdk/test/trace/sampler_benchmark.cc b/sdk/test/trace/sampler_benchmark.cc index 529143b53e..ef9f37af95 100644 --- a/sdk/test/trace/sampler_benchmark.cc +++ b/sdk/test/trace/sampler_benchmark.cc @@ -10,6 +10,7 @@ #include #include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/context/context_value.h" // IWYU pragma: keep #include "opentelemetry/exporters/memory/in_memory_span_exporter.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/sdk/trace/exporter.h" From fb6fde824428fa53f9afbc0796edd60ed90c6e85 Mon Sep 17 00:00:00 2001 From: WenTao Ou Date: Mon, 2 Dec 2024 16:05:03 +0800 Subject: [PATCH 86/89] [BUILD] Upgrade cmake (#3167) --- CMakeLists.txt | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 177296d81c..6abf96cd99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,23 +1,30 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 -cmake_minimum_required(VERSION 3.9) +cmake_minimum_required(VERSION 3.10) -# See https://cmake.org/cmake/help/v3.3/policy/CMP0057.html required by certain -# versions of gtest -cmake_policy(SET CMP0057 NEW) - -# See https://cmake.org/cmake/help/v3.12/policy/CMP0074.html required by certain -# version of zlib which CURL depends on. +# See https://cmake.org/cmake/help/latest/policy/CMP0074.html required by +# certain version of zlib which CURL depends on. if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12") cmake_policy(SET CMP0074 NEW) endif() +# Allow to use normal variable for option() +if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13") + cmake_policy(SET CMP0077 NEW) +endif() + # Prefer CMAKE_MSVC_RUNTIME_LIBRARY if possible if(POLICY CMP0091) cmake_policy(SET CMP0091 NEW) endif() +# MSVC RTTI flag /GR should not be not added to CMAKE_CXX_FLAGS by default. @see +# https://cmake.org/cmake/help/latest/policy/CMP0117.html +if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.20.0") + cmake_policy(SET CMP0117 NEW) +endif() + project(opentelemetry-cpp) # Mark variables as used so cmake doesn't complain about them From f167c36eec5efb103f4277675acd0ffe2e92d2bc Mon Sep 17 00:00:00 2001 From: "Alex E." <36134278+chusitoo@users.noreply.github.com> Date: Mon, 2 Dec 2024 17:00:03 -0500 Subject: [PATCH 87/89] [SHIM] Add size to all string view mappings between OT and OTel (#3181) --- .../opentelemetry/opentracingshim/propagation.h | 16 +++++++++------- .../opentelemetry/opentracingshim/shim_utils.h | 7 +++++-- opentracing-shim/src/span_context_shim.cc | 2 +- opentracing-shim/src/span_shim.cc | 14 +++++++++----- opentracing-shim/src/tracer_shim.cc | 13 +++++++------ 5 files changed, 31 insertions(+), 21 deletions(-) diff --git a/opentracing-shim/include/opentelemetry/opentracingshim/propagation.h b/opentracing-shim/include/opentelemetry/opentracingshim/propagation.h index b2a9be5a80..4e44276a3d 100644 --- a/opentracing-shim/include/opentelemetry/opentracingshim/propagation.h +++ b/opentracing-shim/include/opentelemetry/opentracingshim/propagation.h @@ -29,7 +29,8 @@ class CarrierWriterShim : public opentelemetry::context::propagation::TextMapCar virtual void Set(nostd::string_view key, nostd::string_view value) noexcept override { - writer_.Set(key.data(), value.data()); + writer_.Set(opentracing::string_view{key.data(), key.size()}, + opentracing::string_view{value.data(), value.size()}); } private: @@ -46,17 +47,17 @@ class CarrierReaderShim : public opentelemetry::context::propagation::TextMapCar nostd::string_view value; // First try carrier.LookupKey since that can potentially be the fastest approach. - if (auto result = reader_.LookupKey(key.data())) + if (auto result = reader_.LookupKey(opentracing::string_view{key.data(), key.size()})) { - value = result.value().data(); + value = nostd::string_view{result.value().data(), result.value().size()}; } else // Fall back to iterating through all of the keys. { reader_.ForeachKey([key, &value](opentracing::string_view k, opentracing::string_view v) -> opentracing::expected { - if (k == key.data()) + if (key == nostd::string_view{k.data(), k.size()}) { - value = v.data(); + value = nostd::string_view{v.data(), v.size()}; // Found key, so bail out of the loop with a success error code. return opentracing::make_unexpected(std::error_code{}); } @@ -77,8 +78,9 @@ class CarrierReaderShim : public opentelemetry::context::propagation::TextMapCar return reader_ .ForeachKey([&callback](opentracing::string_view key, opentracing::string_view) -> opentracing::expected { - return callback(key.data()) ? opentracing::make_expected() - : opentracing::make_unexpected(std::error_code{}); + return callback(nostd::string_view{key.data(), key.size()}) + ? opentracing::make_expected() + : opentracing::make_unexpected(std::error_code{}); }) .has_value(); } diff --git a/opentracing-shim/include/opentelemetry/opentracingshim/shim_utils.h b/opentracing-shim/include/opentelemetry/opentracingshim/shim_utils.h index a7feb5efc4..3436473870 100644 --- a/opentracing-shim/include/opentelemetry/opentracingshim/shim_utils.h +++ b/opentracing-shim/include/opentelemetry/opentracingshim/shim_utils.h @@ -29,7 +29,10 @@ static inline opentelemetry::common::AttributeValue attributeFromValue( AttributeValue operator()(int64_t v) { return v; } AttributeValue operator()(uint64_t v) { return v; } AttributeValue operator()(const std::string &v) { return nostd::string_view{v}; } - AttributeValue operator()(opentracing::string_view v) { return nostd::string_view{v.data()}; } + AttributeValue operator()(opentracing::string_view v) + { + return nostd::string_view{v.data(), v.size()}; + } AttributeValue operator()(std::nullptr_t) { return nostd::string_view{}; } AttributeValue operator()(const char *v) { return v; } AttributeValue operator()(opentracing::util::recursive_wrapper) @@ -54,7 +57,7 @@ static inline std::string stringFromValue(const opentracing::Value &value) std::string operator()(int64_t v) { return std::to_string(v); } std::string operator()(uint64_t v) { return std::to_string(v); } std::string operator()(const std::string &v) { return v; } - std::string operator()(opentracing::string_view v) { return std::string{v.data()}; } + std::string operator()(opentracing::string_view v) { return std::string{v.data(), v.size()}; } std::string operator()(std::nullptr_t) { return std::string{}; } std::string operator()(const char *v) { return std::string{v}; } std::string operator()(opentracing::util::recursive_wrapper) diff --git a/opentracing-shim/src/span_context_shim.cc b/opentracing-shim/src/span_context_shim.cc index 54af4da9a3..cd1069e9d9 100644 --- a/opentracing-shim/src/span_context_shim.cc +++ b/opentracing-shim/src/span_context_shim.cc @@ -23,7 +23,7 @@ bool SpanContextShim::BaggageItem(nostd::string_view key, std::string &value) co void SpanContextShim::ForeachBaggageItem(VisitBaggageItem f) const { baggage_->GetAllEntries([&f](nostd::string_view key, nostd::string_view value) { - return f(key.data(), value.data()); + return f(std::string{key.data(), key.size()}, std::string{value.data(), value.size()}); }); } diff --git a/opentracing-shim/src/span_shim.cc b/opentracing-shim/src/span_shim.cc index 1be909f1bd..afc974f057 100644 --- a/opentracing-shim/src/span_shim.cc +++ b/opentracing-shim/src/span_shim.cc @@ -45,7 +45,7 @@ void SpanShim::FinishWithOptions(const opentracing::FinishSpanOptions &finish_sp void SpanShim::SetOperationName(opentracing::string_view name) noexcept { - span_->UpdateName(name.data()); + span_->UpdateName(nostd::string_view{name.data(), name.size()}); } void SpanShim::SetTag(opentracing::string_view key, const opentracing::Value &value) noexcept @@ -57,7 +57,8 @@ void SpanShim::SetTag(opentracing::string_view key, const opentracing::Value &va } else { - span_->SetAttribute(key.data(), utils::attributeFromValue(value)); + auto key_view = nostd::string_view{key.data(), key.size()}; + span_->SetAttribute(key_view, utils::attributeFromValue(value)); } } @@ -68,9 +69,11 @@ void SpanShim::SetBaggageItem(opentracing::string_view restricted_key, // Baggage key/value pair, and sets it as the current instance for this Span Shim. if (restricted_key.empty() || value.empty()) return; + auto restricted_key_view = nostd::string_view{restricted_key.data(), restricted_key.size()}; + auto value_view = nostd::string_view{value.data(), value.size()}; // This operation MUST be safe to be called concurrently. const std::lock_guard guard(context_lock_); - context_ = context_.newWithKeyValue(restricted_key.data(), value.data()); + context_ = context_.newWithKeyValue(restricted_key_view, value_view); } std::string SpanShim::BaggageItem(opentracing::string_view restricted_key) const noexcept @@ -82,7 +85,8 @@ std::string SpanShim::BaggageItem(opentracing::string_view restricted_key) const // This operation MUST be safe to be called concurrently. const std::lock_guard guard(context_lock_); std::string value; - return context_.BaggageItem(restricted_key.data(), value) ? value : ""; + auto restricted_key_view = nostd::string_view{restricted_key.data(), restricted_key.size()}; + return context_.BaggageItem(restricted_key_view, value) ? value : ""; } void SpanShim::Log(std::initializer_list fields) noexcept @@ -128,7 +132,7 @@ void SpanShim::logImpl(nostd::span fields, for (const auto &entry : fields) { - nostd::string_view key = entry.first.data(); + nostd::string_view key{entry.first.data(), entry.first.size()}; // ... including mapping of the following key/value pairs: if (is_error) { diff --git a/opentracing-shim/src/tracer_shim.cc b/opentracing-shim/src/tracer_shim.cc index 7848cba478..e06961a88e 100644 --- a/opentracing-shim/src/tracer_shim.cc +++ b/opentracing-shim/src/tracer_shim.cc @@ -24,12 +24,13 @@ std::unique_ptr TracerShim::StartSpanWithOptions( if (is_closed_) return nullptr; - const auto &opts = utils::makeOptionsShim(options); - const auto &links = utils::makeIterableLinks(options); - const auto &attributes = utils::makeIterableTags(options); - const auto &baggage = utils::makeBaggage(options); - auto span = tracer_->StartSpan(operation_name.data(), attributes, links, opts); - auto span_shim = new (std::nothrow) SpanShim(*this, span, baggage); + const auto &opts = utils::makeOptionsShim(options); + const auto &links = utils::makeIterableLinks(options); + const auto &attributes = utils::makeIterableTags(options); + const auto &baggage = utils::makeBaggage(options); + auto operation_name_view = nostd::string_view{operation_name.data(), operation_name.size()}; + auto span = tracer_->StartSpan(operation_name_view, attributes, links, opts); + auto span_shim = new (std::nothrow) SpanShim(*this, span, baggage); // If an initial set of tags is specified and the OpenTracing error tag // is included after the OpenTelemetry Span was created. From ac4bba7363a0ed162eee868014acf5cc6c6b96ca Mon Sep 17 00:00:00 2001 From: Volodymyr Kolesnykov Date: Tue, 3 Dec 2024 00:33:19 +0200 Subject: [PATCH 88/89] [EXPORTER] Refactor `ElasticSearchRecordable` (#3164) --- .../src/es_log_record_exporter.cc | 2 +- .../elasticsearch/src/es_log_recordable.cc | 193 ++++-------------- 2 files changed, 40 insertions(+), 155 deletions(-) diff --git a/exporters/elasticsearch/src/es_log_record_exporter.cc b/exporters/elasticsearch/src/es_log_record_exporter.cc index 1ec786a198..cb7386f3da 100644 --- a/exporters/elasticsearch/src/es_log_record_exporter.cc +++ b/exporters/elasticsearch/src/es_log_record_exporter.cc @@ -63,7 +63,7 @@ class ResponseHandler : public http_client::EventHandler { log_message = BuildResponseLogMessage(response, body_); - OTEL_INTERNAL_LOG_ERROR("ES Log Exporter] Export failed, " << log_message); + OTEL_INTERNAL_LOG_ERROR("[ES Log Exporter] Export failed, " << log_message); } if (console_debug_) diff --git a/exporters/elasticsearch/src/es_log_recordable.cc b/exporters/elasticsearch/src/es_log_recordable.cc index 3412a8cc61..0e7c3b0344 100644 --- a/exporters/elasticsearch/src/es_log_recordable.cc +++ b/exporters/elasticsearch/src/es_log_recordable.cc @@ -1,14 +1,41 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include + #include "opentelemetry/exporters/elasticsearch/es_log_recordable.h" #include "opentelemetry/logs/severity.h" +#include "opentelemetry/nostd/variant.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/trace/span_id.h" #include "opentelemetry/trace/trace_flags.h" #include "opentelemetry/trace/trace_id.h" +namespace nlohmann +{ +template <> +struct adl_serializer +{ + static void to_json(json &j, const opentelemetry::sdk::common::OwnedAttributeValue &v) + { + opentelemetry::nostd::visit([&j](const auto &value) { j = value; }, v); + } +}; + +template <> +struct adl_serializer +{ + static void to_json(json &j, const opentelemetry::common::AttributeValue &v) + { + opentelemetry::nostd::visit([&j](const auto &value) { j = value; }, v); + } +}; +} // namespace nlohmann + OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter { @@ -18,146 +45,13 @@ void ElasticSearchRecordable::WriteValue( const opentelemetry::sdk::common::OwnedAttributeValue &value, const std::string &name) { - namespace common = opentelemetry::sdk::common; - switch (value.index()) - { - case common::kTypeBool: - json_[name] = opentelemetry::nostd::get(value) ? true : false; - return; - case common::kTypeInt: - json_[name] = opentelemetry::nostd::get(value); - return; - case common::kTypeInt64: - json_[name] = opentelemetry::nostd::get(value); - return; - case common::kTypeUInt: - json_[name] = opentelemetry::nostd::get(value); - return; - case common::kTypeUInt64: - json_[name] = opentelemetry::nostd::get(value); - return; - case common::kTypeDouble: - json_[name] = opentelemetry::nostd::get(value); - return; - case common::kTypeString: - json_[name] = opentelemetry::nostd::get(value).data(); - return; - default: - return; - } + json_[name] = value; } void ElasticSearchRecordable::WriteValue(const opentelemetry::common::AttributeValue &value, const std::string &name) { - - // Assert size of variant to ensure that this method gets updated if the variant - // definition changes - - if (nostd::holds_alternative(value)) - { - json_[name] = opentelemetry::nostd::get(value) ? true : false; - } - else if (nostd::holds_alternative(value)) - { - json_[name] = opentelemetry::nostd::get(value); - } - else if (nostd::holds_alternative(value)) - { - json_[name] = opentelemetry::nostd::get(value); - } - else if (nostd::holds_alternative(value)) - { - json_[name] = opentelemetry::nostd::get(value); - } - else if (nostd::holds_alternative(value)) - { - json_[name] = opentelemetry::nostd::get(value); - } - else if (nostd::holds_alternative(value)) - { - json_[name] = opentelemetry::nostd::get(value); - } - else if (nostd::holds_alternative(value)) - { - json_[name] = std::string(nostd::get(value)); - } - else if (nostd::holds_alternative(value)) - { - json_[name] = static_cast(opentelemetry::nostd::get(value)); - } - else if (nostd::holds_alternative>(value)) - { - nlohmann::json array_value = nlohmann::json::array(); - for (const auto &val : nostd::get>(value)) - { - array_value.push_back(val); - } - json_[name] = array_value; - } - else if (nostd::holds_alternative>(value)) - { - nlohmann::json array_value = nlohmann::json::array(); - for (const auto &val : nostd::get>(value)) - { - array_value.push_back(val); - } - json_[name] = array_value; - } - else if (nostd::holds_alternative>(value)) - { - nlohmann::json array_value = nlohmann::json::array(); - for (const auto &val : nostd::get>(value)) - { - array_value.push_back(val); - } - json_[name] = array_value; - } - else if (nostd::holds_alternative>(value)) - { - nlohmann::json array_value = nlohmann::json::array(); - for (const auto &val : nostd::get>(value)) - { - array_value.push_back(val); - } - json_[name] = array_value; - } - else if (nostd::holds_alternative>(value)) - { - nlohmann::json array_value = nlohmann::json::array(); - for (const auto &val : nostd::get>(value)) - { - array_value.push_back(val); - } - json_[name] = array_value; - } - else if (nostd::holds_alternative>(value)) - { - nlohmann::json array_value = nlohmann::json::array(); - for (const auto &val : nostd::get>(value)) - { - array_value.push_back(val); - } - json_[name] = array_value; - } - else if (nostd::holds_alternative>(value)) - { - nlohmann::json array_value = nlohmann::json::array(); - for (const auto &val : nostd::get>(value)) - { - array_value.push_back(val); - } - json_[name] = array_value; - } - else if (nostd::holds_alternative>(value)) - { - nlohmann::json array_value = nlohmann::json::array(); - for (const auto &val : nostd::get>(value)) - { - array_value.push_back(static_cast(val)); - } - json_[name] = array_value; - } + json_[name] = value; } ElasticSearchRecordable::ElasticSearchRecordable() noexcept : sdk::logs::Recordable() @@ -180,27 +74,19 @@ void ElasticSearchRecordable::SetTimestamp( #if __cplusplus >= 202002L const std::string dateStr = std::format("{:%FT%T%Ez}", timePoint); #else - const static int dateToSecondsSize = 19; - const static int millisecondsSize = 8; - const static int timeZoneSize = 1; - const static int dateSize = dateToSecondsSize + millisecondsSize + timeZoneSize; - std::time_t time = std::chrono::system_clock::to_time_t(timePoint); std::tm tm = *std::gmtime(&time); - - char bufferDate[dateSize]; // example: 2024-10-18T07:26:00.123456Z - std::strftime(bufferDate, sizeof(bufferDate), "%Y-%m-%dT%H:%M:%S", &tm); auto microseconds = std::chrono::duration_cast(timePoint.time_since_epoch()) % std::chrono::seconds(1); - char bufferMilliseconds[millisecondsSize]; - std::snprintf(bufferMilliseconds, sizeof(bufferMilliseconds), ".%06ld", + // `sizeof()` includes the null terminator + constexpr auto dateSize = sizeof("YYYY-MM-DDTHH:MM:SS.uuuuuuZ"); + char bufferDate[dateSize]; + auto offset = std::strftime(bufferDate, sizeof(bufferDate), "%Y-%m-%dT%H:%M:%S", &tm); + std::snprintf(bufferDate + offset, sizeof(bufferDate) - offset, ".%06ldZ", static_cast(microseconds.count())); - std::strcat(bufferDate, bufferMilliseconds); - std::strcat(bufferDate, "Z"); - const std::string dateStr(bufferDate); #endif @@ -221,9 +107,8 @@ void ElasticSearchRecordable::SetSeverity(opentelemetry::logs::Severity severity std::uint32_t severity_index = static_cast(severity); if (severity_index >= std::extent::value) { - std::stringstream sout; - sout << "Invalid severity(" << severity_index << ")"; - severityField = sout.str(); + severityField = + std::string("Invalid severity(").append(std::to_string(severity_index)).append(")"); } else { @@ -240,7 +125,7 @@ void ElasticSearchRecordable::SetTraceId(const opentelemetry::trace::TraceId &tr { if (trace_id.IsValid()) { - char trace_buf[32]; + char trace_buf[opentelemetry::trace::TraceId::kSize * 2]; trace_id.ToLowerBase16(trace_buf); json_["traceid"] = std::string(trace_buf, sizeof(trace_buf)); } @@ -254,7 +139,7 @@ void ElasticSearchRecordable::SetSpanId(const opentelemetry::trace::SpanId &span { if (span_id.IsValid()) { - char span_buf[16]; + char span_buf[opentelemetry::trace::SpanId::kSize * 2]; span_id.ToLowerBase16(span_buf); json_["spanid"] = std::string(span_buf, sizeof(span_buf)); } @@ -282,7 +167,7 @@ void ElasticSearchRecordable::SetAttribute( void ElasticSearchRecordable::SetResource( const opentelemetry::sdk::resource::Resource &resource) noexcept { - for (auto &attribute : resource.GetAttributes()) + for (const auto &attribute : resource.GetAttributes()) { WriteValue(attribute.second, attribute.first); } From 150256c1720b279a1dfc7c380d17e13e90cee15d Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Tue, 3 Dec 2024 00:29:24 +0100 Subject: [PATCH 89/89] [SEMANTIC CONVENTIONS] Upgrade to semantic conventions 1.29.0 (#3182) --- .../semconv/incubating/cicd_attributes.h | 8 +- .../incubating/cloudfoundry_attributes.h | 11 +- .../semconv/incubating/container_metrics.h | 42 ++ .../semconv/incubating/db_attributes.h | 122 +++++- .../semconv/incubating/db_metrics.h | 409 +++++++++++------- .../incubating/feature_flag_attributes.h | 92 +++- .../semconv/incubating/gen_ai_attributes.h | 38 +- .../semconv/incubating/geo_attributes.h | 102 +++++ .../semconv/incubating/k8s_metrics.h | 232 ++++++++++ .../semconv/incubating/network_attributes.h | 11 +- .../semconv/incubating/process_attributes.h | 20 + .../semconv/incubating/process_metrics.h | 28 +- .../semconv/incubating/service_attributes.h | 26 +- .../semconv/incubating/system_metrics.h | 42 ++ .../semconv/incubating/test_attributes.h | 4 +- .../semconv/incubating/url_attributes.h | 45 +- .../incubating/user_agent_attributes.h | 26 ++ .../semconv/incubating/vcs_attributes.h | 218 +++++++++- .../semconv/incubating/vcs_metrics.h | 394 +++++++++++++++++ .../semconv/network_attributes.h | 11 +- .../opentelemetry/semconv/schema_url.h | 2 +- .../opentelemetry/semconv/url_attributes.h | 45 +- buildscripts/semantic-convention/generate.sh | 2 +- 23 files changed, 1680 insertions(+), 250 deletions(-) create mode 100644 api/include/opentelemetry/semconv/incubating/geo_attributes.h create mode 100644 api/include/opentelemetry/semconv/incubating/vcs_metrics.h diff --git a/api/include/opentelemetry/semconv/incubating/cicd_attributes.h b/api/include/opentelemetry/semconv/incubating/cicd_attributes.h index 246563a8e8..622de977ce 100644 --- a/api/include/opentelemetry/semconv/incubating/cicd_attributes.h +++ b/api/include/opentelemetry/semconv/incubating/cicd_attributes.h @@ -31,8 +31,8 @@ static constexpr const char *kCicdPipelineRunId = "cicd.pipeline.run.id"; /** * The human readable name of a task within a pipeline. Task here most closely aligns with a computing process in a pipeline. - * Other terms for tasks include commands, steps, and procedures. + * href="https://wikipedia.org/wiki/Pipeline_(computing)">computing process in a pipeline. Other + * terms for tasks include commands, steps, and procedures. */ static constexpr const char *kCicdPipelineTaskName = "cicd.pipeline.task.name"; @@ -42,8 +42,8 @@ static constexpr const char *kCicdPipelineTaskName = "cicd.pipeline.task.name"; static constexpr const char *kCicdPipelineTaskRunId = "cicd.pipeline.task.run.id"; /** - * The URL of the pipeline run providing the - * complete address in order to locate and identify the pipeline run. + * The URL of the pipeline run providing the complete + * address in order to locate and identify the pipeline run. */ static constexpr const char *kCicdPipelineTaskRunUrlFull = "cicd.pipeline.task.run.url.full"; diff --git a/api/include/opentelemetry/semconv/incubating/cloudfoundry_attributes.h b/api/include/opentelemetry/semconv/incubating/cloudfoundry_attributes.h index 0eda006baa..a0740e5b38 100644 --- a/api/include/opentelemetry/semconv/incubating/cloudfoundry_attributes.h +++ b/api/include/opentelemetry/semconv/incubating/cloudfoundry_attributes.h @@ -32,10 +32,13 @@ static constexpr const char *kCloudfoundryAppId = "cloudfoundry.app.id"; * The index of the application instance. 0 when just one instance is active. *

      * CloudFoundry defines the @code instance_id @endcode in the Loggegator v2 envelope. It - * is used for logs and metrics emitted by CloudFoundry. It is supposed to contain the application - * instance index for applications deployed on the runtime.

      Application instrumentation should - * use the value from environment variable @code CF_INSTANCE_INDEX @endcode. + * href="https://github.com/cloudfoundry/loggregator-api#v2-envelope">Loggregator v2 envelope. + * It is used for logs and metrics emitted by CloudFoundry. It is + * supposed to contain the application instance index for applications + * deployed on the runtime. + *

      + * Application instrumentation should use the value from environment + * variable @code CF_INSTANCE_INDEX @endcode. */ static constexpr const char *kCloudfoundryAppInstanceId = "cloudfoundry.app.instance.id"; diff --git a/api/include/opentelemetry/semconv/incubating/container_metrics.h b/api/include/opentelemetry/semconv/incubating/container_metrics.h index 8fa2541b32..ef3d9fa71d 100644 --- a/api/include/opentelemetry/semconv/incubating/container_metrics.h +++ b/api/include/opentelemetry/semconv/incubating/container_metrics.h @@ -219,6 +219,48 @@ CreateAsyncDoubleMetricContainerNetworkIo(metrics::Meter *meter) kMetricContainerNetworkIo, descrMetricContainerNetworkIo, unitMetricContainerNetworkIo); } +/** + * The time the container has been running + *

      + * Instrumentations SHOULD use a gauge with type @code double @endcode and measure uptime in seconds + * as a floating point number with the highest precision available. The actual accuracy would depend + * on the instrumentation and operating system.

      gauge + */ +static constexpr const char *kMetricContainerUptime = "metric.container.uptime"; +static constexpr const char *descrMetricContainerUptime = "The time the container has been running"; +static constexpr const char *unitMetricContainerUptime = "s"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricContainerUptime( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricContainerUptime, descrMetricContainerUptime, + unitMetricContainerUptime); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricContainerUptime( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricContainerUptime, descrMetricContainerUptime, + unitMetricContainerUptime); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricContainerUptime(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricContainerUptime, descrMetricContainerUptime, + unitMetricContainerUptime); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricContainerUptime(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricContainerUptime, descrMetricContainerUptime, + unitMetricContainerUptime); +} + } // namespace container } // namespace semconv OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/db_attributes.h b/api/include/opentelemetry/semconv/incubating/db_attributes.h index 7c5d3304bb..22148fed13 100644 --- a/api/include/opentelemetry/semconv/incubating/db_attributes.h +++ b/api/include/opentelemetry/semconv/incubating/db_attributes.h @@ -98,12 +98,13 @@ static constexpr const char *kDbClientConnectionsState = "db.client.connections. * The name of a collection (table, container) within the database. *

      * It is RECOMMENDED to capture the value as provided by the application without attempting to do - * any case normalization. If the collection name is parsed from the query text, it SHOULD be the - * first collection name found in the query and it SHOULD match the value provided in the query text - * including any schema and database name prefix. For batch operations, if the individual operations - * are known to have the same collection name then that collection name SHOULD be used, otherwise - * @code db.collection.name @endcode SHOULD NOT be captured. This attribute has stability level - * RELEASE CANDIDATE. + * any case normalization.

      The collection name SHOULD NOT be extracted from @code db.query.text + * @endcode, unless the query format is known to only ever have a single collection name present. + *

      + * For batch operations, if the individual operations are known to have the same collection name + * then that collection name SHOULD be used. + *

      + * This attribute has stability level RELEASE CANDIDATE. */ static constexpr const char *kDbCollectionName = "db.collection.name"; @@ -126,6 +127,12 @@ static constexpr const char *kDbCosmosdbClientId = "db.cosmosdb.client_id"; */ static constexpr const char *kDbCosmosdbConnectionMode = "db.cosmosdb.connection_mode"; +/** + * Account or request consistency level. + */ +static constexpr const char *kDbCosmosdbConsistencyLevel = "db.cosmosdb.consistency_level"; + /** * Deprecated, use @code db.collection.name @endcode instead. *

      @@ -136,17 +143,30 @@ OPENTELEMETRY_DEPRECATED static constexpr const char *kDbCosmosdbContainer = "db.cosmosdb.container"; /** - * Cosmos DB Operation Type. + * Deprecated, no replacement at this time. + *

      + * @deprecated + * No replacement at this time. */ +OPENTELEMETRY_DEPRECATED static constexpr const char *kDbCosmosdbOperationType = "db.cosmosdb.operation_type"; /** - * RU consumed for that operation + * List of regions contacted during operation in the order that they were contacted. If there is + * more than one region listed, it indicates that the operation was performed on multiple regions + * i.e. cross-regional call.

      Region name matches the format of @code displayName @endcode in Azure + * Location API + */ +static constexpr const char *kDbCosmosdbRegionsContacted = "db.cosmosdb.regions_contacted"; + +/** + * Request units consumed for the operation. */ static constexpr const char *kDbCosmosdbRequestCharge = "db.cosmosdb.request_charge"; /** - * Request payload size in bytes + * Request payload size in bytes. */ static constexpr const char *kDbCosmosdbRequestContentLength = "db.cosmosdb.request_content_length"; @@ -270,25 +290,53 @@ static constexpr const char *kDbOperationBatchSize = "db.operation.batch.size"; /** * The name of the operation or command being executed. *

      - * It is RECOMMENDED to capture the value as provided by the application without attempting to do - * any case normalization. If the operation name is parsed from the query text, it SHOULD be the - * first operation name found in the query. For batch operations, if the individual operations are - * known to have the same operation name then that operation name SHOULD be used prepended by @code - * BATCH @endcode, otherwise @code db.operation.name @endcode SHOULD be @code BATCH @endcode or - * some other database system specific term if more applicable. This attribute has stability level - * RELEASE CANDIDATE. + * It is RECOMMENDED to capture the value as provided by the application + * without attempting to do any case normalization. + *

      + * The operation name SHOULD NOT be extracted from @code db.query.text @endcode, + * unless the query format is known to only ever have a single operation name present. + *

      + * For batch operations, if the individual operations are known to have the same operation name + * then that operation name SHOULD be used prepended by @code BATCH @endcode, + * otherwise @code db.operation.name @endcode SHOULD be @code BATCH @endcode or some other database + * system specific term if more applicable. + *

      + * This attribute has stability level RELEASE CANDIDATE. */ static constexpr const char *kDbOperationName = "db.operation.name"; +/** + * A database operation parameter, with @code @endcode being the parameter name, and the + * attribute value being a string representation of the parameter value.

      If a parameter has no + * name and instead is referenced only by index, then @code @endcode SHOULD be the 0-based + * index. If @code db.query.text @endcode is also captured, then @code db.operation.parameter. + * @endcode SHOULD match up with the parameterized placeholders present in @code db.query.text + * @endcode. This attribute has stability level RELEASE CANDIDATE. + */ +static constexpr const char *kDbOperationParameter = "db.operation.parameter"; + /** * A query parameter used in @code db.query.text @endcode, with @code @endcode being the * parameter name, and the attribute value being a string representation of the parameter value.

      - * Query parameters should only be captured when @code db.query.text @endcode is parameterized with - * placeholders. If a parameter has no name and instead is referenced only by index, then @code - * @endcode SHOULD be the 0-based index. This attribute has stability level RELEASE CANDIDATE. + * @deprecated + * Replaced by @code db.operation.parameter @endcode. */ +OPENTELEMETRY_DEPRECATED static constexpr const char *kDbQueryParameter = "db.query.parameter"; +/** + * Low cardinality representation of a database query text. + *

      + * @code db.query.summary @endcode provides static summary of the query text. It describes a class + * of database queries and is useful as a grouping key, especially when analyzing telemetry for + * database calls involving complex queries. Summary may be available to the instrumentation through + * instrumentation hooks or other means. If it is not available, instrumentations that support query + * parsing SHOULD generate a summary following Generating + * query summary section. This attribute has stability level RELEASE CANDIDATE. + */ +static constexpr const char *kDbQuerySummary = "db.query.summary"; + /** * The database query being executed. *

      @@ -314,6 +362,11 @@ static constexpr const char *kDbQueryText = "db.query.text"; OPENTELEMETRY_DEPRECATED static constexpr const char *kDbRedisDatabaseIndex = "db.redis.database_index"; +/** + * Number of rows returned by the operation. + */ +static constexpr const char *kDbResponseReturnedRows = "db.response.returned_rows"; + /** * Database response status code. *

      @@ -452,7 +505,7 @@ static constexpr const char *kUsed = "used"; namespace DbCosmosdbConnectionModeValues { /** - * Gateway (HTTP) connections mode + * Gateway (HTTP) connection. */ static constexpr const char *kGateway = "gateway"; @@ -463,6 +516,35 @@ static constexpr const char *kDirect = "direct"; } // namespace DbCosmosdbConnectionModeValues +namespace DbCosmosdbConsistencyLevelValues +{ +/** + * none + */ +static constexpr const char *kStrong = "Strong"; + +/** + * none + */ +static constexpr const char *kBoundedStaleness = "BoundedStaleness"; + +/** + * none + */ +static constexpr const char *kSession = "Session"; + +/** + * none + */ +static constexpr const char *kEventual = "Eventual"; + +/** + * none + */ +static constexpr const char *kConsistentPrefix = "ConsistentPrefix"; + +} // namespace DbCosmosdbConsistencyLevelValues + namespace DbCosmosdbOperationTypeValues { /** diff --git a/api/include/opentelemetry/semconv/incubating/db_metrics.h b/api/include/opentelemetry/semconv/incubating/db_metrics.h index d3dd52190e..9543a70baa 100644 --- a/api/include/opentelemetry/semconv/incubating/db_metrics.h +++ b/api/include/opentelemetry/semconv/incubating/db_metrics.h @@ -365,31 +365,31 @@ CreateSyncDoubleMetricDbClientConnectionWaitTime(metrics::Meter *meter) * @code ms @endcode to @code s @endcode.

      histogram */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kMetricDbClientConnectionsCreateTimeDeprecated = - "metric.db.client.connections.create_time.deprecated"; +static constexpr const char *kMetricDbClientConnectionsCreateTime = + "metric.db.client.connections.create_time"; OPENTELEMETRY_DEPRECATED -static constexpr const char *descrMetricDbClientConnectionsCreateTimeDeprecated = +static constexpr const char *descrMetricDbClientConnectionsCreateTime = "Deprecated, use `db.client.connection.create_time` instead. Note: the unit also changed from " "`ms` to `s`."; OPENTELEMETRY_DEPRECATED -static constexpr const char *unitMetricDbClientConnectionsCreateTimeDeprecated = "ms"; +static constexpr const char *unitMetricDbClientConnectionsCreateTime = "ms"; OPENTELEMETRY_DEPRECATED static inline nostd::unique_ptr> -CreateSyncInt64MetricDbClientConnectionsCreateTimeDeprecated(metrics::Meter *meter) +CreateSyncInt64MetricDbClientConnectionsCreateTime(metrics::Meter *meter) { - return meter->CreateUInt64Histogram(kMetricDbClientConnectionsCreateTimeDeprecated, - descrMetricDbClientConnectionsCreateTimeDeprecated, - unitMetricDbClientConnectionsCreateTimeDeprecated); + return meter->CreateUInt64Histogram(kMetricDbClientConnectionsCreateTime, + descrMetricDbClientConnectionsCreateTime, + unitMetricDbClientConnectionsCreateTime); } OPENTELEMETRY_DEPRECATED static inline nostd::unique_ptr> -CreateSyncDoubleMetricDbClientConnectionsCreateTimeDeprecated(metrics::Meter *meter) +CreateSyncDoubleMetricDbClientConnectionsCreateTime(metrics::Meter *meter) { - return meter->CreateDoubleHistogram(kMetricDbClientConnectionsCreateTimeDeprecated, - descrMetricDbClientConnectionsCreateTimeDeprecated, - unitMetricDbClientConnectionsCreateTimeDeprecated); + return meter->CreateDoubleHistogram(kMetricDbClientConnectionsCreateTime, + descrMetricDbClientConnectionsCreateTime, + unitMetricDbClientConnectionsCreateTime); } /** @@ -401,48 +401,48 @@ CreateSyncDoubleMetricDbClientConnectionsCreateTimeDeprecated(metrics::Meter *me * updowncounter */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kMetricDbClientConnectionsIdleMaxDeprecated = - "metric.db.client.connections.idle.max.deprecated"; +static constexpr const char *kMetricDbClientConnectionsIdleMax = + "metric.db.client.connections.idle.max"; OPENTELEMETRY_DEPRECATED -static constexpr const char *descrMetricDbClientConnectionsIdleMaxDeprecated = +static constexpr const char *descrMetricDbClientConnectionsIdleMax = "Deprecated, use `db.client.connection.idle.max` instead."; OPENTELEMETRY_DEPRECATED -static constexpr const char *unitMetricDbClientConnectionsIdleMaxDeprecated = "{connection}"; +static constexpr const char *unitMetricDbClientConnectionsIdleMax = "{connection}"; OPENTELEMETRY_DEPRECATED static inline nostd::unique_ptr> -CreateSyncInt64MetricDbClientConnectionsIdleMaxDeprecated(metrics::Meter *meter) +CreateSyncInt64MetricDbClientConnectionsIdleMax(metrics::Meter *meter) { - return meter->CreateInt64UpDownCounter(kMetricDbClientConnectionsIdleMaxDeprecated, - descrMetricDbClientConnectionsIdleMaxDeprecated, - unitMetricDbClientConnectionsIdleMaxDeprecated); + return meter->CreateInt64UpDownCounter(kMetricDbClientConnectionsIdleMax, + descrMetricDbClientConnectionsIdleMax, + unitMetricDbClientConnectionsIdleMax); } OPENTELEMETRY_DEPRECATED static inline nostd::unique_ptr> -CreateSyncDoubleMetricDbClientConnectionsIdleMaxDeprecated(metrics::Meter *meter) +CreateSyncDoubleMetricDbClientConnectionsIdleMax(metrics::Meter *meter) { - return meter->CreateDoubleUpDownCounter(kMetricDbClientConnectionsIdleMaxDeprecated, - descrMetricDbClientConnectionsIdleMaxDeprecated, - unitMetricDbClientConnectionsIdleMaxDeprecated); + return meter->CreateDoubleUpDownCounter(kMetricDbClientConnectionsIdleMax, + descrMetricDbClientConnectionsIdleMax, + unitMetricDbClientConnectionsIdleMax); } OPENTELEMETRY_DEPRECATED static inline nostd::shared_ptr -CreateAsyncInt64MetricDbClientConnectionsIdleMaxDeprecated(metrics::Meter *meter) +CreateAsyncInt64MetricDbClientConnectionsIdleMax(metrics::Meter *meter) { - return meter->CreateInt64ObservableUpDownCounter(kMetricDbClientConnectionsIdleMaxDeprecated, - descrMetricDbClientConnectionsIdleMaxDeprecated, - unitMetricDbClientConnectionsIdleMaxDeprecated); + return meter->CreateInt64ObservableUpDownCounter(kMetricDbClientConnectionsIdleMax, + descrMetricDbClientConnectionsIdleMax, + unitMetricDbClientConnectionsIdleMax); } OPENTELEMETRY_DEPRECATED static inline nostd::shared_ptr -CreateAsyncDoubleMetricDbClientConnectionsIdleMaxDeprecated(metrics::Meter *meter) +CreateAsyncDoubleMetricDbClientConnectionsIdleMax(metrics::Meter *meter) { - return meter->CreateDoubleObservableUpDownCounter(kMetricDbClientConnectionsIdleMaxDeprecated, - descrMetricDbClientConnectionsIdleMaxDeprecated, - unitMetricDbClientConnectionsIdleMaxDeprecated); + return meter->CreateDoubleObservableUpDownCounter(kMetricDbClientConnectionsIdleMax, + descrMetricDbClientConnectionsIdleMax, + unitMetricDbClientConnectionsIdleMax); } /** @@ -454,48 +454,48 @@ CreateAsyncDoubleMetricDbClientConnectionsIdleMaxDeprecated(metrics::Meter *mete * updowncounter */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kMetricDbClientConnectionsIdleMinDeprecated = - "metric.db.client.connections.idle.min.deprecated"; +static constexpr const char *kMetricDbClientConnectionsIdleMin = + "metric.db.client.connections.idle.min"; OPENTELEMETRY_DEPRECATED -static constexpr const char *descrMetricDbClientConnectionsIdleMinDeprecated = +static constexpr const char *descrMetricDbClientConnectionsIdleMin = "Deprecated, use `db.client.connection.idle.min` instead."; OPENTELEMETRY_DEPRECATED -static constexpr const char *unitMetricDbClientConnectionsIdleMinDeprecated = "{connection}"; +static constexpr const char *unitMetricDbClientConnectionsIdleMin = "{connection}"; OPENTELEMETRY_DEPRECATED static inline nostd::unique_ptr> -CreateSyncInt64MetricDbClientConnectionsIdleMinDeprecated(metrics::Meter *meter) +CreateSyncInt64MetricDbClientConnectionsIdleMin(metrics::Meter *meter) { - return meter->CreateInt64UpDownCounter(kMetricDbClientConnectionsIdleMinDeprecated, - descrMetricDbClientConnectionsIdleMinDeprecated, - unitMetricDbClientConnectionsIdleMinDeprecated); + return meter->CreateInt64UpDownCounter(kMetricDbClientConnectionsIdleMin, + descrMetricDbClientConnectionsIdleMin, + unitMetricDbClientConnectionsIdleMin); } OPENTELEMETRY_DEPRECATED static inline nostd::unique_ptr> -CreateSyncDoubleMetricDbClientConnectionsIdleMinDeprecated(metrics::Meter *meter) +CreateSyncDoubleMetricDbClientConnectionsIdleMin(metrics::Meter *meter) { - return meter->CreateDoubleUpDownCounter(kMetricDbClientConnectionsIdleMinDeprecated, - descrMetricDbClientConnectionsIdleMinDeprecated, - unitMetricDbClientConnectionsIdleMinDeprecated); + return meter->CreateDoubleUpDownCounter(kMetricDbClientConnectionsIdleMin, + descrMetricDbClientConnectionsIdleMin, + unitMetricDbClientConnectionsIdleMin); } OPENTELEMETRY_DEPRECATED static inline nostd::shared_ptr -CreateAsyncInt64MetricDbClientConnectionsIdleMinDeprecated(metrics::Meter *meter) +CreateAsyncInt64MetricDbClientConnectionsIdleMin(metrics::Meter *meter) { - return meter->CreateInt64ObservableUpDownCounter(kMetricDbClientConnectionsIdleMinDeprecated, - descrMetricDbClientConnectionsIdleMinDeprecated, - unitMetricDbClientConnectionsIdleMinDeprecated); + return meter->CreateInt64ObservableUpDownCounter(kMetricDbClientConnectionsIdleMin, + descrMetricDbClientConnectionsIdleMin, + unitMetricDbClientConnectionsIdleMin); } OPENTELEMETRY_DEPRECATED static inline nostd::shared_ptr -CreateAsyncDoubleMetricDbClientConnectionsIdleMinDeprecated(metrics::Meter *meter) +CreateAsyncDoubleMetricDbClientConnectionsIdleMin(metrics::Meter *meter) { - return meter->CreateDoubleObservableUpDownCounter(kMetricDbClientConnectionsIdleMinDeprecated, - descrMetricDbClientConnectionsIdleMinDeprecated, - unitMetricDbClientConnectionsIdleMinDeprecated); + return meter->CreateDoubleObservableUpDownCounter(kMetricDbClientConnectionsIdleMin, + descrMetricDbClientConnectionsIdleMin, + unitMetricDbClientConnectionsIdleMin); } /** @@ -507,48 +507,47 @@ CreateAsyncDoubleMetricDbClientConnectionsIdleMinDeprecated(metrics::Meter *mete * updowncounter */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kMetricDbClientConnectionsMaxDeprecated = - "metric.db.client.connections.max.deprecated"; +static constexpr const char *kMetricDbClientConnectionsMax = "metric.db.client.connections.max"; OPENTELEMETRY_DEPRECATED -static constexpr const char *descrMetricDbClientConnectionsMaxDeprecated = +static constexpr const char *descrMetricDbClientConnectionsMax = "Deprecated, use `db.client.connection.max` instead."; OPENTELEMETRY_DEPRECATED -static constexpr const char *unitMetricDbClientConnectionsMaxDeprecated = "{connection}"; +static constexpr const char *unitMetricDbClientConnectionsMax = "{connection}"; OPENTELEMETRY_DEPRECATED static inline nostd::unique_ptr> -CreateSyncInt64MetricDbClientConnectionsMaxDeprecated(metrics::Meter *meter) +CreateSyncInt64MetricDbClientConnectionsMax(metrics::Meter *meter) { - return meter->CreateInt64UpDownCounter(kMetricDbClientConnectionsMaxDeprecated, - descrMetricDbClientConnectionsMaxDeprecated, - unitMetricDbClientConnectionsMaxDeprecated); + return meter->CreateInt64UpDownCounter(kMetricDbClientConnectionsMax, + descrMetricDbClientConnectionsMax, + unitMetricDbClientConnectionsMax); } OPENTELEMETRY_DEPRECATED static inline nostd::unique_ptr> -CreateSyncDoubleMetricDbClientConnectionsMaxDeprecated(metrics::Meter *meter) +CreateSyncDoubleMetricDbClientConnectionsMax(metrics::Meter *meter) { - return meter->CreateDoubleUpDownCounter(kMetricDbClientConnectionsMaxDeprecated, - descrMetricDbClientConnectionsMaxDeprecated, - unitMetricDbClientConnectionsMaxDeprecated); + return meter->CreateDoubleUpDownCounter(kMetricDbClientConnectionsMax, + descrMetricDbClientConnectionsMax, + unitMetricDbClientConnectionsMax); } OPENTELEMETRY_DEPRECATED static inline nostd::shared_ptr -CreateAsyncInt64MetricDbClientConnectionsMaxDeprecated(metrics::Meter *meter) +CreateAsyncInt64MetricDbClientConnectionsMax(metrics::Meter *meter) { - return meter->CreateInt64ObservableUpDownCounter(kMetricDbClientConnectionsMaxDeprecated, - descrMetricDbClientConnectionsMaxDeprecated, - unitMetricDbClientConnectionsMaxDeprecated); + return meter->CreateInt64ObservableUpDownCounter(kMetricDbClientConnectionsMax, + descrMetricDbClientConnectionsMax, + unitMetricDbClientConnectionsMax); } OPENTELEMETRY_DEPRECATED static inline nostd::shared_ptr -CreateAsyncDoubleMetricDbClientConnectionsMaxDeprecated(metrics::Meter *meter) +CreateAsyncDoubleMetricDbClientConnectionsMax(metrics::Meter *meter) { - return meter->CreateDoubleObservableUpDownCounter(kMetricDbClientConnectionsMaxDeprecated, - descrMetricDbClientConnectionsMaxDeprecated, - unitMetricDbClientConnectionsMaxDeprecated); + return meter->CreateDoubleObservableUpDownCounter(kMetricDbClientConnectionsMax, + descrMetricDbClientConnectionsMax, + unitMetricDbClientConnectionsMax); } /** @@ -560,50 +559,48 @@ CreateAsyncDoubleMetricDbClientConnectionsMaxDeprecated(metrics::Meter *meter) * updowncounter */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kMetricDbClientConnectionsPendingRequestsDeprecated = - "metric.db.client.connections.pending_requests.deprecated"; +static constexpr const char *kMetricDbClientConnectionsPendingRequests = + "metric.db.client.connections.pending_requests"; OPENTELEMETRY_DEPRECATED -static constexpr const char *descrMetricDbClientConnectionsPendingRequestsDeprecated = +static constexpr const char *descrMetricDbClientConnectionsPendingRequests = "Deprecated, use `db.client.connection.pending_requests` instead."; OPENTELEMETRY_DEPRECATED -static constexpr const char *unitMetricDbClientConnectionsPendingRequestsDeprecated = "{request}"; +static constexpr const char *unitMetricDbClientConnectionsPendingRequests = "{request}"; OPENTELEMETRY_DEPRECATED static inline nostd::unique_ptr> -CreateSyncInt64MetricDbClientConnectionsPendingRequestsDeprecated(metrics::Meter *meter) +CreateSyncInt64MetricDbClientConnectionsPendingRequests(metrics::Meter *meter) { - return meter->CreateInt64UpDownCounter(kMetricDbClientConnectionsPendingRequestsDeprecated, - descrMetricDbClientConnectionsPendingRequestsDeprecated, - unitMetricDbClientConnectionsPendingRequestsDeprecated); + return meter->CreateInt64UpDownCounter(kMetricDbClientConnectionsPendingRequests, + descrMetricDbClientConnectionsPendingRequests, + unitMetricDbClientConnectionsPendingRequests); } OPENTELEMETRY_DEPRECATED static inline nostd::unique_ptr> -CreateSyncDoubleMetricDbClientConnectionsPendingRequestsDeprecated(metrics::Meter *meter) +CreateSyncDoubleMetricDbClientConnectionsPendingRequests(metrics::Meter *meter) { - return meter->CreateDoubleUpDownCounter(kMetricDbClientConnectionsPendingRequestsDeprecated, - descrMetricDbClientConnectionsPendingRequestsDeprecated, - unitMetricDbClientConnectionsPendingRequestsDeprecated); + return meter->CreateDoubleUpDownCounter(kMetricDbClientConnectionsPendingRequests, + descrMetricDbClientConnectionsPendingRequests, + unitMetricDbClientConnectionsPendingRequests); } OPENTELEMETRY_DEPRECATED static inline nostd::shared_ptr -CreateAsyncInt64MetricDbClientConnectionsPendingRequestsDeprecated(metrics::Meter *meter) +CreateAsyncInt64MetricDbClientConnectionsPendingRequests(metrics::Meter *meter) { - return meter->CreateInt64ObservableUpDownCounter( - kMetricDbClientConnectionsPendingRequestsDeprecated, - descrMetricDbClientConnectionsPendingRequestsDeprecated, - unitMetricDbClientConnectionsPendingRequestsDeprecated); + return meter->CreateInt64ObservableUpDownCounter(kMetricDbClientConnectionsPendingRequests, + descrMetricDbClientConnectionsPendingRequests, + unitMetricDbClientConnectionsPendingRequests); } OPENTELEMETRY_DEPRECATED static inline nostd::shared_ptr -CreateAsyncDoubleMetricDbClientConnectionsPendingRequestsDeprecated(metrics::Meter *meter) +CreateAsyncDoubleMetricDbClientConnectionsPendingRequests(metrics::Meter *meter) { - return meter->CreateDoubleObservableUpDownCounter( - kMetricDbClientConnectionsPendingRequestsDeprecated, - descrMetricDbClientConnectionsPendingRequestsDeprecated, - unitMetricDbClientConnectionsPendingRequestsDeprecated); + return meter->CreateDoubleObservableUpDownCounter(kMetricDbClientConnectionsPendingRequests, + descrMetricDbClientConnectionsPendingRequests, + unitMetricDbClientConnectionsPendingRequests); } /** @@ -615,48 +612,48 @@ CreateAsyncDoubleMetricDbClientConnectionsPendingRequestsDeprecated(metrics::Met * counter */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kMetricDbClientConnectionsTimeoutsDeprecated = - "metric.db.client.connections.timeouts.deprecated"; +static constexpr const char *kMetricDbClientConnectionsTimeouts = + "metric.db.client.connections.timeouts"; OPENTELEMETRY_DEPRECATED -static constexpr const char *descrMetricDbClientConnectionsTimeoutsDeprecated = +static constexpr const char *descrMetricDbClientConnectionsTimeouts = "Deprecated, use `db.client.connection.timeouts` instead."; OPENTELEMETRY_DEPRECATED -static constexpr const char *unitMetricDbClientConnectionsTimeoutsDeprecated = "{timeout}"; +static constexpr const char *unitMetricDbClientConnectionsTimeouts = "{timeout}"; OPENTELEMETRY_DEPRECATED static inline nostd::unique_ptr> -CreateSyncInt64MetricDbClientConnectionsTimeoutsDeprecated(metrics::Meter *meter) +CreateSyncInt64MetricDbClientConnectionsTimeouts(metrics::Meter *meter) { - return meter->CreateUInt64Counter(kMetricDbClientConnectionsTimeoutsDeprecated, - descrMetricDbClientConnectionsTimeoutsDeprecated, - unitMetricDbClientConnectionsTimeoutsDeprecated); + return meter->CreateUInt64Counter(kMetricDbClientConnectionsTimeouts, + descrMetricDbClientConnectionsTimeouts, + unitMetricDbClientConnectionsTimeouts); } OPENTELEMETRY_DEPRECATED static inline nostd::unique_ptr> -CreateSyncDoubleMetricDbClientConnectionsTimeoutsDeprecated(metrics::Meter *meter) +CreateSyncDoubleMetricDbClientConnectionsTimeouts(metrics::Meter *meter) { - return meter->CreateDoubleCounter(kMetricDbClientConnectionsTimeoutsDeprecated, - descrMetricDbClientConnectionsTimeoutsDeprecated, - unitMetricDbClientConnectionsTimeoutsDeprecated); + return meter->CreateDoubleCounter(kMetricDbClientConnectionsTimeouts, + descrMetricDbClientConnectionsTimeouts, + unitMetricDbClientConnectionsTimeouts); } OPENTELEMETRY_DEPRECATED static inline nostd::shared_ptr -CreateAsyncInt64MetricDbClientConnectionsTimeoutsDeprecated(metrics::Meter *meter) +CreateAsyncInt64MetricDbClientConnectionsTimeouts(metrics::Meter *meter) { - return meter->CreateInt64ObservableCounter(kMetricDbClientConnectionsTimeoutsDeprecated, - descrMetricDbClientConnectionsTimeoutsDeprecated, - unitMetricDbClientConnectionsTimeoutsDeprecated); + return meter->CreateInt64ObservableCounter(kMetricDbClientConnectionsTimeouts, + descrMetricDbClientConnectionsTimeouts, + unitMetricDbClientConnectionsTimeouts); } OPENTELEMETRY_DEPRECATED static inline nostd::shared_ptr -CreateAsyncDoubleMetricDbClientConnectionsTimeoutsDeprecated(metrics::Meter *meter) +CreateAsyncDoubleMetricDbClientConnectionsTimeouts(metrics::Meter *meter) { - return meter->CreateDoubleObservableCounter(kMetricDbClientConnectionsTimeoutsDeprecated, - descrMetricDbClientConnectionsTimeoutsDeprecated, - unitMetricDbClientConnectionsTimeoutsDeprecated); + return meter->CreateDoubleObservableCounter(kMetricDbClientConnectionsTimeouts, + descrMetricDbClientConnectionsTimeouts, + unitMetricDbClientConnectionsTimeouts); } /** @@ -668,48 +665,47 @@ CreateAsyncDoubleMetricDbClientConnectionsTimeoutsDeprecated(metrics::Meter *met * updowncounter */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kMetricDbClientConnectionsCountDeprecated = - "metric.db.client.connections.count.deprecated"; +static constexpr const char *kMetricDbClientConnectionsUsage = "metric.db.client.connections.usage"; OPENTELEMETRY_DEPRECATED -static constexpr const char *descrMetricDbClientConnectionsCountDeprecated = +static constexpr const char *descrMetricDbClientConnectionsUsage = "Deprecated, use `db.client.connection.count` instead."; OPENTELEMETRY_DEPRECATED -static constexpr const char *unitMetricDbClientConnectionsCountDeprecated = "{connection}"; +static constexpr const char *unitMetricDbClientConnectionsUsage = "{connection}"; OPENTELEMETRY_DEPRECATED static inline nostd::unique_ptr> -CreateSyncInt64MetricDbClientConnectionsCountDeprecated(metrics::Meter *meter) +CreateSyncInt64MetricDbClientConnectionsUsage(metrics::Meter *meter) { - return meter->CreateInt64UpDownCounter(kMetricDbClientConnectionsCountDeprecated, - descrMetricDbClientConnectionsCountDeprecated, - unitMetricDbClientConnectionsCountDeprecated); + return meter->CreateInt64UpDownCounter(kMetricDbClientConnectionsUsage, + descrMetricDbClientConnectionsUsage, + unitMetricDbClientConnectionsUsage); } OPENTELEMETRY_DEPRECATED static inline nostd::unique_ptr> -CreateSyncDoubleMetricDbClientConnectionsCountDeprecated(metrics::Meter *meter) +CreateSyncDoubleMetricDbClientConnectionsUsage(metrics::Meter *meter) { - return meter->CreateDoubleUpDownCounter(kMetricDbClientConnectionsCountDeprecated, - descrMetricDbClientConnectionsCountDeprecated, - unitMetricDbClientConnectionsCountDeprecated); + return meter->CreateDoubleUpDownCounter(kMetricDbClientConnectionsUsage, + descrMetricDbClientConnectionsUsage, + unitMetricDbClientConnectionsUsage); } OPENTELEMETRY_DEPRECATED static inline nostd::shared_ptr -CreateAsyncInt64MetricDbClientConnectionsCountDeprecated(metrics::Meter *meter) +CreateAsyncInt64MetricDbClientConnectionsUsage(metrics::Meter *meter) { - return meter->CreateInt64ObservableUpDownCounter(kMetricDbClientConnectionsCountDeprecated, - descrMetricDbClientConnectionsCountDeprecated, - unitMetricDbClientConnectionsCountDeprecated); + return meter->CreateInt64ObservableUpDownCounter(kMetricDbClientConnectionsUsage, + descrMetricDbClientConnectionsUsage, + unitMetricDbClientConnectionsUsage); } OPENTELEMETRY_DEPRECATED static inline nostd::shared_ptr -CreateAsyncDoubleMetricDbClientConnectionsCountDeprecated(metrics::Meter *meter) +CreateAsyncDoubleMetricDbClientConnectionsUsage(metrics::Meter *meter) { - return meter->CreateDoubleObservableUpDownCounter(kMetricDbClientConnectionsCountDeprecated, - descrMetricDbClientConnectionsCountDeprecated, - unitMetricDbClientConnectionsCountDeprecated); + return meter->CreateDoubleObservableUpDownCounter(kMetricDbClientConnectionsUsage, + descrMetricDbClientConnectionsUsage, + unitMetricDbClientConnectionsUsage); } /** @@ -720,31 +716,31 @@ CreateAsyncDoubleMetricDbClientConnectionsCountDeprecated(metrics::Meter *meter) * ms @endcode to @code s @endcode.

      histogram */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kMetricDbClientConnectionsUseTimeDeprecated = - "metric.db.client.connections.use_time.deprecated"; +static constexpr const char *kMetricDbClientConnectionsUseTime = + "metric.db.client.connections.use_time"; OPENTELEMETRY_DEPRECATED -static constexpr const char *descrMetricDbClientConnectionsUseTimeDeprecated = +static constexpr const char *descrMetricDbClientConnectionsUseTime = "Deprecated, use `db.client.connection.use_time` instead. Note: the unit also changed from " "`ms` to `s`."; OPENTELEMETRY_DEPRECATED -static constexpr const char *unitMetricDbClientConnectionsUseTimeDeprecated = "ms"; +static constexpr const char *unitMetricDbClientConnectionsUseTime = "ms"; OPENTELEMETRY_DEPRECATED static inline nostd::unique_ptr> -CreateSyncInt64MetricDbClientConnectionsUseTimeDeprecated(metrics::Meter *meter) +CreateSyncInt64MetricDbClientConnectionsUseTime(metrics::Meter *meter) { - return meter->CreateUInt64Histogram(kMetricDbClientConnectionsUseTimeDeprecated, - descrMetricDbClientConnectionsUseTimeDeprecated, - unitMetricDbClientConnectionsUseTimeDeprecated); + return meter->CreateUInt64Histogram(kMetricDbClientConnectionsUseTime, + descrMetricDbClientConnectionsUseTime, + unitMetricDbClientConnectionsUseTime); } OPENTELEMETRY_DEPRECATED static inline nostd::unique_ptr> -CreateSyncDoubleMetricDbClientConnectionsUseTimeDeprecated(metrics::Meter *meter) +CreateSyncDoubleMetricDbClientConnectionsUseTime(metrics::Meter *meter) { - return meter->CreateDoubleHistogram(kMetricDbClientConnectionsUseTimeDeprecated, - descrMetricDbClientConnectionsUseTimeDeprecated, - unitMetricDbClientConnectionsUseTimeDeprecated); + return meter->CreateDoubleHistogram(kMetricDbClientConnectionsUseTime, + descrMetricDbClientConnectionsUseTime, + unitMetricDbClientConnectionsUseTime); } /** @@ -755,31 +751,101 @@ CreateSyncDoubleMetricDbClientConnectionsUseTimeDeprecated(metrics::Meter *meter * ms @endcode to @code s @endcode.

      histogram */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kMetricDbClientConnectionsWaitTimeDeprecated = - "metric.db.client.connections.wait_time.deprecated"; +static constexpr const char *kMetricDbClientConnectionsWaitTime = + "metric.db.client.connections.wait_time"; OPENTELEMETRY_DEPRECATED -static constexpr const char *descrMetricDbClientConnectionsWaitTimeDeprecated = +static constexpr const char *descrMetricDbClientConnectionsWaitTime = "Deprecated, use `db.client.connection.wait_time` instead. Note: the unit also changed from " "`ms` to `s`."; OPENTELEMETRY_DEPRECATED -static constexpr const char *unitMetricDbClientConnectionsWaitTimeDeprecated = "ms"; +static constexpr const char *unitMetricDbClientConnectionsWaitTime = "ms"; OPENTELEMETRY_DEPRECATED static inline nostd::unique_ptr> -CreateSyncInt64MetricDbClientConnectionsWaitTimeDeprecated(metrics::Meter *meter) +CreateSyncInt64MetricDbClientConnectionsWaitTime(metrics::Meter *meter) { - return meter->CreateUInt64Histogram(kMetricDbClientConnectionsWaitTimeDeprecated, - descrMetricDbClientConnectionsWaitTimeDeprecated, - unitMetricDbClientConnectionsWaitTimeDeprecated); + return meter->CreateUInt64Histogram(kMetricDbClientConnectionsWaitTime, + descrMetricDbClientConnectionsWaitTime, + unitMetricDbClientConnectionsWaitTime); } OPENTELEMETRY_DEPRECATED static inline nostd::unique_ptr> -CreateSyncDoubleMetricDbClientConnectionsWaitTimeDeprecated(metrics::Meter *meter) +CreateSyncDoubleMetricDbClientConnectionsWaitTime(metrics::Meter *meter) { - return meter->CreateDoubleHistogram(kMetricDbClientConnectionsWaitTimeDeprecated, - descrMetricDbClientConnectionsWaitTimeDeprecated, - unitMetricDbClientConnectionsWaitTimeDeprecated); + return meter->CreateDoubleHistogram(kMetricDbClientConnectionsWaitTime, + descrMetricDbClientConnectionsWaitTime, + unitMetricDbClientConnectionsWaitTime); +} + +/** + * Number of active client instances + *

      + * updowncounter + */ +static constexpr const char *kMetricDbClientCosmosdbActiveInstanceCount = + "metric.db.client.cosmosdb.active_instance.count"; +static constexpr const char *descrMetricDbClientCosmosdbActiveInstanceCount = + "Number of active client instances"; +static constexpr const char *unitMetricDbClientCosmosdbActiveInstanceCount = "{instance}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientCosmosdbActiveInstanceCount(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricDbClientCosmosdbActiveInstanceCount, + descrMetricDbClientCosmosdbActiveInstanceCount, + unitMetricDbClientCosmosdbActiveInstanceCount); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientCosmosdbActiveInstanceCount(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricDbClientCosmosdbActiveInstanceCount, + descrMetricDbClientCosmosdbActiveInstanceCount, + unitMetricDbClientCosmosdbActiveInstanceCount); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricDbClientCosmosdbActiveInstanceCount(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricDbClientCosmosdbActiveInstanceCount, + descrMetricDbClientCosmosdbActiveInstanceCount, + unitMetricDbClientCosmosdbActiveInstanceCount); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricDbClientCosmosdbActiveInstanceCount(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricDbClientCosmosdbActiveInstanceCount, + descrMetricDbClientCosmosdbActiveInstanceCount, + unitMetricDbClientCosmosdbActiveInstanceCount); +} + +/** + * Request charge consumed + * by the operation

      histogram + */ +static constexpr const char *kMetricDbClientCosmosdbOperationRequestCharge = + "metric.db.client.cosmosdb.operation.request_charge"; +static constexpr const char *descrMetricDbClientCosmosdbOperationRequestCharge = + "[Request charge](https://learn.microsoft.com/azure/cosmos-db/request-units) consumed by the " + "operation"; +static constexpr const char *unitMetricDbClientCosmosdbOperationRequestCharge = "{request_unit}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientCosmosdbOperationRequestCharge(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricDbClientCosmosdbOperationRequestCharge, + descrMetricDbClientCosmosdbOperationRequestCharge, + unitMetricDbClientCosmosdbOperationRequestCharge); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientCosmosdbOperationRequestCharge(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricDbClientCosmosdbOperationRequestCharge, + descrMetricDbClientCosmosdbOperationRequestCharge, + unitMetricDbClientCosmosdbOperationRequestCharge); } /** @@ -811,6 +877,33 @@ CreateSyncDoubleMetricDbClientOperationDuration(metrics::Meter *meter) unitMetricDbClientOperationDuration); } +/** + * The actual number of records returned by the database operation. + *

      + * histogram + */ +static constexpr const char *kMetricDbClientResponseReturnedRows = + "metric.db.client.response.returned_rows"; +static constexpr const char *descrMetricDbClientResponseReturnedRows = + "The actual number of records returned by the database operation."; +static constexpr const char *unitMetricDbClientResponseReturnedRows = "{row}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientResponseReturnedRows(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricDbClientResponseReturnedRows, + descrMetricDbClientResponseReturnedRows, + unitMetricDbClientResponseReturnedRows); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientResponseReturnedRows(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricDbClientResponseReturnedRows, + descrMetricDbClientResponseReturnedRows, + unitMetricDbClientResponseReturnedRows); +} + } // namespace db } // namespace semconv OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/feature_flag_attributes.h b/api/include/opentelemetry/semconv/incubating/feature_flag_attributes.h index 3cd8b8eb2c..9616fc14e0 100644 --- a/api/include/opentelemetry/semconv/incubating/feature_flag_attributes.h +++ b/api/include/opentelemetry/semconv/incubating/feature_flag_attributes.h @@ -20,28 +20,104 @@ namespace feature_flag { /** - * The unique identifier of the feature flag. + * The unique identifier for the flag evaluation context. For example, the targeting key. + */ +static constexpr const char *kFeatureFlagContextId = "feature_flag.context.id"; + +/** + * A message explaining the nature of an error occurring during flag evaluation. + */ +static constexpr const char *kFeatureFlagEvaluationErrorMessage = + "feature_flag.evaluation.error.message"; + +/** + * The reason code which shows how a feature flag value was determined. + */ +static constexpr const char *kFeatureFlagEvaluationReason = "feature_flag.evaluation.reason"; + +/** + * The lookup key of the feature flag. */ static constexpr const char *kFeatureFlagKey = "feature_flag.key"; /** - * The name of the service provider that performs the flag evaluation. + * Identifies the feature flag provider. */ static constexpr const char *kFeatureFlagProviderName = "feature_flag.provider_name"; /** - * SHOULD be a semantic identifier for a value. If one is unavailable, a stringified version of the - * value can be used.

      A semantic identifier, commonly referred to as a variant, provides a means + * The identifier of the flag + * set to which the feature flag belongs. + */ +static constexpr const char *kFeatureFlagSetId = "feature_flag.set.id"; + +/** + * A semantic identifier for an evaluated flag value. + *

      + * A semantic identifier, commonly referred to as a variant, provides a means * for referring to a value without including the value itself. This can * provide additional context for understanding the meaning behind a value. * For example, the variant @code red @endcode maybe be used for the value @code #c05543 @endcode. - *

      - * A stringified version of the value can be used in situations where a - * semantic identifier is unavailable. String representation of the value - * should be determined by the implementer. */ static constexpr const char *kFeatureFlagVariant = "feature_flag.variant"; +/** + * The version of the ruleset used during the evaluation. This may be any stable value which + * uniquely identifies the ruleset. + */ +static constexpr const char *kFeatureFlagVersion = "feature_flag.version"; + +namespace FeatureFlagEvaluationReasonValues +{ +/** + * The resolved value is static (no dynamic evaluation). + */ +static constexpr const char *kStatic = "static"; + +/** + * The resolved value fell back to a pre-configured value (no dynamic evaluation occurred or dynamic + * evaluation yielded no result). + */ +static constexpr const char *kDefault = "default"; + +/** + * The resolved value was the result of a dynamic evaluation, such as a rule or specific + * user-targeting. + */ +static constexpr const char *kTargetingMatch = "targeting_match"; + +/** + * The resolved value was the result of pseudorandom assignment. + */ +static constexpr const char *kSplit = "split"; + +/** + * The resolved value was retrieved from cache. + */ +static constexpr const char *kCached = "cached"; + +/** + * The resolved value was the result of the flag being disabled in the management system. + */ +static constexpr const char *kDisabled = "disabled"; + +/** + * The reason for the resolved value could not be determined. + */ +static constexpr const char *kUnknown = "unknown"; + +/** + * The resolved value is non-authoritative or possibly out of date + */ +static constexpr const char *kStale = "stale"; + +/** + * The resolved value was the result of an error. + */ +static constexpr const char *kError = "error"; + +} // namespace FeatureFlagEvaluationReasonValues + } // namespace feature_flag } // namespace semconv OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/gen_ai_attributes.h b/api/include/opentelemetry/semconv/incubating/gen_ai_attributes.h index ce4a939d07..b56e98f178 100644 --- a/api/include/opentelemetry/semconv/incubating/gen_ai_attributes.h +++ b/api/include/opentelemetry/semconv/incubating/gen_ai_attributes.h @@ -40,7 +40,7 @@ static constexpr const char *kGenAiOpenaiRequestResponseFormat = static constexpr const char *kGenAiOpenaiRequestSeed = "gen_ai.openai.request.seed"; /** - * The service tier requested. May be a specific tier, detault, or auto. + * The service tier requested. May be a specific tier, default, or auto. */ static constexpr const char *kGenAiOpenaiRequestServiceTier = "gen_ai.openai.request.service_tier"; @@ -50,6 +50,12 @@ static constexpr const char *kGenAiOpenaiRequestServiceTier = "gen_ai.openai.req static constexpr const char *kGenAiOpenaiResponseServiceTier = "gen_ai.openai.response.service_tier"; +/** + * A fingerprint to track any eventual change in the Generative AI environment. + */ +static constexpr const char *kGenAiOpenaiResponseSystemFingerprint = + "gen_ai.openai.response.system_fingerprint"; + /** * The name of the operation being performed. *

      @@ -69,6 +75,14 @@ static constexpr const char *kGenAiOperationName = "gen_ai.operation.name"; OPENTELEMETRY_DEPRECATED static constexpr const char *kGenAiPrompt = "gen_ai.prompt"; +/** + * The encoding formats requested in an embeddings operation, if specified. + *

      + * In some GenAI systems the encoding formats are called embedding types. Also, some GenAI systems + * only accept a single format per request. + */ +static constexpr const char *kGenAiRequestEncodingFormats = "gen_ai.request.encoding_formats"; + /** * The frequency penalty setting for the GenAI request. */ @@ -218,6 +232,13 @@ static constexpr const char *kChat = "chat"; */ static constexpr const char *kTextCompletion = "text_completion"; +/** + * Embeddings operation such as OpenAI Create embeddings + * API + */ +static constexpr const char *kEmbeddings = "embeddings"; + } // namespace GenAiOperationNameValues namespace GenAiSystemValues @@ -242,6 +263,21 @@ static constexpr const char *kAnthropic = "anthropic"; */ static constexpr const char *kCohere = "cohere"; +/** + * Azure AI Inference + */ +static constexpr const char *kAzAiInference = "az.ai.inference"; + +/** + * IBM Watsonx AI + */ +static constexpr const char *kIbmWatsonxAi = "ibm.watsonx.ai"; + +/** + * AWS Bedrock + */ +static constexpr const char *kAwsBedrock = "aws.bedrock"; + } // namespace GenAiSystemValues namespace GenAiTokenTypeValues diff --git a/api/include/opentelemetry/semconv/incubating/geo_attributes.h b/api/include/opentelemetry/semconv/incubating/geo_attributes.h new file mode 100644 index 0000000000..b50240e228 --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/geo_attributes.h @@ -0,0 +1,102 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace geo +{ + +/** + * Two-letter code representing continent’s name. + */ +static constexpr const char *kGeoContinentCode = "geo.continent.code"; + +/** + * Two-letter ISO Country Code (ISO 3166-1 + * alpha2). + */ +static constexpr const char *kGeoCountryIsoCode = "geo.country.iso_code"; + +/** + * Locality name. Represents the name of a city, town, village, or similar populated place. + */ +static constexpr const char *kGeoLocalityName = "geo.locality.name"; + +/** + * Latitude of the geo location in WGS84. + */ +static constexpr const char *kGeoLocationLat = "geo.location.lat"; + +/** + * Longitude of the geo location in WGS84. + */ +static constexpr const char *kGeoLocationLon = "geo.location.lon"; + +/** + * Postal code associated with the location. Values appropriate for this field may also be known as + * a postcode or ZIP code and will vary widely from country to country. + */ +static constexpr const char *kGeoPostalCode = "geo.postal_code"; + +/** + * Region ISO code (ISO 3166-2). + */ +static constexpr const char *kGeoRegionIsoCode = "geo.region.iso_code"; + +namespace GeoContinentCodeValues +{ +/** + * Africa + */ +static constexpr const char *kAf = "AF"; + +/** + * Antarctica + */ +static constexpr const char *kAn = "AN"; + +/** + * Asia + */ +static constexpr const char *kAs = "AS"; + +/** + * Europe + */ +static constexpr const char *kEu = "EU"; + +/** + * North America + */ +static constexpr const char *kNa = "NA"; + +/** + * Oceania + */ +static constexpr const char *kOc = "OC"; + +/** + * South America + */ +static constexpr const char *kSa = "SA"; + +} // namespace GeoContinentCodeValues + +} // namespace geo +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/k8s_metrics.h b/api/include/opentelemetry/semconv/incubating/k8s_metrics.h index 2753ba4be1..2495f0bc70 100644 --- a/api/include/opentelemetry/semconv/incubating/k8s_metrics.h +++ b/api/include/opentelemetry/semconv/incubating/k8s_metrics.h @@ -144,6 +144,122 @@ CreateAsyncDoubleMetricK8sNodeMemoryUsage(metrics::Meter *meter) kMetricK8sNodeMemoryUsage, descrMetricK8sNodeMemoryUsage, unitMetricK8sNodeMemoryUsage); } +/** + * Node network errors + *

      + * counter + */ +static constexpr const char *kMetricK8sNodeNetworkErrors = "metric.k8s.node.network.errors"; +static constexpr const char *descrMetricK8sNodeNetworkErrors = "Node network errors"; +static constexpr const char *unitMetricK8sNodeNetworkErrors = "{error}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricK8sNodeNetworkErrors(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricK8sNodeNetworkErrors, descrMetricK8sNodeNetworkErrors, + unitMetricK8sNodeNetworkErrors); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricK8sNodeNetworkErrors(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricK8sNodeNetworkErrors, descrMetricK8sNodeNetworkErrors, + unitMetricK8sNodeNetworkErrors); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricK8sNodeNetworkErrors(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter( + kMetricK8sNodeNetworkErrors, descrMetricK8sNodeNetworkErrors, unitMetricK8sNodeNetworkErrors); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricK8sNodeNetworkErrors(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter( + kMetricK8sNodeNetworkErrors, descrMetricK8sNodeNetworkErrors, unitMetricK8sNodeNetworkErrors); +} + +/** + * Network bytes for the Node + *

      + * counter + */ +static constexpr const char *kMetricK8sNodeNetworkIo = "metric.k8s.node.network.io"; +static constexpr const char *descrMetricK8sNodeNetworkIo = "Network bytes for the Node"; +static constexpr const char *unitMetricK8sNodeNetworkIo = "By"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricK8sNodeNetworkIo( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricK8sNodeNetworkIo, descrMetricK8sNodeNetworkIo, + unitMetricK8sNodeNetworkIo); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricK8sNodeNetworkIo( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricK8sNodeNetworkIo, descrMetricK8sNodeNetworkIo, + unitMetricK8sNodeNetworkIo); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricK8sNodeNetworkIo(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricK8sNodeNetworkIo, descrMetricK8sNodeNetworkIo, + unitMetricK8sNodeNetworkIo); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricK8sNodeNetworkIo(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricK8sNodeNetworkIo, descrMetricK8sNodeNetworkIo, + unitMetricK8sNodeNetworkIo); +} + +/** + * The time the Node has been running + *

      + * Instrumentations SHOULD use a gauge with type @code double @endcode and measure uptime in seconds + * as a floating point number with the highest precision available. The actual accuracy would depend + * on the instrumentation and operating system.

      gauge + */ +static constexpr const char *kMetricK8sNodeUptime = "metric.k8s.node.uptime"; +static constexpr const char *descrMetricK8sNodeUptime = "The time the Node has been running"; +static constexpr const char *unitMetricK8sNodeUptime = "s"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricK8sNodeUptime( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricK8sNodeUptime, descrMetricK8sNodeUptime, + unitMetricK8sNodeUptime); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricK8sNodeUptime( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricK8sNodeUptime, descrMetricK8sNodeUptime, + unitMetricK8sNodeUptime); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr CreateAsyncInt64MetricK8sNodeUptime( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricK8sNodeUptime, descrMetricK8sNodeUptime, + unitMetricK8sNodeUptime); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricK8sNodeUptime( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricK8sNodeUptime, descrMetricK8sNodeUptime, + unitMetricK8sNodeUptime); +} + /** * Total CPU time consumed *

      @@ -268,6 +384,122 @@ CreateAsyncDoubleMetricK8sPodMemoryUsage(metrics::Meter *meter) unitMetricK8sPodMemoryUsage); } +/** + * Pod network errors + *

      + * counter + */ +static constexpr const char *kMetricK8sPodNetworkErrors = "metric.k8s.pod.network.errors"; +static constexpr const char *descrMetricK8sPodNetworkErrors = "Pod network errors"; +static constexpr const char *unitMetricK8sPodNetworkErrors = "{error}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricK8sPodNetworkErrors(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricK8sPodNetworkErrors, descrMetricK8sPodNetworkErrors, + unitMetricK8sPodNetworkErrors); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricK8sPodNetworkErrors( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricK8sPodNetworkErrors, descrMetricK8sPodNetworkErrors, + unitMetricK8sPodNetworkErrors); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricK8sPodNetworkErrors(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter( + kMetricK8sPodNetworkErrors, descrMetricK8sPodNetworkErrors, unitMetricK8sPodNetworkErrors); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricK8sPodNetworkErrors(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter( + kMetricK8sPodNetworkErrors, descrMetricK8sPodNetworkErrors, unitMetricK8sPodNetworkErrors); +} + +/** + * Network bytes for the Pod + *

      + * counter + */ +static constexpr const char *kMetricK8sPodNetworkIo = "metric.k8s.pod.network.io"; +static constexpr const char *descrMetricK8sPodNetworkIo = "Network bytes for the Pod"; +static constexpr const char *unitMetricK8sPodNetworkIo = "By"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricK8sPodNetworkIo( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricK8sPodNetworkIo, descrMetricK8sPodNetworkIo, + unitMetricK8sPodNetworkIo); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricK8sPodNetworkIo( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricK8sPodNetworkIo, descrMetricK8sPodNetworkIo, + unitMetricK8sPodNetworkIo); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricK8sPodNetworkIo(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricK8sPodNetworkIo, descrMetricK8sPodNetworkIo, + unitMetricK8sPodNetworkIo); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricK8sPodNetworkIo(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricK8sPodNetworkIo, descrMetricK8sPodNetworkIo, + unitMetricK8sPodNetworkIo); +} + +/** + * The time the Pod has been running + *

      + * Instrumentations SHOULD use a gauge with type @code double @endcode and measure uptime in seconds + * as a floating point number with the highest precision available. The actual accuracy would depend + * on the instrumentation and operating system.

      gauge + */ +static constexpr const char *kMetricK8sPodUptime = "metric.k8s.pod.uptime"; +static constexpr const char *descrMetricK8sPodUptime = "The time the Pod has been running"; +static constexpr const char *unitMetricK8sPodUptime = "s"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricK8sPodUptime( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricK8sPodUptime, descrMetricK8sPodUptime, + unitMetricK8sPodUptime); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricK8sPodUptime( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricK8sPodUptime, descrMetricK8sPodUptime, + unitMetricK8sPodUptime); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr CreateAsyncInt64MetricK8sPodUptime( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricK8sPodUptime, descrMetricK8sPodUptime, + unitMetricK8sPodUptime); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricK8sPodUptime( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricK8sPodUptime, descrMetricK8sPodUptime, + unitMetricK8sPodUptime); +} + } // namespace k8s } // namespace semconv OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/network_attributes.h b/api/include/opentelemetry/semconv/incubating/network_attributes.h index ea855c5735..5096937112 100644 --- a/api/include/opentelemetry/semconv/incubating/network_attributes.h +++ b/api/include/opentelemetry/semconv/incubating/network_attributes.h @@ -50,6 +50,11 @@ static constexpr const char *kNetworkConnectionSubtype = "network.connection.sub */ static constexpr const char *kNetworkConnectionType = "network.connection.type"; +/** + * The network interface name. + */ +static constexpr const char *kNetworkInterfaceName = "network.interface.name"; + /** * The network IO operation direction. */ @@ -76,7 +81,7 @@ static constexpr const char *kNetworkPeerAddress = "network.peer.address"; static constexpr const char *kNetworkPeerPort = "network.peer.port"; /** - * OSI application layer or non-OSI + * OSI application layer or non-OSI * equivalent.

      The value SHOULD be normalized to lowercase. */ static constexpr const char *kNetworkProtocolName = "network.protocol.name"; @@ -92,7 +97,7 @@ static constexpr const char *kNetworkProtocolName = "network.protocol.name"; static constexpr const char *kNetworkProtocolVersion = "network.protocol.version"; /** - * OSI transport layer or OSI transport layer or inter-process communication * method.

      The value SHOULD be normalized to lowercase.

      Consider always setting the * transport when setting a port number, since a port number is ambiguous without knowing the @@ -102,7 +107,7 @@ static constexpr const char *kNetworkProtocolVersion = "network.protocol.version static constexpr const char *kNetworkTransport = "network.transport"; /** - * OSI network layer or non-OSI equivalent. + * OSI network layer or non-OSI equivalent. *

      * The value SHOULD be normalized to lowercase. */ diff --git a/api/include/opentelemetry/semconv/incubating/process_attributes.h b/api/include/opentelemetry/semconv/incubating/process_attributes.h index de81b12c38..f211c3e41a 100644 --- a/api/include/opentelemetry/semconv/incubating/process_attributes.h +++ b/api/include/opentelemetry/semconv/incubating/process_attributes.h @@ -82,6 +82,16 @@ static constexpr const char *kProcessExecutableBuildIdGo = "process.executable.b * Profiling specific build ID for executables. See the OTel specification for Profiles for more * information. */ +static constexpr const char *kProcessExecutableBuildIdHtlhash = + "process.executable.build_id.htlhash"; + +/** + * "Deprecated, use @code process.executable.build_id.htlhash @endcode instead." + *

      + * @deprecated + * Replaced by @code process.executable.build_id.htlhash @endcode + */ +OPENTELEMETRY_DEPRECATED static constexpr const char *kProcessExecutableBuildIdProfiling = "process.executable.build_id.profiling"; @@ -119,6 +129,16 @@ static constexpr const char *kProcessGroupLeaderPid = "process.group_leader.pid" */ static constexpr const char *kProcessInteractive = "process.interactive"; +/** + * The control group associated with the process. + *

      + * Control groups (cgroups) are a kernel feature used to organize and manage process resources. This + * attribute provides the path(s) to the cgroup(s) associated with the process, which should match + * the contents of the /proc//cgroup file. + */ +static constexpr const char *kProcessLinuxCgroup = "process.linux.cgroup"; + /** * The username of the user that owns the process. */ diff --git a/api/include/opentelemetry/semconv/incubating/process_metrics.h b/api/include/opentelemetry/semconv/incubating/process_metrics.h index 5f851a2d41..a8bb4cb637 100644 --- a/api/include/opentelemetry/semconv/incubating/process_metrics.h +++ b/api/include/opentelemetry/semconv/incubating/process_metrics.h @@ -414,39 +414,43 @@ CreateAsyncDoubleMetricProcessThreadCount(metrics::Meter *meter) /** * The time the process has been running. *

      - * Instrumentations SHOULD use counter with type @code double @endcode and measure uptime with at - * least millisecond precision

      counter + * Instrumentations SHOULD use a gauge with type @code double @endcode and measure uptime in seconds + * as a floating point number with the highest precision available. The actual accuracy would depend + * on the instrumentation and operating system.

      gauge */ static constexpr const char *kMetricProcessUptime = "metric.process.uptime"; static constexpr const char *descrMetricProcessUptime = "The time the process has been running."; static constexpr const char *unitMetricProcessUptime = "s"; -static inline nostd::unique_ptr> CreateSyncInt64MetricProcessUptime( +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricProcessUptime( metrics::Meter *meter) { - return meter->CreateUInt64Counter(kMetricProcessUptime, descrMetricProcessUptime, - unitMetricProcessUptime); + return meter->CreateInt64Gauge(kMetricProcessUptime, descrMetricProcessUptime, + unitMetricProcessUptime); } -static inline nostd::unique_ptr> CreateSyncDoubleMetricProcessUptime( +static inline nostd::unique_ptr> CreateSyncDoubleMetricProcessUptime( metrics::Meter *meter) { - return meter->CreateDoubleCounter(kMetricProcessUptime, descrMetricProcessUptime, - unitMetricProcessUptime); + return meter->CreateDoubleGauge(kMetricProcessUptime, descrMetricProcessUptime, + unitMetricProcessUptime); } +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ static inline nostd::shared_ptr CreateAsyncInt64MetricProcessUptime( metrics::Meter *meter) { - return meter->CreateInt64ObservableCounter(kMetricProcessUptime, descrMetricProcessUptime, - unitMetricProcessUptime); + return meter->CreateInt64ObservableGauge(kMetricProcessUptime, descrMetricProcessUptime, + unitMetricProcessUptime); } static inline nostd::shared_ptr CreateAsyncDoubleMetricProcessUptime( metrics::Meter *meter) { - return meter->CreateDoubleObservableCounter(kMetricProcessUptime, descrMetricProcessUptime, - unitMetricProcessUptime); + return meter->CreateDoubleObservableGauge(kMetricProcessUptime, descrMetricProcessUptime, + unitMetricProcessUptime); } } // namespace process diff --git a/api/include/opentelemetry/semconv/incubating/service_attributes.h b/api/include/opentelemetry/semconv/incubating/service_attributes.h index 7582c19868..4ff3f1ab97 100644 --- a/api/include/opentelemetry/semconv/incubating/service_attributes.h +++ b/api/include/opentelemetry/semconv/incubating/service_attributes.h @@ -34,19 +34,19 @@ namespace service * 4d63009a-8d0f-11ee-aad7-4c796ed8e320 @endcode.

      UUIDs are typically recommended, as only an * opaque value for the purposes of identifying a service instance is needed. Similar to what can be * seen in the man page for the @code /etc/machine-id - * @endcode file, the underlying data, such as pod name and namespace should be treated as - * confidential, being the user's choice to expose it or not via another resource attribute.

      For - * applications running behind an application server (like unicorn), we do not recommend using one - * identifier for all processes participating in the application. Instead, it's recommended each - * division (e.g. a worker thread in unicorn) to have its own instance.id.

      It's not recommended - * for a Collector to set @code service.instance.id @endcode if it can't unambiguously determine the - * service instance that is generating that telemetry. For instance, creating an UUID based on @code - * pod.name @endcode will likely be wrong, as the Collector might not know from which container - * within that pod the telemetry originated. However, Collectors can set the @code - * service.instance.id @endcode if they can unambiguously determine the service instance for that - * telemetry. This is typically the case for scraping receivers, as they know the target address and - * port. + * href="https://www.freedesktop.org/software/systemd/man/latest/machine-id.html">@code + * /etc/machine-id @endcode file, the underlying data, such as pod name and namespace should be + * treated as confidential, being the user's choice to expose it or not via another resource + * attribute.

      For applications running behind an application server (like unicorn), we do not + * recommend using one identifier for all processes participating in the application. Instead, it's + * recommended each division (e.g. a worker thread in unicorn) to have its own instance.id.

      It's + * not recommended for a Collector to set @code service.instance.id @endcode if it can't + * unambiguously determine the service instance that is generating that telemetry. For instance, + * creating an UUID based on @code pod.name @endcode will likely be wrong, as the Collector might + * not know from which container within that pod the telemetry originated. However, Collectors can + * set the @code service.instance.id @endcode if they can unambiguously determine the service + * instance for that telemetry. This is typically the case for scraping receivers, as they know the + * target address and port. */ static constexpr const char *kServiceInstanceId = "service.instance.id"; diff --git a/api/include/opentelemetry/semconv/incubating/system_metrics.h b/api/include/opentelemetry/semconv/incubating/system_metrics.h index a23a8ae4d0..37ea70a213 100644 --- a/api/include/opentelemetry/semconv/incubating/system_metrics.h +++ b/api/include/opentelemetry/semconv/incubating/system_metrics.h @@ -1279,6 +1279,48 @@ CreateAsyncDoubleMetricSystemProcessCreated(metrics::Meter *meter) kMetricSystemProcessCreated, descrMetricSystemProcessCreated, unitMetricSystemProcessCreated); } +/** + * The time the system has been running + *

      + * Instrumentations SHOULD use a gauge with type @code double @endcode and measure uptime in seconds + * as a floating point number with the highest precision available. The actual accuracy would depend + * on the instrumentation and operating system.

      gauge + */ +static constexpr const char *kMetricSystemUptime = "metric.system.uptime"; +static constexpr const char *descrMetricSystemUptime = "The time the system has been running"; +static constexpr const char *unitMetricSystemUptime = "s"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricSystemUptime( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricSystemUptime, descrMetricSystemUptime, + unitMetricSystemUptime); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricSystemUptime( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricSystemUptime, descrMetricSystemUptime, + unitMetricSystemUptime); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr CreateAsyncInt64MetricSystemUptime( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricSystemUptime, descrMetricSystemUptime, + unitMetricSystemUptime); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricSystemUptime( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricSystemUptime, descrMetricSystemUptime, + unitMetricSystemUptime); +} + } // namespace system } // namespace semconv OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/test_attributes.h b/api/include/opentelemetry/semconv/incubating/test_attributes.h index dce482055c..228f0bb273 100644 --- a/api/include/opentelemetry/semconv/incubating/test_attributes.h +++ b/api/include/opentelemetry/semconv/incubating/test_attributes.h @@ -21,7 +21,7 @@ namespace test /** * The fully qualified human readable name of the test case. + * href="https://wikipedia.org/wiki/Test_case">test case. */ static constexpr const char *kTestCaseName = "test.case.name"; @@ -31,7 +31,7 @@ static constexpr const char *kTestCaseName = "test.case.name"; static constexpr const char *kTestCaseResultStatus = "test.case.result.status"; /** - * The human readable name of a test suite. + * The human readable name of a test suite. */ static constexpr const char *kTestSuiteName = "test.suite.name"; diff --git a/api/include/opentelemetry/semconv/incubating/url_attributes.h b/api/include/opentelemetry/semconv/incubating/url_attributes.h index fb3418e26a..781521fa03 100644 --- a/api/include/opentelemetry/semconv/incubating/url_attributes.h +++ b/api/include/opentelemetry/semconv/incubating/url_attributes.h @@ -48,14 +48,33 @@ static constexpr const char *kUrlFragment = "url.fragment"; * Absolute URL describing a network resource according to RFC3986

      For network calls, URL usually has * @code scheme://host[:port][path][?query][#fragment] @endcode format, where the fragment is not - * transmitted over HTTP, but if it is known, it SHOULD be included nevertheless. + * transmitted over HTTP, but if it is known, it SHOULD be included nevertheless.

      * @code url.full @endcode MUST NOT contain credentials passed via URL in form of @code * https://username:password@www.example.com/ @endcode. In such case username and password SHOULD be * redacted and attribute's value SHOULD be @code https://REDACTED:REDACTED@www.example.com/ - * @endcode. + * @endcode.

      * @code url.full @endcode SHOULD capture the absolute URL when it is available (or can be - * reconstructed). Sensitive content provided in @code url.full @endcode SHOULD be scrubbed when - * instrumentations can identify it. + * reconstructed).

      Sensitive content provided in @code url.full @endcode SHOULD be scrubbed when + * instrumentations can identify it.

      + * + * Query string values for the following keys SHOULD be redacted by default and replaced by the + * value @code REDACTED @endcode: + *

      + *

      + * This list is subject to change over time. + *

      + * When a query string value is redacted, the query string key SHOULD still be preserved, e.g. + * @code https://www.example.com/path?color=blue&sig=REDACTED @endcode. */ static constexpr const char *kUrlFull = "url.full"; @@ -88,7 +107,23 @@ static constexpr const char *kUrlPort = "url.port"; * The URI query component *

      * Sensitive content provided in @code url.query @endcode SHOULD be scrubbed when instrumentations - * can identify it. + * can identify it.

      + * + * Query string values for the following keys SHOULD be redacted by default and replaced by the + * value @code REDACTED @endcode:

      + * This list is subject to change over time. + *

      + * When a query string value is redacted, the query string key SHOULD still be preserved, e.g. + * @code q=OpenTelemetry&sig=REDACTED @endcode. */ static constexpr const char *kUrlQuery = "url.query"; diff --git a/api/include/opentelemetry/semconv/incubating/user_agent_attributes.h b/api/include/opentelemetry/semconv/incubating/user_agent_attributes.h index 738bb6de15..1ebffd13ec 100644 --- a/api/include/opentelemetry/semconv/incubating/user_agent_attributes.h +++ b/api/include/opentelemetry/semconv/incubating/user_agent_attributes.h @@ -35,6 +35,18 @@ static constexpr const char *kUserAgentName = "user_agent.name"; */ static constexpr const char *kUserAgentOriginal = "user_agent.original"; +/** + * Specifies the category of synthetic traffic, such as tests or bots. + *

      + * This attribute MAY be derived from the contents of the @code user_agent.original @endcode + * attribute. Components that populate the attribute are responsible for determining what they + * consider to be synthetic bot or test traffic. This attribute can either be set for + * self-identification purposes, or on telemetry detected to be generated as a result of a synthetic + * request. This attribute is useful for distinguishing between genuine client traffic and synthetic + * traffic generated by bots or tests. + */ +static constexpr const char *kUserAgentSyntheticType = "user_agent.synthetic.type"; + /** * Version of the user-agent extracted from original. Usually refers to the browser's version *

      @@ -46,6 +58,20 @@ static constexpr const char *kUserAgentOriginal = "user_agent.original"; */ static constexpr const char *kUserAgentVersion = "user_agent.version"; +namespace UserAgentSyntheticTypeValues +{ +/** + * Bot source. + */ +static constexpr const char *kBot = "bot"; + +/** + * Synthetic test source. + */ +static constexpr const char *kTest = "test"; + +} // namespace UserAgentSyntheticTypeValues + } // namespace user_agent } // namespace semconv OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/vcs_attributes.h b/api/include/opentelemetry/semconv/incubating/vcs_attributes.h index cc38902e88..b5f05d38da 100644 --- a/api/include/opentelemetry/semconv/incubating/vcs_attributes.h +++ b/api/include/opentelemetry/semconv/incubating/vcs_attributes.h @@ -20,22 +20,32 @@ namespace vcs { /** - * The ID of the change (pull request/merge request) if applicable. This is usually a unique (within - * repository) identifier generated by the VCS system. + * The ID of the change (pull request/merge request/changelist) if applicable. This is usually a + * unique (within repository) identifier generated by the VCS system. */ -static constexpr const char *kVcsRepositoryChangeId = "vcs.repository.change.id"; +static constexpr const char *kVcsChangeId = "vcs.change.id"; /** - * The human readable title of the change (pull request/merge request). This title is often a brief - * summary of the change and may get merged in to a ref as the commit summary. + * The state of the change (pull request/merge request/changelist). */ -static constexpr const char *kVcsRepositoryChangeTitle = "vcs.repository.change.title"; +static constexpr const char *kVcsChangeState = "vcs.change.state"; + +/** + * The human readable title of the change (pull request/merge request/changelist). This title is + * often a brief summary of the change and may get merged in to a ref as the commit summary. + */ +static constexpr const char *kVcsChangeTitle = "vcs.change.title"; + +/** + * The type of line change being measured on a branch or change. + */ +static constexpr const char *kVcsLineChangeType = "vcs.line_change.type"; /** * The name of the reference such as * branch or tag in the repository. */ -static constexpr const char *kVcsRepositoryRefName = "vcs.repository.ref.name"; +static constexpr const char *kVcsRefBaseName = "vcs.ref.base.name"; /** * The revision, literally revised @@ -47,24 +57,198 @@ static constexpr const char *kVcsRepositoryRefName = "vcs.repository.ref.name"; * not necessarily have to be a hash; it can simply define a * revision number * which is an integer that is monotonically increasing. In cases where - * it is identical to the @code ref.name @endcode, it SHOULD still be included. It is + * it is identical to the @code ref.base.name @endcode, it SHOULD still be included. It is * up to the implementer to decide which value to set as the revision * based on the VCS system and situational context. */ -static constexpr const char *kVcsRepositoryRefRevision = "vcs.repository.ref.revision"; +static constexpr const char *kVcsRefBaseRevision = "vcs.ref.base.revision"; + +/** + * The type of the reference in the + * repository. + */ +static constexpr const char *kVcsRefBaseType = "vcs.ref.base.type"; + +/** + * The name of the reference such as + * branch or tag in the repository. + */ +static constexpr const char *kVcsRefHeadName = "vcs.ref.head.name"; + +/** + * The revision, literally revised + * version, The revision most often refers to a commit object in Git, or a revision number in + * SVN.

      The revision can be a full hash value (see glossary), + * of the recorded change to a ref within a repository pointing to a + * commit commit object. It does + * not necessarily have to be a hash; it can simply define a + * revision number + * which is an integer that is monotonically increasing. In cases where + * it is identical to the @code ref.head.name @endcode, it SHOULD still be included. It is + * up to the implementer to decide which value to set as the revision + * based on the VCS system and situational context. + */ +static constexpr const char *kVcsRefHeadRevision = "vcs.ref.head.revision"; /** * The type of the reference in the * repository. */ +static constexpr const char *kVcsRefHeadType = "vcs.ref.head.type"; + +/** + * The type of the reference in the + * repository. + */ +static constexpr const char *kVcsRefType = "vcs.ref.type"; + +/** + * Deprecated, use @code vcs.change.id @endcode instead. + *

      + * @deprecated + * Deprecated, use @code vcs.change.id @endcode instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kVcsRepositoryChangeId = "vcs.repository.change.id"; + +/** + * Deprecated, use @code vcs.change.title @endcode instead. + *

      + * @deprecated + * Deprecated, use @code vcs.change.title @endcode instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kVcsRepositoryChangeTitle = "vcs.repository.change.title"; + +/** + * Deprecated, use @code vcs.ref.head.name @endcode instead. + *

      + * @deprecated + * Deprecated, use @code vcs.ref.head.name @endcode instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kVcsRepositoryRefName = "vcs.repository.ref.name"; + +/** + * Deprecated, use @code vcs.ref.head.revision @endcode instead. + *

      + * @deprecated + * Deprecated, use @code vcs.ref.head.revision @endcode instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kVcsRepositoryRefRevision = "vcs.repository.ref.revision"; + +/** + * Deprecated, use @code vcs.ref.head.type @endcode instead. + *

      + * @deprecated + * Deprecated, use @code vcs.ref.head.type @endcode instead. + */ +OPENTELEMETRY_DEPRECATED static constexpr const char *kVcsRepositoryRefType = "vcs.repository.ref.type"; /** - * The URL of the repository providing the complete + * The URL of the repository providing the complete * address in order to locate and identify the repository. */ static constexpr const char *kVcsRepositoryUrlFull = "vcs.repository.url.full"; +/** + * The type of revision comparison. + */ +static constexpr const char *kVcsRevisionDeltaDirection = "vcs.revision_delta.direction"; + +namespace VcsChangeStateValues +{ +/** + * Open means the change is currently active and under review. It hasn't been merged into the target + * branch yet, and it's still possible to make changes or add comments. + */ +static constexpr const char *kOpen = "open"; + +/** + * WIP (work-in-progress, draft) means the change is still in progress and not yet ready for a full + * review. It might still undergo significant changes. + */ +static constexpr const char *kWip = "wip"; + +/** + * Closed means the merge request has been closed without merging. This can happen for various + * reasons, such as the changes being deemed unnecessary, the issue being resolved in another way, + * or the author deciding to withdraw the request. + */ +static constexpr const char *kClosed = "closed"; + +/** + * Merged indicates that the change has been successfully integrated into the target codebase. + */ +static constexpr const char *kMerged = "merged"; + +} // namespace VcsChangeStateValues + +namespace VcsLineChangeTypeValues +{ +/** + * How many lines were added. + */ +static constexpr const char *kAdded = "added"; + +/** + * How many lines were removed. + */ +static constexpr const char *kRemoved = "removed"; + +} // namespace VcsLineChangeTypeValues + +namespace VcsRefBaseTypeValues +{ +/** + * branch + */ +static constexpr const char *kBranch = "branch"; + +/** + * tag + */ +static constexpr const char *kTag = "tag"; + +} // namespace VcsRefBaseTypeValues + +namespace VcsRefHeadTypeValues +{ +/** + * branch + */ +static constexpr const char *kBranch = "branch"; + +/** + * tag + */ +static constexpr const char *kTag = "tag"; + +} // namespace VcsRefHeadTypeValues + +namespace VcsRefTypeValues +{ +/** + * branch + */ +static constexpr const char *kBranch = "branch"; + +/** + * tag + */ +static constexpr const char *kTag = "tag"; + +} // namespace VcsRefTypeValues + namespace VcsRepositoryRefTypeValues { /** @@ -81,6 +265,20 @@ static constexpr const char *kTag = "tag"; } // namespace VcsRepositoryRefTypeValues +namespace VcsRevisionDeltaDirectionValues +{ +/** + * How many revisions the change is behind the target ref. + */ +static constexpr const char *kBehind = "behind"; + +/** + * How many revisions the change is ahead of the target ref. + */ +static constexpr const char *kAhead = "ahead"; + +} // namespace VcsRevisionDeltaDirectionValues + } // namespace vcs } // namespace semconv OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/incubating/vcs_metrics.h b/api/include/opentelemetry/semconv/incubating/vcs_metrics.h new file mode 100644 index 0000000000..ef5749fabe --- /dev/null +++ b/api/include/opentelemetry/semconv/incubating/vcs_metrics.h @@ -0,0 +1,394 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace vcs +{ + +/** + * The number of changes (pull requests/merge requests/changelists) in a repository, categorized by + * their state (e.g. open or merged)

      updowncounter + */ +static constexpr const char *kMetricVcsChangeCount = "metric.vcs.change.count"; +static constexpr const char *descrMetricVcsChangeCount = + "The number of changes (pull requests/merge requests/changelists) in a repository, categorized " + "by their state (e.g. open or merged)"; +static constexpr const char *unitMetricVcsChangeCount = "{change}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricVcsChangeCount(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricVcsChangeCount, descrMetricVcsChangeCount, + unitMetricVcsChangeCount); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricVcsChangeCount(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricVcsChangeCount, descrMetricVcsChangeCount, + unitMetricVcsChangeCount); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricVcsChangeCount( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricVcsChangeCount, descrMetricVcsChangeCount, + unitMetricVcsChangeCount); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricVcsChangeCount(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter( + kMetricVcsChangeCount, descrMetricVcsChangeCount, unitMetricVcsChangeCount); +} + +/** + * The time duration a change (pull request/merge request/changelist) has been in a given state. + *

      + * gauge + */ +static constexpr const char *kMetricVcsChangeDuration = "metric.vcs.change.duration"; +static constexpr const char *descrMetricVcsChangeDuration = + "The time duration a change (pull request/merge request/changelist) has been in a given state."; +static constexpr const char *unitMetricVcsChangeDuration = "s"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricVcsChangeDuration( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricVcsChangeDuration, descrMetricVcsChangeDuration, + unitMetricVcsChangeDuration); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricVcsChangeDuration( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricVcsChangeDuration, descrMetricVcsChangeDuration, + unitMetricVcsChangeDuration); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricVcsChangeDuration(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricVcsChangeDuration, descrMetricVcsChangeDuration, + unitMetricVcsChangeDuration); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricVcsChangeDuration(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricVcsChangeDuration, descrMetricVcsChangeDuration, + unitMetricVcsChangeDuration); +} + +/** + * The amount of time since its creation it took a change (pull request/merge request/changelist) to + * get the first approval

      gauge + */ +static constexpr const char *kMetricVcsChangeTimeToApproval = "metric.vcs.change.time_to_approval"; +static constexpr const char *descrMetricVcsChangeTimeToApproval = + "The amount of time since its creation it took a change (pull request/merge " + "request/changelist) to get the first approval"; +static constexpr const char *unitMetricVcsChangeTimeToApproval = "s"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> +CreateSyncInt64MetricVcsChangeTimeToApproval(metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricVcsChangeTimeToApproval, descrMetricVcsChangeTimeToApproval, + unitMetricVcsChangeTimeToApproval); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricVcsChangeTimeToApproval(metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricVcsChangeTimeToApproval, + descrMetricVcsChangeTimeToApproval, + unitMetricVcsChangeTimeToApproval); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricVcsChangeTimeToApproval(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricVcsChangeTimeToApproval, + descrMetricVcsChangeTimeToApproval, + unitMetricVcsChangeTimeToApproval); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricVcsChangeTimeToApproval(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricVcsChangeTimeToApproval, + descrMetricVcsChangeTimeToApproval, + unitMetricVcsChangeTimeToApproval); +} + +/** + * The number of unique contributors to a repository + *

      + * gauge + */ +static constexpr const char *kMetricVcsContributorCount = "metric.vcs.contributor.count"; +static constexpr const char *descrMetricVcsContributorCount = + "The number of unique contributors to a repository"; +static constexpr const char *unitMetricVcsContributorCount = "{contributor}"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricVcsContributorCount( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricVcsContributorCount, descrMetricVcsContributorCount, + unitMetricVcsContributorCount); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricVcsContributorCount( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricVcsContributorCount, descrMetricVcsContributorCount, + unitMetricVcsContributorCount); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricVcsContributorCount(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge( + kMetricVcsContributorCount, descrMetricVcsContributorCount, unitMetricVcsContributorCount); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricVcsContributorCount(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge( + kMetricVcsContributorCount, descrMetricVcsContributorCount, unitMetricVcsContributorCount); +} + +/** + * The number of refs of type branch or tag in a repository + *

      + * updowncounter + */ +static constexpr const char *kMetricVcsRefCount = "metric.vcs.ref.count"; +static constexpr const char *descrMetricVcsRefCount = + "The number of refs of type branch or tag in a repository"; +static constexpr const char *unitMetricVcsRefCount = "{ref}"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricVcsRefCount( + metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricVcsRefCount, descrMetricVcsRefCount, + unitMetricVcsRefCount); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricVcsRefCount( + metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricVcsRefCount, descrMetricVcsRefCount, + unitMetricVcsRefCount); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricVcsRefCount( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricVcsRefCount, descrMetricVcsRefCount, + unitMetricVcsRefCount); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricVcsRefCount( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricVcsRefCount, descrMetricVcsRefCount, + unitMetricVcsRefCount); +} + +/** + * The number of lines added/removed in a ref (branch) relative to the ref from the @code + * vcs.ref.base.name @endcode attribute

      This metric should be reported for each @code + * vcs.line_change.type @endcode value. For example if a ref added 3 lines and removed 2 lines, + * instrumentation SHOULD report two measurements: 3 and 2 (both positive numbers). + * If number of lines added/removed should be calculated from the start of time, then @code + * vcs.ref.base.name @endcode SHOULD be set to an empty string.

      gauge + */ +static constexpr const char *kMetricVcsRefLinesDelta = "metric.vcs.ref.lines_delta"; +static constexpr const char *descrMetricVcsRefLinesDelta = + "The number of lines added/removed in a ref (branch) relative to the ref from the " + "`vcs.ref.base.name` attribute"; +static constexpr const char *unitMetricVcsRefLinesDelta = "{line}"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricVcsRefLinesDelta( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricVcsRefLinesDelta, descrMetricVcsRefLinesDelta, + unitMetricVcsRefLinesDelta); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricVcsRefLinesDelta( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricVcsRefLinesDelta, descrMetricVcsRefLinesDelta, + unitMetricVcsRefLinesDelta); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricVcsRefLinesDelta(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricVcsRefLinesDelta, descrMetricVcsRefLinesDelta, + unitMetricVcsRefLinesDelta); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricVcsRefLinesDelta(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricVcsRefLinesDelta, descrMetricVcsRefLinesDelta, + unitMetricVcsRefLinesDelta); +} + +/** + * The number of revisions (commits) a ref (branch) is ahead/behind the branch from the @code + * vcs.ref.base.name @endcode attribute

      This metric should be reported for each @code + * vcs.revision_delta.direction @endcode value. For example if branch @code a @endcode is 3 commits + * behind and 2 commits ahead of @code trunk @endcode, instrumentation SHOULD report two + * measurements: 3 and 2 (both positive numbers) and @code vcs.ref.base.name @endcode is set to + * @code trunk @endcode.

      gauge + */ +static constexpr const char *kMetricVcsRefRevisionsDelta = "metric.vcs.ref.revisions_delta"; +static constexpr const char *descrMetricVcsRefRevisionsDelta = + "The number of revisions (commits) a ref (branch) is ahead/behind the branch from the " + "`vcs.ref.base.name` attribute"; +static constexpr const char *unitMetricVcsRefRevisionsDelta = "{revision}"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricVcsRefRevisionsDelta( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricVcsRefRevisionsDelta, descrMetricVcsRefRevisionsDelta, + unitMetricVcsRefRevisionsDelta); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricVcsRefRevisionsDelta( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricVcsRefRevisionsDelta, descrMetricVcsRefRevisionsDelta, + unitMetricVcsRefRevisionsDelta); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricVcsRefRevisionsDelta(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge( + kMetricVcsRefRevisionsDelta, descrMetricVcsRefRevisionsDelta, unitMetricVcsRefRevisionsDelta); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricVcsRefRevisionsDelta(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge( + kMetricVcsRefRevisionsDelta, descrMetricVcsRefRevisionsDelta, unitMetricVcsRefRevisionsDelta); +} + +/** + * Time a ref (branch) created from the default branch (trunk) has existed. The @code ref.type + * @endcode attribute will always be @code branch @endcode

      gauge + */ +static constexpr const char *kMetricVcsRefTime = "metric.vcs.ref.time"; +static constexpr const char *descrMetricVcsRefTime = + "Time a ref (branch) created from the default branch (trunk) has existed. The `ref.type` " + "attribute will always be `branch`"; +static constexpr const char *unitMetricVcsRefTime = "s"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricVcsRefTime( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricVcsRefTime, descrMetricVcsRefTime, unitMetricVcsRefTime); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricVcsRefTime( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricVcsRefTime, descrMetricVcsRefTime, unitMetricVcsRefTime); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr CreateAsyncInt64MetricVcsRefTime( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricVcsRefTime, descrMetricVcsRefTime, + unitMetricVcsRefTime); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricVcsRefTime( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricVcsRefTime, descrMetricVcsRefTime, + unitMetricVcsRefTime); +} + +/** + * The number of repositories in an organization + *

      + * updowncounter + */ +static constexpr const char *kMetricVcsRepositoryCount = "metric.vcs.repository.count"; +static constexpr const char *descrMetricVcsRepositoryCount = + "The number of repositories in an organization"; +static constexpr const char *unitMetricVcsRepositoryCount = "{repository}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricVcsRepositoryCount(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricVcsRepositoryCount, descrMetricVcsRepositoryCount, + unitMetricVcsRepositoryCount); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricVcsRepositoryCount(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricVcsRepositoryCount, descrMetricVcsRepositoryCount, + unitMetricVcsRepositoryCount); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricVcsRepositoryCount(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter( + kMetricVcsRepositoryCount, descrMetricVcsRepositoryCount, unitMetricVcsRepositoryCount); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricVcsRepositoryCount(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter( + kMetricVcsRepositoryCount, descrMetricVcsRepositoryCount, unitMetricVcsRepositoryCount); +} + +} // namespace vcs +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/network_attributes.h b/api/include/opentelemetry/semconv/network_attributes.h index 7e965e6a6e..832a343a66 100644 --- a/api/include/opentelemetry/semconv/network_attributes.h +++ b/api/include/opentelemetry/semconv/network_attributes.h @@ -19,6 +19,11 @@ namespace semconv namespace network { +/** + * The network interface name. + */ +static constexpr const char *kNetworkInterfaceName = "network.interface.name"; + /** * Local address of the network connection - IP address or Unix domain socket name. */ @@ -40,7 +45,7 @@ static constexpr const char *kNetworkPeerAddress = "network.peer.address"; static constexpr const char *kNetworkPeerPort = "network.peer.port"; /** - * OSI application layer or non-OSI + * OSI application layer or non-OSI * equivalent.

      The value SHOULD be normalized to lowercase. */ static constexpr const char *kNetworkProtocolName = "network.protocol.name"; @@ -56,7 +61,7 @@ static constexpr const char *kNetworkProtocolName = "network.protocol.name"; static constexpr const char *kNetworkProtocolVersion = "network.protocol.version"; /** - * OSI transport layer or OSI transport layer or inter-process communication * method.

      The value SHOULD be normalized to lowercase.

      Consider always setting the * transport when setting a port number, since a port number is ambiguous without knowing the @@ -66,7 +71,7 @@ static constexpr const char *kNetworkProtocolVersion = "network.protocol.version static constexpr const char *kNetworkTransport = "network.transport"; /** - * OSI network layer or non-OSI equivalent. + * OSI network layer or non-OSI equivalent. *

      * The value SHOULD be normalized to lowercase. */ diff --git a/api/include/opentelemetry/semconv/schema_url.h b/api/include/opentelemetry/semconv/schema_url.h index a25e28b5ea..ca35597ba4 100644 --- a/api/include/opentelemetry/semconv/schema_url.h +++ b/api/include/opentelemetry/semconv/schema_url.h @@ -19,6 +19,6 @@ namespace semconv /** * The URL of the OpenTelemetry schema for these keys and values. */ -static constexpr const char *kSchemaUrl = "https://opentelemetry.io/schemas/1.28.0"; +static constexpr const char *kSchemaUrl = "https://opentelemetry.io/schemas/1.29.0"; } // namespace semconv OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/semconv/url_attributes.h b/api/include/opentelemetry/semconv/url_attributes.h index 25ed5b03ab..9a9c2bb671 100644 --- a/api/include/opentelemetry/semconv/url_attributes.h +++ b/api/include/opentelemetry/semconv/url_attributes.h @@ -28,14 +28,33 @@ static constexpr const char *kUrlFragment = "url.fragment"; * Absolute URL describing a network resource according to RFC3986

      For network calls, URL usually has * @code scheme://host[:port][path][?query][#fragment] @endcode format, where the fragment is not - * transmitted over HTTP, but if it is known, it SHOULD be included nevertheless. + * transmitted over HTTP, but if it is known, it SHOULD be included nevertheless.

      * @code url.full @endcode MUST NOT contain credentials passed via URL in form of @code * https://username:password@www.example.com/ @endcode. In such case username and password SHOULD be * redacted and attribute's value SHOULD be @code https://REDACTED:REDACTED@www.example.com/ - * @endcode. + * @endcode.

      * @code url.full @endcode SHOULD capture the absolute URL when it is available (or can be - * reconstructed). Sensitive content provided in @code url.full @endcode SHOULD be scrubbed when - * instrumentations can identify it. + * reconstructed).

      Sensitive content provided in @code url.full @endcode SHOULD be scrubbed when + * instrumentations can identify it.

      + * + * Query string values for the following keys SHOULD be redacted by default and replaced by the + * value @code REDACTED @endcode: + *

      + *

      + * This list is subject to change over time. + *

      + * When a query string value is redacted, the query string key SHOULD still be preserved, e.g. + * @code https://www.example.com/path?color=blue&sig=REDACTED @endcode. */ static constexpr const char *kUrlFull = "url.full"; @@ -51,7 +70,23 @@ static constexpr const char *kUrlPath = "url.path"; * The URI query component *

      * Sensitive content provided in @code url.query @endcode SHOULD be scrubbed when instrumentations - * can identify it. + * can identify it.

      + * + * Query string values for the following keys SHOULD be redacted by default and replaced by the + * value @code REDACTED @endcode:

      + * This list is subject to change over time. + *

      + * When a query string value is redacted, the query string key SHOULD still be preserved, e.g. + * @code q=OpenTelemetry&sig=REDACTED @endcode. */ static constexpr const char *kUrlQuery = "url.query"; diff --git a/buildscripts/semantic-convention/generate.sh b/buildscripts/semantic-convention/generate.sh index b6fecb4459..ac9023d188 100755 --- a/buildscripts/semantic-convention/generate.sh +++ b/buildscripts/semantic-convention/generate.sh @@ -16,7 +16,7 @@ ROOT_DIR="${SCRIPT_DIR}/../../" # freeze the spec & generator tools versions to make the generation reproducible # repository: https://github.com/open-telemetry/semantic-conventions -SEMCONV_VERSION=1.28.0 +SEMCONV_VERSION=1.29.0 # repository: https://github.com/open-telemetry/weaver WEAVER_VERSION=0.10.0