Skip to content

Commit fa3def5

Browse files
committed
annotate all trace events with the current tag
1 parent 3dd7632 commit fa3def5

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

include/reactor-cpp/trace.hh

+10-2
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,15 @@ TRACEPOINT_EVENT(
3737
reaction_execution_starts,
3838
TP_ARGS(
3939
int, worker_id_arg,
40-
const std::string&, reaction_name_arg
40+
const std::string&, reaction_name_arg,
41+
const reactor::LogicalTime&, tag_arg
4142
),
4243
TP_FIELDS(
4344
ctf_string(reaction_name, reaction_name_arg.c_str())
4445
ctf_integer(int, worker_id, worker_id_arg)
46+
ctf_integer(unsigned long, timestamp_ns,
47+
tag_arg.time_point().time_since_epoch().count())
48+
ctf_integer(unsigned, timestamp_microstep, tag_arg.micro_step())
4549
)
4650
)
4751

@@ -50,11 +54,15 @@ TRACEPOINT_EVENT(
5054
reaction_execution_finishes,
5155
TP_ARGS(
5256
int, worker_id_arg,
53-
const std::string&, reaction_name_arg
57+
const std::string&, reaction_name_arg,
58+
const reactor::LogicalTime&, tag_arg
5459
),
5560
TP_FIELDS(
5661
ctf_string(reaction_name, reaction_name_arg.c_str())
5762
ctf_integer(int, worker_id, worker_id_arg)
63+
ctf_integer(unsigned long, timestamp_ns,
64+
tag_arg.time_point().time_since_epoch().count())
65+
ctf_integer(unsigned, timestamp_microstep, tag_arg.micro_step())
5866
)
5967
)
6068

lib/scheduler.cc

+4-2
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,11 @@ void Worker::work() const {
7070
void Worker::execute_reaction(Reaction* reaction) const {
7171
log::Debug() << "(Worker " << id << ") "
7272
<< "execute reaction " << reaction->fqn();
73-
tracepoint(reactor_cpp, reaction_execution_starts, id, reaction->fqn());
73+
tracepoint(reactor_cpp, reaction_execution_starts, id, reaction->fqn(),
74+
scheduler.logical_time());
7475
reaction->trigger();
75-
tracepoint(reactor_cpp, reaction_execution_finishes, id, reaction->fqn());
76+
tracepoint(reactor_cpp, reaction_execution_finishes, id, reaction->fqn(),
77+
scheduler.logical_time());
7678
}
7779

7880
void Scheduler::schedule() {

tracing/ctf_to_json.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ def reaction_execution_starts_to_dict(msg):
144144
"ts": get_timestamp_us(msg),
145145
"pid": 0,
146146
"tid": int(event["worker_id"]),
147+
"args": {
148+
"microstep": int(event["timestamp_microstep"]),
149+
"timestamp_ns": int(event["timestamp_ns"])
150+
}
147151
}
148152

149153

@@ -156,6 +160,10 @@ def reaction_execution_finishes_to_dict(msg):
156160
"ts": get_timestamp_us(msg),
157161
"pid": 0,
158162
"tid": int(event["worker_id"]),
163+
"args": {
164+
"microstep": int(event["timestamp_microstep"]),
165+
"timestamp_ns": int(event["timestamp_ns"])
166+
}
159167
}
160168

161169

@@ -172,7 +180,8 @@ def schedule_action_to_dict(msg):
172180
"s": "t",
173181
"cname": "terrible",
174182
"args": {
175-
"microstep": int(event["timestamp_microstep"])
183+
"microstep": int(event["timestamp_microstep"]),
184+
"timestamp_ns": int(event["timestamp_ns"])
176185
}
177186
}
178187

@@ -190,7 +199,8 @@ def trigger_reaction_to_dict(msg):
190199
"s": "t",
191200
"cname": "light_memory_dump",
192201
"args": {
193-
"microstep": int(event["timestamp_microstep"])
202+
"microstep": int(event["timestamp_microstep"]),
203+
"timestamp_ns": int(event["timestamp_ns"])
194204
}
195205
}
196206

0 commit comments

Comments
 (0)