File: et_collector.3

package info (click to toggle)
erlang-manpages 1%3A12.b.3-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 4,188 kB
  • ctags: 2
  • sloc: makefile: 68; perl: 30; sh: 15
file content (472 lines) | stat: -rw-r--r-- 10,584 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
.TH et_collector 3 "et  1.3" "Ericsson AB" "ERLANG MODULE DEFINITION"
.SH MODULE
et_collector \- Collect trace events and provide a backing storage appropriate for iteration 
.SH DESCRIPTION
.LP
Interface module for the Event Trace (ET) application

.SH EXPORTS
.LP
.B
start_link(Options) -> {ok, CollectorPid} | {error, Reason}
.br
.RS
.TP
Types
Options = [option()]
.br
option() = {parent_pid, pid()} | {event_order, event_order()} | {dict_insert, {filter, collector}, collector_fun()} | {dict_insert, {filter, event_filter_name()}, event_filter_fun()} | {dict_insert, {subscriber, pid()}, dict_val()} | {dict_insert, dict_key(), dict_val()} | {dict_delete, dict_key()} | {trace_client, trace_client()} | {trace_global, boolean()} | {trace_pattern, trace_pattern()} | {trace_port, integer()} | {trace_max_queue, integer()}
.br
event_order() = trace_ts | event_ts
.br
trace_pattern() = {report_module(), extended_dbg_match_spec()} | undefined
.br
report_module() = atom() | undefined <v>extended_dbg_match_spec()() = detail_level() | dbg_match_spec()
.br
detail_level() = min | max | integer(X) when X =< 0, X >= 100
.br
trace_client() = {event_file, file_name()} | {dbg_trace_type(), dbg_trace_parameters()}
.br
file_name() = string()
.br
collector_fun() = trace_filter_fun() | event_filter_fun()
.br
trace_filter_fun() = fun(TraceData) -> false | true | {true, NewEvent}
.br
event_filter_fun() = fun(Event) -> false | true | {true, NewEvent}
.br
event_filter_name() = atom()
.br
TraceData = erlang_trace_data()
.br
Event = NewEvent = record(event)
.br
dict_key() = term()
.br
dict_val() = term()
.br
CollectorPid = pid()
.br
Reason = term()
.br
.RE
.RS
.LP
Start a collector process\&.
.LP
The collector collects trace events and keeps them ordered by their timestamp\&. The timestamp may either reflect the time when the actual trace data was generated (trace_ts) or when the trace data was transformed into an event record (event_ts)\&. If the time stamp is missing in the trace data (missing timestamp option to erlang:trace/4) the trace_ts will be set to the event_ts\&.
.LP
Events are reported to the collector directly with the report function or indirectly via one or more trace clients\&. All reported events are first filtered thru the collector filter before they are stored by the collector\&. By replacing the default collector filter with a customized dito it is possible to allow any trace data as input\&. The collector filter is a dictionary entry with the predefined key {filter, collector} and the value is a fun of arity 1\&. See et_selector:make_event/1 for interface details, such as which erlang:trace/1 tuples that are accepted\&.
.LP
The collector has a built-in dictionary service\&. Any term may be stored as value in the dictionary and bound to a unique key\&. When new values are inserted with an existing key, the new values will overwrite the existing ones\&. Processes may subscribe on dictionary updates by using {subscriber, pid()} as dictionary key\&. All dictionary updates will be propagated to the subscriber processes matching the pattern {{subscriber, \&'_\&'}, \&'_\&'} where the first \&'_\&' is interpreted as a pid()\&.
.LP
In global trace mode, the collector will automatically start tracing on all connected Erlang nodes\&. When a node connects, a port tracer will be started on that node and a corresponding trace client on the collector node\&. By default the global trace pattern is \&'max\&'\&.
.LP
Default values:
.RS 2
.TP 2
*
parent_pid - self()\&.
.TP 2
*
event_order - trace_ts\&.
.TP 2
*
trace_global - false\&.
.TP 2
*
trace_pattern - undefined\&.
.TP 2
*
trace_port - 4711\&.
.TP 2
*
trace_max_queue - 50\&.
.RE
.RE
.LP
.B
stop(CollectorPid) -> ok
.br
.RS
.TP
Types
CollectorPid = pid()
.br
.RE
.RS
.LP
Stop a collector process\&.
.RE
.LP
.B
save_event_file(CollectorPid, FileName, Options) -> ok | {error, Reason}
.br
.RS
.TP
Types
CollectorPid = pid()
.br
FileName = string()
.br
Options = [option()]
.br
Reason = term()
.br
option() = event_option() | file_option() | table_option()
.br
event_option() = existing
.br
file_option() = write | append
.br
table_option() = keep | clear
.br
.RE
.RS
.LP
Save the events to a file\&.
.LP
By default the currently stored events (existing) are written to a brand new file (write) and the events are kept (keep) after they have been written to the file\&.
.LP
Instead of keeping the events after writing them to file, it is possible to remove all stored events after they have successfully written to file (clear)\&.
.LP
The options defaults to existing, write and keep\&.
.RE
.LP
.B
load_event_file(CollectorPid, FileName) -> {ok, BadBytes} | exit(Reason)
.br
.RS
.TP
Types
CollectorPid = pid()
.br
FileName = string()
.br
BadBytes = integer(X) where X >= 0
.br
Reason = term()
.br
.RE
.RS
.LP
Load the event table from a file\&.
.RE
.LP
.B
report(Handle, TraceOrEvent) -> {ok, Continuation} | exit(Reason)
.br
.B
report_event(Handle, DetailLevel, FromTo, Label, Contents) -> {ok, Continuation} | exit(Reason)
.br
.B
report_event(Handle, DetailLevel, From, To, Label, Contents) -> {ok, Continuation} | exit(Reason)
.br
.RS
.TP
Types
Handle = Initial | Continuation
.br
Initial = collector_pid()
.br
collector_pid() = pid()
.br
Continuation = record(table_handle)
.br
TraceOrEvent = record(event) | dbg_trace_tuple() | end_of_trace
.br
Reason = term()
.br
DetailLevel = integer(X) when X =< 0, X >= 100
.br
From = actor()
.br
To = actor()
.br
FromTo = actor()
.br
Label = atom() | string() | term()
.br
Contents = [{Key, Value}] | term()
.br
actor() = term()
.br
.RE
.RS
.LP
Report an event to the collector\&.
.LP
All events are filtered thru the collector filter, which optionally may transform or discard the event\&. The first call should use the pid of the collector process as report handle, while subsequent calls should use the table handle\&.
.RE
.LP
.B
make_key(Type, Stuff) -> Key
.br
.RS
.TP
Types
Type = record(table_handle) | trace_ts | event_ts
.br
Stuff = record(event) | Key
.br
Key = record(event_ts) | record(trace_ts)
.br
.RE
.RS
.LP
Make a key out of an event record or an old key\&.
.RE
.LP
.B
get_table_handle(CollectorPid) -> Handle
.br
.RS
.TP
Types
CollectorPid = pid()
.br
Handle = record(table_handle)
.br
.RE
.RS
.LP
Return a table handle\&.
.RE
.LP
.B
get_global_pid() -> CollectorPid | exit(Reason)
.br
.RS
.TP
Types
CollectorPid = pid()
.br
Reason = term()
.br
.RE
.RS
.LP
Return a the identity of the globally registered collector if there is any\&.
.RE
.LP
.B
change_pattern(CollectorPid, RawPattern) -> {old_pattern, TracePattern}
.br
.RS
.TP
Types
CollectorPid = pid()
.br
RawPattern = {report_module(), extended_dbg_match_spec()}
.br
report_module() = atom() | undefined
.br
extended_dbg_match_spec()() = detail_level() | dbg_match_spec()
.br
RawPattern = detail_level()
.br
detail_level() = min | max | integer(X) when X =< 0, X >= 100
.br
TracePattern = {report_module(), dbg_match_spec_match_spec()}
.br
.RE
.RS
.LP
Change active trace pattern globally on all trace nodes\&.
.RE
.LP
.B
dict_insert(CollectorPid, {filter, collector}, FilterFun) -> ok
.br
.B
dict_insert(CollectorPid, {subscriber, SubscriberPid}, Void) -> ok
.br
.B
dict_insert(CollectorPid, Key, Val) -> ok
.br
.RS
.TP
Types
CollectorPid = pid()
.br
FilterFun = filter_fun() 
.br
SubscriberPid = pid()
.br
Void = term()
.br
Key = term()
.br
Val = term()
.br
.RE
.RS
.LP
Insert a dictionary entry and send a {et, {dict_insert, Key, Val}} tuple to all registered subscribers\&.
.LP
If the entry is a new subscriber, it will imply that the new subscriber process first will get one message for each already stored dictionary entry, before it and all old subscribers will get this particular entry\&. The collector process links to and then supervises the subscriber process\&. If the subscriber process dies it will imply that it gets unregistered as with a normal dict_delete/2\&.
.RE
.LP
.B
dict_lookup(CollectorPid, Key) -> [Val]
.br
.RS
.TP
Types
CollectorPid = pid()
.br
FilterFun = filter_fun() 
.br
CollectorPid = pid()
.br
Key = term()
.br
Val = term()
.br
.RE
.RS
.LP
Lookup a dictionary entry and return zero or one value\&.
.RE
.LP
.B
dict_delete(CollectorPid, Key) -> ok
.br
.RS
.TP
Types
CollectorPid = pid()
.br
SubscriberPid = pid()
.br
Key = {subscriber, SubscriberPid} | term()
.br
.RE
.RS
.LP
Delete a dictionary entry and send a {et, {dict_delete, Key}} tuple to all registered subscribers\&.
.LP
If the deleted entry is a registered subscriber, it will imply that the subscriber process gets is unregistered as subscriber as well as it gets it final message\&.
.RE
.LP
.B
dict_match(CollectorPid, Pattern) -> [Match]
.br
.RS
.TP
Types
CollectorPid = pid()
.br
Pattern = \&'_\&' | {key_pattern(), val_pattern()}
.br
key_pattern() = ets_match_object_pattern()
.br
val_pattern() = ets_match_object_pattern()
.br
Match = {key(), val()}
.br
key() = term()
.br
val() = term()
.br
.RE
.RS
.LP
Match some dictionary entries
.RE
.LP
.B
multicast(_CollectorPid, Msg) -> ok
.br
.RS
.TP
Types
CollectorPid = pid()
.br
CollectorPid = pid()
.br
Msg = term()
.br
.RE
.RS
.LP
Sends a message to all registered subscribers\&.
.RE
.LP
.B
start_trace_client(CollectorPid, Type, Parameters) -> file_loaded | {trace_client_pid, pid()} | exit(Reason)
.br
.RS
.TP
Types
Type = dbg_trace_client_type()
.br
Parameters = dbg_trace_client_parameters()
.br
Pid = dbg_trace_client_pid()
.br
.RE
.RS
.LP
Load raw Erlang trace from a file, port or process\&.
.RE
.LP
.B
iterate(Handle, Prev, Limit) -> NewAcc
.br
.RS
.LP
Short for iterate(Handle, Prev, Limit, undefined, Prev) -> NewAcc
.RE
.LP
.B
iterate(Handle, Prev, Limit, Fun, Acc) -> NewAcc
.br
.RS
.TP
Types
Handle = collector_pid() | table_handle()
.br
Prev = first | last | event_key()
.br
Limit = done() | forward() | backward()
.br
collector_pid() = pid()
.br
table_handle() = record(table_handle)
.br
event_key() = record(event) | record(event_ts) | record(trace_ts)
.br
done() = 0
.br
forward() = infinity | integer(X) where X > 0
.br
backward() = \&'-infinity\&' | integer(X) where X < 0
.br
Fun = fun(Event, Acc) -> NewAcc <v>Acc = NewAcc = term()
.br
.RE
.RS
.LP
Iterate over the currently stored events\&.
.LP
Iterates over the currently stored eventsand applies a function for each event\&. The iteration may be performed forwards or backwards and may be limited to a maximum number of events (abs(Limit))\&.
.RE
.LP
.B
clear_table(Handle) -> ok
.br
.RS
.TP
Types
Handle = collector_pid() | table_handle()
.br
collector_pid() = pid()
.br
table_handle() = record(table_handle)
.br
.RE
.RS
.LP
Clear the event table\&.
.RE