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

[EXPORTER] Ignore exception when create thread in OTLP file exporter. #3012

Merged
merged 2 commits into from
Jul 29, 2024

Conversation

owent
Copy link
Member

@owent owent commented Jul 25, 2024

Fixes #3011

Changes

  • Ignore exception when create thread failed.

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

@owent owent requested a review from a team July 25, 2024 14:45
Copy link

codecov bot commented Jul 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.60%. Comparing base (497eaf4) to head (72de424).
Report is 109 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3012      +/-   ##
==========================================
+ Coverage   87.12%   87.60%   +0.49%     
==========================================
  Files         200      190      -10     
  Lines        6109     5870     -239     
==========================================
- Hits         5322     5142     -180     
+ Misses        787      728      -59     

see 122 files with indirect coverage changes

@marcalff marcalff changed the title Ignore exception when create thread in OTLP file exporter. [EXPORTER] Ignore exception when create thread in OTLP file exporter. Jul 26, 2024
Copy link
Member

@marcalff marcalff left a 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 fix.

This is mostly code for robustness: if a thread can not be started, we log an error instead of taking the application down, but opentelemetry will execute in degraded mode, possibly not recording data.

In the long term, we may need to pay closer attention to warnings reported by clang-tidy about exceptions raised in noexcept methods, to find and resolve similar issues that may exist elsewhere already.

cc @msiddhu

@@ -20,6 +20,7 @@
#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep
// clang-format on

#include "opentelemetry/common/macros.h"
Copy link
Member

Choose a reason for hiding this comment

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

macros.h is not needed.

By convention, including version.h also provides macros.h, because it contains the magic line:

#include "opentelemetry/common/macros.h"  // IWYU pragma: export

This was done because every file depends on version.h anyway, so code can reliably make use of various defines like OPENTELEMETRY_HAVE_EXCEPTIONS without having to remember to include macros.h.

Copy link
Member

Choose a reason for hiding this comment

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

Reported by include-what-you-use as:

/home/runner/work/opentelemetry-cpp/opentelemetry-cpp/exporters/otlp/src/otlp_file_client.cc should remove these lines:
- #include "opentelemetry/common/macros.h"  // lines 23-23

because of the export pragma in version.h.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, it's removed now.

@marcalff marcalff merged commit 84368cd into open-telemetry:main Jul 29, 2024
52 checks passed
@owent owent deleted the fixes_3011 branch August 2, 2024 03:55
msiddhu added a commit to msiddhu/opentelemetry-cpp that referenced this pull request Aug 20, 2024
* [EXPORTER] Ignore exception when create thread in OTLP file exporter. (open-telemetry#3012)

* [BUILD] Update MODULE.bazel (open-telemetry#3015)

* [BUILD] Fix build without vcpkg on Windows when gRPC is disabled (open-telemetry#3016)

* [BUILD] Add abi_version_no bazel flag. (open-telemetry#3020)

* [Code health] Expand iwyu coverage to include unit tests. (open-telemetry#3022)

* [BUILD] Version opentelemetry_proto/proto_grpc shared libraries (open-telemetry#2992)

* [SEMANTIC CONVENTIONS] Upgrade semantic conventions to 1.27.0 (open-telemetry#3023)

* [SDK] Support empty histogram buckets (open-telemetry#3027)

* support empty buckets

* Update histogram_test.cc

* Update histogram_test.cc

* test for negative values

* fix count

* [TEST] Fix sync problems in OTLP File exporter tests. (open-telemetry#3031)

---------

Co-authored-by: WenTao Ou <owentou@tencent.com>
Co-authored-by: Carbo Kuo <BYVoid@users.noreply.github.com>
Co-authored-by: Manuel Bergler <m.bergler@tum.de>
Co-authored-by: Marc Alff <marc.alff@oracle.com>
Co-authored-by: Troels Hoffmeyer <Troels.d.hoffmeyer@gmail.com>
Co-authored-by: Lalit Kumar Bhasin <lalit_fin@yahoo.com>
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.

OTLP File exporter may crash if create thread failed
2 participants