Skip to content

Build failure (C4996) when including opentelemetry/logs/provider.h with opentelemetry-cpp[geneva] #3835

@lukeina2z

Description

@lukeina2z

Steps to Reproduce

  1. Follow this article to integrate vcpkg with MSBuild/VisualStudio.

    Tutorial: Install and use packages with MSBuild in Visual Studio
    https://learn.microsoft.com/en-us/vcpkg/get_started/get-started-msbuild

    .\vcpkg.exe integrate install
  2. Create a C++ console application in Visual Studio 2022.

  3. In Visual Studio, open Tools → Command Line → Developer Command Prompt.

  4. Run:

    vcpkg new --application
    vcpkg add port opentelemetry-cpp[geneva]
  5. In the project Property Pages, set: vcpkg → Use Vcpkg Manifest = Yes

  6. Include the following header in your .cpp file:

    #include "opentelemetry/logs/provider.h"
  7. Build the project.

Expected Result

The project builds successfully with no errors.

Actual Result

The build fails with error C4996 due to deprecated symbols:

opentelemetry::v1::logs::EventLogger was declared deprecated
opentelemetry::v1::logs::EventLogger::~EventLogger was declared deprecated
opentelemetry::v1::logs::EventLoggerProvider was declared deprecated
opentelemetry::v1::logs::EventLoggerProvider::~EventLoggerProvider was declared deprecated
opentelemetry::v1::logs::Provider::GetEventProvider was declared deprecated

Additional Notes

This header is included because its APIs are required to set the Geneva TracerProvider as the global default, specifically to call:

GetLoggerProvider()
SetLoggerProvider()

Here is my testing project for this issue: https://github.com/lukeina2z/playground/tree/main/cpp/LogProviderWarning

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtriage/acceptedIndicates an issue or PR is ready to be actively worked on.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions