Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

917 B
Raw Blame
package zeus

import (
	neturl "net/url"
	"sync"

	"github.com/SigNoz/signoz/pkg/errors"
	"github.com/SigNoz/signoz/pkg/zeus"
)

// This will be set via ldflags at build time.
var (
	url           string = "<unset>"
	deprecatedURL string = "<unset>"
)

var (
	config zeus.Config
	once   sync.Once
)

// initializes the Zeus configuration.
func Config() zeus.Config {
	once.Do(func() {
		parsedURL, err := neturl.Parse(url)
		if err != nil {
			panic(errors.WrapInternalf(err, errors.CodeInternal, "invalid zeus URL"))
		}

		deprecatedParsedURL, err := neturl.Parse(deprecatedURL)
		if err != nil {
			panic(errors.WrapInternalf(err, errors.CodeInternal, "invalid zeus deprecated URL"))
		}

		config = zeus.Config{URL: parsedURL, DeprecatedURL: deprecatedParsedURL}
		if err := config.Validate(); err != nil {
			panic(errors.WrapInternalf(err, errors.CodeInternal, "invalid zeus config"))
		}
	})

	return config
}