KiCad PCB EDA Suite
Loading...
Searching...
No Matches
app_monitor.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.TXT for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include <kicommon.h>
23#include <string>
24#include <set>
25#include <wx/string.h>
26#include <wx/filename.h>
27
28namespace APP_MONITOR
29{
42
51
52 class TRANSACTION_IMPL;
53
60 {
61 public:
62 TRANSACTION( const std::string& aName, const std::string& aOperation );
64
65 void Start();
66 void StartSpan( const std::string& aOperation, const std::string& aDescription );
67 void FinishSpan();
68 void Finish();
69
70#ifdef KICAD_USE_SENTRY
71 private:
72 // We use a IMPL to avoid seeding sentry everywhere
73 TRANSACTION_IMPL* m_impl = nullptr;
74#endif
75 };
76
86 {
87 wxString file;
88 int line;
89 wxString func;
90 wxString cond;
91 };
92
94 bool operator<( const ASSERT_CACHE_KEY& aKey1, const ASSERT_CACHE_KEY& aKey2 );
95
104 {
105 public:
106 SENTRY( const SENTRY& obj ) = delete;
107
108 static SENTRY* Instance()
109 {
110 if( m_instance == nullptr )
111 m_instance = new SENTRY();
112
113 return m_instance;
114 }
115
116 void Init();
117 void Cleanup();
118
119 bool IsOptedIn();
120 void AddTag( const wxString& aKey, const wxString& aValue );
121 void SetSentryOptIn( bool aOptIn );
122 const wxString& GetSentryId();
123 void ResetSentryId();
124
125 void LogAssert( const ASSERT_CACHE_KEY& aKey, const wxString& aMsg );
126 void LogException( const wxString& aMsg, bool aUnhandled );
127
128 private:
129 SENTRY();
130
131 bool isConfiguredOptedIn();
132 void sentryInit();
133 wxString sentryCreateUid();
134 void readOrCreateUid();
135
137
140 wxFileName m_sentry_uid_fn;
141 wxString m_sentryUid;
142
143 std::set<ASSERT_CACHE_KEY> m_assertCache;
144 };
145
149 KICOMMON_API void AddBreadcrumb( BREADCRUMB_TYPE aType, const wxString& aMsg, const wxString& aCategory,
151
152
156 KICOMMON_API void AddNavigationBreadcrumb( const wxString& aMsg, const wxString& aCategory );
157
158
162 KICOMMON_API void AddTransactionBreadcrumb( const wxString& aMsg, const wxString& aCategory );
163}
This is a singleton class intended to manage sentry.
std::set< ASSERT_CACHE_KEY > m_assertCache
wxFileName m_sentry_uid_fn
SENTRY(const SENTRY &obj)=delete
static SENTRY * m_instance
wxFileName m_sentry_optin_fn
static SENTRY * Instance()
This represents a sentry transaction which is used for time-performance metrics You start a transacti...
Definition app_monitor.h:60
void StartSpan(const std::string &aOperation, const std::string &aDescription)
TRANSACTION(const std::string &aName, const std::string &aOperation)
#define KICOMMON_API
Definition kicommon.h:27
void AddTransactionBreadcrumb(const wxString &aMsg, const wxString &aCategory)
Add a transaction breadcrumb.
void AddBreadcrumb(BREADCRUMB_TYPE aType, const wxString &aMsg, const wxString &aCategory, BREADCRUMB_LEVEL aLevel)
Add a sentry breadcrumb.
void AddNavigationBreadcrumb(const wxString &aMsg, const wxString &aCategory)
Add a navigation breadcrumb.
bool operator<(const ASSERT_CACHE_KEY &aKey1, const ASSERT_CACHE_KEY &aKey2)
This struct represents a key being used for the std::set that deduplicates asserts during this runnin...
Definition app_monitor.h:86