Skip to content

Reorder the destructor of members in LoggerProvider and TracerProvider#1245

Merged
ThomsonTan merged 8 commits intoopen-telemetry:mainfrom
owent:fix_crash_when_destroying_tracer
Mar 8, 2022
Merged

Reorder the destructor of members in LoggerProvider and TracerProvider#1245
ThomsonTan merged 8 commits intoopen-telemetry:mainfrom
owent:fix_crash_when_destroying_tracer

Conversation

@owent
Copy link
Copy Markdown
Member

@owent owent commented Mar 4, 2022

…r. It's safe to shutdown multiple times.(Fix #1244)

Signed-off-by: owentou owentou@tencent.com

Fixes #1244

Changes

  1. Reorder the destructor of members in LoggerProvider and TracerProvider.
  2. It's safe to shutdown multiple times.

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 March 4, 2022 16:04
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 4, 2022

Codecov Report

Merging #1245 (67963f1) into main (cba0a2a) will increase coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1245      +/-   ##
==========================================
+ Coverage   92.29%   92.31%   +0.03%     
==========================================
  Files         198      198              
  Lines        7273     7281       +8     
==========================================
+ Hits         6712     6721       +9     
+ Misses        561      560       -1     
Impacted Files Coverage Δ
ext/test/http/curl_http_test.cc 95.17% <100.00%> (ø)
sdk/src/trace/batch_span_processor.cc 93.03% <100.00%> (+1.36%) ⬆️
sdk/src/trace/tracer_provider.cc 76.75% <100.00%> (+2.39%) ⬆️
sdk/test/trace/batch_span_processor_test.cc 100.00% <100.00%> (ø)
sdk/test/trace/tracer_provider_test.cc 100.00% <100.00%> (ø)

Comment thread sdk/include/opentelemetry/sdk/logs/logger.h
Comment thread sdk/test/logs/logger_provider_sdk_test.cc
@owent
Copy link
Copy Markdown
Member Author

owent commented Mar 4, 2022

It's too late on my timezone. I will solve the failed jobs tomorrow.

Comment thread sdk/include/opentelemetry/sdk/logs/logger_provider.h
Comment thread sdk/test/logs/simple_log_processor_test.cc
Copy link
Copy Markdown
Member

@esigo esigo 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 PR.

@owent owent force-pushed the fix_crash_when_destroying_tracer branch from d9792f5 to 3b54c24 Compare March 7, 2022 02:16
@esigo
Copy link
Copy Markdown
Member

esigo commented Mar 7, 2022

@owent could you please rebase?

Comment thread ext/test/http/curl_http_test.cc Outdated
// order of declaration is important here - instrumentation library should destroy after
// logger-context.
std::unique_ptr<instrumentationlibrary::InstrumentationLibrary> instrumentation_library_;
std::shared_ptr<LoggerContext> context_;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is cyclic dependency still an issue here as it changes weak_ptr to shared_ptr?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There is no cyclic dependency right now.It's only be hold in Logger and LoggerProvider and Logger is only hold by LoggerProvider.

Comment thread sdk/src/logs/multi_log_processor.cc
}

// Should only shutdown exporter ONCE.
if (!already_shutdown && exporter_ != nullptr)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is showing down is going, later call to Shutdown will just return true even if the previous Shutdown has not been completed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes and thanks, it's definitely a problem.I add a mutex lock to prevent this.

owent and others added 8 commits March 8, 2022 09:57
…r. It's safe to shutdown multiple times.(Fix open-telemetry#1244)

Signed-off-by: owentou <owentou@tencent.com>
…comparison of integer expressions of different signedness: 'int' and 'const long unsigned int' [-Wsign-compare]`

Signed-off-by: owentou <owentou@tencent.com>
…nd `SimpleSpanProcessor`

Signed-off-by: owentou <owentou@tencent.com>
Signed-off-by: owentou <owentou@tencent.com>
Signed-off-by: owentou <owentou@tencent.com>
+ Temporary fix the `Export()` may be called too many times when we shutdown or just wakeup worker thread once.This problem is completely fixed in open-telemetry#1209 but not merged yet.
+ Fix http client may has a different error code when our network is under a proxy.
Signed-off-by: owentou <owentou@tencent.com>
@owent owent force-pushed the fix_crash_when_destroying_tracer branch from 3b54c24 to 67963f1 Compare March 8, 2022 02:23
@owent
Copy link
Copy Markdown
Member Author

owent commented Mar 8, 2022

@owent could you please rebase?

Done

@ThomsonTan ThomsonTan changed the title Reorder the destructor of members in LoggerProvider and TracerProvide… Reorder the destructor of members in LoggerProvider and TracerProvider Mar 8, 2022
@ThomsonTan ThomsonTan merged commit c96a3e3 into open-telemetry:main Mar 8, 2022
@owent owent deleted the fix_crash_when_destroying_tracer branch March 9, 2022 06:58
@lalitb lalitb mentioned this pull request Mar 22, 2022
3 tasks
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.

Crash when destroy LoggerProvider and TracerProvider

4 participants