Debian Codegraph @

internal/golangorgx/tools/event/core/event.go

raw symbols SCIP
1 // Copyright 2019 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // Package core provides support for event based telemetry.
6 package corescip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/
7
8 import (
9 "fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/"
10 "timescip-go gomod github.com/golang/go/src go1.24.0 time/"
11
12 "cuelang.org/go/internal/golangorgx/tools/event/labelscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/label`/"
13 )
14
15 // Event holds the information about an event of note that occurred.
16 type Eventscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event# struct {
17 atscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#at. timescip-go gomod github.com/golang/go/src go1.24.0 time/.Timescip-go gomod github.com/golang/go/src go1.24.0 time/Time#
18
19 // As events are often on the stack, storing the first few labels directly
20 // in the event can avoid an allocation at all for the very common cases of
21 // simple events.
22 // The length needs to be large enough to cope with the majority of events
23 // but no so large as to cause undue stack pressure.
24 // A log message with two values will use 3 labels (one for each value and
25 // one for the message itself).
26
27 staticscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#static. [3]labelscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/label`/.Labelscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/label`/Label# // inline storage for the first few labels
28 dynamicscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#dynamic. []labelscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/label`/.Labelscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/label`/Label# // dynamically sized storage for remaining labels
29 }
30
31 // eventLabelMap implements label.Map for a the labels of an Event.
32 type eventLabelMapscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/eventLabelMap# struct {
33 eventscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/eventLabelMap#event. Eventscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#
34 }
35
36 func (ev Eventscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#) Atscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#At().() timescip-go gomod github.com/golang/go/src go1.24.0 time/.Timescip-go gomod github.com/golang/go/src go1.24.0 time/Time# { return ev.atscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#at. }
37
38 func (ev Eventscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#) Formatscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#Format().(f fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Statescip-go gomod github.com/golang/go/src go1.24.0 fmt/State#, r rune) {
39 if !ev.atscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#at..IsZeroscip-go gomod github.com/golang/go/src go1.24.0 time/Time#IsZero().() {
40 fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprint().(f, ev.atscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#at..Formatscip-go gomod github.com/golang/go/src go1.24.0 time/Time#Format().("2006/01/02 15:04:05 "))
41 }
42 for index := 0; ev.Validscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#Valid().(index); index++ {
43 if l := ev.Labelscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#Label().(index); l.Validscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/label`/Label#Valid().() {
44 fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(f, "\n\t%v", l)
45 }
46 }
47 }
48
49 func (ev Eventscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#) Validscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#Valid().(index int) bool {
50 return index >= 0 && index < len(ev.staticscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#static.)+len(ev.dynamicscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#dynamic.)
51 }
52
53 func (ev Eventscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#) Labelscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#Label().(index int) labelscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/label`/.Labelscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/label`/Label# {
54 if index < len(ev.staticscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#static.) {
55 return ev.staticscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#static.[index]
56 }
57 return ev.dynamicscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#dynamic.[index-len(ev.staticscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#static.)]
58 }
59
60 func (ev Eventscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#) Findscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#Find().(key labelscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/label`/.Keyscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/label`/Key#) labelscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/label`/.Labelscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/label`/Label# {
61 for _, l := range ev.staticscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#static. {
62 if l.Keyscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/label`/Label#Key().() == key {
63 return l
64 }
65 }
66 for _, l := range ev.dynamicscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#dynamic. {
67 if l.Keyscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/label`/Label#Key().() == key {
68 return l
69 }
70 }
71 return labelscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/label`/.Labelscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/label`/Label#{}
72 }
73
74 func MakeEventscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/MakeEvent().(static [3]labelscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/label`/.Labelscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/label`/Label#, labels []labelscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/label`/.Labelscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/label`/Label#) Eventscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event# {
75 return Eventscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#{
76 staticscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#static.: static,
77 dynamicscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#dynamic.: labels,
78 }
79 }
80
81 // CloneEvent event returns a copy of the event with the time adjusted to at.
82 func CloneEventscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/CloneEvent().(ev Eventscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#, at timescip-go gomod github.com/golang/go/src go1.24.0 time/.Timescip-go gomod github.com/golang/go/src go1.24.0 time/Time#) Eventscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event# {
83 ev.atscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/tools/event/core`/Event#at. = at
84 return ev
85 }