server

package
v0.81.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package server implements a dummy http Datadog intake, meant to be used with integration and e2e tests. It runs an catch-all http server that stores submitted payloads into a dictionary of api.Payloads, indexed by the route It implements 3 testing endpoints:

  • /fakeintake/payloads/<payload_route> returns any received payloads on the specified route as [api.Payload]s
  • /fakeintake/health returns current fakeintake server health
  • /fakeintake/routestats returns stats for collected payloads, by route
  • /fakeintake/flushPayloads returns all stored payloads and clear them up

Package server implements a dummy http Datadog intake, meant to be used with integration and e2e tests. It runs an catch-all http server that stores submitted payloads into a dictionary of api.Payloads, indexed by the route It implements 3 testing endpoints:

  • /fakeintake/payloads/<payload_route> returns any received payloads on the specified route as [api.Payload]s
  • /fakeintake/health returns current fakeintake server health
  • /fakeintake/routestats returns stats for collected payloads, by route
  • /fakeintake/flushPayloads returns all stored payloads and clear them up

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option added in v0.54.0

type Option func(*Server)

Option is a function that modifies a Server

func WithAddress added in v0.53.0

func WithAddress(addr string) Option

WithAddress changes the server host:port. If host is empty, it will bind to 0.0.0.0 If the port is empty or 0, a port number is automatically chosen

func WithClock

func WithClock(clock clock.Clock) Option

WithClock changes the clock used by the server

func WithDDDevForward added in v0.57.0

func WithDDDevForward() Option

WithDDDevForward enable forwarding payload to dddev

func WithPort

func WithPort(port int) Option

WithPort changes the server port. If the port is 0, a port number is automatically chosen

func WithReadyChannel

func WithReadyChannel(ready chan bool) Option

WithReadyChannel assign a boolean channel to get notified when the server is ready

func WithRemoteConfig added in v0.80.0

func WithRemoteConfig(orgUUID string) Option

WithRemoteConfig enables fakeintake's Remote Config endpoints. The server loads or generates a persistent ed25519 signing key under ~/.fakeintake/signing.key and prints the resulting datadog.yaml snippet.

orgUUID and apiKey are advisory: orgUUID is returned by /api/v0.1/org; apiKey is logged on mismatch but never enforced. Pass empty strings for defaults ("42" / "test-api-key").

func WithRemoteConfigInitialState added in v0.80.0

func WithRemoteConfigInitialState(path string) Option

WithRemoteConfigInitialState preloads one config from a YAML file.

func WithRemoteConfigKeyData added in v0.81.0

func WithRemoteConfigKeyData(hexSeed string) Option

WithRemoteConfigKeyData supplies the ed25519 signing key as a hex-encoded 32-byte seed string. When set, the key is never written to disk and WithRemoteConfigKeyPath is ignored. Use this for ephemeral environments (e.g. ECS Fargate) where a fixed, pre-known key is required so the agent's config_root/director_root can be set at provisioning time.

func WithRemoteConfigKeyPath added in v0.80.0

func WithRemoteConfigKeyPath(path string) Option

WithRemoteConfigKeyPath overrides the on-disk path for the ed25519 signing key seed. Empty falls back to ~/.fakeintake/signing.key.

func WithRemoteConfigVersion added in v0.80.0

func WithRemoteConfigVersion(v uint64) Option

WithRemoteConfigVersion seeds the version counter (default 1). Used to keep the agent's remote-config.db in sync across restarts.

func WithRetention

func WithRetention(retention time.Duration) Option

WithRetention changes the retention time of payloads in the store

type Server

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

Server is a struct implementing a fakeintake server

func InitialiseForTests added in v0.51.0

func InitialiseForTests(t *testing.T, opts ...Option) (*Server, *clock.Mock)

InitialiseForTests starts a server with a mock clock and waits for it to be ready. It returns the mock clock and the server. Use defer server.Stop() to stop the server after calling this function.

func NewServer

func NewServer(options ...Option) *Server

NewServer creates a new fakeintake server and starts it on localhost:port options accept WithPort and WithReadyChan. Call Server.Start() to start the server in a separate go-routine If the port is 0, a port number is automatically chosen

func (*Server) IsRunning

func (fi *Server) IsRunning() bool

IsRunning returns true if the fakeintake server is running

func (*Server) Start

func (fi *Server) Start()

Start Starts a fake intake server in a separate go-routine Notifies when ready to the ready channel

func (*Server) Stop

func (fi *Server) Stop() error

Stop Gracefully stop the http server

func (*Server) URL

func (fi *Server) URL() string

URL returns the URL of the fakeintake server

Directories

Path Synopsis
Package rcstore implements the TUF metadata signing used by fakeintake's Remote Config endpoints.
Package rcstore implements the TUF metadata signing used by fakeintake's Remote Config endpoints.
Package serverstore implements storing logic for fakeintake server Stores raw payloads and try parsing known payloads dumping them to json
Package serverstore implements storing logic for fakeintake server Stores raw payloads and try parsing known payloads dumping them to json

Jump to

Keyboard shortcuts

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