analytics

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package analytics provides a partitioned Moesif-compatible analytics collector for integration tests.

Index

Constants

View Source
const Port = 3007

Port is the container port used by the testbench.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Request      RequestDetails  `json:"request"`
	Response     ResponseDetails `json:"response"`
	UserID       string          `json:"user_id,omitempty"`
	CompanyID    string          `json:"company_id,omitempty"`
	SessionToken string          `json:"session_token,omitempty"`
	Metadata     interface{}     `json:"metadata,omitempty"`
	Direction    string          `json:"direction,omitempty"`
	Weight       int             `json:"weight,omitempty"`
	Tags         string          `json:"tags,omitempty"`
	A2A          any             `json:"a2a,omitempty"`
}

Event is the Moesif-shaped event buffered by the collector.

type HeaderValues

type HeaderValues map[string][]string

HeaderValues preserves all values associated with each HTTP header name.

func (*HeaderValues) UnmarshalJSON

func (h *HeaderValues) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts standard multi-valued headers and legacy scalar values.

type RequestDetails

type RequestDetails struct {
	Time             time.Time    `json:"time"`
	URI              string       `json:"uri"`
	Verb             string       `json:"verb"`
	Headers          HeaderValues `json:"headers,omitempty"`
	APIVersion       string       `json:"api_version,omitempty"`
	IPAddress        string       `json:"ip_address,omitempty"`
	Body             interface{}  `json:"body,omitempty"`
	TransferEncoding string       `json:"transfer_encoding,omitempty"`
}

RequestDetails is the request half of an event.

type ResponseDetails

type ResponseDetails struct {
	Time             time.Time    `json:"time"`
	Status           int          `json:"status"`
	Headers          HeaderValues `json:"headers,omitempty"`
	Body             interface{}  `json:"body,omitempty"`
	IPAddress        string       `json:"ip_address,omitempty"`
	TransferEncoding string       `json:"transfer_encoding,omitempty"`
}

ResponseDetails is the response half of an event.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service implements testbench.Service and testbench.Partitioned.

func New

func New() *Service

New returns a new analytics service.

func (*Service) Handler

func (s *Service) Handler() http.Handler

Handler serves the partitioned routes.

func (*Service) Name

func (s *Service) Name() string

Name returns the service registration name.

func (*Service) PartitionKey

func (s *Service) PartitionKey() string

PartitionKey returns the partitioning strategy used by this stateful service.

func (*Service) Port

func (s *Service) Port() int

Port returns the service's listening port.

func (*Service) Stateful

func (s *Service) Stateful() bool

Stateful reports whether the service keeps request-specific state.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL