diff --git a/pkgs/by-name/op/opentelemetry-cpp/0001-Disable-tests-requiring-network-access.patch b/pkgs/by-name/op/opentelemetry-cpp/0001-Disable-tests-requiring-network-access.patch new file mode 100644 index 000000000000..067fb7f23878 --- /dev/null +++ b/pkgs/by-name/op/opentelemetry-cpp/0001-Disable-tests-requiring-network-access.patch @@ -0,0 +1,79 @@ +diff --git a/ext/test/http/curl_http_test.cc b/ext/test/http/curl_http_test.cc +index 7c66d98b..62d40f49 100644 +--- a/ext/test/http/curl_http_test.cc ++++ b/ext/test/http/curl_http_test.cc +@@ -229,7 +229,7 @@ TEST_F(BasicCurlHttpTests, HttpResponse) + ASSERT_EQ(count, 4); + } + +-TEST_F(BasicCurlHttpTests, SendGetRequest) ++TEST_F(BasicCurlHttpTests, DISABLED_SendGetRequest) + { + received_requests_.clear(); + auto session_manager = http_client::HttpClientFactory::Create(); +@@ -246,7 +246,7 @@ TEST_F(BasicCurlHttpTests, SendGetRequest) + ASSERT_TRUE(handler->got_response_); + } + +-TEST_F(BasicCurlHttpTests, SendPostRequest) ++TEST_F(BasicCurlHttpTests, DISABLED_SendPostRequest) + { + received_requests_.clear(); + auto session_manager = http_client::HttpClientFactory::Create(); +@@ -325,7 +325,7 @@ TEST_F(BasicCurlHttpTests, CurlHttpOperations) + delete handler; + } + +-TEST_F(BasicCurlHttpTests, SendGetRequestSync) ++TEST_F(BasicCurlHttpTests, DISABLED_SendGetRequestSync) + { + received_requests_.clear(); + curl::HttpClientSync http_client; +@@ -336,7 +336,7 @@ TEST_F(BasicCurlHttpTests, SendGetRequestSync) + EXPECT_EQ(result.GetSessionState(), http_client::SessionState::Response); + } + +-TEST_F(BasicCurlHttpTests, SendGetRequestSyncTimeout) ++TEST_F(BasicCurlHttpTests, DISABLED_SendGetRequestSyncTimeout) + { + received_requests_.clear(); + curl::HttpClientSync http_client; +@@ -350,7 +350,7 @@ TEST_F(BasicCurlHttpTests, SendGetRequestSyncTimeout) + result.GetSessionState() == http_client::SessionState::SendFailed); + } + +-TEST_F(BasicCurlHttpTests, SendPostRequestSync) ++TEST_F(BasicCurlHttpTests, DISABLED_SendPostRequestSync) + { + received_requests_.clear(); + curl::HttpClientSync http_client; +@@ -378,7 +378,7 @@ TEST_F(BasicCurlHttpTests, GetBaseUri) + "http://127.0.0.1:31339/"); + } + +-TEST_F(BasicCurlHttpTests, SendGetRequestAsync) ++TEST_F(BasicCurlHttpTests, DISABLED_SendGetRequestAsync) + { + curl::HttpClient http_client; + +@@ -452,7 +452,7 @@ TEST_F(BasicCurlHttpTests, SendGetRequestAsyncTimeout) + } + } + +-TEST_F(BasicCurlHttpTests, SendPostRequestAsync) ++TEST_F(BasicCurlHttpTests, DISABLED_SendPostRequestAsync) + { + curl::HttpClient http_client; + +@@ -491,7 +491,7 @@ TEST_F(BasicCurlHttpTests, SendPostRequestAsync) + } + } + +-TEST_F(BasicCurlHttpTests, FinishInAsyncCallback) ++TEST_F(BasicCurlHttpTests, DISABLED_FinishInAsyncCallback) + { + curl::HttpClient http_client; + +-- +2.40.1 + diff --git a/pkgs/by-name/op/opentelemetry-cpp/0002-Disable-segfaulting-test-on-Darwin.patch b/pkgs/by-name/op/opentelemetry-cpp/0002-Disable-segfaulting-test-on-Darwin.patch new file mode 100644 index 000000000000..84c125b8b96e --- /dev/null +++ b/pkgs/by-name/op/opentelemetry-cpp/0002-Disable-segfaulting-test-on-Darwin.patch @@ -0,0 +1,16 @@ +diff --git a/api/test/singleton/singleton_test.cc b/api/test/singleton/singleton_test.cc +index 187e26f..ddbe29f 100644 +--- a/api/test/singleton/singleton_test.cc ++++ b/api/test/singleton/singleton_test.cc +@@ -306,7 +306,7 @@ void cleanup_otel() + trace_api::Provider::SetTracerProvider(provider); + } + +-TEST(SingletonTest, Uniqueness) ++TEST(SingletonTest, DISABLED_Uniqueness) + { + do_something(); + +-- +2.42.0 + diff --git a/pkgs/by-name/op/opentelemetry-cpp/package.nix b/pkgs/by-name/op/opentelemetry-cpp/package.nix new file mode 100644 index 000000000000..5bc1a46ad6ce --- /dev/null +++ b/pkgs/by-name/op/opentelemetry-cpp/package.nix @@ -0,0 +1,79 @@ +{ lib +, stdenv +, fetchFromGitHub +, cmake +, gtest +, protobuf +, curl +, grpc +, prometheus-cpp +, nlohmann_json +, nix-update-script +}: + +let + opentelemetry-proto = fetchFromGitHub { + owner = "open-telemetry"; + repo = "opentelemetry-proto"; + rev = "v1.0.0"; + hash = "sha256-1IylAZs8gElpruSX52A+ZopU8jXH/MjRE+FQV3gQ+Gk="; + }; +in +stdenv.mkDerivation (finalAttrs: { + pname = "opentelemetry-cpp"; + version = "1.13.0"; + + src = fetchFromGitHub { + owner = "open-telemetry"; + repo = "opentelemetry-cpp"; + rev = "v${finalAttrs.version}"; + hash = "sha256-Tf1ZnmHavnwwvRb4Tes20LMld+w/2kRo5UErT8pHf3w="; + }; + + patches = [ + ./0001-Disable-tests-requiring-network-access.patch + ] ++ lib.optional stdenv.isDarwin ./0002-Disable-segfaulting-test-on-Darwin.patch; + + nativeBuildInputs = [ cmake ]; + + buildInputs = [ + curl + grpc + nlohmann_json + prometheus-cpp + protobuf + ]; + + doCheck = true; + + checkInputs = [ + gtest + ]; + + strictDeps = true; + + cmakeFlags = [ + "-DBUILD_SHARED_LIBS=ON" + "-DWITH_OTLP_HTTP=ON" + "-DWITH_OTLP_GRPC=ON" + "-DWITH_ABSEIL=ON" + "-DWITH_PROMETHEUS=ON" + "-DWITH_ELASTICSEARCH=ON" + "-DWITH_ZIPKIN=ON" + "-DWITH_BENCHMARK=OFF" + "-DOTELCPP_PROTO_PATH=${opentelemetry-proto}" + ]; + + outputs = [ "out" "dev" ]; + + passthru.updateScript = nix-update-script { }; + + meta = { + description = "The OpenTelemetry C++ Client Library"; + homepage = "https://github.com/open-telemetry/opentelemetry-cpp"; + license = [ lib.licenses.asl20 ]; + maintainers = with lib.maintainers; [ jfroche ]; + # https://github.com/protocolbuffers/protobuf/issues/14492 + broken = !(stdenv.buildPlatform.canExecute stdenv.hostPlatform); + }; +})