Help us shape the future of Go! Take the 2026 Go Developer Survey

signoz

package
v1.4.33 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package signoz provides source-scoped, bounded read operations for SigNoz.

Index

Constants

View Source
const (
	QueryRangePath  = "/api/v5/query_range"
	FieldKeysPath   = "/api/v1/fields/keys"
	FieldValuesPath = "/api/v1/fields/values"
	MetricsPath     = "/api/v2/metrics"

	DefaultLimit  = 50
	MaximumLimit  = 100
	MaximumOffset = 10_000
)

Variables

View Source
var (
	ErrInvalidConfig    = errors.New("invalid SigNoz configuration")
	ErrInvalidArgument  = errors.New("invalid SigNoz arguments")
	ErrResponseTooLarge = errors.New("SigNoz response exceeded its safe bound")
)

Functions

func Retryable

func Retryable(err error) bool

Retryable reports whether an ingest caller may safely retry a read.

func ScrubExactSecret

func ScrubExactSecret(value, secret string) string

ScrubExactSecret removes every occurrence of secret from value.

func ScrubExactSecretValue

func ScrubExactSecretValue(value any, secret string) any

ScrubExactSecretValue returns a fresh copy of JSON-shaped maps and arrays with the exact secret removed from every map key and string value.

func ScrubSignalExactSecret

func ScrubSignalExactSecret(signal core.Signal, secret string) core.Signal

ScrubSignalExactSecret returns a fresh signal with the exact secret removed from every provider-controlled string and nested structure.

Types

type Client

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

Client owns the shared read-only SigNoz HTTP transport.

func NewClient

func NewClient(config Config, policy Policy) (*Client, error)

NewClient validates a source endpoint and constructs its read-only transport.

func (*Client) Do

func (client *Client) Do(ctx context.Context, method, path string, query url.Values, payload any) ([]byte, error)

Do executes one bounded request against an allowlisted read endpoint.

func (*Client) Endpoint

func (client *Client) Endpoint(path string) (string, error)

Endpoint returns one allowlisted endpoint URL.

type Config

type Config struct {
	Address            string
	APIKey             string
	InsecureSkipVerify bool
	AllowLoopback      bool
	AllowPrivate       bool
	RootCAs            *x509.CertPool
	ScopeFilter        string
}

Config contains one source's trusted connection and scope settings.

type FieldRequest

type FieldRequest struct {
	MetricName string
	SearchText string
	Context    string
	DataType   string
	Name       string
}

FieldRequest scopes field discovery to a trusted signal and optional metric.

type MetricRequest

type MetricRequest struct {
	Start            time.Time
	End              time.Time
	Service          string
	MetricName       string
	Temporality      string
	TimeAggregation  string
	SpaceAggregation string
	Step             time.Duration
	Limit            int
}

MetricRequest is a bounded time-series read for one named metric.

type Policy

type Policy struct {
	Timeout                    time.Duration
	MaximumBytes               int64
	MaximumWindow              time.Duration
	MaximumRows                int
	MaximumSeries              int
	MaximumFieldKeys           int
	MaximumDatapointsPerSeries int
	MaximumDatapoints          int
}

Policy contains independent resource budgets for one use of the service.

func IngestPolicy

func IngestPolicy() Policy

IngestPolicy preserves the larger response and timeout budgets used by source ingestion.

func ToolPolicy

func ToolPolicy() Policy

ToolPolicy is the bounded interactive-read policy used by model tools.

type Result

type Result struct {
	Data       map[string]any `json:"data"`
	Count      int            `json:"count"`
	Truncated  bool           `json:"truncated"`
	Truncation []string       `json:"truncation,omitempty"`
	Offset     int            `json:"offset,omitempty"`
	Limit      int            `json:"limit"`
}

Result is a model-neutral bounded response from SigNoz.

type SearchRequest

type SearchRequest struct {
	Start      time.Time
	End        time.Time
	Service    string
	SearchText string
	Severity   string
	Operation  string
	ErrorOnly  *bool
	Offset     int
	Limit      int
}

SearchRequest is a bounded raw logs or spans read. Filter is always composed with the configured source scope and cannot replace it.

type Service

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

Service owns transport, validation, source scope, budgets, and redaction for one source.

func NewService

func NewService(config Config, policy Policy) (*Service, error)

NewService validates one source and constructs a bounded read-only service.

func (*Service) DiscoveryAvailable

func (service *Service) DiscoveryAvailable() bool

DiscoveryAvailable reports whether source-wide metadata discovery is safe. SigNoz discovery endpoints do not accept the configured query scope.

func (*Service) FieldKeys

func (service *Service) FieldKeys(ctx context.Context, signal Signal, request FieldRequest) (Result, error)

FieldKeys discovers bounded fields for one trusted signal.

func (*Service) FieldValues

func (service *Service) FieldValues(ctx context.Context, signal Signal, request FieldRequest) (Result, error)

FieldValues discovers bounded observed values for one trusted signal field.

func (*Service) ListMetrics

func (service *Service) ListMetrics(ctx context.Context, search string, limit int) (Result, error)

ListMetrics discovers bounded metric metadata from the configured source.

func (*Service) QueryMetrics

func (service *Service) QueryMetrics(ctx context.Context, request MetricRequest) (Result, error)

QueryMetrics reads bounded time series for one metric from the configured source.

func (*Service) SearchLogs

func (service *Service) SearchLogs(ctx context.Context, request SearchRequest) (Result, error)

SearchLogs reads bounded log rows from the configured source.

func (*Service) SearchTraces

func (service *Service) SearchTraces(ctx context.Context, request SearchRequest) (Result, error)

SearchTraces reads bounded span rows from the configured source.

func (*Service) SetScrubber

func (service *Service) SetScrubber(scrubber core.Scrubber)

SetScrubber applies the shared redaction policy before data leaves the service.

type Signal

type Signal string

Signal is a SigNoz query signal selected by trusted source configuration.

const (
	SignalLogs    Signal = "logs"
	SignalTraces  Signal = "traces"
	SignalMetrics Signal = "metrics"
)

type StatusError

type StatusError struct {
	StatusCode int
}

StatusError carries an upstream status without including its response body.

func (*StatusError) Error

func (err *StatusError) Error() string

Jump to

Keyboard shortcuts

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