diff --git a/coprocess/proto/coprocess_session_state.proto b/coprocess/proto/coprocess_session_state.proto index ed9e10c10fd..5e5fd551455 100644 --- a/coprocess/proto/coprocess_session_state.proto +++ b/coprocess/proto/coprocess_session_state.proto @@ -180,4 +180,8 @@ message SessionState { // MaxQueryDepth relates to graphQL APIs. If the session key has a maximum query depth limit defined then it is included in the // session instance. Currently unsupported and under development. int64 max_query_depth = 31; + + // DoNotTrack is set to true to prevent the session from being tracked in the analytics. + // This is useful if there is a key which analytics are not required (e.g. health checks) + bool do_not_track = 32; } diff --git a/gateway/handler_error.go b/gateway/handler_error.go index 2d5a9bcd799..c6bb662d3b9 100644 --- a/gateway/handler_error.go +++ b/gateway/handler_error.go @@ -198,6 +198,12 @@ func (e *ErrorHandler) HandleError(w http.ResponseWriter, r *http.Request, errMs oauthClientID := "" session := ctxGetSession(r) + + // If the key is configured to not track, then we don't track + if session.DoNotTrack { + return + } + tags := make([]string, 0, estimateTagsCapacity(session, e.Spec)) if session != nil { diff --git a/gateway/handler_success.go b/gateway/handler_success.go index a6b7c3adddf..40c283ed5b7 100644 --- a/gateway/handler_success.go +++ b/gateway/handler_success.go @@ -187,6 +187,12 @@ func (s *SuccessHandler) RecordHit(r *http.Request, timing analytics.Latency, co oauthClientID := "" var alias string session := ctxGetSession(r) + + // If the key is configured to not track, then we don't track + if session.DoNotTrack { + return + } + tags := make([]string, 0, estimateTagsCapacity(session, s.Spec)) if session != nil { oauthClientID = session.OauthClientID diff --git a/user/session.go b/user/session.go index ec6ebfbf11b..6422337474c 100644 --- a/user/session.go +++ b/user/session.go @@ -285,6 +285,7 @@ type SessionState struct { LastUpdated string `json:"last_updated" msg:"last_updated"` IdExtractorDeadline int64 `json:"id_extractor_deadline" msg:"id_extractor_deadline"` SessionLifetime int64 `bson:"session_lifetime" json:"session_lifetime"` + DoNotTrack bool `json:"do_not_track" msg:"do_not_track"` // Used to store token hash keyHash string