Skip to content

feat: Add AutoEscalation — Elixir port of Opsbox::AutoEscalation#52

Closed
Jez-A wants to merge 6 commits intoauto_escalation_adf_builderfrom
auto_escalation_in_zexbox
Closed

feat: Add AutoEscalation — Elixir port of Opsbox::AutoEscalation#52
Jez-A wants to merge 6 commits intoauto_escalation_adf_builderfrom
auto_escalation_in_zexbox

Conversation

@Jez-A
Copy link
Contributor

@Jez-A Jez-A commented Mar 3, 2026

Summary

PR: #55 adds the OpenTelemetry URL helpers. Merge first.

PR: #53 adds the Jira client used to search, create, add comments, and transition issues and tickets. Stacked on #55.

PR: #54 adds the AdfBuilder which builds Atlassian Document Format (ADF) maps for Jira issue descriptions and comments. Stacked on #53.

The planned merge order is 55, then 53, then 54, then 52 (this PR).

Usage

rescue
  e ->
    Zexbox.AutoEscalation.handle_error(
      e,
      "checkout",
      "High",
      "Purchase Ops",
      __STACKTRACE__,
      %{email: user.email},
      %{basket_id: basket.id}
    )

Impact

Allows us to connect critical-path exceptions and errors into our medic system seamlessly.

Stacked on: #54

Test plan

  • mix test test/zexbox/auto_escalation_test.exs — 21 tests covering new-ticket path, existing-ticket path, disabled state, search failure fallback, and custom fingerprints
  • mix test — full suite green

🤖 Generated with Claude Code

@Jez-A Jez-A force-pushed the auto_escalation_in_zexbox branch from fdafb20 to 99ee28f Compare March 3, 2026 14:52
@Jez-A Jez-A changed the title feat: Add Zexbox.AutoEscalation — Elixir port of Opsbox::AutoEscalation feat: Add AutoEscalation — Elixir port of Opsbox::AutoEscalation Mar 3, 2026
@Jez-A Jez-A changed the base branch from master to auto_escalation_adf_builder March 3, 2026 14:53
end

defp auto_escalation_enabled? do
Application.get_env(:zexbox, :auto_escalation_enabled, true) == true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This environment variable will need to be added

@Jez-A Jez-A mentioned this pull request Mar 3, 2026
2 tasks
@Jez-A Jez-A force-pushed the auto_escalation_adf_builder branch from 1217069 to 846cb0b Compare March 3, 2026 15:43
@Jez-A Jez-A force-pushed the auto_escalation_in_zexbox branch from 0551ddc to 5d3d3e9 Compare March 3, 2026 15:43
@Jez-A Jez-A force-pushed the auto_escalation_adf_builder branch from 846cb0b to 698e096 Compare March 3, 2026 17:07
@Jez-A Jez-A force-pushed the auto_escalation_in_zexbox branch 2 times, most recently from 69a3558 to dd05be9 Compare March 9, 2026 10:17
@Jez-A Jez-A force-pushed the auto_escalation_adf_builder branch from 0c230ce to 4ec7726 Compare March 9, 2026 10:51
Jez-A and others added 6 commits March 9, 2026 10:54
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds Zexbox.AutoEscalation, which handles automatic error-to-on-call
escalation via Jira. When an error is rescued, this module:

1. Generates a fingerprint (action::ErrorClass) and searches Jira for an
   open ticket with that fingerprint (exact-match JQL, excludes resolved
   statuses: Done / No Further Action / Ready for Support Approval).
2. If found: adds an ADF comment documenting the new occurrence.
3. If not found: creates a Bug ticket with ADF description, sets the
   fingerprint and ZIGL Team custom fields, then transitions to "To do".

Returns {:ok, ticket_map}, {:error, reason}, or {:disabled, nil}.
Uses the SP project key in :production, SS otherwise.

Usage from a rescue block:

    rescue
      e ->
        Zexbox.AutoEscalation.handle_error(
          error: e,
          stacktrace: __STACKTRACE__,
          action: "checkout",
          priority: "High",
          zigl_team: "Purchase Ops"
        )

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…guments

Mirrors the JiraClient refactor: handle_error/5, generate_fingerprint/2,
and all private helpers now use explicit positional args instead of keyword
lists. JiraClient call sites updated to match the new positional API.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replaces the trailing keyword opts with 5 named positional args with
defaults: stacktrace, user_context, additional_context, fingerprint,
custom_description. Bumps FunctionArity max_arity to 9 in .credo.exs
to accommodate the intentionally explicit public API.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Jez-A Jez-A force-pushed the auto_escalation_in_zexbox branch from dd05be9 to c919862 Compare March 9, 2026 10:54
@Jez-A Jez-A closed this Mar 10, 2026
@Jez-A Jez-A deleted the auto_escalation_in_zexbox branch March 10, 2026 12:36
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.

1 participant