// Copyright 2019 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.
// Package core provides support for event based telemetry.
package coreimport ()// Event holds the information about an event of note that occurred.typeEventstruct {attime.Time// As events are often on the stack, storing the first few labels directly // in the event can avoid an allocation at all for the very common cases of // simple events. // The length needs to be large enough to cope with the majority of events // but no so large as to cause undue stack pressure. // A log message with two values will use 3 labels (one for each value and // one for the message itself).static [3]label.Label// inline storage for the first few labelsdynamic []label.Label// dynamically sized storage for remaining labels}// eventLabelMap implements label.Map for a the labels of an Event.typeeventLabelMapstruct {eventEvent}func ( Event) () time.Time { return .at }func ( Event) ( fmt.State, rune) {if !.at.IsZero() {fmt.Fprint(, .at.Format("2006/01/02 15:04:05 ")) }for := 0; .Valid(); ++ {if := .Label(); .Valid() {fmt.Fprintf(, "\n\t%v", ) } }}func ( Event) ( int) bool {return >= 0 && < len(.static)+len(.dynamic)}func ( Event) ( int) label.Label {if < len(.static) {return .static[] }return .dynamic[-len(.static)]}func ( Event) ( label.Key) label.Label {for , := range .static {if .Key() == {return } }for , := range .dynamic {if .Key() == {return } }returnlabel.Label{}}func ( [3]label.Label, []label.Label) Event {returnEvent{static: ,dynamic: , }}// CloneEvent event returns a copy of the event with the time adjusted to at.func ( Event, time.Time) Event { .at = return}
The pages are generated with Goldsv0.4.9. (GOOS=linux GOARCH=amd64)