Skip to content

Commit d0ef15c

Browse files
committed
fix sample
1 parent ae7233d commit d0ef15c

File tree

7 files changed

+215
-26
lines changed

7 files changed

+215
-26
lines changed

.bazelrc

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,8 @@ common --skip_incompatible_explicit_targets
2626
common --enable_platform_specific_config
2727
common --enable_runfiles
2828

29-
<<<<<<< HEAD
3029
build --build_tag_filters=-jaeger,-opentracing,-opentracing_shim
3130
test --test_tag_filters=-jaeger,-opentracing,-opentracing_shim
32-
=======
33-
# Make globs that don't match anything fail
34-
common --incompatible_disallow_empty_glob
35-
36-
# Needed by gRPC to build on some platforms.
37-
build --copt -DGRPC_BAZEL_BUILD
38-
>>>>>>> 9d998e33412bbff3c227fdf1a2d1403527345d0e
3931

4032
build --experimental_convenience_symlinks=clean
4133

MODULE.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ module(
55
)
66

77
bazel_dep(name = "abseil-cpp", version = "20240722.0.bcr.1")
8+
single_version_override(
9+
module_name = "abseil-cpp",
10+
patch_strip = 1,
11+
patches = [
12+
"bazel/absl_win10_cache_zone.diff",
13+
],
14+
)
815
bazel_dep(name = "aspect_bazel_lib", version = "2.9.4")
916
bazel_dep(name = "bazel_skylib", version = "1.7.1")
1017
bazel_dep(name = "boringssl", version = "0.20241024.0")

