Skip to content

Commit 923e71b

Browse files
authored
Cover pending requests with logs (#1714)
The extended logs are under the ifdef, so they don't appear in production. This is a temporary commit to extend the logs for certain integration tests, so that we could have more insights from the CI failed psv and sv jobs. This commit will be reverted once OCMAM-771 is resolved. Relates-To: OCMAM-771 Signed-off-by: Mykola Malik <ext-mykola.malik@here.com>
1 parent 8ce8ddc commit 923e71b

2 files changed

Lines changed: 68 additions & 7 deletions

File tree

olp-cpp-sdk-core/include/olp/core/client/PendingRequests.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2021 HERE Europe B.V.
2+
* Copyright (C) 2019-2026 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,6 +36,8 @@ namespace client {
3636
*/
3737
class CORE_API PendingRequests final {
3838
public:
39+
~PendingRequests();
40+
3941
/**
4042
* @brief Cancels all the pending tasks.
4143
*

olp-cpp-sdk-core/src/client/PendingRequests.cpp

Lines changed: 65 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2021 HERE Europe B.V.
2+
* Copyright (C) 2019-2026 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,13 +29,25 @@ namespace {
2929
constexpr auto kLogTag = "PendingRequests";
3030
}
3131

32+
PendingRequests::~PendingRequests() {
33+
#ifdef LOGGING_ENABLE_EXTENDED_INFO_LEVEL
34+
OLP_SDK_LOG_INFO_F(kLogTag, "Destructor: pending task count=%zu, this=%p",
35+
GetTaskCount(), static_cast<void*>(this));
36+
#endif // LOGGING_ENABLE_EXTENDED_INFO_LEVEL
37+
}
38+
3239
bool PendingRequests::CancelAll() {
3340
ContextMap contexts;
3441
{
3542
std::lock_guard<std::mutex> lock(task_contexts_lock_);
3643
contexts = task_contexts_;
3744
}
3845

46+
#ifdef LOGGING_ENABLE_EXTENDED_INFO_LEVEL
47+
OLP_SDK_LOG_INFO_F(kLogTag, "CancelAll: pending task count=%zu, this=%p",
48+
contexts.size(), static_cast<void*>(this));
49+
#endif // LOGGING_ENABLE_EXTENDED_INFO_LEVEL
50+
3951
for (auto context : contexts) {
4052
context.CancelToken().Cancel();
4153
}
@@ -52,23 +64,70 @@ bool PendingRequests::CancelAllAndWait() {
5264
contexts = std::move(task_contexts_);
5365
}
5466

67+
#ifdef LOGGING_ENABLE_EXTENDED_INFO_LEVEL
68+
OLP_SDK_LOG_INFO_F(
69+
kLogTag, "CancelAllAndWait: started, pending task count=%zu, this=%p",
70+
contexts.size(), static_cast<void*>(this));
71+
#endif // LOGGING_ENABLE_EXTENDED_INFO_LEVEL
72+
5573
for (auto context : contexts) {
5674
if (!context.BlockingCancel()) {
57-
OLP_SDK_LOG_WARNING(kLogTag, "Timeout, when waiting on BlockingCancel");
75+
OLP_SDK_LOG_WARNING_F(kLogTag,
76+
"Timeout, when waiting on BlockingCancel, this=%p",
77+
static_cast<void*>(this));
5878
}
5979
}
6080

81+
#ifdef LOGGING_ENABLE_EXTENDED_INFO_LEVEL
82+
OLP_SDK_LOG_INFO_F(kLogTag, "CancelAllAndWait: finished, this=%p",
83+
static_cast<void*>(this));
84+
#endif // LOGGING_ENABLE_EXTENDED_INFO_LEVEL
85+
6186
return true;
6287
}
6388

6489
void PendingRequests::Insert(TaskContext task_context) {
65-
std::lock_guard<std::mutex> lock(task_contexts_lock_);
66-
task_contexts_.insert(task_context);
90+
#ifdef LOGGING_ENABLE_EXTENDED_INFO_LEVEL
91+
size_t size = 0;
92+
#endif // LOGGING_ENABLE_EXTENDED_INFO_LEVEL
93+
94+
{
95+
std::lock_guard<std::mutex> lock(task_contexts_lock_);
96+
task_contexts_.insert(task_context);
97+
98+
#ifdef LOGGING_ENABLE_EXTENDED_INFO_LEVEL
99+
size = task_contexts_.size();
100+
#endif // LOGGING_ENABLE_EXTENDED_INFO_LEVEL
101+
}
102+
103+
#ifdef LOGGING_ENABLE_EXTENDED_INFO_LEVEL
104+
OLP_SDK_LOG_INFO_F(
105+
kLogTag,
106+
"Insert: a new task context inserted. Pending task count=%zu, this=%p",
107+
size, static_cast<void*>(this));
108+
#endif // LOGGING_ENABLE_EXTENDED_INFO_LEVEL
67109
}
68110

69111
void PendingRequests::Remove(TaskContext task_context) {
70-
std::lock_guard<std::mutex> lock(task_contexts_lock_);
71-
task_contexts_.erase(task_context);
112+
#ifdef LOGGING_ENABLE_EXTENDED_INFO_LEVEL
113+
size_t size = 0;
114+
#endif // LOGGING_ENABLE_EXTENDED_INFO_LEVEL
115+
116+
{
117+
std::lock_guard<std::mutex> lock(task_contexts_lock_);
118+
task_contexts_.erase(task_context);
119+
120+
#ifdef LOGGING_ENABLE_EXTENDED_INFO_LEVEL
121+
size = task_contexts_.size();
122+
#endif // LOGGING_ENABLE_EXTENDED_INFO_LEVEL
123+
}
124+
125+
#ifdef LOGGING_ENABLE_EXTENDED_INFO_LEVEL
126+
OLP_SDK_LOG_INFO_F(
127+
kLogTag,
128+
"Remove: a task context removed. Pending task count=%zu, this=%p", size,
129+
static_cast<void*>(this));
130+
#endif // LOGGING_ENABLE_EXTENDED_INFO_LEVEL
72131
}
73132

74133
size_t PendingRequests::GetTaskCount() const {

0 commit comments

Comments
 (0)