telemetry

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package telemetry provides a consent-gated telemetry client that signs event POSTs with the node's Ed25519 identity and sends them to a configured telemetry endpoint. When the consent flag is off (empty URL), the client is a hard no-op: no dial, no buffering, no goroutines.

Index

Constants

View Source
const (
	HeaderTimestamp = "X-Pilot-Timestamp"
	HeaderPubKey    = "X-Pilot-Public-Key"
	HeaderSignature = "X-Pilot-Signature"
)

Canonical signing header names, matching the telemetry server's internal/sig contract.

View Source
const DefaultEndpoint = "https://telemetry.pilotprotocol.network/v1/events"

DefaultEndpoint is the production telemetry ingestion URL.

Variables

This section is empty.

Functions

func SignMessage

func SignMessage(priv ed25519.PrivateKey, body []byte) (ts, pubB64, sigB64 string, err error)

SignMessage implements the signing contract directly, without an HTTP POST. Useful for tests and for components that want to sign arbitrary byte payloads. Returns (timestamp, pubKeyB64, signatureB64, error).

Types

type Client

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

Client is a consent-gated telemetry sender. Zero value is a no-op.

func New

func New(url string, nodeID int64) *Client

New creates a consent-gated telemetry client. When url is empty the client is a permanent no-op.

func NewClientFromIdentity

func NewClientFromIdentity(url, identityPath string, nodeID int64) *Client

NewClientFromIdentity creates a consent-gated telemetry client from an Ed25519 identity file on disk and a telemetry URL. When url is empty the client is a permanent no-op. When the identity file does not exist (first-run grace), Send calls are no-ops until the identity is created.

func (*Client) Send

func (c *Client) Send(events ...Event) error

Send POSTs one or more events to the telemetry endpoint. Returns immediately (no-op) when the client is disabled (no consent) or no signer is configured.

The request is Ed25519-signed with the node's identity, following the telemetry server's signing contract:

  • X-Pilot-Timestamp: unix seconds (decimal string)
  • X-Pilot-Public-Key: base64(std) of the 32-byte Ed25519 public key
  • X-Pilot-Signature: base64(std) of the Ed25519 signature over (timestamp + "\n" + body)

func (*Client) SetSigner

func (c *Client) SetSigner(sign signFunc, pubKeyB64 string)

SetSigner installs the Ed25519 signing function and the corresponding base64-encoded public key. Must be called before the first Send call. When signer is nil the client stays disabled.

type Event

type Event struct {
	EventID string          `json:"event_id"`
	Kind    string          `json:"kind"`
	TS      string          `json:"ts"` // RFC3339; empty = server defaults to receive time
	NodeID  int64           `json:"node_id,omitempty"`
	Payload json.RawMessage `json:"payload"`
}

Event is the wire shape sent to the telemetry endpoint.

Jump to

Keyboard shortcuts

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