clienttelemetry

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package clienttelemetry ingests best-effort telemetry events reported by the React client (API call outcomes, unhandled errors) and re-emits them as OpenTelemetry spans so they show up alongside server-side traces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Record

func Record(ctx context.Context, ev Event)

Record turns ev into a span, honouring Traceparent so it joins whatever trace the client's matching API request belongs to.

Types

type Event

type Event struct {
	// Type is "api" or "error".
	Type string `json:"type"`
	// Name identifies what happened, e.g. "GET /site" or "unhandled".
	Name string `json:"name"`
	// StartTime and EndTime are Unix milliseconds. EndTime is zero for
	// instantaneous events (errors), in which case the span is zero-length.
	StartTime int64 `json:"startTime"`
	EndTime   int64 `json:"endTime,omitempty"`
	// Traceparent is the W3C traceparent header the client sent with the
	// matching API request, if any, so this event joins the same trace.
	Traceparent string `json:"traceparent,omitempty"`
	// Attributes are short, string-valued tags (status code, path, etc).
	Attributes map[string]string `json:"attributes,omitempty"`
	Message    string            `json:"message,omitempty"`
	Stack      string            `json:"stack,omitempty"`
}

Event is one client-reported occurrence: either a completed API call or an unhandled error.

type Handlers

type Handlers struct{}

Handlers serves the telemetry ingest endpoint.

func NewHandlers

func NewHandlers() *Handlers

func (*Handlers) Register

func (h *Handlers) Register(g *echo.Group)

Register mounts POST /telemetry on the /api/v1 group. Deliberately unguarded: a signed-out visitor hitting a login error, or any page that crashes before a session loads, must still be reportable.

Jump to

Keyboard shortcuts

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