Skip to content
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

[API] Fix inclusion header files and use forward declaration #2124

Merged

Conversation

cngzhnp
Copy link
Contributor

@cngzhnp cngzhnp commented Apr 27, 2023

Fixes #2043 but only API side.

Changes

Please provide a brief description of the changes here.

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@cngzhnp cngzhnp force-pushed the feature/api/forward_declaration branch 14 times, most recently from 5e58615 to 0baef79 Compare April 27, 2023 21:03
@codecov
Copy link

codecov bot commented Apr 27, 2023

Codecov Report

Merging #2124 (fd69aec) into main (80f3018) will decrease coverage by 0.03%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2124      +/-   ##
==========================================
- Coverage   87.19%   87.15%   -0.03%     
==========================================
  Files         166      166              
  Lines        4784     4777       -7     
==========================================
- Hits         4171     4163       -8     
- Misses        613      614       +1     
Impacted Files Coverage Δ
.../include/opentelemetry/common/key_value_iterable.h 100.00% <ø> (ø)
...ude/opentelemetry/common/key_value_iterable_view.h 88.89% <ø> (ø)
api/include/opentelemetry/common/kv_properties.h 98.97% <ø> (ø)
api/include/opentelemetry/common/string_util.h 100.00% <ø> (ø)
api/include/opentelemetry/common/timestamp.h 80.44% <ø> (ø)
api/include/opentelemetry/context/context.h 100.00% <ø> (ø)
...lemetry/context/propagation/composite_propagator.h 100.00% <ø> (ø)
...ntelemetry/context/propagation/global_propagator.h 100.00% <ø> (ø)
...elemetry/context/propagation/text_map_propagator.h 50.00% <ø> (ø)
...pi/include/opentelemetry/context/runtime_context.h 97.60% <ø> (ø)
... and 31 more

... and 1 file with indirect coverage changes

@cngzhnp cngzhnp force-pushed the feature/api/forward_declaration branch 2 times, most recently from 479bdcc to 2690363 Compare April 27, 2023 21:49
@cngzhnp cngzhnp force-pushed the feature/api/forward_declaration branch from 2690363 to 2edcbe4 Compare April 27, 2023 21:57
@cngzhnp cngzhnp marked this pull request as ready for review April 27, 2023 22:29
@cngzhnp cngzhnp requested a review from a team April 27, 2023 22:29
@cngzhnp
Copy link
Contributor Author

cngzhnp commented Apr 27, 2023

@marcalff Could you please review these changes only related to API folder?

@lalitb
Copy link
Member

lalitb commented May 2, 2023

Changes look good in general, and nicely done. I think this would be the breaking change for applications if they are taking dependency on these unnecessary header inclusions in our API. These applications need to explicitly include these removed header files / forward-declared classes.

Copy link
Member

@lalitb lalitb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving the changes with nit comments. I believe @marcalff has already approved these api changes as indicated here - #2043 (review). Still have concern on this breaking the existing application code, so would be good to discuss when/how to merge/release in next community meeting.

@@ -41,6 +40,11 @@
OPENTELEMETRY_BEGIN_NAMESPACE
namespace plugin
{

struct LoaderInfo;
class Factory;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this required ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to put this class as a forward declaration, probably even stands on my early trials. Will be removed.

@@ -102,15 +102,14 @@ class OPENTELEMETRY_EXPORT NoopTracer final : public Tracer,
/**
* No-op implementation of a TracerProvider.
*/
class OPENTELEMETRY_EXPORT NoopTracerProvider final : public opentelemetry::trace::TracerProvider
class OPENTELEMETRY_EXPORT NoopTracerProvider final : public trace_api::TracerProvider
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we instead use trace::TracerProvider, and remove trace_api namespace alias from the header file. It's not recommended to have namespace alias in header files (though this is existing code)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right. I'd change it as you wish.

Copy link
Member

@lalitb lalitb May 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the trace_api alias defined here is been used in other places too, as the CI tests are failing. We can keep it here in that case. Sorry about that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted back only trace_api alias. However, I will take it as a note, maybe it would be removed after same changes are applied to SDK too.

@cngzhnp cngzhnp force-pushed the feature/api/forward_declaration branch from 296472a to 2f78c15 Compare May 3, 2023 07:42
@@ -2,6 +2,12 @@
// SPDX-License-Identifier: Apache-2.0

#include "opentelemetry/plugin/dynamic_load.h"
#ifdef _WIN32
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed as the #ifdef _WIN32 is included in opentelemetry/plugin/dynamic_load.h which has already been included above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In dynamic_load.h file, there is no preprocessor definition anymore, I removed it in this pull request. Because there is only one function declaration which is not related to operating system itself.

However, only this source file is related to operating system itself with dynamic_load and which has to be included like that. Otherwise, there will be a compiler error on test codes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was the including of such dynamic_load_<os>.h moved out of dynamic_load.h? With change, the user code like the test code here need to include both files separately. It looks to me that including the os header in dynamic_load.h is more convenient.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will revert it back.

@ThomsonTan ThomsonTan merged commit 990da7d into open-telemetry:main May 7, 2023
@marcalff marcalff changed the title Fix inclusion header files and use forward declaration for API [BUILD] Fix inclusion header files and use forward declaration for API May 23, 2023
@marcalff marcalff changed the title [BUILD] Fix inclusion header files and use forward declaration for API [API] Fix inclusion header files and use forward declaration May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants