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.

refactor: using global config's ingestion URL (#10019)

swapnil-signozde4ca50a406b
diff --git a/ee/query-service/app/api/api.go b/ee/query-service/app/api/api.go
index 7addedab4b..996f782453 100644
--- a/ee/query-service/app/api/api.go
+++ b/ee/query-service/app/api/api.go
@@ -10,6 +10,7 @@ import (
"github.com/SigNoz/signoz/ee/query-service/usage"
"github.com/SigNoz/signoz/pkg/alertmanager"
"github.com/SigNoz/signoz/pkg/apis/fields"
+ "github.com/SigNoz/signoz/pkg/global"
"github.com/SigNoz/signoz/pkg/http/middleware"
querierAPI "github.com/SigNoz/signoz/pkg/querier"
baseapp "github.com/SigNoz/signoz/pkg/query-service/app"
@@ -36,6 +37,7 @@ type APIHandlerOptions struct {
GatewayUrl string
// Querier Influx Interval
FluxInterval time.Duration
+ GlobalConfig global.Config
}
type APIHandler struct {
diff --git a/ee/query-service/app/api/cloudIntegrations.go b/ee/query-service/app/api/cloudIntegrations.go
index 1103841a34..35da4756f9 100644
--- a/ee/query-service/app/api/cloudIntegrations.go
+++ b/ee/query-service/app/api/cloudIntegrations.go
@@ -76,7 +76,7 @@ func (ah *APIHandler) CloudIntegrationsGenerateConnectionParams(w http.ResponseW
return
}
- ingestionUrl, signozApiUrl, apiErr := ah.getIngestionUrlAndSigNozAPIUrl(r.Context(), license.Key)
+ signozApiUrl, apiErr := ah.getIngestionUrlAndSigNozAPIUrl(r.Context(), license.Key)
if apiErr != nil {
RespondError(w, basemodel.WrapApiError(
apiErr, "couldn't deduce ingestion url and signoz api url",
@@ -84,7 +84,7 @@ func (ah *APIHandler) CloudIntegrationsGenerateConnectionParams(w http.ResponseW
return
}
- result.IngestionUrl = ingestionUrl
+ result.IngestionUrl = ah.opts.GlobalConfig.IngestionURL.String()
result.SigNozAPIUrl = signozApiUrl
gatewayUrl := ah.opts.GatewayUrl
@@ -186,7 +186,7 @@ func (ah *APIHandler) getOrCreateCloudIntegrationUser(
}
func (ah *APIHandler) getIngestionUrlAndSigNozAPIUrl(ctx context.Context, licenseKey string) (
- string, string, *basemodel.ApiError,
+ string, *basemodel.ApiError,
) {
// TODO: remove this struct from here
type deploymentResponse struct {
@@ -200,7 +200,7 @@ func (ah *APIHandler) getIngestionUrlAndSigNozAPIUrl(ctx context.Context, licens
respBytes, err := ah.Signoz.Zeus.GetDeployment(ctx, licenseKey)
if err != nil {
- return "", "", basemodel.InternalError(fmt.Errorf(
+ return "", basemodel.InternalError(fmt.Errorf(
"couldn't query for deployment info: error: %w", err,
))
}
@@ -209,7 +209,7 @@ func (ah *APIHandler) getIngestionUrlAndSigNozAPIUrl(ctx context.Context, licens
err = json.Unmarshal(respBytes, resp)
if err != nil {
- return "", "", basemodel.InternalError(fmt.Errorf(
+ return "", basemodel.InternalError(fmt.Errorf(
"couldn't unmarshal deployment info response: error: %w", err,
))
}
@@ -219,16 +219,14 @@ func (ah *APIHandler) getIngestionUrlAndSigNozAPIUrl(ctx context.Context, licens
if len(regionDns) < 1 || len(deploymentName) < 1 {
// Fail early if actual response structure and expectation here ever diverge
- return "", "", basemodel.InternalError(fmt.Errorf(
+ return "", basemodel.InternalError(fmt.Errorf(
"deployment info response not in expected shape. couldn't determine region dns and deployment name",
))
}
- ingestionUrl := fmt.Sprintf("https://ingest.%s", regionDns)
-
signozApiUrl := fmt.Sprintf("https://%s.%s", deploymentName, regionDns)
- return ingestionUrl, signozApiUrl, nil
+ return signozApiUrl, nil
}
type ingestionKey struct {
diff --git a/ee/query-service/app/server.go b/ee/query-service/app/server.go
index 5a9db96e41..f89e56632f 100644
--- a/ee/query-service/app/server.go
+++ b/ee/query-service/app/server.go
@@ -172,6 +172,7 @@ func NewServer(config signoz.Config, signoz *signoz.SigNoz) (*Server, error) {
FluxInterval: config.Querier.FluxInterval,
Gateway: gatewayProxy,
GatewayUrl: config.Gateway.URL.String(),
+ GlobalConfig: config.Global,
}
apiHandler, err := api.NewAPIHandler(apiOpts, signoz)
diff --git a/pkg/global/signozglobal/handler.go b/pkg/global/signozglobal/handler.go
index 7572e9aead..2c930ec0e7 100644
--- a/pkg/global/signozglobal/handler.go
+++ b/pkg/global/signozglobal/handler.go
@@ -16,8 +16,8 @@ func NewHandler(global global.Global) global.Handler {
return &handler{global: global}
}
-func (handker *handler) GetConfig(rw http.ResponseWriter, r *http.Request) {
- cfg := handker.global.GetConfig()
+func (handler *handler) GetConfig(rw http.ResponseWriter, r *http.Request) {
+ cfg := handler.global.GetConfig()
render.Success(rw, http.StatusOK, types.NewGettableGlobalConfig(cfg.ExternalURL, cfg.IngestionURL))
}
diff --git a/tests/integration/fixtures/signoz.py b/tests/integration/fixtures/signoz.py
index dd0de8fc69..f36f96bc4b 100644
--- a/tests/integration/fixtures/signoz.py
+++ b/tests/integration/fixtures/signoz.py
@@ -66,6 +66,7 @@ def signoz( # pylint: disable=too-many-arguments,too-many-positional-arguments
"SIGNOZ_PROMETHEUS_ACTIVE__QUERY__TRACKER_ENABLED": False,
"SIGNOZ_GATEWAY_URL": gateway.container_configs["8080"].base(),
"SIGNOZ_TOKENIZER_JWT_SECRET": "secret",
+ "SIGNOZ_GLOBAL_INGESTION__URL": "https://ingest.test.signoz.cloud"
}
| sqlstore.env
| clickhouse.env