-
Notifications
You must be signed in to change notification settings - Fork 8
/
evt_parse.go
761 lines (621 loc) · 19.6 KB
/
evt_parse.go
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
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
package trace2receiver
import (
"bytes"
"encoding/json"
"fmt"
"time"
"go.uber.org/zap"
)
type TrEvent struct {
// Common/Required fields for all Trace2 JSON Events.
mf_event string
mf_sid string
mf_thread string
mf_time time.Time
pmf_repo *int64 // (aka repo_id) is optional
//mf_file -- optional
//mf_line -- optional
// Variable portion depends on the type of the event.
pm_version *TrEventVersion
pm_start *TrEventStart
pm_atexit *TrEventAtExit // "exit" or "atexit"
pm_signal *TrEventSignal
pm_error *TrEventError
pm_cmd_path *TrEventCmdPath
pm_cmd_ancestry *TrEventCmdAncestry
pm_cmd_name *TrEventCmdName
pm_cmd_mode *TrEventCmdMode
pm_alias *TrEventAlias
pm_child_start *TrEventChildStart
pm_child_exit *TrEventChildExit
pm_child_ready *TrEventChildReady
pm_thread_start *TrEventThreadStart
pm_thread_exit *TrEventThreadExit
pm_exec *TrEventExec
pm_exec_result *TrEventExecResult
pm_def_param *TrEventDefParam
pm_def_repo *TrEventDefRepo
pm_region_enter *TrEventRegionEnter
pm_region_leave *TrEventRegionLeave
pm_generic_data *TrEventGenericData
pm_timer *TrEventTimer // "timer" and "th_timer"
pm_counter *TrEventCounter // "counter" and "th_counter"
}
type FnExtractKeys func(evt *TrEvent, jm *jmap) (err error)
type ExtractKeysMap map[string]FnExtractKeys
var ekm *ExtractKeysMap = &ExtractKeysMap{
"version": extract_keys__version,
"start": extract_keys__start,
"exit": extract_keys__atexit,
"atexit": extract_keys__atexit,
"signal": extract_keys__signal,
"error": extract_keys__error,
"cmd_path": extract_keys__cmd_path,
"cmd_ancestry": extract_keys__cmd_ancestry,
"cmd_name": extract_keys__cmd_name,
"cmd_mode": extract_keys__cmd_mode,
"alias": extract_keys__alias,
"child_start": extract_keys__child_start,
"child_exit": extract_keys__child_exit,
"child_ready": extract_keys__child_ready,
"thread_start": extract_keys__thread_start,
"thread_exit": extract_keys__thread_exit,
"exec": extract_keys__exec,
"exec_result": extract_keys__exec_result,
"def_param": extract_keys__def_param,
"def_repo": extract_keys__def_repo,
"region_enter": extract_keys__region_enter,
"region_leave": extract_keys__region_leave,
"data": extract_keys__data,
"data_json": extract_keys__data_json,
"timer": extract_keys__timer,
"th_timer": extract_keys__timer,
"counter": extract_keys__counter,
"th_counter": extract_keys__counter,
"too_many_files": nil, // we don't care about this
}
var CommandControlVerbPrefix []byte = []byte("cc: ")
// Parse the raw line of text from the client and parse it.
//
// If is JSON, parse and validate it as a Trace2 event message.
// If it is a command/control from the helper tool, process it.
// If it is blank/empty or a "#-style" comment line, ignore it.
//
// Returns (nil, err) if we had an error.
// Returns (nil, nil) if we had command/control data.
// Returns (evt, nil) if we had event data.
func evt_parse(rawLine []byte, logger *zap.Logger, allowCommands bool) (*TrEvent, error) {
trimmed := bytes.TrimSpace(rawLine)
if len(trimmed) == 0 || trimmed[0] == '#' {
return nil, nil
}
if trimmed[0] == '{' {
return parse_json(trimmed)
}
if bytes.HasPrefix(trimmed, CommandControlVerbPrefix) {
if allowCommands {
return nil, do_command_verb(trimmed[len(CommandControlVerbPrefix):], logger)
} else {
logger.Debug(fmt.Sprintf("command verbs are disabled: '%s'", trimmed))
return nil, nil
}
}
logger.Debug(fmt.Sprintf("unrecognized data stream verb: '%s'", trimmed))
return nil, nil
}
func do_command_verb(cmd []byte, logger *zap.Logger) error {
logger.Debug(fmt.Sprintf("Command verb: '%s'", cmd))
// TODO do something with the rest of the line and return.
logger.Debug(fmt.Sprintf("invalid command verb: '%s'", cmd))
return nil
}
// Process a raw line of text from the client. This should contain a single
// line of Trace2 data in JSON format. But we do allow command and control
// verbs (primarily for test and debug).
func processRawLine(rawLine []byte, tr2 *trace2Dataset, logger *zap.Logger, allowCommands bool) error {
logger.Debug(fmt.Sprintf("[dsid %06d] saw: %s", tr2.datasetId, rawLine))
evt, err := evt_parse(rawLine, logger, allowCommands)
if err != nil {
logger.Error(err.Error())
return err
}
if evt != nil {
tr2.sawData = true
err = evt_apply(tr2, evt)
if err != nil {
if rce, ok := err.(*RejectClientError); ok {
// Silently reject the client without logging an error.
logger.Debug(rce.Error())
return rce
}
logger.Error(err.Error())
return err
}
}
return nil
}
func parse_json(line []byte) (*TrEvent, error) {
var err error
var jm *jmap = new(jmap)
if err = json.Unmarshal(line, jm); err != nil {
return nil, err
}
evt := &TrEvent{}
if err = extract_keys__common(evt, jm); err != nil {
return evt, err
}
ekfn, ok := (*ekm)[evt.mf_event]
if !ok {
// Unrecognized event type. Ignore since the Trace2 format
// is allowed to add new event types in the future.
//
// TODO Consider debug level logging this.
return evt, nil
}
if ekfn == nil {
// Recognized event type, but we either don't care about
// it or don't have any event-specific fields to extract.
return evt, nil
}
return evt, ekfn(evt, jm)
}
// Parse common key/value pairs found in almost all Trace2 events.
func extract_keys__common(evt *TrEvent, jm *jmap) (err error) {
if evt.mf_event, err = jm.getRequiredString("event"); err != nil {
return err
}
if evt.mf_sid, err = jm.getRequiredString("sid"); err != nil {
return err
}
if evt.mf_thread, err = jm.getRequiredString("thread"); err != nil {
return err
}
if evt.mf_time, err = jm.getRequiredTime("time"); err != nil {
// Force a failure if "time" is omitted.
//
// We require "time" on all events so that we can set the span
// duration on bracketed units of work. However, "time" is not
// emitted by Git on most events when in "brief" mode. For now,
// don't bother trying to support clients in brief mode.
return err
}
if evt.pmf_repo, err = jm.getOptionalInt64("repo"); err != nil {
return err
}
// TODO Do we care about "file" and "line"?
return nil
}
// Event fields only present in an "event":"version" event
type TrEventVersion struct {
mf_evt string // 'evt'
mf_exe string // 'exe'
}
func extract_keys__version(evt *TrEvent, jm *jmap) (err error) {
evt.pm_version = &TrEventVersion{}
if evt.pm_version.mf_evt, err = jm.getRequiredString("evt"); err != nil {
return err
}
if evt.pm_version.mf_exe, err = jm.getRequiredString("exe"); err != nil {
return err
}
return nil
}
// Event fields only present in an "event":"start" event
type TrEventStart struct {
mf_argv []interface{}
// TODO? t_abs
}
func extract_keys__start(evt *TrEvent, jm *jmap) (err error) {
evt.pm_start = &TrEventStart{}
if evt.pm_start.mf_argv, err = jm.getRequiredArray("argv"); err != nil {
return err
}
return nil
}
// Event fields only present in an "event":"exit" or "event":"atexit" event
type TrEventAtExit struct {
mf_code int64
// TODO? t_abs
}
func extract_keys__atexit(evt *TrEvent, jm *jmap) (err error) {
if evt.pm_atexit == nil {
evt.pm_atexit = &TrEventAtExit{}
}
if evt.pm_atexit.mf_code, err = jm.getRequiredInt64("code"); err != nil {
return err
}
return nil
}
// Event fields only present in an "event":"signal" event
type TrEventSignal struct {
mf_signo int64
// TODO? t_abs
}
func extract_keys__signal(evt *TrEvent, jm *jmap) (err error) {
evt.pm_signal = &TrEventSignal{}
if evt.pm_signal.mf_signo, err = jm.getRequiredInt64("signo"); err != nil {
return err
}
return nil
}
// Event fields only present in an "event":"error" event
type TrEventError struct {
mf_msg string
mf_fmt string
}
func extract_keys__error(evt *TrEvent, jm *jmap) (err error) {
evt.pm_error = &TrEventError{}
if evt.pm_error.mf_msg, err = jm.getRequiredString("msg"); err != nil {
return err
}
if evt.pm_error.mf_fmt, err = jm.getRequiredString("fmt"); err != nil {
return err
}
return nil
}
// Event fields only present in an "event":"cmd_path" event
type TrEventCmdPath struct {
mf_path string
}
func extract_keys__cmd_path(evt *TrEvent, jm *jmap) (err error) {
evt.pm_cmd_path = &TrEventCmdPath{}
if evt.pm_cmd_path.mf_path, err = jm.getRequiredString("path"); err != nil {
return err
}
return nil
}
// Event fields only present in an "event":"ancestry" event
type TrEventCmdAncestry struct {
mf_ancestry []interface{}
}
func extract_keys__cmd_ancestry(evt *TrEvent, jm *jmap) (err error) {
evt.pm_cmd_ancestry = &TrEventCmdAncestry{}
if evt.pm_cmd_ancestry.mf_ancestry, err = jm.getRequiredArray("ancestry"); err != nil {
return err
}
return nil
}
// Event fields only present in an "event":"cmd_name" event
type TrEventCmdName struct {
mf_name string
mf_hierarchy string
}
func extract_keys__cmd_name(evt *TrEvent, jm *jmap) (err error) {
evt.pm_cmd_name = &TrEventCmdName{}
if evt.pm_cmd_name.mf_name, err = jm.getRequiredString("name"); err != nil {
return err
}
if evt.pm_cmd_name.mf_hierarchy, err = jm.getRequiredString("hierarchy"); err != nil {
return err
}
return nil
}
// Event fields only present in an "event":"cmd_mode" event
type TrEventCmdMode struct {
mf_name string
}
func extract_keys__cmd_mode(evt *TrEvent, jm *jmap) (err error) {
evt.pm_cmd_mode = &TrEventCmdMode{}
if evt.pm_cmd_mode.mf_name, err = jm.getRequiredString("name"); err != nil {
return err
}
return nil
}
// Event fields only present in an "event":"alias" event
type TrEventAlias struct {
mf_alias string
mf_argv []interface{}
}
func extract_keys__alias(evt *TrEvent, jm *jmap) (err error) {
evt.pm_alias = &TrEventAlias{}
if evt.pm_alias.mf_alias, err = jm.getRequiredString("alias"); err != nil {
return err
}
if evt.pm_alias.mf_argv, err = jm.getRequiredArray("argv"); err != nil {
return err
}
return nil
}
// Event fields only present in an "event":"child_start" event
type TrEventChildStart struct {
mf_child_id int64
mf_child_class string
mf_use_shell bool
mf_argv []interface{}
pmf_hook_name *string // only set when child_class is "hook"
pmf_cd *string // optional
}
func extract_keys__child_start(evt *TrEvent, jm *jmap) (err error) {
evt.pm_child_start = &TrEventChildStart{}
if evt.pm_child_start.mf_child_id, err = jm.getRequiredInt64("child_id"); err != nil {
return err
}
if evt.pm_child_start.mf_child_class, err = jm.getRequiredString("child_class"); err != nil {
return err
}
if evt.pm_child_start.mf_use_shell, err = jm.getRequiredBool("use_shell"); err != nil {
return err
}
if evt.pm_child_start.mf_argv, err = jm.getRequiredArray("argv"); err != nil {
return err
}
if evt.pm_child_start.mf_child_class == "hook" {
evt.pm_child_start.pmf_hook_name = new(string)
if *evt.pm_child_start.pmf_hook_name, err = jm.getRequiredString("hook_name"); err != nil {
return err
}
}
if evt.pm_child_start.pmf_cd, err = jm.getOptionalString("cd"); err != nil {
return err
}
return nil
}
// Event fields only present in an "event":"child_exit" event
type TrEventChildExit struct {
mf_child_id int64
mf_pid int64
mf_code int64
// TODO? t_rel
}
func extract_keys__child_exit(evt *TrEvent, jm *jmap) (err error) {
evt.pm_child_exit = &TrEventChildExit{}
if evt.pm_child_exit.mf_child_id, err = jm.getRequiredInt64("child_id"); err != nil {
return err
}
if evt.pm_child_exit.mf_pid, err = jm.getRequiredInt64("pid"); err != nil {
return err
}
if evt.pm_child_exit.mf_code, err = jm.getRequiredInt64("code"); err != nil {
return err
}
return nil
}
// Event fields only present in an "event":"child_ready" event.
// Note that there is no exit-code, only a ready state hint.
type TrEventChildReady struct {
mf_child_id int64
mf_pid int64
mf_ready string
// TODO? t_rel
}
func extract_keys__child_ready(evt *TrEvent, jm *jmap) (err error) {
evt.pm_child_ready = &TrEventChildReady{}
if evt.pm_child_ready.mf_child_id, err = jm.getRequiredInt64("child_id"); err != nil {
return err
}
if evt.pm_child_ready.mf_pid, err = jm.getRequiredInt64("pid"); err != nil {
return err
}
if evt.pm_child_ready.mf_ready, err = jm.getRequiredString("ready"); err != nil {
return err
}
return nil
}
// Event fields only present in an "event":"thread_start" event
type TrEventThreadStart struct {
}
func extract_keys__thread_start(evt *TrEvent, jm *jmap) (err error) {
evt.pm_thread_start = &TrEventThreadStart{}
return nil
}
// Event fields only present in an "event":"thread_exit" event
type TrEventThreadExit struct {
// TODO? t_rel
}
func extract_keys__thread_exit(evt *TrEvent, jm *jmap) (err error) {
evt.pm_thread_exit = &TrEventThreadExit{}
return nil
}
// Event fields only present in an "event":"exec" event
type TrEventExec struct {
mf_exec_id int64
mf_argv []interface{}
pmf_exe *string // optional
}
func extract_keys__exec(evt *TrEvent, jm *jmap) (err error) {
evt.pm_exec = &TrEventExec{}
if evt.pm_exec.mf_exec_id, err = jm.getRequiredInt64("exec_id"); err != nil {
return err
}
if evt.pm_exec.mf_argv, err = jm.getRequiredArray("argv"); err != nil {
return err
}
if evt.pm_exec.pmf_exe, err = jm.getOptionalString("exe"); err != nil {
return err
}
return nil
}
// Event fields only present in an "event":"exec_result" event
type TrEventExecResult struct {
mf_exec_id int64
mf_code int64
}
func extract_keys__exec_result(evt *TrEvent, jm *jmap) (err error) {
evt.pm_exec_result = &TrEventExecResult{}
if evt.pm_exec_result.mf_exec_id, err = jm.getRequiredInt64("exec_id"); err != nil {
return err
}
if evt.pm_exec_result.mf_code, err = jm.getRequiredInt64("code"); err != nil {
return err
}
return nil
}
// Event fields only present in an "event":"def_param" event
type TrEventDefParam struct {
mf_param string
mf_value string
pmf_scope *string // added to Git in 2022/08, so do not require it yet
}
func extract_keys__def_param(evt *TrEvent, jm *jmap) (err error) {
evt.pm_def_param = &TrEventDefParam{}
if evt.pm_def_param.mf_param, err = jm.getRequiredString("param"); err != nil {
return err
}
if evt.pm_def_param.mf_value, err = jm.getRequiredString("value"); err != nil {
return err
}
if evt.pm_def_param.pmf_scope, err = jm.getOptionalString("scope"); err != nil {
return err
}
return nil
}
// Event fields only present in an "event":"def_repo" event
type TrEventDefRepo struct {
mf_worktree string
}
func extract_keys__def_repo(evt *TrEvent, jm *jmap) (err error) {
evt.pm_def_repo = &TrEventDefRepo{}
// "repo" (aka the `repo_id`) was handled in the common fields
// section, but it was considered optional. Force it for this
// event.
if evt.pmf_repo == nil {
return fmt.Errorf("key 'repo' is not present in Trace2 event")
}
if evt.pm_def_repo.mf_worktree, err = jm.getRequiredString("worktree"); err != nil {
return err
}
return nil
}
// Event fields only present in an "event":"region_enter" event
type TrEventRegionEnter struct {
mf_nesting int64
pmf_category *string // optional category
pmf_label *string // optional label
pmf_msg *string // optional message
}
func extract_keys__region_enter(evt *TrEvent, jm *jmap) (err error) {
evt.pm_region_enter = &TrEventRegionEnter{}
if evt.pm_region_enter.mf_nesting, err = jm.getRequiredInt64("nesting"); err != nil {
return err
}
// "repo" (aka the `repo_id`) was handled in the common fields section
if evt.pm_region_enter.pmf_category, err = jm.getOptionalString("category"); err != nil {
return err
}
if evt.pm_region_enter.pmf_label, err = jm.getOptionalString("label"); err != nil {
return err
}
if evt.pm_region_enter.pmf_msg, err = jm.getOptionalString("msg"); err != nil {
return err
}
return nil
}
// Event fields only present in an "event":"region_leave" event
type TrEventRegionLeave struct {
mf_nesting int64
pmf_category *string // optional category
pmf_label *string // optional label
pmf_msg *string // optional message
// TODO? t_rel
}
func extract_keys__region_leave(evt *TrEvent, jm *jmap) (err error) {
evt.pm_region_leave = &TrEventRegionLeave{}
if evt.pm_region_leave.mf_nesting, err = jm.getRequiredInt64("nesting"); err != nil {
return err
}
// "repo" (aka the `repo_id`) was handled in the common fields section
if evt.pm_region_leave.pmf_category, err = jm.getOptionalString("category"); err != nil {
return err
}
if evt.pm_region_leave.pmf_label, err = jm.getOptionalString("label"); err != nil {
return err
}
if evt.pm_region_leave.pmf_msg, err = jm.getOptionalString("msg"); err != nil {
return err
}
return nil
}
// Event fields only present in a "data" or "data_json" event.
// The value type can be string or int64 for the former.
type TrEventGenericData struct {
mf_nesting int64
mf_category string
mf_key string
mf_generic_value interface{}
// TODO? t_rel
// TODO? t_abs
}
func extract_keys__data(evt *TrEvent, jm *jmap) (err error) {
evt.pm_generic_data = &TrEventGenericData{}
// "repo" (aka the `repo_id`) was handled in the common fields section
if evt.pm_generic_data.mf_nesting, err = jm.getRequiredInt64("nesting"); err != nil {
return err
}
if evt.pm_generic_data.mf_category, err = jm.getRequiredString("category"); err != nil {
return err
}
if evt.pm_generic_data.mf_key, err = jm.getRequiredString("key"); err != nil {
return err
}
if evt.pm_generic_data.mf_generic_value, err = jm.getRequiredStringOrInt64("value"); err != nil {
return err
}
return nil
}
func extract_keys__data_json(evt *TrEvent, jm *jmap) (err error) {
evt.pm_generic_data = &TrEventGenericData{}
// "repo" (aka the `repo_id`) was handled in the common fields section
if evt.pm_generic_data.mf_nesting, err = jm.getRequiredInt64("nesting"); err != nil {
return err
}
if evt.pm_generic_data.mf_category, err = jm.getRequiredString("category"); err != nil {
return err
}
if evt.pm_generic_data.mf_key, err = jm.getRequiredString("key"); err != nil {
return err
}
if evt.pm_generic_data.mf_generic_value, err = jm.getRequired("value"); err != nil {
return err
}
return nil
}
// Event fields only present in an "event":"timer" or "event":"th_timer" events
type TrEventTimer struct {
mf_category string
mf_name string
mf_intervals int64
mf_t_total float64 // seconds
mf_t_min float64 // seconds
mf_t_max float64 // seconds
}
func extract_keys__timer(evt *TrEvent, jm *jmap) (err error) {
evt.pm_timer = &TrEventTimer{}
if evt.pm_timer.mf_category, err = jm.getRequiredString("category"); err != nil {
return err
}
if evt.pm_timer.mf_name, err = jm.getRequiredString("name"); err != nil {
return err
}
if evt.pm_timer.mf_intervals, err = jm.getRequiredInt64("intervals"); err != nil {
return err
}
if evt.pm_timer.mf_t_total, err = jm.getRequiredFloat64("t_total"); err != nil {
return err
}
if evt.pm_timer.mf_t_min, err = jm.getRequiredFloat64("t_min"); err != nil {
return err
}
if evt.pm_timer.mf_t_max, err = jm.getRequiredFloat64("t_max"); err != nil {
return err
}
return nil
}
// Event fields only present in "event":"counter" and "event":"th_counter" events
type TrEventCounter struct {
mf_category string
mf_name string
mf_count int64
}
func extract_keys__counter(evt *TrEvent, jm *jmap) (err error) {
evt.pm_counter = &TrEventCounter{}
if evt.pm_counter.mf_category, err = jm.getRequiredString("category"); err != nil {
return err
}
if evt.pm_counter.mf_name, err = jm.getRequiredString("name"); err != nil {
return err
}
if evt.pm_counter.mf_count, err = jm.getRequiredInt64("count"); err != nil {
return err
}
return nil
}