36
36
namespace llvm {
37
37
namespace telemetry {
38
38
39
- // Configuration for the Telemeter class.
40
- // This struct can be extended as needed.
39
+ // / Configuration for the Telemeter class.
40
+ // / This stores configurations from both users and vendors and is passed
41
+ // / to the Telemeter upon contruction. (Any changes to the config after
42
+ // / the Telemeter's construction will not have effect on it).
43
+ // /
44
+ // / This struct can be extended as needed to add additional configuration
45
+ // / points specific to a vendor's implementation.
41
46
struct Config {
42
47
// If true, telemetry will be enabled.
43
48
bool EnableTelemetry;
@@ -51,11 +56,11 @@ struct Config {
51
56
std::vector<std::string> AdditionalDestinations;
52
57
};
53
58
54
- // Defines a convenient type for timestamp of various events.
55
- // This is used by the EventStats below.
59
+ // / Defines a convenient type for timestamp of various events.
60
+ // / This is used by the EventStats below.
56
61
using SteadyTimePoint = std::chrono::time_point<std::chrono::steady_clock>;
57
62
58
- // Various time (and possibly memory) statistics of an event.
63
+ // / Various time (and possibly memory) statistics of an event.
59
64
struct EventStats {
60
65
// REQUIRED: Start time of an event
61
66
SteadyTimePoint Start;
@@ -69,25 +74,34 @@ struct EventStats {
69
74
: Start(Start), End(End) {}
70
75
};
71
76
77
+ // / Describes the exit signal of an event.
78
+ // / This is used by TelemetryInfo below.
72
79
struct ExitDescription {
73
80
int ExitCode;
74
81
std::string Description;
75
82
};
76
83
77
- // For isa, dyn_cast, etc operations on TelemetryInfo.
84
+ // / For isa, dyn_cast, etc operations on TelemetryInfo.
78
85
typedef unsigned KindType;
79
- // The EntryKind is defined as a struct because it is expectend to be
80
- // extended by subclasses which may have additional TelemetryInfo
81
- // types defined.
86
+ // / This struct is used by TelemetryInfo to support isa<>, dyn_cast<>
87
+ // / operations.
88
+ // / It is defined as a struct(rather than an enum) because it is
89
+ // / expectend to be extended by subclasses which may have
90
+ // / additional TelemetryInfo types defined to describe different events.
82
91
struct EntryKind {
83
92
static const KindType Base = 0 ;
84
93
};
85
94
86
- // TelemetryInfo is the data courier, used to forward data from
87
- // the tool being monitored to the Telemery framework.
88
- //
89
- // This base class contains only the basic set of telemetry data.
90
- // Downstream implementations can add more fields as needed.
95
+ // / TelemetryInfo is the data courier, used to move instrumented data
96
+ // / the tool being monitored to the Telemery framework.
97
+ // /
98
+ // / This base class contains only the basic set of telemetry data.
99
+ // / Downstream implementations can add more fields as needed to describe
100
+ // / additional events.
101
+ // /
102
+ // / For eg., The LLDB debugger can define a DebugCommandInfo subclass
103
+ // / which has additional fields about the debug-command being instrumented,
104
+ // / such as `CommandArguments` or `CommandName`.
91
105
struct TelemetryInfo {
92
106
// This represents a unique-id, conventionally corresponding to
93
107
// a tools' session - ie., every time the tool starts until it exits.
@@ -123,23 +137,23 @@ struct TelemetryInfo {
123
137
}
124
138
};
125
139
126
- // This class presents a data sink to which the Telemetry framework
127
- // sends data.
128
- //
129
- // Its implementation is transparent to the framework.
130
- // It is up to the vendor to decide which pieces of data to forward
131
- // and where to forward them.
140
+ // / This class presents a data sink to which the Telemetry framework
141
+ // / sends data.
142
+ // /
143
+ // / Its implementation is transparent to the framework.
144
+ // / It is up to the vendor to decide which pieces of data to forward
145
+ // / and where to forward them.
132
146
class Destination {
133
147
public:
134
148
virtual ~Destination () = default ;
135
149
virtual Error emitEntry (const TelemetryInfo *Entry) = 0;
136
150
virtual std::string name () const = 0;
137
151
};
138
152
139
- // This class is the main interaction point between any LLVM tool
140
- // and this framework.
141
- // It is responsible for collecting telemetry data from the tool being
142
- // monitored.
153
+ // / This class is the main interaction point between any LLVM tool
154
+ // / and this framework.
155
+ // / It is responsible for collecting telemetry data from the tool being
156
+ // / monitored and transmitting the data elsewhere .
143
157
class Telemeter {
144
158
public:
145
159
// Invoked upon tool startup
0 commit comments