usagetypes
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package usagetypes contains the types for usage events. These are kept intheir own package to avoid importing any real code from coderd.
Imports in this package should be limited to the standard library and thefollowing packages ONLY:
- github.com/google/uuid
- golang.org/x/xerrors
This package is imported by the Tallyman codebase.
Index¶
- Constants
- func ParseEvent(data json.RawMessage, out Event) error
- type DCManagedAgentsV1
- type DiscreteEvent
- type Event
- type TallymanV1IngestAcceptedEvent
- type TallymanV1IngestEvent
- type TallymanV1IngestRejectedEvent
- type TallymanV1IngestRequest
- type TallymanV1IngestResponse
- type TallymanV1Response
- type UnknownEventTypeError
- type UsageEventType
Constants¶
const (TallymanCoderLicenseKeyHeader = "Coder-License-Key"TallymanCoderDeploymentIDHeader = "Coder-Deployment-ID")
Variables¶
This section is empty.
Functions¶
funcParseEvent¶
func ParseEvent(datajson.RawMessage, outEvent)error
ParseEvent parses the raw event data into the provided event. It fails ifthere is any unknown fields or extra data at the end of the JSON. Thereturned event is validated.
Types¶
typeDCManagedAgentsV1¶
type DCManagedAgentsV1 struct {Countuint64 `json:"count"`}DCManagedAgentsV1 is a discrete usage event for the number of managed agents.This event is sent in the following situations:
- Once on first startup after usage tracking is added to the product withthe count of all existing managed agents (count=N)
- A new managed agent is created (count=1)
func (DCManagedAgentsV1)EventType¶
func (DCManagedAgentsV1) EventType()UsageEventType
func (DCManagedAgentsV1)Fields¶
func (eDCManagedAgentsV1) Fields() map[string]any
func (DCManagedAgentsV1)Valid¶
func (eDCManagedAgentsV1) Valid()error
typeDiscreteEvent¶
type DiscreteEvent interface {Event// contains filtered or unexported methods}DiscreteEvent is a usage event that is collected as a discrete event.
typeEvent¶
type Event interface {EventType()UsageEventTypeValid()errorFields() map[string]any// fields to be marshaled and sent to tallyman/Metronome// contains filtered or unexported methods}Event is a usage event that can be collected by the usage collector.
Note that the following event types should not be updated once they aremerged into the product. Please consult Dean before making any changes.
This type cannot be implemented outside of this package as it this packageis the source of truth for the coder/tallyman repo.
funcParseEventWithType¶
func ParseEventWithType(eventTypeUsageEventType, datajson.RawMessage) (Event,error)
ParseEventWithType parses the raw event data into the specified Go type. Itfails if there is any unknown fields or extra data after the event. Thereturned event is validated.
If the event type is unknown, UnknownEventTypeError is returned.
typeTallymanV1IngestAcceptedEvent¶
type TallymanV1IngestAcceptedEvent struct {IDstring `json:"id"`}TallymanV1IngestAcceptedEvent is an event that was accepted by the TallymanAPI.
typeTallymanV1IngestEvent¶
type TallymanV1IngestEvent struct {IDstring `json:"id"`EventTypeUsageEventType `json:"event_type"`EventDatajson.RawMessage `json:"event_data"`CreatedAttime.Time `json:"created_at"`}TallymanV1IngestEvent is an event to be ingested into the Tallyman API.
func (TallymanV1IngestEvent)Valid¶
func (eTallymanV1IngestEvent) Valid()error
Valid validates the TallymanV1IngestEvent. It does not validate the eventbody.
typeTallymanV1IngestRejectedEvent¶
type TallymanV1IngestRejectedEvent struct {IDstring `json:"id"`Messagestring `json:"message"`Permanentbool `json:"permanent"`}TallymanV1IngestRejectedEvent is an event that was rejected by the TallymanAPI.
typeTallymanV1IngestRequest¶
type TallymanV1IngestRequest struct {Events []TallymanV1IngestEvent `json:"events"`}TallymanV1IngestRequest is a request to the Tallyman API to ingest usageevents.
typeTallymanV1IngestResponse¶
type TallymanV1IngestResponse struct {AcceptedEvents []TallymanV1IngestAcceptedEvent `json:"accepted_events"`RejectedEvents []TallymanV1IngestRejectedEvent `json:"rejected_events"`}TallymanV1IngestResponse is a response from the Tallyman API to ingest usageevents.
typeTallymanV1Response¶
type TallymanV1Response struct {Messagestring `json:"message"`}TallymanV1Response is a generic response with a message from the TallymanAPI. It is typically returned when there is an error.
typeUnknownEventTypeError¶
type UnknownEventTypeError struct {EventTypestring}UnknownEventTypeError is returned by ParseEventWithType when an unknown eventtype is encountered.
func (UnknownEventTypeError)Error¶
func (eUnknownEventTypeError) Error()string
Error implements error.
typeUsageEventType¶
type UsageEventTypestring
UsageEventType is an enum of all usage event types. It mirrors the databasetype `usage_event_type`.
const (UsageEventTypeDCManagedAgentsV1UsageEventType = "dc_managed_agents_v1")All event types.
When adding a new event type, ensure you add it to the Valid method and theParseEventWithType function.
func (UsageEventType)IsDiscrete¶
func (eUsageEventType) IsDiscrete()bool
func (UsageEventType)IsHeartbeat¶
func (eUsageEventType) IsHeartbeat()bool
func (UsageEventType)Valid¶
func (eUsageEventType) Valid()bool