Operations
This section covers operational aspects of using the Nexla SDK in production environments, including monitoring, observability, error handling, and troubleshooting.
Advanced Operations
For detailed observability setup, monitoring strategies, and advanced operational patterns, see the Observability & Tracing page in our Nexla SDK guides.
Observability & Monitoringā
The SDK provides built-in observability features for production environments:
- OpenTelemetry Integration: Optional tracing for monitoring and debugging
- Comprehensive Metrics: Track pipeline performance and resource usage
- Error Tracking: Rich exception handling with context and retry hints
- Rate Limiting: Automatic handling of API rate limits with exponential backoff
Monitoring Flow Healthā
Flow Health Check
def check_flow_health():
flows = client.flows.list(flows_only=True)
status_count = {}
for flow in flows:
status = flow.status
status_count[status] = status_count.get(status, 0) + 1
print("š„ Flow Health Summary:")
for status, count in status_count.items():
emoji = "ā
" if status == "running" else "ā ļø" if status == "paused" else "ā"
print(f" {emoji} {status.title()}: {count} flows")
check_flow_health()
Get Recent Notificationsā
Notification Monitoring
try:
notifications = client.notifications.list()
print(f"\nš Recent Notifications ({len(notifications[:5])} shown):")
for notif in notifications[:5]:
print(f" š {notif.type}: {notif.message}")
print(f" Time: {notif.created_time}")
print(f" Severity: {notif.severity}")
print()
except Exception as e:
print(f"ā¹ļø Notifications not available: {e}")
Error Handlingā
The SDK provides comprehensive error handling with rich exception classes:
Error Handling Example
from nexla_sdk import NexlaClient
from nexla_sdk.exceptions import NexlaAPIError, AuthenticationError
client = NexlaClient()
try:
# This might fail if flow doesn't exist
flow = client.flows.get("non-existent-flow-id")
except AuthenticationError:
print("ā Authentication failed - check your credentials")
except NexlaAPIError as e:
print(f"ā API Error: {e.message}")
print(f"Status Code: {e.status_code}")
except Exception as e:
print(f"ā Unexpected error: {e}")
Error Typesā
- 400 ā
ValidationError - 401 ā
AuthenticationError - 403 ā
AuthorizationError - 404 ā
NotFoundError - 409 ā
ResourceConflictError - 429 ā
RateLimitError(withretry_afterif available) - 5xx ā
ServerError
Rate Limits & Retriesā
The SDK handles rate limiting automatically with exponential backoff:
Rate Limit Handling
from nexla_sdk.exceptions import RateLimitError
def list_sources_with_backoff(client: NexlaClient):
try:
return client.sources.list(per_page=100)
except RateLimitError as exc:
wait = exc.retry_after or 30
print(f"Hit rate limit, retrying in {wait}s")
raise
Retry Configurationā
The underlying RequestsHttpClient configures automatic retries for transient HTTP status codes (429, 502, 503, 504) using urllib3 Retry.
Troubleshootingā
Common Issuesā
-
Authentication Errors
- Verify your service key or access token
- Check if credentials have expired
- Ensure proper permissions
-
Connection Errors
- Verify network connectivity
- Check API endpoint URL
- Confirm firewall settings
-
Rate Limiting
- Implement exponential backoff
- Use pagination for large datasets
- Monitor rate limit headers
Debugging Tipsā
Debug Configuration
import logging
# Enable debug logging
logging.basicConfig(level=logging.DEBUG)
# Initialize client with debug info
client = NexlaClient()
Next Stepsā
- Error Handling - Detailed error management strategies
- Rate Limits & Retries - Best practices for API usage
- Troubleshooting - Common issues and solutions