core.requester

Requester object to make HTTP requests to the Jobmon FastAPI services.

Attributes

logger

Classes

Requester

Handles HTTP requests to the jobmon server with configurable OTLP integration.

Functions

http_request_ok(→ bool)

Return True if HTTP return codes that are deemed ok.

get_content(→ Tuple[int, Any])

Parse the response.

Module Contents

core.requester.logger
core.requester.http_request_ok(status_code: int) bool

Return True if HTTP return codes that are deemed ok.

class core.requester.Requester(service_url: str, retries_timeout: int = 300, retries_attempts: int = 10, request_timeout: int = 20, use_otlp: bool = False)

Handles HTTP requests to the jobmon server with configurable OTLP integration.

Initialize requester with optional OTLP support.

Parameters:
  • service_url – The jobmon server URL

  • retries_timeout – Total timeout for retries in seconds

  • retries_attempts – Number of retry attempts

  • request_timeout – Individual request timeout in seconds

  • use_otlp – Whether to enable OTLP instrumentation

service_url
retries_timeout = 300
retries_attempts = 10
request_timeout = 20
server_structlog_context: Dict[str, str]
classmethod from_defaults() Requester

Instantiate a requester from default config values.

property url: str

Legacy property for backward compatibility.

add_server_structlog_context(**kwargs: Any) None

Add the structlogging context if it has been provided.

tracing_span(app_route: str, request_type: str) Any
send_request(app_route: str, message: dict, request_type: str, tenacious: bool = True) Tuple[int, Any]

Send a request to the Jobmon server.

async send_request_async(session: aiohttp.ClientSession, app_route: str, message: dict, request_type: str, tenacious: bool = True) Tuple[int, Any]

Send an async request to the Jobmon server with sophisticated retry logic.

This method provides the same robust retry capabilities as the sync version, using tenacity for exponential backoff with jitter, timeout protection, and comprehensive exception handling.

Parameters:
  • session – An active aiohttp ClientSession for making requests.

  • app_route – The API route to request (will be appended to base URL).

  • message – Dictionary containing the request payload.

  • request_type – HTTP method - ‘get’, ‘post’, or ‘put’.

  • tenacious – Whether to enable retry logic (default: True).

Returns:

Tuple of (status_code, response_content).

Raises:
core.requester.get_content(response: Any) Tuple[int, Any]

Parse the response.