Skip to content

feat: Add Zexbox.JiraClient#53

Merged
Jez-A merged 14 commits intomasterfrom
auto_escalation_infra
Mar 9, 2026
Merged

feat: Add Zexbox.JiraClient#53
Jez-A merged 14 commits intomasterfrom
auto_escalation_infra

Conversation

@Jez-A
Copy link
Contributor

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

Summary

This is a port of the Jira client we currently have in Opsbox: https://github.com/Intellection/opsbox/blob/master/lib/opsbox/jira_client.rb

PR: #55 adds the OpenTelemetry URL helpers this stack depends on. Merge first.

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

PR: #52 adds the public entry point to handling errors (AutoEscalation). Stacked on #54.

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

Changes

  • Adds Zexbox.JiraClient: Req-based HTTP client for the Jira Cloud REST API v3 (search issues, create issue, transition, add comment)
  • Adds :req dependency

This module is the infrastructure layer for the AutoEscalation feature (see follow-up PRs).

Stacked on: #55

Test plan

  • mix test test/zexbox/jira_client_test.exs — 10 tests covering all four public JiraClient functions
  • mix test — full suite green

🤖 Generated with Claude Code

Adds OpenTelemetry observability URL helpers that mirror Opsbox::OpenTelemetry.
Provides Grafana Tempo trace URLs, local Jaeger URLs (dev/development), and
Kibana Discover log URLs — all returning nil gracefully when OTEL is unconfigured.

Adds opentelemetry_api ~> 1.4 and jason ~> 1.4 dependencies.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Jez-A Jez-A force-pushed the auto_escalation_infra branch from f1ce788 to 6d6528f Compare March 9, 2026 10:50
@Jez-A Jez-A changed the title feat: Add JiraClient and OpenTelemetry URL helpers feat: Add Zexbox.JiraClient Mar 9, 2026
@Jez-A
Copy link
Contributor Author

Jez-A commented Mar 9, 2026

Manually tested and led to the creation, transition, and commenting of https://zigroup.atlassian.net/browse/SS-136

Jez-A and others added 11 commits March 9, 2026 14:28
Jaeger is not available locally. generate_trace_url/0 now returns nil for
non-production/sandbox environments instead of a localhost Jaeger URL.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds two new utility modules required by the AutoEscalation feature:

- Zexbox.JiraClient: Req-based client for the Jira Cloud REST API v3.
  Supports search, create, transition, and add_comment operations.
  Authenticates via JIRA_USER_EMAIL_ADDRESS / JIRA_API_TOKEN env vars
  or :jira_email / :jira_api_token application config.

- Zexbox.OpenTelemetry: Reads the current process OTEL context (baggage
  and active span) to produce Datadog session, Grafana Tempo trace, and
  Kibana Discover URLs. Returns nil gracefully when OTEL is unconfigured.

Adds :req, :jason, and :opentelemetry_api dependencies to mix.exs.

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

search_latest_issues was using GET with query params, which means the
response body was not guaranteed to be JSON-decoded by Req (Req only
auto-decodes based on the response Content-Type, not the request method).

Two changes:
- search_latest_issues now uses POST /rest/api/3/search/jql with a JSON
  body — the preferred Jira v3 approach. This also allows fields to be
  sent as a proper JSON array rather than a comma-separated string.
- build_client adds Accept: application/json to every request so the
  remaining GET (transitions fetch) also explicitly signals JSON intent
  and Req's decode_body step has a clear content-type to act on.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replaces keyword list opts (Keyword.fetch!/get) with typed positional
arguments throughout, consistent with the rest of the repo's style:

  search_latest_issues(jql, project_key \\ nil)
  create_issue(project_key, summary, description, issuetype, priority, custom_fields \\ %{})
  transition_issue(issue_key, status_name)
  add_comment(issue_key, comment)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Jez-A Jez-A force-pushed the auto_escalation_infra branch from 49ed703 to 8d02399 Compare March 9, 2026 14:31
Jez-A and others added 2 commits March 9, 2026 15:26
- Extract post_comment/2 so add_comment/2 is a clean public one-liner
- Remove leading pipe antipattern in create_issue/6
- Extract browse_url/1 to deduplicate base_url config lookups
- Extract handle_response/1 to unify jira_get/jira_post response handling
- Replace `|| ""` nil guard with to_string/1 in matches_status?/2
- Switch search_latest_issues to GET /issue/search with list fields param

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Jez-A Jez-A merged commit 761cacb into master Mar 9, 2026
3 checks passed
@Jez-A Jez-A deleted the auto_escalation_infra branch March 9, 2026 15:59
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