Skip to content

feat: improve telemetry ISE logging and diagnostics#100

Open
guru-ossdev wants to merge 1 commit into
developfrom
feature/improve-telemetry-error-logging
Open

feat: improve telemetry ISE logging and diagnostics#100
guru-ossdev wants to merge 1 commit into
developfrom
feature/improve-telemetry-error-logging

Conversation

@guru-ossdev
Copy link
Copy Markdown
Contributor

feat(telemetry): improve ISE logging and diagnostics

Summary

This PR enhances telemetry ISE observability by improving logging quality and adding clearer diagnostic signals.

What changed

  • Improved telemetry ISE log messages for better context and traceability.
  • Added/updated diagnostic logging to make issue triage faster.
  • Refined logging behavior to better capture failure paths and runtime state.

Why

  • Reduce time to detect and debug telemetry ISE issues.
  • Provide more actionable operational insights during incident investigation.
  • Improve confidence in troubleshooting across environments.

Impact

  • No functional behavior change intended beyond improved diagnostics.
  • Primary impact is better log clarity and debuggability.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves telemetry ISE observability by adding more explicit error logging around key failure paths in telemetry rule handlers/services (notably XResponseWriter casting failures and DB persistence failures), making production triage and log correlation easier.

Changes:

  • Added error logs when http.ResponseWriter cannot be cast to *xwhttp.XResponseWriter in several telemetry handlers.
  • Added structured error logs for telemetry rule delete/create/update failures when persisting to the DB.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
adminapi/telemetry/telemetry_v2_rule_handler.go Adds a cast-failure log in paginated v2 rules handler.
adminapi/telemetry/telemetry_rule_service.go Adds structured logs on DB failure paths for delete/create/update.
adminapi/telemetry/telemetry_rule_handler.go Adds a cast-failure log in the telemetry rule update handler.
adminapi/telemetry/telemetry_profile_controller.go Adds a cast-failure log in telemetry entry creation flow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}
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.
// 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.

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.
Comment on lines 162 to 166
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)
}
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.
Comment on lines 191 to 194
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)
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants