-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #403 from Infomaniak/KDESKTOP-1264-Implement-Sentr…
…y-transaction Kdesktop 1264 implement sentry transaction.
- Loading branch information
Showing
53 changed files
with
1,373 additions
and
380 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Infomaniak kDrive - Desktop | ||
* Copyright (C) 2023-2024 Infomaniak Network SA | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#pragma once | ||
|
||
#include "libcommon/log/sentry/abstractscopedptrace.h" | ||
|
||
namespace KDC::sentry { | ||
|
||
class AbstractCounterScopedPTrace : public AbstractScopedPTrace { | ||
public: | ||
void start() final { | ||
if (_counter >= _nbOfCyclesPerTrace) { | ||
AbstractScopedPTrace::stop(); | ||
AbstractScopedPTrace::start(); | ||
_counter = 0; | ||
} else | ||
_counter++; | ||
} | ||
|
||
protected: | ||
explicit AbstractCounterScopedPTrace(const PTraceDescriptor &info, unsigned int nbOfCyclePerTrace) : | ||
AbstractScopedPTrace(info, PTraceStatus::Cancelled), _nbOfCyclesPerTrace(nbOfCyclePerTrace) {} | ||
|
||
explicit AbstractCounterScopedPTrace(const PTraceDescriptor &info, unsigned int nbOfCyclePerTrace, int syncDbId) : | ||
AbstractScopedPTrace(info, PTraceStatus::Cancelled, syncDbId), _nbOfCyclesPerTrace(nbOfCyclePerTrace) {} | ||
|
||
private: | ||
void stop(PTraceStatus status = PTraceStatus::Ok) final { | ||
assert(false && "stop() should not be called with CounterScopedPTrace."); | ||
} | ||
void restart() final { | ||
assert(false && "restart() should not be called with CounterScopedPTrace."); | ||
} | ||
unsigned int _nbOfCyclesPerTrace = 0; // The number of time start() should be called before stopping the trace. | ||
unsigned int _counter = 0; | ||
}; | ||
} // namespace KDC::sentry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Infomaniak kDrive - Desktop | ||
* Copyright (C) 2023-2024 Infomaniak Network SA | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#pragma once | ||
|
||
#include "libcommon/log/sentry/handler.h" | ||
#include "libcommon/log/sentry/ptracedescriptor.h" | ||
|
||
namespace KDC::sentry { | ||
class AbstractPTrace; | ||
using PTraceUPtr = std::unique_ptr<AbstractPTrace>; | ||
class AbstractPTrace { | ||
public: | ||
virtual ~AbstractPTrace() = default; | ||
|
||
// Return the current performance trace id. | ||
pTraceId id() const { return _pTraceId; } | ||
virtual void start() { _start(); } | ||
virtual void stop(PTraceStatus status = PTraceStatus::Ok) { _stop(status); } | ||
virtual void restart() { _restart(); } | ||
|
||
protected: | ||
explicit AbstractPTrace(const PTraceDescriptor &info) : _pTraceInfo(info){}; | ||
explicit AbstractPTrace(const PTraceDescriptor &info, int dbId) : _pTraceInfo(info), _syncDbId(dbId){}; | ||
|
||
// Start a new performance trace. | ||
inline AbstractPTrace &_start() { | ||
_pTraceId = sentry::Handler::instance()->startPTrace(_pTraceInfo, _syncDbId); | ||
return *this; | ||
} | ||
|
||
// Stop the performance trace. | ||
void _stop(PTraceStatus status = PTraceStatus::Ok) noexcept { | ||
if (_pTraceId) { // If the performance trace id is set, use it to stop the performance trace (faster). | ||
Handler::instance()->stopPTrace(_pTraceId, status); | ||
_pTraceId = 0; | ||
} else { | ||
Handler::instance()->stopPTrace(_pTraceInfo, _syncDbId, status); | ||
} | ||
} | ||
|
||
// Stop the current performance trace (aborted = false) and start a new one. | ||
void _restart() { | ||
_stop(); | ||
_start(); | ||
} | ||
|
||
private: | ||
AbstractPTrace &operator=(AbstractPTrace &&) = delete; | ||
pTraceId _pTraceId{0}; | ||
PTraceDescriptor _pTraceInfo; | ||
int _syncDbId = -1; | ||
}; | ||
} // namespace KDC::sentry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Infomaniak kDrive - Desktop | ||
* Copyright (C) 2023-2024 Infomaniak Network SA | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#pragma once | ||
|
||
#include "libcommon/log/sentry/abstractptrace.h" | ||
|
||
namespace KDC::sentry { | ||
|
||
class AbstractScopedPTrace : public AbstractPTrace { | ||
public: | ||
~AbstractScopedPTrace() override { _stop(_autoStopStatus); } | ||
|
||
void start() override { _start(); } | ||
|
||
protected: | ||
explicit AbstractScopedPTrace(const PTraceDescriptor &info, PTraceStatus autoStopStatus) : | ||
AbstractPTrace(info), _autoStopStatus(autoStopStatus) { | ||
start(); | ||
} | ||
explicit AbstractScopedPTrace(const PTraceDescriptor &info, PTraceStatus autoStopStatus, int syncDbId) : | ||
AbstractPTrace(info, syncDbId), _autoStopStatus(autoStopStatus) { | ||
start(); | ||
} | ||
|
||
private: | ||
PTraceStatus _autoStopStatus = PTraceStatus::Ok; // The status to use when the object is stopped due to its destruction. | ||
}; | ||
} // namespace KDC::sentry |
Oops, something went wrong.