homebrew-core/Formula/opentelemetry-cpp.rb

85 lines
3.5 KiB
Ruby

class OpentelemetryCpp < Formula
desc "OpenTelemetry C++ Client"
homepage "https://opentelemetry.io/"
url "https://github.com/open-telemetry/opentelemetry-cpp/archive/refs/tags/v1.4.1.tar.gz"
sha256 "301b1ab74a664723560f46c29f228360aff1e2d63e930b963755ea077ae67524"
license "Apache-2.0"
revision 1
head "https://github.com/open-telemetry/opentelemetry-cpp.git", branch: "main"
bottle do
sha256 cellar: :any_skip_relocation, arm64_monterey: "797dd2e8dc4011a8487341602044f07a1f1e8d069c6ca5afc3b75f6da1207cd5"
sha256 cellar: :any_skip_relocation, arm64_big_sur: "d30f54ea0a64791e2b5a5a1e4dbaeb77075d8da2d870d46385495fac3deb00ef"
sha256 cellar: :any_skip_relocation, monterey: "beb628348c82ac410d3d24860d372bd9e4ef3a98a1cf7ef4a7383fbc0f9cc92d"
sha256 cellar: :any_skip_relocation, big_sur: "de86c7e96328713dfb8117a5e34e9f80ebddb03365e1d70d5754c5f59110a9c1"
sha256 cellar: :any_skip_relocation, catalina: "065acb15b78b698523575ebe686815a9017a4efb93703e6e90792e95ace99868"
sha256 cellar: :any_skip_relocation, x86_64_linux: "f3063d75e7860b0880a563c25bc0767d4b8d902ac9c78c72abce7567ee4c9560"
end
depends_on "cmake" => :build
depends_on "boost"
depends_on "grpc"
depends_on "nlohmann-json"
depends_on "prometheus-cpp"
depends_on "protobuf"
depends_on "thrift"
uses_from_macos "curl"
def install
system "cmake", "-S", ".", "-B", "build",
"-DCMAKE_INSTALL_RPATH=#{rpath}",
"-DBUILD_TESTING=OFF",
"-DWITH_ELASTICSEARCH=ON",
"-DWITH_EXAMPLES=OFF",
"-DWITH_JAEGER=ON",
"-DWITH_LOGS_PREVIEW=ON",
"-DWITH_METRICS_PREVIEW=ON",
"-DWITH_OTLP=ON",
"-DWITH_OTLP_GRPC=ON",
"-DWITH_OTLP_HTTP=ON",
"-DWITH_PROMETHEUS=ON",
*std_cmake_args
system "cmake", "--build", "build"
system "cmake", "--install", "build"
end
test do
(testpath/"test.cc").write <<~EOS
#include "opentelemetry/sdk/trace/simple_processor.h"
#include "opentelemetry/sdk/trace/tracer_provider.h"
#include "opentelemetry/trace/provider.h"
#include "opentelemetry/exporters/ostream/span_exporter.h"
#include "opentelemetry/exporters/otlp/otlp_recordable_utils.h"
namespace trace_api = opentelemetry::trace;
namespace trace_sdk = opentelemetry::sdk::trace;
namespace nostd = opentelemetry::nostd;
int main()
{
auto exporter = std::unique_ptr<trace_sdk::SpanExporter>(
new opentelemetry::exporter::trace::OStreamSpanExporter);
auto processor = std::unique_ptr<trace_sdk::SpanProcessor>(
new trace_sdk::SimpleSpanProcessor(std::move(exporter)));
auto provider = nostd::shared_ptr<trace_api::TracerProvider>(
new trace_sdk::TracerProvider(std::move(processor)));
// Set the global trace provider
trace_api::Provider::SetTracerProvider(provider);
auto tracer = provider->GetTracer("library", OPENTELEMETRY_SDK_VERSION);
auto scoped_span = trace_api::Scope(tracer->StartSpan("test"));
}
EOS
system ENV.cxx, "test.cc", "-std=c++11", "-I#{include}", "-L#{lib}",
"-lopentelemetry_resources",
"-lopentelemetry_trace",
"-lopentelemetry_exporter_ostream_span",
"-lopentelemetry_common",
"-pthread",
"-o", "simple-example"
system "./simple-example"
end
end