-
Notifications
You must be signed in to change notification settings - Fork 438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch from MPark variant to absl::variant
as default
#771
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for the cleanup. Though CI is failing for now.
I think it should be fine to break ABI for now, while we are still not GA :)
Probably |
Folks, please don't merge it yet. I pushed the latest update. Unfortunately there are two outstanding issues:
Because I see the same EXACT tests failing now with Abseil, because the variant does not copy temporary 😢 ... OR treats it as Screenshot:
There is also something related to being able to build with original Abseil. What I was trying to avoid is linking to original Abseil. Because Abseil variant implementation otherwise works great as a header-only library. The only problem with that is implementation of exception handler. I need a bit more work on that. I might need an advise from @owent how to export our local Abseil headers, in case if we bundle Abseil within, not needing an external snapshot of it.. to keep the entire API still pure header-only. That's a requirement from someone else. And I need the same (header-only API) for ETW exporter build. It would be sad to lose that pure header-only feature of API target. |
I can try to fix the tests by making sure we pass |
I got down to only 5 test failures by re-adding Basically, for both - Which breaks a simple construct like Refreshed PR with latest stuff. Only 5 tests are now failing, down from 10. Hopefully I can sort out the rest of them in a day. |
… lookup itself using relative paths
…PI with Abseil Variant, but without entire Abseil Library
…s explicitly be defined, no implicit conversion to string_view)
We could add these cmake scripts below into if(WITH_ABSEIL)
target_compile_definitions(opentelemetry_api INTERFACE HAVE_ABSEIL)
target_link_libraries(opentelemetry_api INTERFACE ${CORE_RUNTIME_LIBS})
else()
target_include_directories(
opentelemetry_api
INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include/opentelemetry/nostd>"
"$<INSTALL_INTERFACE:include/opentelemetry/nostd>")
endif() |
@owent - I just pushed an update to use relative paths for local Abseil. I still leave an option for end-users / devs to decide if they want the full Abseil, e.g. |
I like the |
I think it's a good call. Because gRPC uses Abseil anyways, if we are building SDK optimized for that same Abseil, we do not bloat with unnecessary local copy. What I am not certain --- since this is in API, and since this is in the main part of API -- Also another interesting item, maybe we could have also used |
FYI - this issue has been fixed in later versions of std::variant as below: Resolution is described here: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0608r3.html And this issue (P0608R3) is fixed in: I remember there were ownership issues pointed out by @pyohannes earlier for adding support for |
The earlier discussion around this context: |
…es not clash with gRPC Abseil
@pyohannes @lalitb - could you have a quick look? Latest changes address the issues we discussed during SIG meeting:
|
Thanks, @maxgolov - Looks good to me now. @pyohannes, @ThomsonTan - would you like to review changes specific to |
Turn preview features OFF
@@ -7,8 +7,13 @@ | |||
#include "opentelemetry/nostd/variant.h" | |||
// clang-format on | |||
|
|||
#if defined(HAVE_ABSEIL) && !defined(HAVE_ABSEIL_VARIANT) | |||
|
|||
#if defined(HAVE_ABSEIL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@owent - once this PR merged, could you please share some instructions, did we need this for MinGW? I think maybe we're not gonna be needing this code anymore. If we are building with HAVE_ABSEIL
in future, we can demand that the implementation of ThrowBadVariantAccess
comes from Abseil lib linked into the project. That way we can remove it from core.cc
here.. Basically, I'm no longer using this exception handler for our own Abseil private variant, and most likely the code between lines 10 to 36 could be simply removed (in a separate PR 😄 ).
@pyohannes @ThomsonTan @jsuereth I believe I have addressed ALL the questions / issues. Would appreciate feedback on this. Integrating it should allow me to set up the build loops for vs2015-vs2017-vs2019, using Abseil Variant. As well as all tests for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR and the const char *
change LGTM.
Fixes #572 #733
Changes
Why:
a) Boost-licensed not Apache License v2 (forcing us to depend on Boost License unnecessarily)
b) Does not compile with Visual Studio 2015 at all.
How to fix:
absl::variant
, because it is:a) Apache License v2
b) It compiles well with Visual Studio 2015 Update 2.
UPDATE 1: there is a change needed in
common::AttributeValue
to re-addconst char *
, because neitherstd::variant
norabsl::variant
provide an implicit conversion of that type tostring_view
. What happens then, it by-default gets converted tobool
. So any static initializer in the map, for a pair such as{{"key, "value"}}
is gonna break, by assigning the variant value with typebool
instead ofstring_view
. I'm implementing a fix to resolve this. Related issue #733 #734UPDATE 2:
unfortunately we also need to addconst char *
attribute value constructor toOwnedAttributeValue
since otherwise it'd break the SDKResourceAttribute
implementation. In most cases the exporters do not have to deal withconst char *
because transform fromAttributeValue
variant toOwnedAttributeValue
variant presently implies a memcpy ofconst char *
into owningstd::string
object. However, I did adjust all default exporters to potentially deal withconst char *
. This is 3 lines of code per exporter, and I would argue the maintenance cost of that is zero.UPDATE 3: - as discussed, I removed
const char *
fromOwnedAttributeValue
. I also refactoredResourceAttribute
to use a map that allows to transform incomingconst char *
attributes assigned using initializer lists intostd::string
.CHANGELOG.md
updated for non-trivial changesI added a separate document that explains the process of updating Abseil snapshot in this PR #797