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.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
feat(licenses): deprecate licenses v2 (#6626)
Vibhu Pandey951593b0a3d5
diff --git a/ee/query-service/app/api/api.go b/ee/query-service/app/api/api.goindex 5d7d6d2ffa..181186d323 100644--- a/ee/query-service/app/api/api.go+++ b/ee/query-service/app/api/api.go@@ -41,7 +41,6 @@ type APIHandlerOptions struct {FluxInterval time.DurationUseLogsNewSchema boolUseTraceNewSchema bool- UseLicensesV3 bool}type APIHandler struct {@@ -68,7 +67,6 @@ func NewAPIHandler(opts APIHandlerOptions) (*APIHandler, error) {FluxInterval: opts.FluxInterval,UseLogsNewSchema: opts.UseLogsNewSchema,UseTraceNewSchema: opts.UseTraceNewSchema,- UseLicensesV3: opts.UseLicensesV3,})if err != nil {diff --git a/ee/query-service/app/api/license.go b/ee/query-service/app/api/license.goindex 7138e29f80..7a098d4e63 100644--- a/ee/query-service/app/api/license.go+++ b/ee/query-service/app/api/license.go@@ -84,13 +84,6 @@ func (ah *APIHandler) listLicenses(w http.ResponseWriter, r *http.Request) {}func (ah *APIHandler) applyLicense(w http.ResponseWriter, r *http.Request) {- if ah.UseLicensesV3 {- // if the licenses v3 is toggled on then do not apply license in v2 and run the validator!- // TODO: remove after migration to v3 and deprecation from zeus- zap.L().Info("early return from apply license v2 call")- render.Success(w, http.StatusOK, nil)- return- }var l model.Licenseif err := json.NewDecoder(r.Body).Decode(&l); err != nil {@@ -102,7 +95,7 @@ func (ah *APIHandler) applyLicense(w http.ResponseWriter, r *http.Request) {RespondError(w, model.BadRequest(fmt.Errorf("license key is required")), nil)return}- license, apiError := ah.LM().Activate(r.Context(), l.Key)+ license, apiError := ah.LM().ActivateV3(r.Context(), l.Key)if apiError != nil {RespondError(w, apiError, nil)return@@ -265,24 +258,12 @@ func convertLicenseV3ToLicenseV2(licenses []*model.LicenseV3) []model.License {}func (ah *APIHandler) listLicensesV2(w http.ResponseWriter, r *http.Request) {-- var licenses []model.License-- if ah.UseLicensesV3 {- licensesV3, err := ah.LM().GetLicensesV3(r.Context())- if err != nil {- RespondError(w, err, nil)- return- }- licenses = convertLicenseV3ToLicenseV2(licensesV3)- } else {- _licenses, apiError := ah.LM().GetLicenses(r.Context())- if apiError != nil {- RespondError(w, apiError, nil)- return- }- licenses = _licenses+ licensesV3, apierr := ah.LM().GetLicensesV3(r.Context())+ if apierr != nil {+ RespondError(w, apierr, nil)+ return}+ licenses := convertLicenseV3ToLicenseV2(licensesV3)resp := model.Licenses{TrialStart: -1,diff --git a/ee/query-service/app/server.go b/ee/query-service/app/server.goindex a970a34b0e..938b72b5a3 100644--- a/ee/query-service/app/server.go+++ b/ee/query-service/app/server.go@@ -78,7 +78,6 @@ type ServerOptions struct {GatewayUrl stringUseLogsNewSchema boolUseTraceNewSchema bool- UseLicensesV3 bool}// Server runs HTTP api service@@ -135,7 +134,7 @@ func NewServer(serverOptions *ServerOptions) (*Server, error) {}// initiate license manager- lm, err := licensepkg.StartManager("sqlite", localDB, serverOptions.UseLicensesV3)+ lm, err := licensepkg.StartManager("sqlite", localDB)if err != nil {return nil, err}@@ -274,7 +273,6 @@ func NewServer(serverOptions *ServerOptions) (*Server, error) {Gateway: gatewayProxy,UseLogsNewSchema: serverOptions.UseLogsNewSchema,UseTraceNewSchema: serverOptions.UseTraceNewSchema,- UseLicensesV3: serverOptions.UseLicensesV3,}apiHandler, err := api.NewAPIHandler(apiOpts)diff --git a/ee/query-service/integrations/signozio/response.go b/ee/query-service/integrations/signozio/response.goindex f0b0132d1b..891ea77da1 100644--- a/ee/query-service/integrations/signozio/response.go+++ b/ee/query-service/integrations/signozio/response.go@@ -2,18 +2,6 @@ package signoziotype status string-type ActivationResult struct {- Status status `json:"status"`- Data *ActivationResponse `json:"data,omitempty"`- ErrorType string `json:"errorType,omitempty"`- Error string `json:"error,omitempty"`-}--type ActivationResponse struct {- ActivationId string `json:"ActivationId"`- PlanDetails string `json:"PlanDetails"`-}-type ValidateLicenseResponse struct {Status status `json:"status"`Data map[string]interface{} `json:"data"`diff --git a/ee/query-service/integrations/signozio/signozio.go b/ee/query-service/integrations/signozio/signozio.goindex 6c0b937c80..a3a5cad414 100644--- a/ee/query-service/integrations/signozio/signozio.go+++ b/ee/query-service/integrations/signozio/signozio.go@@ -10,7 +10,6 @@ import ("time""github.com/pkg/errors"- "go.uber.org/zap""go.signoz.io/signoz/ee/query-service/constants""go.signoz.io/signoz/ee/query-service/model"@@ -39,86 +38,6 @@ func init() {C = New()}-// ActivateLicense sends key to license.signoz.io and gets activation data-func ActivateLicense(key, siteId string) (*ActivationResponse, *model.ApiError) {- licenseReq := map[string]string{- "key": key,- "siteId": siteId,- }-- reqString, _ := json.Marshal(licenseReq)- httpResponse, err := http.Post(C.Prefix+"/licenses/activate", APPLICATION_JSON, bytes.NewBuffer(reqString))-- if err != nil {- zap.L().Error("failed to connect to license.signoz.io", zap.Error(err))- return nil, model.BadRequest(fmt.Errorf("unable to connect with license.signoz.io, please check your network connection"))- }-- httpBody, err := io.ReadAll(httpResponse.Body)- if err != nil {- zap.L().Error("failed to read activation response from license.signoz.io", zap.Error(err))- return nil, model.BadRequest(fmt.Errorf("failed to read activation response from license.signoz.io"))- }-- defer httpResponse.Body.Close()-- // read api request result- result := ActivationResult{}- err = json.Unmarshal(httpBody, &result)- if err != nil {- zap.L().Error("failed to marshal activation response from license.signoz.io", zap.Error(err))- return nil, model.InternalError(errors.Wrap(err, "failed to marshal license activation response"))- }-- switch httpResponse.StatusCode {- case 200, 201:- return result.Data, nil- case 400, 401:- return nil, model.BadRequest(fmt.Errorf(fmt.Sprintf("failed to activate: %s", result.Error)))- default:- return nil, model.InternalError(fmt.Errorf(fmt.Sprintf("failed to activate: %s", result.Error)))- }--}--// ValidateLicense validates the license key-func ValidateLicense(activationId string) (*ActivationResponse, *model.ApiError) {- validReq := map[string]string{- "activationId": activationId,- }-- reqString, _ := json.Marshal(validReq)- response, err := http.Post(C.Prefix+"/licenses/validate", APPLICATION_JSON, bytes.NewBuffer(reqString))-- if err != nil {- return nil, model.BadRequest(errors.Wrap(err, "unable to connect with license.signoz.io, please check your network connection"))- }-- body, err := io.ReadAll(response.Body)- if err != nil {- return nil, model.BadRequest(errors.Wrap(err, "failed to read validation response from license.signoz.io"))- }-- defer response.Body.Close()-- switch response.StatusCode {- case 200, 201:- a := ActivationResult{}- err = json.Unmarshal(body, &a)- if err != nil {- return nil, model.BadRequest(errors.Wrap(err, "failed to marshal license validation response"))- }- return a.Data, nil- case 400, 401:- return nil, model.BadRequest(errors.Wrap(fmt.Errorf(string(body)),- "bad request error received from license.signoz.io"))- default:- return nil, model.InternalError(errors.Wrap(fmt.Errorf(string(body)),- "internal error received from license.signoz.io"))- }--}-func ValidateLicenseV3(licenseKey string) (*model.LicenseV3, *model.ApiError) {// Creating an HTTP client with a timeout for better controldiff --git a/ee/query-service/license/db.go b/ee/query-service/license/db.goindex 4bd34e232c..1dba4053d7 100644--- a/ee/query-service/license/db.go+++ b/ee/query-service/license/db.go@@ -18,15 +18,13 @@ import (// Repo is license repo. stores license keys in a secured DBtype Repo struct {- db *sqlx.DB- useLicensesV3 bool+ db *sqlx.DB}// NewLicenseRepo initiates a new license repo-func NewLicenseRepo(db *sqlx.DB, useLicensesV3 bool) Repo {+func NewLicenseRepo(db *sqlx.DB) Repo {return Repo{- db: db,- useLicensesV3: useLicensesV3,+ db: db,}}@@ -112,26 +110,16 @@ func (r *Repo) GetActiveLicenseV2(ctx context.Context) (*model.License, *basemod// GetActiveLicense fetches the latest active license from DB.// If the license is not present, expect a nil license and a nil error in the output.func (r *Repo) GetActiveLicense(ctx context.Context) (*model.License, *basemodel.ApiError) {- if r.useLicensesV3 {- zap.L().Info("Using licenses v3 for GetActiveLicense")- activeLicenseV3, err := r.GetActiveLicenseV3(ctx)- if err != nil {- return nil, basemodel.InternalError(fmt.Errorf("failed to get active licenses from db: %v", err))- }-- if activeLicenseV3 == nil {- return nil, nil- }- activeLicenseV2 := model.ConvertLicenseV3ToLicenseV2(activeLicenseV3)- return activeLicenseV2, nil-+ activeLicenseV3, err := r.GetActiveLicenseV3(ctx)+ if err != nil {+ return nil, basemodel.InternalError(fmt.Errorf("failed to get active licenses from db: %v", err))}- active, err := r.GetActiveLicenseV2(ctx)- if err != nil {- return nil, err+ if activeLicenseV3 == nil {+ return nil, nil}- return active, nil+ activeLicenseV2 := model.ConvertLicenseV3ToLicenseV2(activeLicenseV3)+ return activeLicenseV2, nil}func (r *Repo) GetActiveLicenseV3(ctx context.Context) (*model.LicenseV3, error) {diff --git a/ee/query-service/license/manager.go b/ee/query-service/license/manager.goindex 0a4370de3f..c036a01ab5 100644--- a/ee/query-service/license/manager.go+++ b/ee/query-service/license/manager.go@@ -51,12 +51,12 @@ type Manager struct {activeFeatures basemodel.FeatureSet}-func StartManager(dbType string, db *sqlx.DB, useLicensesV3 bool, features ...basemodel.Feature) (*Manager, error) {+func StartManager(dbType string, db *sqlx.DB, features ...basemodel.Feature) (*Manager, error) {if LM != nil {return LM, nil}- repo := NewLicenseRepo(db, useLicensesV3)+ repo := NewLicenseRepo(db)err := repo.InitDB(dbType)if err != nil {@@ -67,32 +67,7 @@ func StartManager(dbType string, db *sqlx.DB, useLicensesV3 bool, features ...barepo: &repo,}- if useLicensesV3 {- // get active license from the db- active, err := m.repo.GetActiveLicenseV2(context.Background())- if err != nil {- return m, err- }-- // if we have an active license then need to fetch the complete details- if active != nil {- // fetch the new license structure from control plane- licenseV3, apiError := validate.ValidateLicenseV3(active.Key)- if apiError != nil {- return m, apiError- }-- // insert the licenseV3 in sqlite db- apiError = m.repo.InsertLicenseV3(context.Background(), licenseV3)- // if the license already exists move ahead.- if apiError != nil && apiError.Typ != model.ErrorConflict {- return m, apiError- }- zap.L().Info("Successfully inserted license from v2 to v3 table")- }- }-- if err := m.start(useLicensesV3, features...); err != nil {+ if err := m.start(features...); err != nil {return m, err}LM = m@@ -100,16 +75,8 @@ func StartManager(dbType string, db *sqlx.DB, useLicensesV3 bool, features ...ba}// start loads active license in memory and initiates validator-func (lm *Manager) start(useLicensesV3 bool, features ...basemodel.Feature) error {-- var err error- if useLicensesV3 {- err = lm.LoadActiveLicenseV3(features...)- } else {- err = lm.LoadActiveLicense(features...)- }-- return err+func (lm *Manager) start(features ...basemodel.Feature) error {+ return lm.LoadActiveLicenseV3(features...)}func (lm *Manager) Stop() {@@ -117,31 +84,6 @@ func (lm *Manager) Stop() {<-lm.terminated}-func (lm *Manager) SetActive(l *model.License, features ...basemodel.Feature) {- lm.mutex.Lock()- defer lm.mutex.Unlock()-- if l == nil {- return- }-- lm.activeLicense = l- lm.activeFeatures = append(l.FeatureSet, features...)- // set default features- setDefaultFeatures(lm)-- err := lm.InitFeatures(lm.activeFeatures)- if err != nil {- zap.L().Panic("Couldn't activate features", zap.Error(err))- }- if !lm.validatorRunning {- // we want to make sure only one validator runs,- // we already have lock() so good to go- lm.validatorRunning = true- go lm.Validator(context.Background())- }--}func (lm *Manager) SetActiveV3(l *model.LicenseV3, features ...basemodel.Feature) {lm.mutex.Lock()defer lm.mutex.Unlock()@@ -172,29 +114,6 @@ func setDefaultFeatures(lm *Manager) {lm.activeFeatures = append(lm.activeFeatures, baseconstants.DEFAULT_FEATURE_SET...)}-// LoadActiveLicense loads the most recent active license-func (lm *Manager) LoadActiveLicense(features ...basemodel.Feature) error {- active, err := lm.repo.GetActiveLicense(context.Background())- if err != nil {- return err- }- if active != nil {- lm.SetActive(active, features...)- } else {- zap.L().Info("No active license found, defaulting to basic plan")- // if no active license is found, we default to basic(free) plan with all default features- lm.activeFeatures = model.BasicPlan- setDefaultFeatures(lm)- err := lm.InitFeatures(lm.activeFeatures)- if err != nil {- zap.L().Error("Couldn't initialize features", zap.Error(err))- return err- }- }-- return nil-}-func (lm *Manager) LoadActiveLicenseV3(features ...basemodel.Feature) error {active, err := lm.repo.GetActiveLicenseV3(context.Background())if err != nil {@@ -265,31 +184,6 @@ func (lm *Manager) GetLicensesV3(ctx context.Context) (response []*model.Licensereturn response, nil}-// Validator validates license after an epoch of time-func (lm *Manager) Validator(ctx context.Context) {- zap.L().Info("Validator started!")- defer close(lm.terminated)- tick := time.NewTicker(validationFrequency)- defer tick.Stop()-- lm.Validate(ctx)-- for {- select {- case <-lm.done:- return- default:- select {- case <-lm.done:- return- case <-tick.C:- lm.Validate(ctx)- }- }-- }-}-// Validator validates license after an epoch of timefunc (lm *Manager) ValidatorV3(ctx context.Context) {zap.L().Info("ValidatorV3 started!")@@ -315,73 +209,6 @@ func (lm *Manager) ValidatorV3(ctx context.Context) {}}-// Validate validates the current active license-func (lm *Manager) Validate(ctx context.Context) (reterr error) {- zap.L().Info("License validation started")- if lm.activeLicense == nil {- return nil- }-- defer func() {- lm.mutex.Lock()-- lm.lastValidated = time.Now().Unix()- if reterr != nil {- zap.L().Error("License validation completed with error", zap.Error(reterr))- atomic.AddUint64(&lm.failedAttempts, 1)- telemetry.GetInstance().SendEvent(telemetry.TELEMETRY_LICENSE_CHECK_FAILED,- map[string]interface{}{"err": reterr.Error()}, "", true, false)- } else {- zap.L().Info("License validation completed with no errors")- }-- lm.mutex.Unlock()- }()-- response, apiError := validate.ValidateLicense(lm.activeLicense.ActivationId)- if apiError != nil {- zap.L().Error("failed to validate license", zap.Error(apiError.Err))- return apiError.Err- }-- if response.PlanDetails == lm.activeLicense.PlanDetails {- // license plan hasnt changed, nothing to do- return nil- }-- if response.PlanDetails != "" {-- // copy and replace the active license record- l := model.License{- Key: lm.activeLicense.Key,- CreatedAt: lm.activeLicense.CreatedAt,- PlanDetails: response.PlanDetails,- ValidationMessage: lm.activeLicense.ValidationMessage,- ActivationId: lm.activeLicense.ActivationId,- }-- if err := l.ParsePlan(); err != nil {- zap.L().Error("failed to parse updated license", zap.Error(err))- return err- }-- // updated plan is parsable, check if plan has changed- if lm.activeLicense.PlanDetails != response.PlanDetails {- err := lm.repo.UpdatePlanDetails(ctx, lm.activeLicense.Key, response.PlanDetails)- if err != nil {- // unexpected db write issue but we can let the user continue- // and wait for update to work in next cycle.- zap.L().Error("failed to validate license", zap.Error(err))- }- }-- // activate the update license plan- lm.SetActive(&l)- }-- return nil-}-func (lm *Manager) RefreshLicense(ctx context.Context) *model.ApiError {license, apiError := validate.ValidateLicenseV3(lm.activeLicenseV3.Key)@@ -429,50 +256,6 @@ func (lm *Manager) ValidateV3(ctx context.Context) (reterr error) {return nil}-// Activate activates a license key with signoz server-func (lm *Manager) Activate(ctx context.Context, key string) (licenseResponse *model.License, errResponse *model.ApiError) {- defer func() {- if errResponse != nil {- userEmail, err := auth.GetEmailFromJwt(ctx)- if err == nil {- telemetry.GetInstance().SendEvent(telemetry.TELEMETRY_LICENSE_ACT_FAILED,- map[string]interface{}{"err": errResponse.Err.Error()}, userEmail, true, false)- }- }- }()-- response, apiError := validate.ActivateLicense(key, "")- if apiError != nil {- zap.L().Error("failed to activate license", zap.Error(apiError.Err))- return nil, apiError- }-- l := &model.License{- Key: key,- ActivationId: response.ActivationId,- PlanDetails: response.PlanDetails,- }-- // parse validity and features from the plan details- err := l.ParsePlan()-- if err != nil {- zap.L().Error("failed to activate license", zap.Error(err))- return nil, model.InternalError(err)- }-- // store the license before activating it- err = lm.repo.InsertLicense(ctx, l)- if err != nil {- zap.L().Error("failed to activate license", zap.Error(err))- return nil, model.InternalError(err)- }-- // license is valid, activate it- lm.SetActive(l)- return l, nil-}-func (lm *Manager) ActivateV3(ctx context.Context, licenseKey string) (licenseResponse *model.LicenseV3, errResponse *model.ApiError) {defer func() {if errResponse != nil {diff --git a/ee/query-service/main.go b/ee/query-service/main.goindex 23824bd636..dd52ab73a5 100644--- a/ee/query-service/main.go+++ b/ee/query-service/main.go@@ -95,7 +95,6 @@ func main() {var useLogsNewSchema boolvar useTraceNewSchema bool- var useLicensesV3 boolvar cacheConfigPath, fluxInterval stringvar enableQueryServiceLogOTLPExport boolvar preferSpanMetrics bool@@ -107,7 +106,6 @@ func main() {flag.BoolVar(&useLogsNewSchema, "use-logs-new-schema", false, "use logs_v2 schema for logs")flag.BoolVar(&useTraceNewSchema, "use-trace-new-schema", false, "use new schema for traces")- flag.BoolVar(&useLicensesV3, "use-licenses-v3", false, "use licenses_v3 schema for licenses")flag.StringVar(&promConfigPath, "config", "./config/prometheus.yml", "(prometheus config to read metrics)")flag.StringVar(&skipTopLvlOpsPath, "skip-top-level-ops", "", "(config file to skip top level operations)")flag.BoolVar(&disableRules, "rules.disable", false, "(disable rule evaluation)")@@ -148,7 +146,6 @@ func main() {GatewayUrl: gatewayUrl,UseLogsNewSchema: useLogsNewSchema,UseTraceNewSchema: useTraceNewSchema,- UseLicensesV3: useLicensesV3,}// Read the jwt secret keydiff --git a/pkg/query-service/app/http_handler.go b/pkg/query-service/app/http_handler.goindex 3e25ab23c8..e14eec7ef6 100644--- a/pkg/query-service/app/http_handler.go+++ b/pkg/query-service/app/http_handler.go@@ -113,7 +113,6 @@ type APIHandler struct {UseLogsNewSchema boolUseTraceNewSchema bool- UseLicensesV3 boolhostsRepo *inframetrics.HostsRepoprocessesRepo *inframetrics.ProcessesRepo@@ -166,8 +165,6 @@ type APIHandlerOpts struct {UseLogsNewSchema boolUseTraceNewSchema bool- // Use Licenses V3 structure- UseLicensesV3 bool}// NewAPIHandler returns an APIHandler@@ -230,7 +227,6 @@ func NewAPIHandler(opts APIHandlerOpts) (*APIHandler, error) {querierV2: querierv2,UseLogsNewSchema: opts.UseLogsNewSchema,UseTraceNewSchema: opts.UseTraceNewSchema,- UseLicensesV3: opts.UseLicensesV3,hostsRepo: hostsRepo,processesRepo: processesRepo,podsRepo: podsRepo,