bazel/absl_win10_cache_zone.diff

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
diff --git a/absl/time/internal/cctz/src/time_zone_lookup.cc b/absl/time/internal/cctz/src/time_zone_lookup.cc
2+
index 989a5640..b6efe030 100644
3+
--- a/absl/time/internal/cctz/src/time_zone_lookup.cc
4+
+++ b/absl/time/internal/cctz/src/time_zone_lookup.cc
5+
@@ -67,7 +67,7 @@ namespace {
6+
#if defined(USE_WIN32_LOCAL_TIME_ZONE)
7+
// Calls the WinRT Calendar.GetTimeZone method to obtain the IANA ID of the
8+
// local time zone. Returns an empty vector in case of an error.
9+
-std::string win32_local_time_zone(const HMODULE combase) {
10+
+static std::string win32_local_time_zone(const HMODULE combase) {
11+
std::string result;
12+
const auto ro_activate_instance =
13+
reinterpret_cast<decltype(&RoActivateInstance)>(
14+
@@ -138,6 +138,43 @@ std::string win32_local_time_zone(const HMODULE combase) {
15+
calendar->Release();
16+
return result;
17+
}
18+
+
19+
+static std::string get_once_win32_local_time_zone() {
20+
+ // Use the WinRT Calendar class to get the local time zone. This feature is
21+
+ // available on Windows 10 and later. The library is dynamically linked to
22+
+ // maintain binary compatibility with Windows XP - Windows 7. On Windows 8,
23+
+ // The combase.dll API functions are available but the RoActivateInstance
24+
+ // call will fail for the Calendar class.
25+
+ std::string winrt_tz;
26+
+ const HMODULE combase =
27+
+ LoadLibraryEx(_T("combase.dll"), nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
28+
+ if (combase) {
29+
+ const auto ro_initialize = reinterpret_cast<decltype(&::RoInitialize)>(
30+
+ GetProcAddress(combase, "RoInitialize"));
31+
+ const auto ro_uninitialize = reinterpret_cast<decltype(&::RoUninitialize)>(
32+
+ GetProcAddress(combase, "RoUninitialize"));
33+
+ if (ro_initialize && ro_uninitialize) {
34+
+ const HRESULT hr = ro_initialize(RO_INIT_MULTITHREADED);
35+
+ // RPC_E_CHANGED_MODE means that a previous RoInitialize call specified
36+
+ // a different concurrency model. The WinRT runtime is initialized and
37+
+ // should work for our purpose here, but we should *not* call
38+
+ // RoUninitialize because it's a failure.
39+
+ if (SUCCEEDED(hr) || hr == RPC_E_CHANGED_MODE) {
40+
+ winrt_tz = win32_local_time_zone(combase);
41+
+ if (SUCCEEDED(hr)) {
42+
+ ro_uninitialize();
43+
+ }
44+
+ }
45+
+ }
46+
+ FreeLibrary(combase);
47+
+ }
48+
+ return winrt_tz;
49+
+}
50+
+
51+
+static std::string& cached_win32_local_time_zone() {
52+
+ static std::string cached_time_zone = get_once_win32_local_time_zone();
53+
+ return cached_time_zone;
54+
+}
55+
#endif
56+
} // namespace
57+
58+
@@ -256,34 +293,7 @@ time_zone local_time_zone() {
59+
}
60+
#endif
61+
#if defined(USE_WIN32_LOCAL_TIME_ZONE)
62+
- // Use the WinRT Calendar class to get the local time zone. This feature is
63+
- // available on Windows 10 and later. The library is dynamically linked to
64+
- // maintain binary compatibility with Windows XP - Windows 7. On Windows 8,
65+
- // The combase.dll API functions are available but the RoActivateInstance
66+
- // call will fail for the Calendar class.
67+
- std::string winrt_tz;
68+
- const HMODULE combase =
69+
- LoadLibraryEx(_T("combase.dll"), nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
70+
- if (combase) {
71+
- const auto ro_initialize = reinterpret_cast<decltype(&::RoInitialize)>(
72+
- GetProcAddress(combase, "RoInitialize"));
73+
- const auto ro_uninitialize = reinterpret_cast<decltype(&::RoUninitialize)>(
74+
- GetProcAddress(combase, "RoUninitialize"));
75+
- if (ro_initialize && ro_uninitialize) {
76+
- const HRESULT hr = ro_initialize(RO_INIT_MULTITHREADED);
77+
- // RPC_E_CHANGED_MODE means that a previous RoInitialize call specified
78+
- // a different concurrency model. The WinRT runtime is initialized and
79+
- // should work for our purpose here, but we should *not* call
80+
- // RoUninitialize because it's a failure.
81+
- if (SUCCEEDED(hr) || hr == RPC_E_CHANGED_MODE) {
82+
- winrt_tz = win32_local_time_zone(combase);
83+
- if (SUCCEEDED(hr)) {
84+
- ro_uninitialize();
85+
- }
86+
- }
87+
- }
88+
- FreeLibrary(combase);
89+
- }
90+
+ std::string winrt_tz = cached_win32_local_time_zone();
91+
if (!winrt_tz.empty()) {
92+
zone = winrt_tz.c_str();
93+
}

x/.bazelrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ build --@otel_sdk//:with_dll=true
33
try-import %workspace%/../../top.bazelrc
44
test --test_output=streamed
55

6-
common:devenv --run_under='"C:/Program Files/Microsoft Visual Studio/2022/Enterprise/Common7/IDE/devenv.exe" /debugexe '
7-
test:devenv --run_under='"C:/Program Files/Microsoft Visual Studio/2022/Enterprise/Common7/IDE/devenv.exe" /debugexe '
6+
common:devenv --run_under='"c:/windows/system32/cmd.exe" /c start /wait devenv /debugexe '
7+
test:devenv --run_under='"c:/windows/system32/cmd.exe" /c start /wait devenv /debugexe '

x/MODULE.bazel

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@ local_path_override(
88
module_name = "otel_sdk",
99
path = "..",
1010
)
11-
1211
bazel_dep(name = "abseil-cpp", version = "20240722.0.bcr.1")
12+
single_version_override(
13+
module_name = "abseil-cpp",
14+
patch_strip = 1,
15+
patches = [
16+
"bazel/absl_win10_cache_zone.diff",
17+
],
18+
)
1319
bazel_dep(name = "aspect_bazel_lib", version = "2.9.4")
1420
bazel_dep(name = "bazel_skylib", version = "1.7.1")
1521
# Below is needed as we have "build --@curl//:use_mbedtls=true" from ..\.bazelrc

x/bazel/absl_win10_cache_zone.diff

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
diff --git a/absl/time/internal/cctz/src/time_zone_lookup.cc b/absl/time/internal/cctz/src/time_zone_lookup.cc
2+
index 989a5640..b6efe030 100644
3+
--- a/absl/time/internal/cctz/src/time_zone_lookup.cc
4+
+++ b/absl/time/internal/cctz/src/time_zone_lookup.cc
5+
@@ -67,7 +67,7 @@ namespace {
6+
#if defined(USE_WIN32_LOCAL_TIME_ZONE)
7+
// Calls the WinRT Calendar.GetTimeZone method to obtain the IANA ID of the
8+
// local time zone. Returns an empty vector in case of an error.
9+
-std::string win32_local_time_zone(const HMODULE combase) {
10+
+static std::string win32_local_time_zone(const HMODULE combase) {
11+
std::string result;
12+
const auto ro_activate_instance =
13+
reinterpret_cast<decltype(&RoActivateInstance)>(
14+
@@ -138,6 +138,43 @@ std::string win32_local_time_zone(const HMODULE combase) {
15+
calendar->Release();
16+
return result;
17+
}
18+
+
19+
+static std::string get_once_win32_local_time_zone() {
20+
+ // Use the WinRT Calendar class to get the local time zone. This feature is
21+
+ // available on Windows 10 and later. The library is dynamically linked to
22+
+ // maintain binary compatibility with Windows XP - Windows 7. On Windows 8,
23+
+ // The combase.dll API functions are available but the RoActivateInstance
24+
+ // call will fail for the Calendar class.
25+
+ std::string winrt_tz;
26+
+ const HMODULE combase =
27+
+ LoadLibraryEx(_T("combase.dll"), nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
28+
+ if (combase) {
29+
+ const auto ro_initialize = reinterpret_cast<decltype(&::RoInitialize)>(
30+
+ GetProcAddress(combase, "RoInitialize"));
31+
+ const auto ro_uninitialize = reinterpret_cast<decltype(&::RoUninitialize)>(
32+
+ GetProcAddress(combase, "RoUninitialize"));
33+
+ if (ro_initialize && ro_uninitialize) {
34+
+ const HRESULT hr = ro_initialize(RO_INIT_MULTITHREADED);
35+
+ // RPC_E_CHANGED_MODE means that a previous RoInitialize call specified
36+
+ // a different concurrency model. The WinRT runtime is initialized and
37+
+ // should work for our purpose here, but we should *not* call
38+
+ // RoUninitialize because it's a failure.
39+
+ if (SUCCEEDED(hr) || hr == RPC_E_CHANGED_MODE) {
40+
+ winrt_tz = win32_local_time_zone(combase);
41+
+ if (SUCCEEDED(hr)) {
42+
+ ro_uninitialize();
43+
+ }
44+
+ }
45+
+ }
46+
+ FreeLibrary(combase);
47+
+ }
48+
+ return winrt_tz;
49+
+}
50+
+
51+
+static std::string& cached_win32_local_time_zone() {
52+
+ static std::string cached_time_zone = get_once_win32_local_time_zone();
53+
+ return cached_time_zone;
54+
+}
55+
#endif
56+
} // namespace
57+
58+
@@ -256,34 +293,7 @@ time_zone local_time_zone() {
59+
}
60+
#endif
61+
#if defined(USE_WIN32_LOCAL_TIME_ZONE)
62+
- // Use the WinRT Calendar class to get the local time zone. This feature is
63+
- // available on Windows 10 and later. The library is dynamically linked to
64+
- // maintain binary compatibility with Windows XP - Windows 7. On Windows 8,
65+
- // The combase.dll API functions are available but the RoActivateInstance
66+
- // call will fail for the Calendar class.
67+
- std::string winrt_tz;
68+
- const HMODULE combase =
69+
- LoadLibraryEx(_T("combase.dll"), nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
70+
- if (combase) {
71+
- const auto ro_initialize = reinterpret_cast<decltype(&::RoInitialize)>(
72+
- GetProcAddress(combase, "RoInitialize"));
73+
- const auto ro_uninitialize = reinterpret_cast<decltype(&::RoUninitialize)>(
74+
- GetProcAddress(combase, "RoUninitialize"));
75+
- if (ro_initialize && ro_uninitialize) {
76+
- const HRESULT hr = ro_initialize(RO_INIT_MULTITHREADED);
77+
- // RPC_E_CHANGED_MODE means that a previous RoInitialize call specified
78+
- // a different concurrency model. The WinRT runtime is initialized and
79+
- // should work for our purpose here, but we should *not* call
80+
- // RoUninitialize because it's a failure.
81+
- if (SUCCEEDED(hr) || hr == RPC_E_CHANGED_MODE) {
82+
- winrt_tz = win32_local_time_zone(combase);
83+
- if (SUCCEEDED(hr)) {
84+
- ro_uninitialize();
85+
- }
86+
- }
87+
- }
88+
- FreeLibrary(combase);
89+
- }
90+
+ std::string winrt_tz = cached_win32_local_time_zone();
91+
if (!winrt_tz.empty()) {
92+
zone = winrt_tz.c_str();
93+
}

x/x.cpp

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -439,23 +439,21 @@ int main(int argc, const char *argv[])
439439
{
440440
using namespace opentelemetry::sdk::common::internal_log;
441441
GlobalLogHandler::SetLogLevel(LogLevel::None);
442-
GlobalLogHandler::SetLogLevel(LogLevel::Debug);
442+
// GlobalLogHandler::SetLogLevel(LogLevel::Debug);
443443
}
444444

445-
proxy_thread p0("127.0.0.1:4317", "unix://p/1");
446-
// proxy_thread p1("unix:q:/p/m/opentelemetry-cpp/1.sock", "unix:q:/p/m/opentelemetry-cpp/2.sock");
447-
// proxy_thread p2("unix:q:/p/m/opentelemetry-cpp/2.sock", "unix:q:/p/m/opentelemetry-cpp/3.sock");
448-
// proxy_thread p1("127.0.0.1:43170", "127.0.0.1:43171");
449-
// proxy_thread p2("127.0.0.1:43171", "127.0.0.1:43172");
450-
// proxy_thread p3("127.0.0.1:43172", "127.0.0.1:43173");
451-
// proxy_thread p4("127.0.0.1:43173", "127.0.0.1:43174");
452-
// proxy_thread p5("127.0.0.1:43174", "127.0.0.1:43175");
453-
// proxy_thread p6("127.0.0.1:43175", "127.0.0.1:43176");
454-
// proxy_thread p7("127.0.0.1:43176", "127.0.0.1:43177");
455-
// proxy_thread p8("127.0.0.1:43177", "127.0.0.1:43178");
456-
// proxy_thread p9("127.0.0.1:43178", "127.0.0.1:43179");
457-
// proxy_thread pA("127.0.0.1:43179", opentelemetry::exporter::otlp::GetOtlpDefaultGrpcEndpoint());
458-
//pA.proxy->SetActive( false );
445+
proxy_thread p0("127.0.0.1:4317", "127.0.0.1:43170");
446+
proxy_thread p1("127.0.0.1:43170", "127.0.0.1:43171");
447+
proxy_thread p2("127.0.0.1:43171", "127.0.0.1:43172");
448+
proxy_thread p3("127.0.0.1:43172", "127.0.0.1:43173");
449+
proxy_thread p4("127.0.0.1:43173", "127.0.0.1:43174");
450+
proxy_thread p5("127.0.0.1:43174", "127.0.0.1:43175");
451+
proxy_thread p6("127.0.0.1:43175", "127.0.0.1:43176");
452+
proxy_thread p7("127.0.0.1:43176", "127.0.0.1:43177");
453+
proxy_thread p8("127.0.0.1:43177", "127.0.0.1:43178");
454+
proxy_thread p9("127.0.0.1:43178", "127.0.0.1:43179");
455+
proxy_thread pA("127.0.0.1:43179", opentelemetry::exporter::otlp::GetOtlpDefaultGrpcEndpoint());
456+
pA.proxy->SetActive( false );
459457

460458
{
461459
using namespace opentelemetry::sdk::common;

0 commit comments

Comments
 (0)