ravn-sdk 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ravn_sdk-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ravn
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,99 @@
1
+ Metadata-Version: 2.4
2
+ Name: ravn-sdk
3
+ Version: 0.1.0
4
+ Summary: Official Python SDK for Ravn — error monitoring and performance tracking
5
+ License: MIT
6
+ Project-URL: Homepage, https://getravn.com
7
+ Project-URL: Documentation, https://docs.getravn.com
8
+ Project-URL: Repository, https://github.com/getravn/ravn-python
9
+ Project-URL: Bug Tracker, https://github.com/getravn/ravn-python/issues
10
+ Keywords: monitoring,error-tracking,observability,logging,apm
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Classifier: Topic :: System :: Monitoring
22
+ Classifier: Topic :: System :: Logging
23
+ Requires-Python: >=3.8
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: requests>=2.28
27
+ Dynamic: license-file
28
+
29
+ # ravn
30
+
31
+ The official Python SDK for [Ravn](https://getravn.com) — lightweight error monitoring and performance tracking for Python applications.
32
+
33
+ ## Installation
34
+
35
+ ```bash
36
+ pip install ravn
37
+ ```
38
+
39
+ ## Quick Start
40
+
41
+ ```python
42
+ import ravn
43
+
44
+ ravn.init(api_key="your_api_key_here")
45
+ ```
46
+
47
+ That's it. Ravn will now automatically capture all unhandled exceptions and report them to your dashboard.
48
+
49
+ ## Features
50
+
51
+ ### Automatic Exception Capture
52
+
53
+ After calling `ravn.init()`, any unhandled exception is automatically sent to Ravn — no try/except needed.
54
+
55
+ ### Manual Exception Capture
56
+
57
+ ```python
58
+ try:
59
+ risky_operation()
60
+ except Exception as e:
61
+ ravn.capture_exception(e, metadata={"user_id": 42})
62
+ ```
63
+
64
+ ### Log Messages
65
+
66
+ ```python
67
+ ravn.capture_message("Payment processed", level="info", metadata={"amount": 99.99})
68
+ ```
69
+
70
+ Supported levels: `info`, `warning`, `error`.
71
+
72
+ ### Performance Monitoring
73
+
74
+ ```python
75
+ @ravn.measure
76
+ def slow_database_query():
77
+ ...
78
+ ```
79
+
80
+ Functions decorated with `@ravn.measure` will automatically send a `warning` event to Ravn if they exceed `slow_threshold_ms` (default: 1000ms).
81
+
82
+ ## Configuration
83
+
84
+ ```python
85
+ ravn.init(
86
+ api_key="your_api_key_here",
87
+ api_url="https://app.getravn.com/api/v1/ingest", # optional override
88
+ slow_threshold_ms=500, # warn if functions take longer than 500ms
89
+ )
90
+ ```
91
+
92
+ ## Requirements
93
+
94
+ - Python >= 3.8
95
+ - `requests >= 2.28`
96
+
97
+ ## License
98
+
99
+ MIT
@@ -0,0 +1,71 @@
1
+ # ravn
2
+
3
+ The official Python SDK for [Ravn](https://getravn.com) — lightweight error monitoring and performance tracking for Python applications.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install ravn
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```python
14
+ import ravn
15
+
16
+ ravn.init(api_key="your_api_key_here")
17
+ ```
18
+
19
+ That's it. Ravn will now automatically capture all unhandled exceptions and report them to your dashboard.
20
+
21
+ ## Features
22
+
23
+ ### Automatic Exception Capture
24
+
25
+ After calling `ravn.init()`, any unhandled exception is automatically sent to Ravn — no try/except needed.
26
+
27
+ ### Manual Exception Capture
28
+
29
+ ```python
30
+ try:
31
+ risky_operation()
32
+ except Exception as e:
33
+ ravn.capture_exception(e, metadata={"user_id": 42})
34
+ ```
35
+
36
+ ### Log Messages
37
+
38
+ ```python
39
+ ravn.capture_message("Payment processed", level="info", metadata={"amount": 99.99})
40
+ ```
41
+
42
+ Supported levels: `info`, `warning`, `error`.
43
+
44
+ ### Performance Monitoring
45
+
46
+ ```python
47
+ @ravn.measure
48
+ def slow_database_query():
49
+ ...
50
+ ```
51
+
52
+ Functions decorated with `@ravn.measure` will automatically send a `warning` event to Ravn if they exceed `slow_threshold_ms` (default: 1000ms).
53
+
54
+ ## Configuration
55
+
56
+ ```python
57
+ ravn.init(
58
+ api_key="your_api_key_here",
59
+ api_url="https://app.getravn.com/api/v1/ingest", # optional override
60
+ slow_threshold_ms=500, # warn if functions take longer than 500ms
61
+ )
62
+ ```
63
+
64
+ ## Requirements
65
+
66
+ - Python >= 3.8
67
+ - `requests >= 2.28`
68
+
69
+ ## License
70
+
71
+ MIT
@@ -0,0 +1,36 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "ravn-sdk"
7
+ version = "0.1.0"
8
+ description = "Official Python SDK for Ravn — error monitoring and performance tracking"
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ requires-python = ">=3.8"
12
+ dependencies = ["requests>=2.28"]
13
+ keywords = ["monitoring", "error-tracking", "observability", "logging", "apm"]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.8",
20
+ "Programming Language :: Python :: 3.9",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Topic :: Software Development :: Libraries :: Python Modules",
25
+ "Topic :: System :: Monitoring",
26
+ "Topic :: System :: Logging",
27
+ ]
28
+
29
+ [project.urls]
30
+ Homepage = "https://getravn.com"
31
+ Documentation = "https://docs.getravn.com"
32
+ Repository = "https://github.com/getravn/ravn-python"
33
+ "Bug Tracker" = "https://github.com/getravn/ravn-python/issues"
34
+
35
+ [tool.setuptools.packages.find]
36
+ where = ["."]
@@ -0,0 +1,145 @@
1
+ """Ravn — Error monitoring and performance tracking SDK for Python."""
2
+
3
+ import atexit
4
+ import functools
5
+ import os
6
+ import platform
7
+ import sys
8
+ import time
9
+ import traceback
10
+ from concurrent.futures import ThreadPoolExecutor
11
+ from typing import Callable, Optional
12
+
13
+ import requests
14
+
15
+ __version__ = "0.1.0"
16
+ __all__ = ["init", "capture_exception", "capture_message", "measure"]
17
+
18
+ _DEFAULT_API_URL = "https://app.getravn.com/api/v1/ingest"
19
+
20
+ _CONFIG: dict = {
21
+ "api_key": None,
22
+ "api_url": _DEFAULT_API_URL,
23
+ "enabled": False,
24
+ "slow_threshold_ms": 1000,
25
+ }
26
+
27
+ _executor = ThreadPoolExecutor(max_workers=1, thread_name_prefix="ravn-worker")
28
+ atexit.register(lambda: _executor.shutdown(wait=True))
29
+
30
+
31
+ def _send_payload(payload: dict) -> None:
32
+ headers = {
33
+ "Content-Type": "application/json",
34
+ "x-api-key": _CONFIG["api_key"],
35
+ }
36
+ try:
37
+ requests.post(_CONFIG["api_url"], json=payload, headers=headers, timeout=3)
38
+ except Exception:
39
+ pass
40
+
41
+
42
+ def _base_metadata(extra: Optional[dict] = None) -> dict:
43
+ meta: dict = {
44
+ "sdk_version": __version__,
45
+ "python_version": platform.python_version(),
46
+ "platform": platform.system(),
47
+ "cwd": os.getcwd(),
48
+ }
49
+ if extra:
50
+ meta.update(extra)
51
+ return meta
52
+
53
+
54
+ def capture_exception(exc: Exception, metadata: Optional[dict] = None) -> None:
55
+ """Capture and report an exception to Ravn."""
56
+ if not _CONFIG["enabled"]:
57
+ return
58
+ try:
59
+ tb = "".join(traceback.format_exception(type(exc), exc, exc.__traceback__))
60
+ payload = {
61
+ "message": f"{type(exc).__name__}: {exc}",
62
+ "level": "error",
63
+ "metadata": _base_metadata({"stack_trace": tb, **(metadata or {})}),
64
+ }
65
+ _executor.submit(_send_payload, payload)
66
+ except Exception:
67
+ pass
68
+
69
+
70
+ def capture_message(
71
+ message: str, level: str = "info", metadata: Optional[dict] = None
72
+ ) -> None:
73
+ """Send an arbitrary log message to Ravn."""
74
+ if not _CONFIG["enabled"]:
75
+ return
76
+ try:
77
+ payload = {
78
+ "message": message,
79
+ "level": level,
80
+ "metadata": _base_metadata(metadata),
81
+ }
82
+ _executor.submit(_send_payload, payload)
83
+ except Exception:
84
+ pass
85
+
86
+
87
+ def _global_exception_handler(exc_type, exc_value, exc_traceback) -> None:
88
+ if issubclass(exc_type, KeyboardInterrupt):
89
+ sys.__excepthook__(exc_type, exc_value, exc_traceback)
90
+ return
91
+ capture_exception(exc_value, metadata={"mechanism": "unhandled_exception"})
92
+ sys.__excepthook__(exc_type, exc_value, exc_traceback)
93
+
94
+
95
+ def init(
96
+ api_key: str,
97
+ api_url: Optional[str] = None,
98
+ slow_threshold_ms: int = 1000,
99
+ ) -> None:
100
+ """Initialize the Ravn SDK.
101
+
102
+ Args:
103
+ api_key: Your Ravn project API key.
104
+ api_url: Override the ingest endpoint (default: Ravn cloud).
105
+ slow_threshold_ms: Performance alert threshold in milliseconds (default: 1000).
106
+ """
107
+ _CONFIG["api_key"] = api_key
108
+ _CONFIG["enabled"] = True
109
+ _CONFIG["slow_threshold_ms"] = slow_threshold_ms
110
+ if api_url:
111
+ _CONFIG["api_url"] = api_url
112
+ sys.excepthook = _global_exception_handler
113
+ print(f"[Ravn] Initialized (key: {api_key[:8]}…)")
114
+
115
+
116
+ def measure(func: Callable) -> Callable:
117
+ """Decorator that reports slow function calls to Ravn.
118
+
119
+ Usage:
120
+ @ravn.measure
121
+ def my_function():
122
+ ...
123
+ """
124
+ @functools.wraps(func)
125
+ def wrapper(*args, **kwargs):
126
+ if not _CONFIG["enabled"]:
127
+ return func(*args, **kwargs)
128
+ start = time.perf_counter()
129
+ try:
130
+ return func(*args, **kwargs)
131
+ finally:
132
+ duration_ms = (time.perf_counter() - start) * 1000
133
+ if duration_ms > _CONFIG["slow_threshold_ms"]:
134
+ capture_message(
135
+ f"Slow function: '{func.__name__}' took {duration_ms:.0f}ms",
136
+ level="warning",
137
+ metadata={
138
+ "function": func.__name__,
139
+ "module": func.__module__,
140
+ "duration_ms": round(duration_ms, 2),
141
+ "threshold_ms": _CONFIG["slow_threshold_ms"],
142
+ },
143
+ )
144
+
145
+ return wrapper
@@ -0,0 +1,99 @@
1
+ Metadata-Version: 2.4
2
+ Name: ravn-sdk
3
+ Version: 0.1.0
4
+ Summary: Official Python SDK for Ravn — error monitoring and performance tracking
5
+ License: MIT
6
+ Project-URL: Homepage, https://getravn.com
7
+ Project-URL: Documentation, https://docs.getravn.com
8
+ Project-URL: Repository, https://github.com/getravn/ravn-python
9
+ Project-URL: Bug Tracker, https://github.com/getravn/ravn-python/issues
10
+ Keywords: monitoring,error-tracking,observability,logging,apm
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Classifier: Topic :: System :: Monitoring
22
+ Classifier: Topic :: System :: Logging
23
+ Requires-Python: >=3.8
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: requests>=2.28
27
+ Dynamic: license-file
28
+
29
+ # ravn
30
+
31
+ The official Python SDK for [Ravn](https://getravn.com) — lightweight error monitoring and performance tracking for Python applications.
32
+
33
+ ## Installation
34
+
35
+ ```bash
36
+ pip install ravn
37
+ ```
38
+
39
+ ## Quick Start
40
+
41
+ ```python
42
+ import ravn
43
+
44
+ ravn.init(api_key="your_api_key_here")
45
+ ```
46
+
47
+ That's it. Ravn will now automatically capture all unhandled exceptions and report them to your dashboard.
48
+
49
+ ## Features
50
+
51
+ ### Automatic Exception Capture
52
+
53
+ After calling `ravn.init()`, any unhandled exception is automatically sent to Ravn — no try/except needed.
54
+
55
+ ### Manual Exception Capture
56
+
57
+ ```python
58
+ try:
59
+ risky_operation()
60
+ except Exception as e:
61
+ ravn.capture_exception(e, metadata={"user_id": 42})
62
+ ```
63
+
64
+ ### Log Messages
65
+
66
+ ```python
67
+ ravn.capture_message("Payment processed", level="info", metadata={"amount": 99.99})
68
+ ```
69
+
70
+ Supported levels: `info`, `warning`, `error`.
71
+
72
+ ### Performance Monitoring
73
+
74
+ ```python
75
+ @ravn.measure
76
+ def slow_database_query():
77
+ ...
78
+ ```
79
+
80
+ Functions decorated with `@ravn.measure` will automatically send a `warning` event to Ravn if they exceed `slow_threshold_ms` (default: 1000ms).
81
+
82
+ ## Configuration
83
+
84
+ ```python
85
+ ravn.init(
86
+ api_key="your_api_key_here",
87
+ api_url="https://app.getravn.com/api/v1/ingest", # optional override
88
+ slow_threshold_ms=500, # warn if functions take longer than 500ms
89
+ )
90
+ ```
91
+
92
+ ## Requirements
93
+
94
+ - Python >= 3.8
95
+ - `requests >= 2.28`
96
+
97
+ ## License
98
+
99
+ MIT
@@ -0,0 +1,10 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ setup.py
5
+ ravn/__init__.py
6
+ ravn_sdk.egg-info/PKG-INFO
7
+ ravn_sdk.egg-info/SOURCES.txt
8
+ ravn_sdk.egg-info/dependency_links.txt
9
+ ravn_sdk.egg-info/requires.txt
10
+ ravn_sdk.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ requests>=2.28
@@ -0,0 +1,2 @@
1
+ dist
2
+ ravn
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,5 @@
1
+ # All packaging metadata lives in pyproject.toml.
2
+ # This file is kept only for backwards compatibility with older tooling.
3
+ from setuptools import setup
4
+
5
+ setup()