Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ jobs:
- name: setup
run: |
./ci/setup_windows_ci_environment.ps1
- name: verify windows deprecation behavior
run: ./ci/check_windows_event_api_deprecation.ps1
- name: run tests
run: ./ci/do_ci.ps1 cmake.maintainer.test

Expand All @@ -359,6 +361,8 @@ jobs:
- name: setup
run: |
./ci/setup_windows_ci_environment.ps1
- name: verify windows deprecation behavior
run: ./ci/check_windows_event_api_deprecation.ps1
- name: run tests
env:
CXX_STANDARD: '20'
Expand All @@ -379,6 +383,8 @@ jobs:
- name: setup
run: |
./ci/setup_windows_ci_environment.ps1
- name: verify windows deprecation behavior
run: ./ci/check_windows_event_api_deprecation.ps1
- name: run tests
env:
CXX_STANDARD: '20'
Expand Down
12 changes: 0 additions & 12 deletions api/include/opentelemetry/logs/event_logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,7 @@ namespace logs
# if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable : 4996)
# elif defined(__GNUC__) && !defined(__clang__) && !defined(__apple_build_version__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
# elif defined(__clang__) || defined(__apple_build_version__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
# endif

/**
* Handles event log record creation.
**/
Expand Down Expand Up @@ -88,13 +81,8 @@ class OPENTELEMETRY_DEPRECATED EventLogger
void IgnoreTraitResult(ValueType &&...)
{}
};

# if defined(_MSC_VER)
# pragma warning(pop)
# elif defined(__GNUC__) && !defined(__clang__) && !defined(__apple_build_version__)
# pragma GCC diagnostic pop
# elif defined(__clang__) || defined(__apple_build_version__)
# pragma clang diagnostic pop
# endif
#endif
} // namespace logs
Expand Down
12 changes: 0 additions & 12 deletions api/include/opentelemetry/logs/event_logger_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,7 @@ class Logger;
# if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable : 4996)
# elif defined(__GNUC__) && !defined(__clang__) && !defined(__apple_build_version__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
# elif defined(__clang__) || defined(__apple_build_version__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
# endif

/**
* Creates new EventLogger instances.
*/
Expand All @@ -43,13 +36,8 @@ class OPENTELEMETRY_DEPRECATED EventLoggerProvider
nostd::shared_ptr<Logger> delegate_logger,
nostd::string_view event_domain) noexcept = 0;
};

# if defined(_MSC_VER)
# pragma warning(pop)
# elif defined(__GNUC__) && !defined(__clang__) && !defined(__apple_build_version__)
# pragma GCC diagnostic pop
# elif defined(__clang__) || defined(__apple_build_version__)
# pragma clang diagnostic pop
# endif
#endif
} // namespace logs
Expand Down
23 changes: 6 additions & 17 deletions api/include/opentelemetry/logs/provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,6 @@ class OPENTELEMETRY_EXPORT Provider
}

#if OPENTELEMETRY_ABI_VERSION_NO < 2
# if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable : 4996)
# elif defined(__GNUC__) && !defined(__clang__) && !defined(__apple_build_version__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
# elif defined(__clang__) || defined(__apple_build_version__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
# endif
/**
* Returns the singleton EventLoggerProvider.
*
Expand All @@ -68,6 +58,9 @@ class OPENTELEMETRY_EXPORT Provider
GetEventLoggerProvider() noexcept
{
std::lock_guard<common::SpinLockMutex> guard(GetLock());
# if defined(_MSC_VER)
# pragma warning(suppress : 4996)
# endif
return nostd::shared_ptr<EventLoggerProvider>(GetEventProvider());
}

Expand All @@ -78,15 +71,11 @@ class OPENTELEMETRY_EXPORT Provider
const nostd::shared_ptr<EventLoggerProvider> &tp) noexcept
{
std::lock_guard<common::SpinLockMutex> guard(GetLock());
GetEventProvider() = tp;
}
# if defined(_MSC_VER)
# pragma warning(pop)
# elif defined(__GNUC__) && !defined(__clang__) && !defined(__apple_build_version__)
# pragma GCC diagnostic pop
# elif defined(__clang__) || defined(__apple_build_version__)
# pragma clang diagnostic pop
# pragma warning(suppress : 4996)
# endif
GetEventProvider() = tp;
}
#endif

private:
Expand Down
92 changes: 92 additions & 0 deletions ci/check_windows_event_api_deprecation.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

$ErrorActionPreference = "Stop"
trap { $host.SetShouldExit(1) }

$SRC_DIR = (Get-Item -Path ".\").FullName
$CHECK_DIR = Join-Path "$SRC_DIR" "build/windows-deprecation-check"
$BUILD_DIR = Join-Path "$CHECK_DIR" "build"

if (Test-Path "$CHECK_DIR") {
Remove-Item -Path "$CHECK_DIR" -Recurse -Force
}
New-Item -Path "$CHECK_DIR" -ItemType Directory | Out-Null

$CMAKE_LISTS = @"
cmake_minimum_required(VERSION 3.15)
project(windows_deprecation_check LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_library(logger_only OBJECT logger_only.cpp)
target_include_directories(logger_only PRIVATE "${SRC_DIR}/api/include")
if (MSVC)
target_compile_options(logger_only PRIVATE /W4 /WX /we4996)
endif()

add_library(event_use OBJECT event_use.cpp)
target_include_directories(event_use PRIVATE "${SRC_DIR}/api/include")
if (MSVC)
target_compile_options(event_use PRIVATE /W4 /WX /we4996)
endif()
"@

$LOGGER_ONLY = @"
#include "opentelemetry/logs/provider.h"

int main()
{
auto lp = opentelemetry::logs::Provider::GetLoggerProvider();
(void)lp;
return 0;
}
"@

$EVENT_USE = @"
#include "opentelemetry/logs/provider.h"

int main()
{
auto ep = opentelemetry::logs::Provider::GetEventLoggerProvider();
(void)ep;
return 0;
}
"@

Set-Content -Path (Join-Path "$CHECK_DIR" "CMakeLists.txt") -Value $CMAKE_LISTS
Set-Content -Path (Join-Path "$CHECK_DIR" "logger_only.cpp") -Value $LOGGER_ONLY
Set-Content -Path (Join-Path "$CHECK_DIR" "event_use.cpp") -Value $EVENT_USE

Push-Location -Path "$CHECK_DIR"
try {
cmake -S . -B build
$exit = $LASTEXITCODE
if ($exit -ne 0) {
exit $exit
}

cmake --build "$BUILD_DIR" --target logger_only
$exit = $LASTEXITCODE
if ($exit -ne 0) {
throw "Expected logger_only target to compile without deprecation errors"
}

$EVENT_LOG = Join-Path "$CHECK_DIR" "event_use_build.log"
cmake --build "$BUILD_DIR" --target event_use *> "$EVENT_LOG"
$exit = $LASTEXITCODE
if ($exit -eq 0) {
throw "Expected event_use target to fail with C4996 (/we4996), but it compiled successfully"
}

$event_output = Get-Content -Path "$EVENT_LOG" -Raw
if ($event_output -notmatch "C4996") {
throw "event_use failed, but not due to C4996 deprecation warning. See $EVENT_LOG"
}

Write-Output "Windows deprecation behavior check passed: logger-only succeeds and Event API usage fails with C4996 (/we4996)."
}
finally {
Pop-Location
}
Loading