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

Jaeger bazel (Linux only) #1077

Merged
merged 12 commits into from
Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ jobs:
key: bazel_test
- name: setup
run: |
sudo ./ci/setup_thrift.sh dependencies_only
sudo ./ci/setup_ci_environment.sh
sudo ./ci/install_bazelisk.sh
- name: run tests
Expand All @@ -165,6 +166,7 @@ jobs:
key: bazel_valgrind
- name: setup
run: |
sudo ./ci/setup_thrift.sh dependencies_only
sudo ./ci/setup_ci_environment.sh
sudo ./ci/install_bazelisk.sh
- name: run tests
Expand All @@ -186,6 +188,7 @@ jobs:
key: bazel_noexcept
- name: setup
run: |
sudo ./ci/setup_thrift.sh dependencies_only
sudo ./ci/setup_ci_environment.sh
sudo ./ci/install_bazelisk.sh
- name: run tests
Expand All @@ -207,6 +210,7 @@ jobs:
key: bazel_asan
- name: setup
run: |
sudo ./ci/setup_thrift.sh dependencies_only
sudo ./ci/setup_ci_environment.sh
sudo ./ci/install_bazelisk.sh
- name: run tests
Expand All @@ -228,6 +232,7 @@ jobs:
key: bazel_tsan
- name: setup
run: |
sudo ./ci/setup_thrift.sh dependencies_only
sudo ./ci/setup_ci_environment.sh
sudo ./ci/install_bazelisk.sh
- name: run tests
Expand Down
30 changes: 30 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,35 @@ upb_deps()

# Load prometheus C++ dependencies.
load("@com_github_jupp0r_prometheus_cpp//bazel:repositories.bzl", "prometheus_cpp_repositories")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "rules_foreign_cc",
sha256 = "69023642d5781c68911beda769f91fcbc8ca48711db935a75da7f6536b65047f",
strip_prefix = "rules_foreign_cc-0.6.0",
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.6.0.tar.gz",
)

load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
Copy link
Member

@lalitb lalitb Nov 25, 2021

Choose a reason for hiding this comment

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

Can we use rules_foreign_cc to build and install boost library too - if that helps to support for Windows? Probably, we can create a github issue for Windows support, for someone to pick it up.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, I'll raise another PR for Windows support.


rules_foreign_cc_dependencies()

_ALL_CONTENT = """\
filegroup(
name = "all_srcs",
srcs = glob(["**"]),
visibility = ["//visibility:public"],
)
"""

http_archive(
name = "thrift",
build_file_content = _ALL_CONTENT,
sha256 = "5ae1c4d16452a22eaf9d802ba7489907147c2b316ff38c9758918552fae5132c",
strip_prefix = "thrift-0.14.1",
urls = [
"https://github.com/apache/thrift/archive/refs/tags/v0.14.1.tar.gz",
],
)

prometheus_cpp_repositories()
2 changes: 1 addition & 1 deletion ci/do_ci.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ $action = $args[0]

