mirror of
https://github.com/hanzoai/o11y.git
synced 2026-10-15 12:58:33 +00:00
* fork: own SigNoz platform deps under hanzoai, repath imports off upstream brand
Phase 1 of the full-fork mandate: eliminate upstream-branded SigNoz modules,
own them as public hanzoai forks, and repath all imports to hanzoai paths.
Owned deps (new public hanzoai forks, module renamed to hanzoai path):
github.com/SigNoz/signoz-otel-collector v0.144.3
-> github.com/hanzoai/signoz-otel-collector v0.144.6 (module renamed)
github.com/SigNoz/clickhouse-go-mock v0.14.0
-> github.com/hanzoai/clickhouse-go-mock v0.14.1 (module renamed)
github.com/SigNoz/govaluate v0.0.0-20240203125216-988004ccc7fd
-> github.com/hanzoai/govaluate v0.1.0 (module renamed)
github.com/SigNoz/expr (replace target for github.com/expr-lang/expr)
-> github.com/hanzoai/expr v1.17.8 (upstream module path preserved,
consumed via replace exactly like the prior SigNoz/expr fork)
In-repo repath: the vendored SigNoz source tree in pkg/, ee/, cmd/ is now
self-referenced as github.com/hanzoai/o11y/... instead of
github.com/SigNoz/signoz/... (1300+ import lines across 377 files), matching
the 750 files already on the hanzoai path. Zero SigNoz-branded module
references remain in go.mod or any .go import.
Generic ecosystem libraries (golang.org/x, google.golang.org, prometheus,
opentelemetry, gin, cobra, luxfi/*, etc.) are left untouched — only the
SigNoz platform fork is owned.
Pre-existing (NOT introduced here): origin/main does not `go build ./...`
because 22 packages are imported but absent from the vendored tree; 14 of
them (roletypes, grammar, cloudintegrations, resourcefilter, integrationtypes,
metricsexplorer, metrics_explorer, times, agg_rewrite, bucket_cache,
sqlitesqlstore, sqlschema/postgressqlschema, sqlstore/postgressqlstore,
cloudintegrations/services) exist in no upstream SigNoz version and must be
vendored into hanzoai/o11y from hanzoai/signoz@770f464f to finish. This
repath is orthogonal to that gap.
* docs(LLM.md): fork boundary map + pre-existing compile-gap inventory
---------
Co-authored-by: Hanzo Dev <[email protected]>
130 lines
3.9 KiB
Go
130 lines
3.9 KiB
Go
package auditor
|
|
|
|
import (
|
|
"net/url"
|
|
"time"
|
|
|
|
"github.com/hanzoai/o11y/pkg/errors"
|
|
"github.com/hanzoai/o11y/pkg/factory"
|
|
)
|
|
|
|
var _ factory.Config = (*Config)(nil)
|
|
|
|
type Config struct {
|
|
// Provider specifies the audit export implementation to use.
|
|
Provider string `mapstructure:"provider"`
|
|
|
|
// BufferSize is the async channel capacity for audit events.
|
|
// Events are dropped when the buffer is full (fail-open).
|
|
BufferSize int `mapstructure:"buffer_size"`
|
|
|
|
// BatchSize is the maximum number of events per export batch.
|
|
BatchSize int `mapstructure:"batch_size"`
|
|
|
|
// FlushInterval is the maximum time between export flushes.
|
|
FlushInterval time.Duration `mapstructure:"flush_interval"`
|
|
|
|
OTLPHTTP OTLPHTTPConfig `mapstructure:"otlphttp"`
|
|
|
|
File FileConfig `mapstructure:"file"`
|
|
}
|
|
|
|
// OTLPHTTPConfig holds configuration for the OTLP HTTP exporter provider.
|
|
// Fields map to go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp options.
|
|
type OTLPHTTPConfig struct {
|
|
// Endpoint is the target scheme://host:port of the OTLP HTTP endpoint.
|
|
Endpoint *url.URL `mapstructure:"endpoint"`
|
|
|
|
// Insecure disables TLS, using HTTP instead of HTTPS.
|
|
Insecure bool `mapstructure:"insecure"`
|
|
|
|
// Timeout is the maximum duration for an export attempt.
|
|
Timeout time.Duration `mapstructure:"timeout"`
|
|
|
|
// Headers are additional HTTP headers sent with every export request.
|
|
Headers map[string]string `mapstructure:"headers"`
|
|
|
|
// Retry configures exponential backoff retry policy for failed exports.
|
|
Retry RetryConfig `mapstructure:"retry"`
|
|
}
|
|
|
|
type FileConfig struct {
|
|
// Path is the absolute path to the audit log file. The file is opened with
|
|
// O_APPEND|O_CREATE|O_WRONLY; existing contents are preserved across runs.
|
|
Path string `mapstructure:"path"`
|
|
}
|
|
|
|
// RetryConfig configures exponential backoff for the OTLP HTTP exporter.
|
|
type RetryConfig struct {
|
|
// Enabled controls whether retries are attempted on transient failures.
|
|
Enabled bool `mapstructure:"enabled"`
|
|
|
|
// InitialInterval is the initial wait time before the first retry.
|
|
InitialInterval time.Duration `mapstructure:"initial_interval"`
|
|
|
|
// MaxInterval is the upper bound on backoff interval.
|
|
MaxInterval time.Duration `mapstructure:"max_interval"`
|
|
|
|
// MaxElapsedTime is the total maximum time spent retrying.
|
|
MaxElapsedTime time.Duration `mapstructure:"max_elapsed_time"`
|
|
}
|
|
|
|
func newConfig() factory.Config {
|
|
return Config{
|
|
Provider: "noop",
|
|
BufferSize: 1000,
|
|
BatchSize: 100,
|
|
FlushInterval: time.Second,
|
|
OTLPHTTP: OTLPHTTPConfig{
|
|
Endpoint: &url.URL{
|
|
Scheme: "http",
|
|
Host: "localhost:4318",
|
|
Path: "/v1/logs",
|
|
},
|
|
Timeout: 10 * time.Second,
|
|
Retry: RetryConfig{
|
|
Enabled: true,
|
|
InitialInterval: 5 * time.Second,
|
|
MaxInterval: 30 * time.Second,
|
|
MaxElapsedTime: time.Minute,
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
func NewConfigFactory() factory.ConfigFactory {
|
|
return factory.NewConfigFactory(factory.MustNewName("auditor"), newConfig)
|
|
}
|
|
|
|
func (c Config) Validate() error {
|
|
if c.BufferSize <= 0 {
|
|
return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "auditor::buffer_size must be greater than 0")
|
|
}
|
|
|
|
if c.BatchSize <= 0 {
|
|
return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "auditor::batch_size must be greater than 0")
|
|
}
|
|
|
|
if c.FlushInterval <= 0 {
|
|
return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "auditor::flush_interval must be greater than 0")
|
|
}
|
|
|
|
if c.BatchSize > c.BufferSize {
|
|
return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "auditor::batch_size must not exceed auditor::buffer_size")
|
|
}
|
|
|
|
if c.Provider == "otlphttp" {
|
|
if c.OTLPHTTP.Endpoint == nil {
|
|
return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "auditor::otlphttp::endpoint must be set when provider is otlphttp")
|
|
}
|
|
}
|
|
|
|
if c.Provider == "file" {
|
|
if c.File.Path == "" {
|
|
return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "auditor::file::path must be set when provider is file")
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|