Movatterモバイル変換


[0]ホーム

URL:


usagetypes

package
v2.28.4Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2025 License:AGPL-3.0Imports:6Imported by:0

Details

Repository

github.com/coder/coder

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

View Source
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)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

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

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

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp