Skip to content

Commit

Permalink
Jaeger bazel (Linux only) (#1077)
Browse files Browse the repository at this point in the history
  • Loading branch information
esigo authored Nov 25, 2021
1 parent 1e1fb8b commit 6b9ed3d
Show file tree
Hide file tree
Showing 11 changed files with 166 additions and 17 deletions.
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")

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

0 comments on commit 6b9ed3d

Please sign in to comment.