Skip to content

Commit

Permalink
- Disabled the new skyframe analysis+execution phase due to symlink p…
Browse files Browse the repository at this point in the history
…roblems encountered

- Accomodated with the upstream repo set_cxx_stdlib settings and this repo's //:with_dll
- Fixed loading of component_g/componnent_h dlls in the api/test/singleton
- removed the need of the BAZEL_BUILD for the above, and then for various #include
- Added OPENTELEMETRY_EXPOR to FilteredOrderedAttributeMap
  • Loading branch information
dstanev-atvi committed Feb 12, 2024
1 parent baed16e commit 3e5e294
Show file tree
Hide file tree
Showing 26 changed files with 79 additions and 100 deletions.
2 changes: 2 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
common --noexperimental_merged_skyframe_analysis_execution

# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0
common --nolegacy_external_runfiles
Expand Down
1 change: 1 addition & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ load("dll_deps.bzl", "force_compilation_mode")
bool_flag(
name = "with_dll",
build_setting_default = False,
visibility = ["//visibility:public"],
)

config_setting(
Expand Down
14 changes: 9 additions & 5 deletions api/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ cc_library(
name = "api",
hdrs = glob(["include/**/*.h"]),
defines = select({
":with_external_abseil": ["HAVE_ABSEIL", "OPENTELEMETRY_DLL=0"],
"//:with_dll_enabled": ["OPENTELEMETRY_DLL=-1"], # -1=dllexport, 1=dllimport, 0=static
# }) + select({
":with_external_abseil": ["HAVE_ABSEIL"],
":set_cxx_stdlib_none": [],
### automatic selection
":set_cxx_stdlib_best": ["OPENTELEMETRY_STL_VERSION=(__cplusplus/100)"],
Expand All @@ -42,7 +40,10 @@ cc_library(
":set_cxx_stdlib_2017": ["OPENTELEMETRY_STL_VERSION=2017"],
":set_cxx_stdlib_2020": ["OPENTELEMETRY_STL_VERSION=2020"],
":set_cxx_stdlib_2023": ["OPENTELEMETRY_STL_VERSION=2023"],
"//conditions:default": [],
"//:with_dll_enabled": [], # For select completeness
}) + select({
"//:with_dll_enabled": ["OPENTELEMETRY_DLL=-1"],
"//conditions:default": ["OPENTELEMETRY_DLL=0"],
}),
strip_include_prefix = "include",
tags = ["api"],
Expand Down Expand Up @@ -75,7 +76,10 @@ filegroup(

[config_setting(
name = "set_cxx_stdlib_%s" % v,
flag_values = {":with_cxx_stdlib": v},
flag_values = {
":with_cxx_stdlib": v,
"//:with_dll": "false",
},
) for v in CPP_STDLIBS]

config_setting(
Expand Down
7 changes: 5 additions & 2 deletions api/test/singleton/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

load("//:dll_deps.bzl", "dll_deps", "avoid_dll_lock")
load("//:dll_deps.bzl", "avoid_dll_lock", "dll_deps")

avoid_dll_lock()

Expand Down Expand Up @@ -171,7 +171,6 @@ cc_test(
srcs = [
"singleton_test.cc",
],
defines = ["BAZEL_BUILD"],
linkopts = [
"-ldl",
],
Expand All @@ -180,6 +179,10 @@ cc_test(
"api",
"test",
],
data = [
"component_g",
"component_h"
],
deps = dll_deps([
"component_a",
"component_b",
Expand Down
31 changes: 26 additions & 5 deletions api/test/singleton/singleton_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
Once singleton are supported for windows,
expand this test to use ::LoadLibrary, ::GetProcAddress, ::FreeLibrary
*/
#ifndef _WIN32
#ifdef _WIN32
# include <windows.h>
#else
# include <dlfcn.h>
#endif

Expand Down Expand Up @@ -49,29 +51,50 @@ void do_something()
and that the test passes in this case.
*/

#ifndef BAZEL_BUILD
/* Call do_something_in_g() */

#ifdef _WIN32
HMODULE component_g = LoadLibraryA("component_g.dll");
#else
void *component_g = dlopen("libcomponent_g.so", RTLD_NOW);
#endif
EXPECT_NE(component_g, nullptr);

#ifdef _WIN32
auto *func_g = (void (*)())GetProcAddress(component_g, "do_something_in_g");
#else
auto *func_g = (void (*)())dlsym(component_g, "do_something_in_g");
#endif
EXPECT_NE(func_g, nullptr);

(*func_g)();

#ifdef _WIN32
FreeLibrary(component_g);
#else
dlclose(component_g);
#endif

/* Call do_something_in_h() */

#ifdef _WIN32
HMODULE component_h = LoadLibraryA("component_h.dll");
#else
void *component_h = dlopen("libcomponent_h.so", RTLD_NOW);
#endif
EXPECT_NE(component_h, nullptr);

#ifdef _WIN32
auto *func_h = (void (*)())GetProcAddress(component_h, "do_something_in_h");
#else
auto *func_h = (void (*)())dlsym(component_h, "do_something_in_h");
#endif
EXPECT_NE(func_h, nullptr);

(*func_h)();

#ifdef _WIN32
FreeLibrary(component_h);
#else
dlclose(component_h);
#endif
}
Expand Down Expand Up @@ -360,14 +383,12 @@ TEST(SingletonTest, Uniqueness)
EXPECT_EQ(span_f_f1_count, 2);
EXPECT_EQ(span_f_f2_count, 1);

#ifndef BAZEL_BUILD
EXPECT_EQ(span_g_lib_count, 1);
EXPECT_EQ(span_g_f1_count, 2);
EXPECT_EQ(span_g_f2_count, 1);
EXPECT_EQ(span_h_lib_count, 1);
EXPECT_EQ(span_h_f1_count, 2);
EXPECT_EQ(span_h_f2_count, 1);
#endif

EXPECT_EQ(unknown_span_count, 0);

Expand Down
2 changes: 0 additions & 2 deletions bazel/otel_cc_benchmark.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def otel_cc_benchmark(name, srcs, deps, tags = [""]):
srcs = srcs,
deps = deps + ["@com_github_google_benchmark//:benchmark"],
tags = tags + ["manual"],
defines = ["BAZEL_BUILD"],
)

# The result of running the benchmark, captured into a text file.
Expand All @@ -48,5 +47,4 @@ def otel_cc_benchmark(name, srcs, deps, tags = [""]):
deps = deps + ["@com_github_google_benchmark//:benchmark"],
args = ["--benchmark_min_time=0"],
tags = tags + ["benchmark"],
defines = ["BAZEL_BUILD"],
)
5 changes: 3 additions & 2 deletions examples/common/foo_library/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

load("//:dll_deps.bzl", "dll_deps", "avoid_dll_lock")
load("//:dll_deps.bzl", "avoid_dll_lock", "dll_deps")

avoid_dll_lock()

Expand All @@ -15,7 +15,8 @@ cc_library(
hdrs = [
"foo_library.h",
],
defines = ["BAZEL_BUILD"],
# TODO(malkia): Find out why include_prefix / strip_include_prefix do not work here!
includes = [".."],
deps = dll_deps([
"//api",
"//sdk:headers",
Expand Down
5 changes: 3 additions & 2 deletions examples/common/logs_foo_library/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

load("//:dll_deps.bzl", "dll_deps", "avoid_dll_lock")
load("//:dll_deps.bzl", "avoid_dll_lock", "dll_deps")

avoid_dll_lock()

Expand All @@ -15,7 +15,8 @@ cc_library(
hdrs = [
"foo_library.h",
],
defines = ["BAZEL_BUILD"],
# TODO(malkia): Find out why include_prefix / strip_include_prefix do not work here!
includes = [".."],
deps = dll_deps([
"//api",
"//sdk:headers",
Expand Down
5 changes: 3 additions & 2 deletions examples/common/metrics_foo_library/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

load("//:dll_deps.bzl", "dll_deps", "avoid_dll_lock")
load("//:dll_deps.bzl", "avoid_dll_lock", "dll_deps")

avoid_dll_lock()

Expand All @@ -15,7 +15,8 @@ cc_library(
hdrs = [
"foo_library.h",
],
defines = ["BAZEL_BUILD"],
# TODO(malkia): Find out why include_prefix / strip_include_prefix do not work here!
includes = [".."],
deps = dll_deps([
"//api",
"//sdk:headers",
Expand Down
14 changes: 10 additions & 4 deletions examples/grpc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,24 @@ cc_proto_library(
)

cc_grpc_library(
name = "messages_cc_grpc",
name = "_messages_cc_grpc",
srcs = [":messages_proto"],
grpc_only = True,
deps = [":messages_cc_proto"],
)

# Ideally we should not need this proxy cc_library
# But neither cc_proto_library nor cc_grpc_library allow for
# include_prefix, includes or strip_include_prefix right now.
cc_library(
name = "messages_cc_grpc",
deps = [ "_messages_cc_grpc" ],
includes = ["protos"],
)

cc_library(
name = "tracer_common",
srcs = ["tracer_common.h"],
defines = ["BAZEL_BUILD"],
tags = ["ostream"],
deps = dll_deps([
"//exporters/ostream:ostream_span_exporter",
Expand All @@ -41,7 +49,6 @@ cc_binary(
srcs = [
"client.cc",
],
defines = ["BAZEL_BUILD"],
tags = ["ostream"],
deps = dll_deps([
"messages_cc_grpc",
Expand All @@ -57,7 +64,6 @@ cc_binary(
srcs = [
"server.cc",
],
defines = ["BAZEL_BUILD"],
tags = ["ostream"],
deps = dll_deps([
"messages_cc_grpc",
Expand Down
6 changes: 1 addition & 5 deletions examples/grpc/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
// ambiguity with `nostd::variant` if compiled with Visual Studio 2015. Other
// modern compilers are unaffected.
#include <grpcpp/grpcpp.h>
#ifdef BAZEL_BUILD
# include "examples/grpc/protos/messages.grpc.pb.h"
#else
# include "messages.grpc.pb.h"
#endif
#include "messages.grpc.pb.h"

#include <iostream>
#include <memory>
Expand Down
6 changes: 1 addition & 5 deletions examples/grpc/server.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#ifdef BAZEL_BUILD
# include "examples/grpc/protos/messages.grpc.pb.h"
#else
# include "messages.grpc.pb.h"
#endif
#include "messages.grpc.pb.h"

#include "opentelemetry/trace/context.h"
#include "opentelemetry/trace/semantic_conventions.h"
Expand Down
6 changes: 1 addition & 5 deletions examples/logs_simple/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
#include "opentelemetry/sdk/logs/processor.h"
#include "opentelemetry/sdk/logs/simple_log_record_processor_factory.h"

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

namespace logs_api = opentelemetry::logs;
namespace logs_sdk = opentelemetry::sdk::logs;
Expand Down
6 changes: 1 addition & 5 deletions examples/metrics_simple/metrics_ostream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
#include "opentelemetry/sdk/metrics/view/meter_selector_factory.h"
#include "opentelemetry/sdk/metrics/view/view_factory.h"

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

namespace metrics_sdk = opentelemetry::sdk::metrics;
namespace common = opentelemetry::common;
Expand Down
6 changes: 1 addition & 5 deletions examples/multi_processor/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@
#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
#include "foo_library/foo_library.h"

using opentelemetry::exporter::memory::InMemorySpanData;
namespace trace_api = opentelemetry::trace;
Expand Down
6 changes: 1 addition & 5 deletions examples/otlp/grpc_log_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@

#include <string>

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

namespace trace = opentelemetry::trace;
namespace nostd = opentelemetry::nostd;
Expand Down
6 changes: 1 addition & 5 deletions examples/otlp/grpc_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@
// destroy and shutdown exporters.It's optional to users.
#include "opentelemetry/sdk/trace/tracer_provider.h"

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

namespace trace = opentelemetry::trace;
namespace trace_sdk = opentelemetry::sdk::trace;
Expand Down
6 changes: 1 addition & 5 deletions examples/otlp/grpc_metric_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
#include <memory>
#include <thread>

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

namespace metric_sdk = opentelemetry::sdk::metrics;
namespace common = opentelemetry::common;
Expand Down
6 changes: 1 addition & 5 deletions examples/otlp/http_log_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@
#include <iostream>
#include <string>

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

namespace trace = opentelemetry::trace;
namespace otlp = opentelemetry::exporter::otlp;
Expand Down
6 changes: 1 addition & 5 deletions examples/otlp/http_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@

#include <string>

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

namespace trace = opentelemetry::trace;
namespace trace_sdk = opentelemetry::sdk::trace;
Expand Down
Loading

0 comments on commit 3e5e294

Please sign in to comment.