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
28
namespace
APP_MONITOR
29
{
30
enum class
BREADCRUMB_TYPE
31
{
32
DEFAULT
,
33
DBG
,
34
ERR
,
35
NAVIGATION
,
36
INFO
,
37
QUERY
,
38
TRANSACTION
,
39
UI
,
40
USER
,
41
};
42
43
enum class
BREADCRUMB_LEVEL
44
{
45
FATAL
,
46
ERR
,
47
WARNING
,
48
INFO
,
49
DBG
50
};
51
52
class
TRANSACTION_IMPL;
53
59
class
KICOMMON_API
TRANSACTION
60
{
61
public
:
62
TRANSACTION
(
const
std::string& aName,
const
std::string& aOperation );
63
~TRANSACTION
();
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
85
struct
KICOMMON_API
ASSERT_CACHE_KEY
86
{
87
wxString
file
;
88
int
line
;
89
wxString
func
;
90
wxString
cond
;
91
};
92
93
KICOMMON_API
94
bool
operator<
(
const
ASSERT_CACHE_KEY
& aKey1,
const
ASSERT_CACHE_KEY
& aKey2 );
95
103
class
KICOMMON_API
SENTRY
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
136
static
SENTRY
*
m_instance
;
137
138
bool
m_isOptedIn
;
139
wxFileName
m_sentry_optin_fn
;
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,
150
BREADCRUMB_LEVEL
aLevel =
BREADCRUMB_LEVEL::INFO
);
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
}
APP_MONITOR::SENTRY
This is a singleton class intended to manage sentry.
Definition
app_monitor.h:104
APP_MONITOR::SENTRY::m_assertCache
std::set< ASSERT_CACHE_KEY > m_assertCache
Definition
app_monitor.h:143
APP_MONITOR::SENTRY::m_sentry_uid_fn
wxFileName m_sentry_uid_fn
Definition
app_monitor.h:140
APP_MONITOR::SENTRY::m_sentryUid
wxString m_sentryUid
Definition
app_monitor.h:141
APP_MONITOR::SENTRY::SENTRY
SENTRY(const SENTRY &obj)=delete
APP_MONITOR::SENTRY::m_isOptedIn
bool m_isOptedIn
Definition
app_monitor.h:138
APP_MONITOR::SENTRY::m_instance
static SENTRY * m_instance
Definition
app_monitor.h:136
APP_MONITOR::SENTRY::m_sentry_optin_fn
wxFileName m_sentry_optin_fn
Definition
app_monitor.h:139
APP_MONITOR::SENTRY::Instance
static SENTRY * Instance()
Definition
app_monitor.h:108
APP_MONITOR::TRANSACTION
This represents a sentry transaction which is used for time-performance metrics You start a transacti...
Definition
app_monitor.h:60
APP_MONITOR::TRANSACTION::FinishSpan
void FinishSpan()
Definition
app_monitor.cpp:491
APP_MONITOR::TRANSACTION::Finish
void Finish()
Definition
app_monitor.cpp:480
APP_MONITOR::TRANSACTION::StartSpan
void StartSpan(const std::string &aOperation, const std::string &aDescription)
Definition
app_monitor.cpp:469
APP_MONITOR::TRANSACTION::TRANSACTION
TRANSACTION(const std::string &aName, const std::string &aOperation)
Definition
app_monitor.cpp:439
APP_MONITOR::TRANSACTION::Start
void Start()
Definition
app_monitor.cpp:458
kicommon.h
KICOMMON_API
#define KICOMMON_API
Definition
kicommon.h:27
APP_MONITOR
Definition
app_monitor.cpp:321
APP_MONITOR::AddTransactionBreadcrumb
void AddTransactionBreadcrumb(const wxString &aMsg, const wxString &aCategory)
Add a transaction breadcrumb.
Definition
app_monitor.cpp:372
APP_MONITOR::BREADCRUMB_TYPE
BREADCRUMB_TYPE
Definition
app_monitor.h:31
APP_MONITOR::BREADCRUMB_TYPE::USER
@ USER
Definition
app_monitor.h:40
APP_MONITOR::BREADCRUMB_TYPE::INFO
@ INFO
Definition
app_monitor.h:36
APP_MONITOR::BREADCRUMB_TYPE::QUERY
@ QUERY
Definition
app_monitor.h:37
APP_MONITOR::BREADCRUMB_TYPE::NAVIGATION
@ NAVIGATION
Definition
app_monitor.h:35
APP_MONITOR::BREADCRUMB_TYPE::DEFAULT
@ DEFAULT
Definition
app_monitor.h:32
APP_MONITOR::BREADCRUMB_TYPE::UI
@ UI
Definition
app_monitor.h:39
APP_MONITOR::BREADCRUMB_TYPE::DBG
@ DBG
Definition
app_monitor.h:33
APP_MONITOR::BREADCRUMB_TYPE::ERR
@ ERR
Definition
app_monitor.h:34
APP_MONITOR::BREADCRUMB_LEVEL
BREADCRUMB_LEVEL
Definition
app_monitor.h:44
APP_MONITOR::BREADCRUMB_LEVEL::WARNING
@ WARNING
Definition
app_monitor.h:47
APP_MONITOR::BREADCRUMB_LEVEL::FATAL
@ FATAL
Definition
app_monitor.h:45
APP_MONITOR::BREADCRUMB_LEVEL::INFO
@ INFO
Definition
app_monitor.h:48
APP_MONITOR::AddBreadcrumb
void AddBreadcrumb(BREADCRUMB_TYPE aType, const wxString &aMsg, const wxString &aCategory, BREADCRUMB_LEVEL aLevel)
Add a sentry breadcrumb.
Definition
app_monitor.cpp:340
APP_MONITOR::AddNavigationBreadcrumb
void AddNavigationBreadcrumb(const wxString &aMsg, const wxString &aCategory)
Add a navigation breadcrumb.
Definition
app_monitor.cpp:364
APP_MONITOR::operator<
bool operator<(const ASSERT_CACHE_KEY &aKey1, const ASSERT_CACHE_KEY &aKey2)
Definition
app_monitor.cpp:325
APP_MONITOR::ASSERT_CACHE_KEY
This struct represents a key being used for the std::set that deduplicates asserts during this runnin...
Definition
app_monitor.h:86
APP_MONITOR::ASSERT_CACHE_KEY::func
wxString func
Definition
app_monitor.h:89
APP_MONITOR::ASSERT_CACHE_KEY::cond
wxString cond
Definition
app_monitor.h:90
APP_MONITOR::ASSERT_CACHE_KEY::line
int line
Definition
app_monitor.h:88
APP_MONITOR::ASSERT_CACHE_KEY::file
wxString file
Definition
app_monitor.h:87
src
include
app_monitor.h
Generated on Fri Jun 26 2026 00:05:36 for KiCad PCB EDA Suite by
1.13.2