Files
zeekayandGitHub babbdec4b8 debrand: SigNoz -> O11y across the tree (+ otel-collector v0.144.7, schema cutover migration) (#28)
* debrand: signoz/SigNoz/SIGNOZ -> o11y/O11y/O11Y across the tree

Rename all SigNoz *branding* to O11y in file contents, file/dir names,
package names, env vars, config keys, comments, docs, SDK code, and the
ClickHouse schema identifiers the querier reads.

Collector dependency:
- Repoint github.com/hanzoai/signoz-otel-collector ->
  github.com/hanzoai/otel-collector and bump v0.144.6 -> v0.144.7
  (go.mod + go.sum reconciled via go mod tidy). Internal package paths
  also debranded upstream: signozschemamigrator -> o11yschemamigrator,
  signozlogspipelineprocessor -> o11ylogspipelineprocessor.
- Fix: v0.144.7 dropped otelconst.DistributedFieldKeysTable from the
  collector's public constants; pin FieldKeysTable = "distributed_field_keys"
  locally in pkg/telemetrymetadata/tables.go.

Package/dir renames (package decl + all importers):
  pkg/apiserver/signozapiserver -> o11yapiserver, plus signozalertmanager,
  signozauthzapi, signozglobal, signozquerier, signozruler, and pkg/signoz -> pkg/o11y.

Schema (read plane): signoz_traces/metrics/logs/metadata/analytics/meter and
signoz_index_v3/index_v2/error_index_v2/spans (+ distributed_*) -> o11y_*.
Data-preserving cutover migration added:
  deploy/clickhouse/migrations/0001_rename_signoz_to_o11y.sql
  (metadata-only RENAME DATABASE/TABLE, no drop/recreate).

Preserved (attribution / external / wire contracts):
- LICENSE + NOTICE verbatim (incl. "software from SigNoz", "Copyright ... SigNoz Inc.").
- Upstream github.com/SigNoz/* repo URLs + @SigNoz/* CODEOWNERS teams.
- Billing resource-attribute regex "signoz.workspace.*" (external wire contract).

go build ./pkg/... ./cmd/... = 0; gofmt clean; renamed+schema pkg tests pass.

* o11y: bump collector to v0.144.8 (o11y_* physical schema writer) + lockstep deploy plan

Collector v0.144.8's schema-migrator + exporters now CREATE/WRITE the same
o11y_* physical databases/tables the querier reads and the RENAME migration
(0001_rename_signoz_to_o11y.sql) targets.

Cross-checked byte-identical: writer DB set == migration target DB set (6);
writer prefixed-table set == migration target table set (8); o11y querier
reads and cloud reads are subsets of that set. Zero table-name mismatches
between writer, readers, and migration.

Collector go.mod unchanged between v0.144.7 and v0.144.8 (identical go.mod
hash) — pure source rename, no module-graph change.

Adds deploy/clickhouse/DEPLOY_signoz_to_o11y_cutover.md: the lockstep order
(collector v0.144.8 -> RENAME migration -> o11y+cloud readers) with a
fresh/scratch-ClickHouse pre-flight (create via migrator, emit trace+metric,
query back) and rollback. Ships together or telemetry blackholes.

go build ./pkg/... ./cmd/community = 0.
2026-07-09 13:08:55 -07:00

131 lines
4.5 KiB
Go

package rules
import (
"context"
"testing"
"time"
"github.com/DATA-DOG/go-sqlmock"
"github.com/hanzoai/o11y/pkg/alertmanager"
alertmanagermock "github.com/hanzoai/o11y/pkg/alertmanager/alertmanagertest"
"github.com/hanzoai/o11y/pkg/cache"
"github.com/hanzoai/o11y/pkg/cache/cachetest"
"github.com/hanzoai/o11y/pkg/flagger"
"github.com/hanzoai/o11y/pkg/instrumentation/instrumentationtest"
"github.com/hanzoai/o11y/pkg/prometheus"
"github.com/hanzoai/o11y/pkg/prometheus/prometheustest"
"github.com/hanzoai/o11y/pkg/querier"
"github.com/hanzoai/o11y/pkg/querier/o11yquerier"
"github.com/hanzoai/o11y/pkg/sqlstore"
"github.com/hanzoai/o11y/pkg/sqlstore/sqlstoretest"
"github.com/hanzoai/o11y/pkg/telemetrystore"
"github.com/hanzoai/o11y/pkg/telemetrystore/telemetrystoretest"
"github.com/stretchr/testify/require"
)
type queryMatcherAny struct {
}
func (m *queryMatcherAny) Match(x string, y string) error {
return nil
}
// TestManagerOptions provides options for customizing the test manager creation.
type TestManagerOptions struct {
// AlertmanagerHook is a function that will be called with the Alertmanager mock
// after it's created but before it's used. This allows customizing the mock behavior.
AlertmanagerHook func(alertmanager.Alertmanager)
// SqlStoreHook is a function that will be called with the SQLStore mock
// after it's created but before it's used. This allows customizing the mock behavior.
SqlStoreHook func(sqlstore.SQLStore)
// TelemetryStoreHook is a function that will be called with the TelemetryStore mock
// after it's created but before it's used. This allows customizing the mock behavior.
TelemetryStoreHook func(telemetrystore.TelemetryStore)
// ManagerOptionsHook is a function that will be called with the ManagerOptions
// before the manager is created. This allows customizing the manager options (e.g., setting Prometheus).
ManagerOptionsHook func(*ManagerOptions)
}
// NewTestManager creates a Manager instance for testing purposes.
// It sets up all the necessary mocks and dependencies required for testing.
// Options can be provided to customize the manager behavior. If nil, default options are used.
func NewTestManager(t *testing.T, testOpts *TestManagerOptions) *Manager {
// mocking the alertmanager + capturing the triggered test alerts
fAlert := alertmanagermock.NewMockAlertmanager(t)
// Call the Alertmanager hook if provided
if testOpts != nil && testOpts.AlertmanagerHook != nil {
testOpts.AlertmanagerHook(fAlert)
}
cacheObj, err := cachetest.New(cache.Config{
Provider: "memory",
Memory: cache.Memory{
NumCounters: 1000,
MaxCost: 1 << 20,
},
})
require.NoError(t, err)
// Create SQLStore mock
sqlStore := sqlstoretest.New(sqlstore.Config{Provider: "sqlite"}, sqlmock.QueryMatcherRegexp)
// Call the SqlStore hook if provided
if testOpts != nil && testOpts.SqlStoreHook != nil {
testOpts.SqlStoreHook(sqlStore)
}
// Create TelemetryStore mock
telemetryStore := telemetrystoretest.New(telemetrystore.Config{}, &queryMatcherAny{})
// Call the TelemetryStore hook if provided
if testOpts != nil && testOpts.TelemetryStoreHook != nil {
testOpts.TelemetryStoreHook(telemetryStore)
}
// Create reader with mocked telemetry store
cache, err := cachetest.New(cache.Config{
Provider: "memory",
Memory: cache.Memory{
NumCounters: 10 * 1000,
MaxCost: 1 << 26,
},
})
require.NoError(t, err)
providerSettings := instrumentationtest.New().ToProviderSettings()
prometheus := prometheustest.New(context.Background(), providerSettings, prometheus.Config{Timeout: 2 * time.Minute}, telemetryStore)
flagger, err := flagger.New(context.Background(), instrumentationtest.New().ToProviderSettings(), flagger.Config{}, flagger.MustNewRegistry())
if err != nil {
t.Fatalf("failed to create flagger: %v", err)
}
// Create querier with test values
providerFactory := o11yquerier.NewFactory(telemetryStore, prometheus, cache, flagger)
mockQuerier, err := providerFactory.New(context.Background(), providerSettings, querier.Config{})
require.NoError(t, err)
mgrOpts := &ManagerOptions{
Logger: instrumentationtest.New().Logger(),
Cache: cacheObj,
Alertmanager: fAlert,
Querier: mockQuerier,
TelemetryStore: telemetryStore,
SQLStore: sqlStore, // SQLStore needed for SendAlerts to query organizations
}
// Call the ManagerOptions hook if provided to allow customization
if testOpts != nil && testOpts.ManagerOptionsHook != nil {
testOpts.ManagerOptionsHook(mgrOpts)
}
mgr, err := NewManager(mgrOpts)
require.NoError(t, err)
return mgr
}