From 8c02f8ec31a0cf08e64a178b4a05b77e51635a38 Mon Sep 17 00:00:00 2001 From: Vishal Sharma Date: Mon, 1 Apr 2024 15:06:38 +0530 Subject: [PATCH] chore: rate limit param (#4785) --- pkg/query-service/app/http_handler.go | 4 ++-- pkg/query-service/model/queryParams.go | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/query-service/app/http_handler.go b/pkg/query-service/app/http_handler.go index aab6cb3393..7f9e6795a7 100644 --- a/pkg/query-service/app/http_handler.go +++ b/pkg/query-service/app/http_handler.go @@ -401,7 +401,7 @@ func (aH *APIHandler) RegisterRoutes(router *mux.Router, am *AuthMiddleware) { router.HandleFunc("/api/v1/explorer/views/{viewId}", am.EditAccess(aH.deleteSavedView)).Methods(http.MethodDelete) router.HandleFunc("/api/v1/feedback", am.OpenAccess(aH.submitFeedback)).Methods(http.MethodPost) - router.HandleFunc("/api/v1/events", am.ViewAccess(aH.registerEvent)).Methods(http.MethodPost) + router.HandleFunc("/api/v1/event", am.ViewAccess(aH.registerEvent)).Methods(http.MethodPost) // router.HandleFunc("/api/v1/get_percentiles", aH.getApplicationPercentiles).Methods(http.MethodGet) router.HandleFunc("/api/v1/services", am.ViewAccess(aH.getServices)).Methods(http.MethodPost) @@ -1516,7 +1516,7 @@ func (aH *APIHandler) registerEvent(w http.ResponseWriter, r *http.Request) { } userEmail, err := auth.GetEmailFromJwt(r.Context()) if err == nil { - telemetry.GetInstance().SendEvent(request.EventName, request.Attributes, userEmail, true, true) + telemetry.GetInstance().SendEvent(request.EventName, request.Attributes, userEmail, request.RateLimited, true) aH.WriteJSON(w, r, map[string]string{"data": "Event Processed Successfully"}) } else { RespondError(w, &model.ApiError{Typ: model.ErrorInternal, Err: err}, nil) diff --git a/pkg/query-service/model/queryParams.go b/pkg/query-service/model/queryParams.go index 11020a0abf..4a24dba2b6 100644 --- a/pkg/query-service/model/queryParams.go +++ b/pkg/query-service/model/queryParams.go @@ -165,8 +165,9 @@ type GetTopOperationsParams struct { } type RegisterEventParams struct { - EventName string `json:"eventName"` - Attributes map[string]interface{} `json:"attributes"` + EventName string `json:"eventName"` + Attributes map[string]interface{} `json:"attributes"` + RateLimited bool `json:"rateLimited"` } type GetUsageParams struct {