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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#pragma once
25
26#include <kicommon.h>
27#include <string>
28#include <set>
29#include <wx/string.h>
30#include <wx/filename.h>
31
32namespace APP_MONITOR
33{
34 enum class BREADCRUMB_TYPE
35 {
36 DEFAULT,
37 DBG,
38 ERR,
40 INFO,
41 QUERY,
43 UI,
44 USER,
45 };
46
48 {
49 FATAL,
50 ERR,
51 WARNING,
52 INFO,
53 DBG
54 };
55
56 class TRANSACTION_IMPL;
57
64 {
65 public:
66 TRANSACTION( const std::string& aName, const std::string& aOperation );
68
69 void Start();
70 void StartSpan( const std::string& aOperation, const std::string& aDescription );
71 void FinishSpan();
72 void Finish();
73
74#ifdef KICAD_USE_SENTRY
75 private:
76 // We use a IMPL to avoid seeding sentry everywhere
77 TRANSACTION_IMPL* m_impl = nullptr;
78#endif
79 };
80
90 {
91 wxString file;
92 int line;
93 wxString func;
94 wxString cond;
95 };
96
98 bool operator<( const ASSERT_CACHE_KEY& aKey1, const ASSERT_CACHE_KEY& aKey2 );
99
108 {
109 public:
110 SENTRY( const SENTRY& obj ) = delete;
111
112 static SENTRY* Instance()
113 {
114 if( m_instance == nullptr )
115 m_instance = new SENTRY();
116
117 return m_instance;
118 }
119
120 void Init();
121 void Cleanup();
122
123 bool IsOptedIn();
124 void AddTag( const wxString& aKey, const wxString& aValue );
125 void SetSentryOptIn( bool aOptIn );
126 const wxString& GetSentryId();
127 void ResetSentryId();
128
129 void LogAssert( const ASSERT_CACHE_KEY& aKey, const wxString& aMsg );
130 void LogException( const wxString& aMsg );
131
132 private:
133 SENTRY();
134
135 bool isConfiguredOptedIn();
136 void sentryInit();
137 wxString sentryCreateUid();
138 void readOrCreateUid();
139
141
144 wxFileName m_sentry_uid_fn;
145 wxString m_sentryUid;
146
147 std::set<ASSERT_CACHE_KEY> m_assertCache;
148 };
149
153 KICOMMON_API void AddBreadcrumb( BREADCRUMB_TYPE aType, const wxString& aMsg, const wxString& aCategory,
155
156
160 KICOMMON_API void AddNavigationBreadcrumb( const wxString& aMsg, const wxString& aCategory );
161
162
166 KICOMMON_API void AddTransactionBreadcrumb( const wxString& aMsg, const wxString& aCategory );
167}
This is a singleton class intended to manage sentry.
Definition: app_monitor.h:108
std::set< ASSERT_CACHE_KEY > m_assertCache
Definition: app_monitor.h:147
wxFileName m_sentry_uid_fn
Definition: app_monitor.h:144
SENTRY(const SENTRY &obj)=delete
static SENTRY * m_instance
Definition: app_monitor.h:140
wxFileName m_sentry_optin_fn
Definition: app_monitor.h:143
static SENTRY * Instance()
Definition: app_monitor.h:112
This represents a sentry transaction which is used for time-performance metrics You start a transacti...
Definition: app_monitor.h:64
#define KICOMMON_API
Definition: kicommon.h:28
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:90