Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Legacy gRPC e2e C++11 CI #1787

Closed
wants to merge 13 commits into from
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
third_party
tools
out
examples/e2e
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,27 @@ jobs:
- name: run tests
run: ./ci/do_ci.sh bazel.tsan

bazel_e2e:
name: Bazel e2e gRPC C++11
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Mount Bazel Cache
uses: actions/cache@v3
env:
cache-name: bazel_cache
with:
path: /home/runner/.cache/bazel
key: bazel_tsan
- name: setup
run: |
sudo ./ci/setup_ci_environment.sh
sudo ./ci/install_bazelisk.sh
- name: run tests
run: ./ci/do_ci.sh bazel.e2e

bazel_osx:
name: Bazel on MacOS
runs-on: macos-latest
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@

tags
.cache/clangd/*

e2e/bazel-*
5 changes: 5 additions & 0 deletions examples/e2e/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# bazelrc file

build --cxxopt='-std=c++11'
build --action_env=GRPC_BAZEL_RUNTIME=1
build --define=use_fast_cpp_protos=true
12 changes: 12 additions & 0 deletions examples/e2e/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cc_binary(
name = "e2e_example_otlp_grpc",
srcs = [
"grpc_main.cc",
],
deps = [
"@io_opentelemetry_cpp//api",
"@io_opentelemetry_cpp//examples/common/foo_library:common_foo_library",
"@io_opentelemetry_cpp//exporters/otlp:otlp_grpc_exporter",
"@io_opentelemetry_cpp//sdk/src/trace",
],
)
36 changes: 36 additions & 0 deletions examples/e2e/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
workspace(name = "otel_e2e")

load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, cleaned.

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

http_archive(
name = "io_opentelemetry_cpp",
repo_mapping = {
"@com_github_grpc_grpc": "@com_github_grpc_grpc_latest11",
},
strip_prefix = "opentelemetry-cpp-grpc_e2e",
urls = [
"https:/esigo/opentelemetry-cpp/archive/grpc_e2e.zip",
],
)

# Load OpenTelemetry dependencies after load.
load("@io_opentelemetry_cpp//bazel:repository.bzl", "opentelemetry_cpp_deps")

opentelemetry_cpp_deps()

# Load gRPC dependencies after load.
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")

grpc_deps()

# Load extra gRPC dependencies due to https:/grpc/grpc/issues/20511
load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")

grpc_extra_deps()

load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", "cc_grpc_library")
load("@upb//bazel:workspace_deps.bzl", "upb_deps")

upb_deps()
50 changes: 50 additions & 0 deletions examples/e2e/grpc_main.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#include "opentelemetry/exporters/otlp/otlp_grpc_exporter_factory.h"
#include "opentelemetry/sdk/trace/simple_processor_factory.h"
#include "opentelemetry/sdk/trace/tracer_provider_factory.h"
#include "opentelemetry/trace/provider.h"

#ifdef BAZEL_BUILD
# include "examples/common/foo_library/foo_library.h"
#else
# include "foo_library/foo_library.h"
#endif

namespace trace = opentelemetry::trace;
namespace nostd = opentelemetry::nostd;
namespace trace_sdk = opentelemetry::sdk::trace;
namespace otlp = opentelemetry::exporter::otlp;

namespace
{
opentelemetry::exporter::otlp::OtlpGrpcExporterOptions opts;
void InitTracer()
{
// Create OTLP exporter instance
auto exporter = otlp::OtlpGrpcExporterFactory::Create(opts);
auto processor = trace_sdk::SimpleSpanProcessorFactory::Create(std::move(exporter));
std::shared_ptr<opentelemetry::trace::TracerProvider> provider =
trace_sdk::TracerProviderFactory::Create(std::move(processor));
// Set the global trace provider
trace::Provider::SetTracerProvider(provider);
}
} // namespace

int main(int argc, char *argv[])
{
if (argc > 1)
{
opts.endpoint = argv[1];
if (argc > 2)
{
opts.use_ssl_credentials = true;
opts.ssl_credentials_cacert_path = argv[2];
}
}
// Removing this line will leave the default noop TracerProvider in place.
InitTracer();

foo_library();
}