Skip to content

Commit 6b9ed3d

Browse files
authored
Jaeger bazel (Linux only) (#1077)
1 parent 1e1fb8b commit 6b9ed3d

11 files changed

Lines changed: 166 additions & 17 deletions

File tree

.github/workflows/ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ jobs:
144144
key: bazel_test
145145
- name: setup
146146
run: |
147+
sudo ./ci/setup_thrift.sh dependencies_only
147148
sudo ./ci/setup_ci_environment.sh
148149
sudo ./ci/install_bazelisk.sh
149150
- name: run tests
@@ -165,6 +166,7 @@ jobs:
165166
key: bazel_valgrind
166167
- name: setup
167168
run: |
169+
sudo ./ci/setup_thrift.sh dependencies_only
168170
sudo ./ci/setup_ci_environment.sh
169171
sudo ./ci/install_bazelisk.sh
170172
- name: run tests
@@ -186,6 +188,7 @@ jobs:
186188
key: bazel_noexcept
187189
- name: setup
188190
run: |
191+
sudo ./ci/setup_thrift.sh dependencies_only
189192
sudo ./ci/setup_ci_environment.sh
190193
sudo ./ci/install_bazelisk.sh
191194
- name: run tests
@@ -207,6 +210,7 @@ jobs:
207210
key: bazel_asan
208211
- name: setup
209212
run: |
213+
sudo ./ci/setup_thrift.sh dependencies_only
210214
sudo ./ci/setup_ci_environment.sh
211215
sudo ./ci/install_bazelisk.sh
212216
- name: run tests
@@ -228,6 +232,7 @@ jobs:
228232
key: bazel_tsan
229233
- name: setup
230234
run: |
235+
sudo ./ci/setup_thrift.sh dependencies_only
231236
sudo ./ci/setup_ci_environment.sh
232237
sudo ./ci/install_bazelisk.sh
233238
- name: run tests

WORKSPACE

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,35 @@ upb_deps()
3636

3737
# Load prometheus C++ dependencies.
3838
load("@com_github_jupp0r_prometheus_cpp//bazel:repositories.bzl", "prometheus_cpp_repositories")
39+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
40+
41+
http_archive(
42+
name = "rules_foreign_cc",
43+
sha256 = "69023642d5781c68911beda769f91fcbc8ca48711db935a75da7f6536b65047f",
44+
strip_prefix = "rules_foreign_cc-0.6.0",
45+
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.6.0.tar.gz",
46+
)
47+
48+
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
49+
50+
rules_foreign_cc_dependencies()
51+
52+
_ALL_CONTENT = """\
53+
filegroup(
54+
name = "all_srcs",
55+
srcs = glob(["**"]),
56+
visibility = ["//visibility:public"],
57+
)
58+
"""
59+
60+
http_archive(
61+
name = "thrift",
62+
build_file_content = _ALL_CONTENT,
63+
sha256 = "5ae1c4d16452a22eaf9d802ba7489907147c2b316ff38c9758918552fae5132c",
64+
strip_prefix = "thrift-0.14.1",
65+
urls = [
66+
"https://github.com/apache/thrift/archive/refs/tags/v0.14.1.tar.gz",
67+
],
68+
)
3969

4070
prometheus_cpp_repositories()

ci/do_ci.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ $action = $args[0]
55

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

8-
$BAZEL_OPTIONS="--copt=-DENABLE_METRICS_PREVIEW --copt=-DENABLE_LOGS_PREVIEW"
8+
$BAZEL_OPTIONS="--copt=-DENABLE_METRICS_PREVIEW --copt=-DENABLE_LOGS_PREVIEW --build_tag_filters=-jaeger"
99
$BAZEL_TEST_OPTIONS="$BAZEL_OPTIONS --test_output=errors"
1010

1111
if (!(test-path build)) {

ci/do_ci.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ BAZEL_OPTIONS="--copt=-DENABLE_METRICS_PREVIEW --copt=-DENABLE_LOGS_PREVIEW"
2727
BAZEL_TEST_OPTIONS="$BAZEL_OPTIONS --test_output=errors"
2828

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

3333
BAZEL_STARTUP_OPTIONS="--output_user_root=$HOME/.cache/bazel"

ci/setup_thrift.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ apt install -y --no-install-recommends \
1717
libssl-dev \
1818
ninja-build
1919

20+
if [[ "$1" == "dependencies_only" ]]; then
21+
exit 0;
22+
fi
23+
2024
pushd $BUILD_DIR
2125
wget https://github.com/apache/thrift/archive/refs/tags/v${THRIFT_VERSION}.tar.gz
2226
tar -zxvf v${THRIFT_VERSION}.tar.gz

examples/jaeger/BUILD

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# TODO: enable bazel build
2-
# cc_binary(
3-
# name = "example_jaeger",
4-
# srcs = [
5-
# "main.cc",
6-
# ],
7-
# deps = [
8-
# "//examples/common/foo_library:common_foo_library",
9-
# "//api",
10-
# "//exporters/jaeger:jaeger_exporter",
11-
# "//sdk/src/trace",
12-
# ],
13-
# )
1+
cc_binary(
2+
name = "example_jaeger",
3+
srcs = [
4+
"main.cc",
5+
],
6+
tags = ["jaeger"],
7+
deps = [
8+
"//api",
9+
"//examples/common/foo_library:common_foo_library",
10+
"//exporters/jaeger:opentelemetry_exporter_jaeger_trace",
11+
"//sdk/src/trace",
12+
],
13+
)

exporters/jaeger/BUILD

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
package(default_visibility = ["//visibility:public"])
2+
3+
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")
4+
5+
cmake(
6+
name = "thrift",
7+
cache_entries = {
8+
"CMAKE_BUILD_TYPE": "Release",
9+
"BUILD_COMPILER": "OFF",
10+
"BUILD_CPP": "ON",
11+
"BUILD_LIBRARIES": "ON",
12+
"BUILD_NODEJS": "OFF",
13+
"BUILD_PYTHON": "OFF",
14+
"BUILD_JAVASCRIPT": "OFF",
15+
"BUILD_C_GLIB": "OFF",
16+
"BUILD_JAVA": "OFF",
17+
"BUILD_TESTING": "OFF",
18+
"BUILD_TUTORIALS": "OFF",
19+
"WITH_HASKELL": "OFF",
20+
"CMAKE_CXX_FLAGS": "-fexceptions",
21+
},
22+
lib_source = "@thrift//:all_srcs",
23+
out_static_libs = [
24+
"libthrift.a",
25+
"libthriftnb.a",
26+
"libthriftz.a",
27+
],
28+
tags = ["jaeger"],
29+
target_compatible_with = [
30+
"@platforms//os:linux",
31+
],
32+
)
33+
34+
cc_library(
35+
name = "jaeger_thrift_gencpp",
36+
srcs = [
37+
"thrift-gen/Agent.cpp",
38+
"thrift-gen/Collector.cpp",
39+
"thrift-gen/ZipkinCollector.cpp",
40+
"thrift-gen/jaeger_types.cpp",
41+
"thrift-gen/zipkincore_constants.cpp",
42+
"thrift-gen/zipkincore_types.cpp",
43+
],
44+
hdrs = [
45+
"thrift-gen/Agent.h",
46+
"thrift-gen/Collector.h",
47+
"thrift-gen/ZipkinCollector.h",
48+
"thrift-gen/agent_types.h",
49+
"thrift-gen/jaeger_types.h",
50+
"thrift-gen/zipkincore_constants.h",
51+
"thrift-gen/zipkincore_types.h",
52+
],
53+
copts = ["-fexceptions"],
54+
strip_include_prefix = "thrift-gen",
55+
tags = ["jaeger"],
56+
deps = [
57+
":thrift",
58+
"//ext/src/http/client/curl:http_client_curl",
59+
],
60+
)
61+
62+
cc_library(
63+
name = "jaeger_exporter",
64+
srcs = [
65+
],
66+
hdrs = [
67+
"src/THttpTransport.h",
68+
"src/TUDPTransport.h",
69+
"src/http_transport.h",
70+
"src/sender.h",
71+
"src/thrift_sender.h",
72+
"src/transport.h",
73+
"src/udp_transport.h",
74+
],
75+
copts = ["-fexceptions"],
76+
strip_include_prefix = "src",
77+
tags = ["jaeger"],
78+
deps = [
79+
":jaeger_thrift_gencpp",
80+
],
81+
)
82+
83+
cc_library(
84+
name = "opentelemetry_exporter_jaeger_trace",
85+
srcs = [
86+
"src/THttpTransport.cc",
87+
"src/TUDPTransport.cc",
88+
"src/http_transport.cc",
89+
"src/jaeger_exporter.cc",
90+
"src/recordable.cc",
91+
"src/thrift_sender.cc",
92+
"src/udp_transport.cc",
93+
],
94+
hdrs = [
95+
"include/opentelemetry/exporters/jaeger/jaeger_exporter.h",
96+
"include/opentelemetry/exporters/jaeger/recordable.h",
97+
],
98+
copts = ["-fexceptions"],
99+
strip_include_prefix = "include",
100+
tags = ["jaeger"],
101+
deps = [
102+
":jaeger_exporter",
103+
],
104+
)

exporters/jaeger/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ below:
2727

2828
### Bazel install Instructions
2929

30-
TODO
30+
Refer to install instructions
31+
[INSTALL.md](../../INSTALL.md#building-as-standalone-bazel-project).
32+
33+
```console
34+
bazel build //exporters/jaeger:opentelemetry_exporter_jaeger_trace
35+
```
3136

3237
## Usage
3338

exporters/jaeger/src/sender.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#pragma once
55

6+
#include <opentelemetry/exporters/jaeger/recordable.h>
67
#include <opentelemetry/version.h>
78

89
OPENTELEMETRY_BEGIN_NAMESPACE

exporters/jaeger/src/thrift_sender.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
#include "thrift_sender.h"
5+
#include <opentelemetry/exporters/jaeger/recordable.h>
56
#include "udp_transport.h"
67

78
OPENTELEMETRY_BEGIN_NAMESPACE

0 commit comments

Comments
 (0)