Documentation
¶
Index ¶
- Constants
- Variables
- func ClientTrackingMiddleware(tracker *ClientTracker, integrationTracker *IntegrationTracker) func(http.Handler) http.Handler
- func ClientTrackingUnaryInterceptor(tracker *ClientTracker, integrationTracker *IntegrationTracker) grpc.UnaryServerInterceptor
- func SanitizeClientHeader(raw string) string
- type ClientInfo
- type ClientTracker
- type ClientType
- type IntegrationTracker
- type Payload
- type Telemeter
Constants ¶
const ( DefaultTelemetryConsumerURL = "aHR0cHM6Ly90ZWxlbWV0cnkud2Vhdmlh" + "dGUuaW8vd2VhdmlhdGUtdGVsZW1ldHJ5" DefaultTelemetryPushInterval = 24 * time.Hour )
Variables ¶
var PayloadType = struct { Init string Update string Terminate string }{ Init: "INIT", Update: "UPDATE", Terminate: "TERMINATE", }
PayloadType is the discrete set of statuses which indicate the type of payload sent
Functions ¶
func ClientTrackingMiddleware ¶ added in v1.36.0
func ClientTrackingMiddleware(tracker *ClientTracker, integrationTracker *IntegrationTracker) func(http.Handler) http.Handler
ClientTrackingMiddleware creates an HTTP middleware that tracks client SDK usage and client integration usage. It should be placed early in the middleware chain to capture all requests.
func ClientTrackingUnaryInterceptor ¶ added in v1.36.5
func ClientTrackingUnaryInterceptor(tracker *ClientTracker, integrationTracker *IntegrationTracker) grpc.UnaryServerInterceptor
ClientTrackingUnaryInterceptor creates a gRPC unary interceptor that tracks client SDK usage (from x-weaviate-client) and integration usage (from x-weaviate-client-integration) via the gRPC metadata. It also sets the sanitized client header in the context under "clientIdentifier", combining tracking and context-setting to avoid parsing metadata twice. Either tracker may be nil; the respective metadata header is then ignored.
func SanitizeClientHeader ¶ added in v1.36.5
SanitizeClientHeader caps length of user-controlled client header values before they enter context/logs.
Types ¶
type ClientInfo ¶ added in v1.36.0
type ClientInfo struct {
Type ClientType `json:"type"`
Version string `json:"version"`
}
ClientInfo represents a client SDK with its type and version
func IdentifyClientFromHeader ¶ added in v1.36.5
func IdentifyClientFromHeader(headerValue string) ClientInfo
IdentifyClientFromHeader parses a client header value (e.g. "weaviate-client-python/4.10.0") and returns the identified client info. The header follows the pattern: weaviate-client-{sdk}/{version} where sdk is one of: python, java, typescript, go, csharp, php, ruby
type ClientTracker ¶ added in v1.36.0
type ClientTracker struct {
// contains filtered or unexported fields
}
ClientTracker tracks client SDK usage. Only known SDK types are recorded; unknown or missing headers are ignored to avoid noise.
func NewClientTracker ¶ added in v1.36.0
func NewClientTracker(logger logrus.FieldLogger) *ClientTracker
NewClientTracker creates a new client tracker and starts its background goroutine.
func (*ClientTracker) Get ¶ added in v1.36.0
func (ct *ClientTracker) Get() map[ClientType]map[string]int64
Get returns the current client counts without resetting. Useful for inspection without clearing data. Returns nil if the tracker has been stopped.
func (*ClientTracker) GetAndReset ¶ added in v1.36.0
func (ct *ClientTracker) GetAndReset() map[ClientType]map[string]int64
GetAndReset returns the current client counts and resets the tracker. This is called when building telemetry payloads to get usage data for the reporting period. Returns nil if the tracker has been stopped.
func (*ClientTracker) Stop ¶ added in v1.36.0
func (ct *ClientTracker) Stop()
Stop gracefully shuts down the background goroutine. This is safe to call multiple times.
func (*ClientTracker) Track ¶ added in v1.36.0
func (ct *ClientTracker) Track(r *http.Request)
Track records a client request. This is non-blocking and safe to call from any goroutine. If the internal buffer is full, the event is dropped silently (telemetry is best-effort).
func (*ClientTracker) TrackHeader ¶ added in v1.36.5
func (ct *ClientTracker) TrackHeader(headerValue string)
TrackHeader records a client from a raw header value. This is useful for gRPC requests where there is no *http.Request available.
type ClientType ¶ added in v1.36.0
type ClientType string
ClientType represents the type of client SDK
const ( ClientTypePython ClientType = "python" ClientTypeJava ClientType = "java" ClientTypeCSharp ClientType = "csharp" ClientTypeTypeScript ClientType = "typescript" ClientTypeGo ClientType = "go" ClientTypePHP ClientType = "php" ClientTypeRuby ClientType = "ruby" ClientTypeUnknown ClientType = "unknown" )
type IntegrationTracker ¶ added in v1.38.0
type IntegrationTracker struct {
// contains filtered or unexported fields
}
IntegrationTracker tracks client integration usage. Unlike ClientTracker, it accepts any arbitrary integration name without a predefined list, since new integrations are created frequently.
func NewIntegrationTracker ¶ added in v1.38.0
func NewIntegrationTracker(logger logrus.FieldLogger) *IntegrationTracker
NewIntegrationTracker creates a new integration tracker and starts its background goroutine.
func (*IntegrationTracker) Get ¶ added in v1.38.0
func (it *IntegrationTracker) Get() map[string]map[string]int64
Get returns the current integration counts without resetting. Returns nil if the tracker has been stopped.
func (*IntegrationTracker) GetAndReset ¶ added in v1.38.0
func (it *IntegrationTracker) GetAndReset() map[string]map[string]int64
GetAndReset returns the current integration counts and resets the tracker. Returns nil if the tracker has been stopped.
func (*IntegrationTracker) Stop ¶ added in v1.38.0
func (it *IntegrationTracker) Stop()
Stop gracefully shuts down the background goroutine. This is safe to call multiple times.
func (*IntegrationTracker) Track ¶ added in v1.38.0
func (it *IntegrationTracker) Track(r *http.Request)
Track records a client integration request. This is non-blocking and safe to call from any goroutine. If the internal buffer is full, the event is dropped silently (telemetry is best-effort). Any non-empty integration name is accepted.
func (*IntegrationTracker) TrackHeader ¶ added in v1.38.0
func (it *IntegrationTracker) TrackHeader(headerValue string)
TrackHeader records an integration from a raw header value. This is useful for gRPC requests where there is no *http.Request available. The header is parsed using the same {name}/{version} format as the HTTP path and length-capped via SanitizeClientHeader.
type Payload ¶
type Payload struct {
MachineID strfmt.UUID `json:"machineId"`
Type string `json:"type"`
Version string `json:"version"`
ObjectsCount int64 `json:"objs"`
OS string `json:"os"`
Arch string `json:"arch"`
UsedModules []string `json:"usedModules,omitempty"`
CollectionsCount int `json:"collectionsCount"`
ClientUsage map[ClientType]map[string]int64 `json:"clientUsage,omitempty"`
ClientIntegrationUsage map[string]map[string]int64 `json:"clientIntegrationUsage,omitempty"`
CloudProvider *string `json:"cloudProvider,omitempty"`
UniqueID *string `json:"uniqueID,omitempty"`
}
Payload is the object transmitted for telemetry purposes
type Telemeter ¶
type Telemeter struct {
// contains filtered or unexported fields
}
Telemeter is responsible for managing the transmission of telemetry data
func New ¶
func New(nodesStatusGetter nodesStatusGetter, schemaManager schemaManager, logger logrus.FieldLogger, consumerURL string, pushInterval time.Duration, telemetryEnabled bool, ) *Telemeter
New creates a new Telemeter instance. consumerURL should be base64-encoded. If empty, uses DefaultTelemetryConsumerURL. pushInterval defaults to DefaultTelemetryPushInterval if zero.
func (*Telemeter) GetClientTracker ¶ added in v1.36.0
func (tel *Telemeter) GetClientTracker() *ClientTracker
GetClientTracker returns the client tracker instance for use in middleware
func (*Telemeter) GetIntegrationTracker ¶ added in v1.38.0
func (tel *Telemeter) GetIntegrationTracker() *IntegrationTracker
GetIntegrationTracker returns the integration tracker instance for use in middleware