Documentation
¶
Index ¶
- Constants
- Variables
- func ClientArch() string
- func GetEventBufferLength() int
- func OsLang() string
- func SendAppRunConnectedEvent(sdkVersion string, goVersion string)
- func SendAppRunDisconnectedEvent(stats AppRunStats)
- func SendInstallEvent()
- func SendServerActivityEvent(stats AppRunStats, numActiveAppRuns int)
- func SendShutdownEvent()
- func SendStartupEvent()
- func SetTrayApp(isTrayApp bool)
- func UnameKernelRelease() string
- func UploadEvents() error
- func UploadEventsAsync()
- func WriteTEvent(event TEvent)
- type AppRunStats
- type TEvent
- type TEventProps
- type TEventUserProps
- type TEventsInputType
Constants ¶
const CloudDefaultTimeout = 5 * time.Second
const ErrorCooldownPeriod = time.Hour // Wait 1 hour after an error before trying again
const TEventsBatchSize = 200
const TEventsMaxBatches = 10
const TEventsUrl = "/tevents"
Variables ¶
var Disabled atomic.Bool
var IsTrayApp atomic.Bool
var ValidEventNames = map[string]bool{ "server:install": true, "server:startup": true, "server:shutdown": true, "server:activity": true, "server:panic": true, "apprun:connected": true, "apprun:disconnected": true, "apprun:activity": true, "frontend:tab": true, "frontend:selectapprun": true, "frontend:click": true, "frontend:activity": true, "frontend:error": true, "frontend:search:logs": true, "frontend:search:goroutine": true, "frontend:search:watch": true, }
Functions ¶
func ClientArch ¶
func ClientArch() string
func GetEventBufferLength ¶
func GetEventBufferLength() int
GetEventBufferLength returns the current number of events in the buffer with proper locking
func SendAppRunConnectedEvent ¶
SendAppRunConnectedEvent sends an "apprun:connected" telemetry event
func SendAppRunDisconnectedEvent ¶
func SendAppRunDisconnectedEvent(stats AppRunStats)
SendAppRunDisconnectedEvent sends an "apprun:disconnected" telemetry event
func SendInstallEvent ¶
func SendInstallEvent()
SendInstallEvent sends an "outrig:install" telemetry event
func SendServerActivityEvent ¶
func SendServerActivityEvent(stats AppRunStats, numActiveAppRuns int)
SendServerActivityEvent sends a "server:activity" telemetry event with stats aggregated across all app runs
func SendShutdownEvent ¶
func SendShutdownEvent()
SendShutdownEvent sends a "server:shutdown" telemetry event
func SendStartupEvent ¶
func SendStartupEvent()
SendStartupEvent sends a "server:startup" telemetry event
func SetTrayApp ¶
func SetTrayApp(isTrayApp bool)
SetTrayApp sets whether the server was started from the tray app
func UnameKernelRelease ¶
func UnameKernelRelease() string
func UploadEventsAsync ¶
func UploadEventsAsync()
UploadEventsAsync calls UploadEvents in a separate goroutine It first checks if we're in the cooldown period to avoid spawning unnecessary goroutines
func WriteTEvent ¶
func WriteTEvent(event TEvent)
WriteTEvent adds a telemetry event to the in-memory buffer If the buffer exceeds hardMaxBufferSize, the event will be dropped
Types ¶
type AppRunStats ¶
type AppRunStats struct {
LogLines int `json:"apprun:loglines,omitempty"`
GoRoutines int `json:"apprun:goroutines,omitempty"`
Watches int `json:"apprun:watches,omitempty"`
Collections int `json:"apprun:collections,omitempty"`
SDKVersion string `json:"apprun:sdkversion,omitempty"`
ConnTimeMs int64 `json:"apprun:conntimems,omitempty"`
AppRunCount int `json:"apprun:count,omitempty"`
}
AppRunStats contains statistics about an app run session
func (AppRunStats) Add ¶
func (s AppRunStats) Add(other AppRunStats) AppRunStats
Add adds another AppRunStats to this one and returns the result
func (AppRunStats) Sub ¶
func (s AppRunStats) Sub(other AppRunStats) AppRunStats
Sub subtracts another AppRunStats from this one and returns the result
type TEvent ¶
type TEvent struct {
Uuid string `json:"uuid,omitempty"`
Ts int64 `json:"ts,omitempty"`
TsLocal string `json:"tslocal,omitempty"` // iso8601 format (wall clock converted to PT)
Event string `json:"event"`
Props TEventProps `json:"props"` // Don't scan directly to map
}
func GrabEvents ¶
GrabEvents takes the lock, gets up to maxSize events from the buffer, and returns them If maxSize <= 0, it returns all events
func MakeTEvent ¶
func MakeTEvent(event string, props TEventProps) *TEvent
func MakeUntypedTEvent ¶
func (*TEvent) EnsureTimestamps ¶
func (t *TEvent) EnsureTimestamps()
func (*TEvent) UserSetOnceProps ¶
func (t *TEvent) UserSetOnceProps() *TEventUserProps
func (*TEvent) UserSetProps ¶
func (t *TEvent) UserSetProps() *TEventUserProps
type TEventProps ¶
type TEventProps struct {
TEventUserProps `tstype:"-"` // generally don't need to set these since they will be automatically copied over
PanicType string `json:"debug:panictype,omitempty"`
FrontendTab string `json:"frontend:tab,omitempty"`
FrontendSearchFeatures []string `json:"frontend:logsearchfeatures,omitempty"`
FrontendSearchLatency int `json:"frontend:searchlatency,omitempty"`
FrontendSearchItems int `json:"frontend:searchitems,omitempty"`
FrontendClickType string `json:"frontend:clicktype,omitempty"`
ServerNumAppRuns int `json:"server:numappruns,omitempty"`
ServerNumApps int `json:"server:numapps,omitempty"`
ServerTrayApp bool `json:"server:trayapp,omitempty"`
// counts for app run activity
AppRunLogLines int `json:"apprun:loglines,omitempty"`
AppRunGoRoutines int `json:"apprun:goroutines,omitempty"`
AppRunWatches int `json:"apprun:watches,omitempty"`
AppRunCollections int `json:"apprun:collections,omitempty"`
AppRunSDKVersion string `json:"apprun:sdkversion,omitempty"`
AppRunSDKFullVersion string `json:"apprun:sdkfullversion,omitempty"`
AppRunGoVersion string `json:"apprun:goversion,omitempty"`
AppRunConnTimeMs int64 `json:"apprun:conntimems,omitempty"`
AppRunCount int `json:"apprun:count,omitempty"`
UserSet *TEventUserProps `json:"$set,omitempty"`
UserSetOnce *TEventUserProps `json:"$set_once,omitempty"`
}
func (*TEventProps) ApplyAppRunStats ¶
func (p *TEventProps) ApplyAppRunStats(stats AppRunStats)
ApplyAppRunStats applies the fields from an AppRunStats struct to this TEventProps
type TEventUserProps ¶
type TEventUserProps struct {
ServerArch string `json:"server:arch,omitempty"`
ServerVersion string `json:"server:version,omitempty"`
ServerFullVersion string `json:"server:fullversion,omitempty"`
ServerInitialVersion string `json:"server:initial_version,omitempty"`
ServerBuildTime string `json:"server:buildtime,omitempty"`
ServerBuildCommit string `json:"server:buildcommit,omitempty"`
ServerOSRelease string `json:"server:osrelease,omitempty"`
ServerIsDev bool `json:"server:isdev,omitempty"`
ServerLang string `json:"server:lang,omitempty"`
LocCountryCode string `json:"loc:countrycode,omitempty"`
LocRegionCode string `json:"loc:regioncode,omitempty"`
}