$SRC_DIR=(Get-Item -Path ".\").FullName

$BAZEL_OPTIONS="--copt=-DENABLE_METRICS_PREVIEW --copt=-DENABLE_LOGS_PREVIEW"
$BAZEL_OPTIONS="--copt=-DENABLE_METRICS_PREVIEW --copt=-DENABLE_LOGS_PREVIEW --build_tag_filters=-jaeger"
$BAZEL_TEST_OPTIONS="$BAZEL_OPTIONS --test_output=errors"

if (!(test-path build)) {
Expand Down
2 changes: 1 addition & 1 deletion ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ BAZEL_OPTIONS="--copt=-DENABLE_METRICS_PREVIEW --copt=-DENABLE_LOGS_PREVIEW"
BAZEL_TEST_OPTIONS="$BAZEL_OPTIONS --test_output=errors"

# https://github.com/bazelbuild/bazel/issues/4341
BAZEL_MACOS_OPTIONS="$BAZEL_OPRIONS --features=-supports_dynamic_linker"
BAZEL_MACOS_OPTIONS="$BAZEL_OPRIONS --features=-supports_dynamic_linker --build_tag_filters=-jaeger"
BAZEL_MACOS_TEST_OPTIONS="$BAZEL_MACOS_OPTIONS --test_output=errors"

BAZEL_STARTUP_OPTIONS="--output_user_root=$HOME/.cache/bazel"
Expand Down
4 changes: 4 additions & 0 deletions ci/setup_thrift.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ apt install -y --no-install-recommends \
libssl-dev \
ninja-build

if [[ "$1" == "dependencies_only" ]]; then
exit 0;
fi

pushd $BUILD_DIR
wget https://github.com/apache/thrift/archive/refs/tags/v${THRIFT_VERSION}.tar.gz
tar -zxvf v${THRIFT_VERSION}.tar.gz
Expand Down
26 changes: 13 additions & 13 deletions examples/jaeger/BUILD
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# TODO: enable bazel build
# cc_binary(
# name = "example_jaeger",
# srcs = [
# "main.cc",
# ],
# deps = [
# "//examples/common/foo_library:common_foo_library",
# "//api",
# "//exporters/jaeger:jaeger_exporter",
# "//sdk/src/trace",
# ],
# )
cc_binary(
name = "example_jaeger",
srcs = [
"main.cc",
],
tags = ["jaeger"],
deps = [
"//api",
"//examples/common/foo_library:common_foo_library",
"//exporters/jaeger:opentelemetry_exporter_jaeger_trace",
"//sdk/src/trace",
],
)
104 changes: 104 additions & 0 deletions exporters/jaeger/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package(default_visibility = ["//visibility:public"])

load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")

cmake(
name = "thrift",
cache_entries = {
"CMAKE_BUILD_TYPE": "Release",
"BUILD_COMPILER": "OFF",
"BUILD_CPP": "ON",
"BUILD_LIBRARIES": "ON",
"BUILD_NODEJS": "OFF",
"BUILD_PYTHON": "OFF",
"BUILD_JAVASCRIPT": "OFF",
"BUILD_C_GLIB": "OFF",
"BUILD_JAVA": "OFF",
"BUILD_TESTING": "OFF",
"BUILD_TUTORIALS": "OFF",
"WITH_HASKELL": "OFF",
"CMAKE_CXX_FLAGS": "-fexceptions",
},
lib_source = "@thrift//:all_srcs",
out_static_libs = [
"libthrift.a",
"libthriftnb.a",
"libthriftz.a",
],
tags = ["jaeger"],
target_compatible_with = [
"@platforms//os:linux",
],
)

cc_library(
name = "jaeger_thrift_gencpp",
srcs = [
"thrift-gen/Agent.cpp",
"thrift-gen/Collector.cpp",
"thrift-gen/ZipkinCollector.cpp",
"thrift-gen/jaeger_types.cpp",
"thrift-gen/zipkincore_constants.cpp",
"thrift-gen/zipkincore_types.cpp",
],
hdrs = [
"thrift-gen/Agent.h",
"thrift-gen/Collector.h",
"thrift-gen/ZipkinCollector.h",
"thrift-gen/agent_types.h",
"thrift-gen/jaeger_types.h",
"thrift-gen/zipkincore_constants.h",
"thrift-gen/zipkincore_types.h",
],
copts = ["-fexceptions"],
strip_include_prefix = "thrift-gen",
tags = ["jaeger"],
deps = [
":thrift",
"//ext/src/http/client/curl:http_client_curl",
],
)

cc_library(
name = "jaeger_exporter",
srcs = [
],
hdrs = [
"src/THttpTransport.h",
"src/TUDPTransport.h",
"src/http_transport.h",
"src/sender.h",
"src/thrift_sender.h",
"src/transport.h",
"src/udp_transport.h",
],
copts = ["-fexceptions"],
strip_include_prefix = "src",
tags = ["jaeger"],
deps = [
":jaeger_thrift_gencpp",
],
)

cc_library(
name = "opentelemetry_exporter_jaeger_trace",
srcs = [
"src/THttpTransport.cc",
"src/TUDPTransport.cc",
"src/http_transport.cc",
"src/jaeger_exporter.cc",
"src/recordable.cc",
"src/thrift_sender.cc",
"src/udp_transport.cc",
],
hdrs = [
"include/opentelemetry/exporters/jaeger/jaeger_exporter.h",
"include/opentelemetry/exporters/jaeger/recordable.h",
],
copts = ["-fexceptions"],
strip_include_prefix = "include",
tags = ["jaeger"],
deps = [
":jaeger_exporter",
],
)
7 changes: 6 additions & 1 deletion exporters/jaeger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ below:

### Bazel install Instructions

TODO
Refer to install instructions
[INSTALL.md](../../INSTALL.md#building-as-standalone-bazel-project).

```console
bazel build //exporters/jaeger:opentelemetry_exporter_jaeger_trace
```

## Usage

Expand Down
1 change: 1 addition & 0 deletions exporters/jaeger/src/sender.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#pragma once

#include <opentelemetry/exporters/jaeger/recordable.h>
#include <opentelemetry/version.h>

OPENTELEMETRY_BEGIN_NAMESPACE
Expand Down
1 change: 1 addition & 0 deletions exporters/jaeger/src/thrift_sender.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

#include "thrift_sender.h"
#include <opentelemetry/exporters/jaeger/recordable.h>
#include "udp_transport.h"

OPENTELEMETRY_BEGIN_NAMESPACE
Expand Down
1 change: 0 additions & 1 deletion exporters/jaeger/src/thrift_sender.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <mutex>
#include <vector>

#include <opentelemetry/exporters/jaeger/recordable.h>
#include <thrift/protocol/TCompactProtocol.h>
#include <thrift/transport/TBufferTransports.h>

Expand Down