Skip to content

Elasticsearch exporter build fails with nlohmann_json version 3.10.5 and older #3312

@dbarker

Description

@dbarker

Describe your environment
main at b4328c0
Ubuntu 22.04 github runner (setup with ./ci/setup_goolgletest.sh)

Steps to reproduce
Set up a Ubuntu 22.04 runner
Build with WITH_ELASTICSEARCH=ON

What is the expected behavior?
Build succeeds

What is the actual behavior?
Build fails

/home/runner/work/opentelemetry-cpp/opentelemetry-cpp/exporters/elasticsearch/src/es_log_recordable.cc:35:9: error: no match for ‘operator=’ (operand types are ‘nlohmann::basic_json<>’ and ‘const opentelemetry::v1::nostd::span<const unsigned char>’)
   35 |     *j_ = u;
      |     ~~~~^~~
In file included from /home/runner/work/opentelemetry-cpp/opentelemetry-cpp/exporters/elasticsearch/src/es_log_recordable.cc:8:
/usr/include/nlohmann/json.hpp:1926:17: note: candidate: ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>& nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::operator=(nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>) [with ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer]’
 1926 |     basic_json& operator=(basic_json other) noexcept (
      |                 ^~~~~~~~
/usr/include/nlohmann/json.hpp:1926:38: note:   no known conversion for argument 1 from ‘const opentelemetry::v1::nostd::span<const unsigned char>’ to ‘nlohmann::basic_json<>’
 1926 |     basic_json& operator=(basic_json other) noexcept (
      |                           ~~~~~~~~~~~^~~~~
make[2]: *** [exporters/elasticsearch/CMakeFiles/opentelemetry_exporter_elasticsearch_logs.dir/build.make:93: exporters/elasticsearch/CMakeFiles/opentelemetry_exporter_elasticsearch_logs.dir/src/es_log_recordable.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:9780: exporters/elasticsearch/CMakeFiles/opentelemetry_exporter_elasticsearch_logs.dir/all] Error 2

Additional context
The ubuntu runners install nlohmann-json3-dev with ci/setup_googletest.sh The Elasticsearch exporter can build against the package on Ubuntu 24.04 (version 3.11.3) but fails on Ubuntu 22.04 (version 3.10.5) and older.

Metadata

Metadata

Assignees

No one assigned

    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