Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions adminapi/telemetry/telemetry_profile_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func CreateTelemetryEntryFor(w http.ResponseWriter, r *http.Request) {
}
xw, ok := w.(*xwhttp.XResponseWriter)
if !ok {
log.Error("Unable to cast responsewriter to XResponseWriter in CreateTelemetryEntryFor")
xwhttp.Error(w, http.StatusInternalServerError, xwcommon.NewRemoteErrorAS(http.StatusInternalServerError, "responsewriter cast error"))
return
}
Expand Down
2 changes: 2 additions & 0 deletions adminapi/telemetry/telemetry_rule_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"net/http"

"github.com/gorilla/mux"
log "github.com/sirupsen/logrus"

xutil "github.com/rdkcentral/xconfadmin/util"

Expand Down Expand Up @@ -183,6 +184,7 @@ func UpdateTelemetryRuleHandler(w http.ResponseWriter, r *http.Request) {
// r.Body is already drained in the middleware
xw, ok := w.(*xwhttp.XResponseWriter)
if !ok {
log.Error("failed to cast responsewriter to XResponseWriter in UpdateTelemetryRuleHandler")
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This log message starts with a lowercase "failed" and differs from the other cast-failure messages ("Unable to cast responsewriter...") used in nearby telemetry handlers. Standardizing casing/wording makes grepping and alerting on these diagnostics more reliable.

Suggested change
log.Error("failed to cast responsewriter to XResponseWriter in UpdateTelemetryRuleHandler")
log.Error("Unable to cast responsewriter to XResponseWriter in UpdateTelemetryRuleHandler")

Copilot uses AI. Check for mistakes.
xhttp.WriteAdminErrorResponse(w, http.StatusInternalServerError, "unable to cast XResponseWriter object")
return
}
Expand Down
4 changes: 4 additions & 0 deletions adminapi/telemetry/telemetry_rule_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"strings"

ru "github.com/rdkcentral/xconfwebconfig/rulesengine"
log "github.com/sirupsen/logrus"

queries "github.com/rdkcentral/xconfadmin/adminapi/queries"
xcommon "github.com/rdkcentral/xconfadmin/common"
Expand Down Expand Up @@ -66,6 +67,7 @@ func DeleteTelemetryRulebyId(id string, app string) *xwhttp.ResponseEntity {

err = DeleteOneTelemetryRule(id)
if err != nil {
log.WithFields(log.Fields{"entity_id": id, "error": err}).Error("Failed to delete telemetry rule")
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To improve triage across tenants/environments, consider including app/ApplicationType as a structured field in this error log (it is available as a parameter here).

Suggested change
log.WithFields(log.Fields{"entity_id": id, "error": err}).Error("Failed to delete telemetry rule")
log.WithFields(log.Fields{"entity_id": id, "app": app, "error": err}).Error("Failed to delete telemetry rule")

Copilot uses AI. Check for mistakes.
return xwhttp.NewResponseEntity(http.StatusInternalServerError, err, nil)
}

Expand Down Expand Up @@ -159,6 +161,7 @@ func CreateTelemetryRule(tmrule *xwlogupload.TelemetryRule, app string) *xwhttp.

tmrule.Updated = xwutil.GetTimestamp()
if err := db.GetCachedSimpleDao().SetOne(db.TABLE_TELEMETRY_RULES, tmrule.ID, tmrule); err != nil {
log.WithFields(log.Fields{"entity_id": tmrule.ID, "error": err}).Error("Failed to save telemetry rule")
return xwhttp.NewResponseEntity(http.StatusInternalServerError, err, nil)
}
Comment on lines 162 to 166
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To improve triage across tenants/environments, consider including app/ApplicationType as a structured field in this error log (it is available as a parameter here).

Copilot uses AI. Check for mistakes.

Expand Down Expand Up @@ -187,6 +190,7 @@ func UpdateTelemetryRule(tmrule *xwlogupload.TelemetryRule, app string) *xwhttp.

tmrule.Updated = xwutil.GetTimestamp()
if err = db.GetCachedSimpleDao().SetOne(db.TABLE_TELEMETRY_RULES, tmrule.ID, tmrule); err != nil {
log.WithFields(log.Fields{"entity_id": tmrule.ID, "error": err}).Error("Failed to update telemetry rule")
return xwhttp.NewResponseEntity(http.StatusInternalServerError, err, nil)
Comment on lines 191 to 194
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To improve triage across tenants/environments, consider including app/ApplicationType as a structured field in this error log (it is available as a parameter here).

Copilot uses AI. Check for mistakes.
}

Expand Down
3 changes: 3 additions & 0 deletions adminapi/telemetry/telemetry_v2_rule_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ func GetTelemetryTwoRulesFilteredWithPage(w http.ResponseWriter, r *http.Request
}
xw, ok := w.(*xwhttp.XResponseWriter)
if !ok {
log.Error("Failed to cast response writer to XResponseWriter in GetTelemetryTwoRulesFilteredWithPage")
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new cast-failure log message uses different wording than the other XResponseWriter cast logs in this file (e.g., "Unable to cast responsewriter..."). Consider standardizing the message text and also logging the concrete type of w (e.g., via a field like writer_type) to make this diagnostic actionable.

Suggested change
log.Error("Failed to cast response writer to XResponseWriter in GetTelemetryTwoRulesFilteredWithPage")
log.WithField("writer_type", fmt.Sprintf("%T", w)).
Error("Unable to cast responsewriter to XResponseWriter in GetTelemetryTwoRulesFilteredWithPage")

Copilot uses AI. Check for mistakes.
xhttp.AdminError(w, xwcommon.NewRemoteErrorAS(http.StatusInternalServerError, "responsewriter cast error"))
return
}
Expand Down Expand Up @@ -202,6 +203,7 @@ func CreateTelemetryTwoRuleHandler(w http.ResponseWriter, r *http.Request) {
// r.Body is already drained in the middleware
xw, ok := w.(*xwhttp.XResponseWriter)
if !ok {
log.Error("Unable to cast responsewriter to XResponseWriter in CreateTelemetryTwoRuleHandler")
xhttp.AdminError(w, xwcommon.NewRemoteErrorAS(http.StatusInternalServerError, "responsewriter cast error"))
return
}
Expand Down Expand Up @@ -282,6 +284,7 @@ func UpdateTelemetryTwoRuleHandler(w http.ResponseWriter, r *http.Request) {
// r.Body is already drained in the middleware
xw, ok := w.(*xwhttp.XResponseWriter)
if !ok {
log.Error("Unable to cast responsewriter to XResponseWriter in UpdateTelemetryTwoRuleHandler")
xhttp.AdminError(w, xwcommon.NewRemoteErrorAS(http.StatusInternalServerError, "responsewriter cast error"))
return
}
Expand Down
Loading