hyperprobe-agent 1.2.24__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.
- hyperprobe_agent-1.2.24/LICENSE +13 -0
- hyperprobe_agent-1.2.24/PKG-INFO +154 -0
- hyperprobe_agent-1.2.24/README.md +119 -0
- hyperprobe_agent-1.2.24/hyperprobe/__init__.py +7 -0
- hyperprobe_agent-1.2.24/hyperprobe/agent.py +499 -0
- hyperprobe_agent-1.2.24/hyperprobe/bootstrap.py +40 -0
- hyperprobe_agent-1.2.24/hyperprobe/core/__init__.py +1 -0
- hyperprobe_agent-1.2.24/hyperprobe/core/broker.py +131 -0
- hyperprobe_agent-1.2.24/hyperprobe/core/evaluator.py +119 -0
- hyperprobe_agent-1.2.24/hyperprobe/core/injection/__init__.py +0 -0
- hyperprobe_agent-1.2.24/hyperprobe/core/injection/sitecustomize.py +18 -0
- hyperprobe_agent-1.2.24/hyperprobe/core/logger.py +121 -0
- hyperprobe_agent-1.2.24/hyperprobe/core/monitoring_engine.py +788 -0
- hyperprobe_agent-1.2.24/hyperprobe/core/probe_output.py +177 -0
- hyperprobe_agent-1.2.24/hyperprobe/core/quota.py +73 -0
- hyperprobe_agent-1.2.24/hyperprobe/core/safety.py +136 -0
- hyperprobe_agent-1.2.24/hyperprobe/core/serializer.py +214 -0
- hyperprobe_agent-1.2.24/hyperprobe/core/trace_extractor.py +93 -0
- hyperprobe_agent-1.2.24/hyperprobe/protos/__init__.py +7 -0
- hyperprobe_agent-1.2.24/hyperprobe/protos/agent_pb2.py +57 -0
- hyperprobe_agent-1.2.24/hyperprobe/protos/agent_pb2_grpc.py +199 -0
- hyperprobe_agent-1.2.24/hyperprobe_agent.egg-info/PKG-INFO +154 -0
- hyperprobe_agent-1.2.24/hyperprobe_agent.egg-info/SOURCES.txt +35 -0
- hyperprobe_agent-1.2.24/hyperprobe_agent.egg-info/dependency_links.txt +1 -0
- hyperprobe_agent-1.2.24/hyperprobe_agent.egg-info/entry_points.txt +2 -0
- hyperprobe_agent-1.2.24/hyperprobe_agent.egg-info/requires.txt +8 -0
- hyperprobe_agent-1.2.24/hyperprobe_agent.egg-info/top_level.txt +1 -0
- hyperprobe_agent-1.2.24/setup.cfg +4 -0
- hyperprobe_agent-1.2.24/setup.py +44 -0
- hyperprobe_agent-1.2.24/tests/test_agent.py +184 -0
- hyperprobe_agent-1.2.24/tests/test_evaluator.py +65 -0
- hyperprobe_agent-1.2.24/tests/test_logger.py +69 -0
- hyperprobe_agent-1.2.24/tests/test_metric_probes.py +423 -0
- hyperprobe_agent-1.2.24/tests/test_multithreading_integration.py +132 -0
- hyperprobe_agent-1.2.24/tests/test_p1_regressions.py +401 -0
- hyperprobe_agent-1.2.24/tests/test_probe_output.py +370 -0
- hyperprobe_agent-1.2.24/tests/test_serializer.py +87 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Hyperprobe Proprietary License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Hyperprobe. All rights reserved.
|
|
4
|
+
|
|
5
|
+
This software and its associated documentation are proprietary to Hyperprobe.
|
|
6
|
+
No permission is granted to use, copy, modify, distribute, sublicense, or
|
|
7
|
+
create derivative works except as expressly authorized under a written
|
|
8
|
+
commercial license agreement with Hyperprobe.
|
|
9
|
+
|
|
10
|
+
A valid commercial license from Hyperprobe is required to operate this
|
|
11
|
+
software.
|
|
12
|
+
|
|
13
|
+
For licensing inquiries, visit https://hyperprobe.co/.
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hyperprobe-agent
|
|
3
|
+
Version: 1.2.24
|
|
4
|
+
Summary: Production-grade, non-breaking live debugger and telemetry agent for Python.
|
|
5
|
+
Home-page: https://www.hyperprobe.co
|
|
6
|
+
Author: Arif, Saksham, Karan
|
|
7
|
+
Author-email: arif@hypertest.co, saksham@hypertest.co, karan@hypertest.co
|
|
8
|
+
License: Hyperprobe Proprietary License
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Requires-Python: >=3.12
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: protobuf<6.0.0,>=4.25.3
|
|
17
|
+
Requires-Dist: grpcio>=1.62.2
|
|
18
|
+
Provides-Extra: dev
|
|
19
|
+
Requires-Dist: grpcio>=1.50.0; extra == "dev"
|
|
20
|
+
Requires-Dist: grpcio-tools>=1.50.0; extra == "dev"
|
|
21
|
+
Requires-Dist: protobuf>=4.21.0; extra == "dev"
|
|
22
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
23
|
+
Dynamic: author
|
|
24
|
+
Dynamic: author-email
|
|
25
|
+
Dynamic: classifier
|
|
26
|
+
Dynamic: description
|
|
27
|
+
Dynamic: description-content-type
|
|
28
|
+
Dynamic: home-page
|
|
29
|
+
Dynamic: license
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
Dynamic: provides-extra
|
|
32
|
+
Dynamic: requires-dist
|
|
33
|
+
Dynamic: requires-python
|
|
34
|
+
Dynamic: summary
|
|
35
|
+
|
|
36
|
+
# HyperProbe Python Agent
|
|
37
|
+
|
|
38
|
+
Production-grade, non-breaking live debugger and telemetry agent for Python.
|
|
39
|
+
|
|
40
|
+
HyperProbe allows you to debug running Python applications in real-time without breaking them, restarting them, or altering production traffic. It leverages modern Python's fast, low-overhead monitoring APIs (`sys.monitoring`) to securely and dynamically extract stack frames, local variables, and logs at targeted lines.
|
|
41
|
+
|
|
42
|
+
## Features
|
|
43
|
+
|
|
44
|
+
- **Non-Breaking Snapshot Probes:** Capture local variables and stack traces dynamically at any line of code.
|
|
45
|
+
- **Dynamic Log Probes:** Inject live log templates to print formatted output without redeploying code.
|
|
46
|
+
- **Counter Probes:** Emit a value of `1` whenever a configured source line is reached.
|
|
47
|
+
- **Metric Probes:** Safely evaluate a numerical Python expression and emit its value.
|
|
48
|
+
- **Duration Probes:** Measure elapsed monotonic time in milliseconds between two source lines, with optional request correlation.
|
|
49
|
+
- **Zero-Code-Change Auto-Instrumentation:** Prepend our bootstrap runtime to any Python process without editing your application's code.
|
|
50
|
+
- **Circular Reference & Deep Object Protection:** Memory-safe serialization of deeply nested or cyclic variables.
|
|
51
|
+
- **High-Performance Safety Guard:** Automatically pauses monitoring and goes idle if CPU/memory boundaries or pause budgets are exceeded.
|
|
52
|
+
|
|
53
|
+
## Metric-family probes
|
|
54
|
+
|
|
55
|
+
Counter, metric, and duration probes are created through HyperProbe in the same way as snapshot and log probes. No application code changes or additional public SDK calls are required.
|
|
56
|
+
|
|
57
|
+
| Probe | Configuration | Emitted `metric_value` |
|
|
58
|
+
| --- | --- | --- |
|
|
59
|
+
| Counter | `metric_name` and one runtime location | `1` per matching hit |
|
|
60
|
+
| Metric | `metric_name`, `metric_expression`, and one runtime location | The finite numerical expression result |
|
|
61
|
+
| Duration | `metric_name`, primary and secondary runtime locations, and optional `correlation_expression` | Monotonic elapsed milliseconds |
|
|
62
|
+
|
|
63
|
+
Conditions are evaluated at every configured location. Metric expressions use the same restricted, read-only Python evaluator as conditions and watches. Numerical strings follow Node SDK `parseFloat` behavior for compatibility; invalid or non-finite values are exported with `metric_value` set to `0` and a populated `capture_error`.
|
|
64
|
+
|
|
65
|
+
Duration correlation expressions must evaluate to a string or number. When omitted or when they evaluate to `None`, a singleton correlation key is used. Unmatched duration ends are ignored, and pending starts expire after 60 seconds.
|
|
66
|
+
|
|
67
|
+
## Installation
|
|
68
|
+
|
|
69
|
+
Install the package via `pip` (or `testpypi` for testing):
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pip install hyperprobe-agent
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Usage
|
|
76
|
+
|
|
77
|
+
Run your application using the `hyperprobe-run` launcher. This automatically injects the live-debugging runtime before your code executes:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
HYPERPROBE_BROKER_URL="https://logger.app.hyperprobe.co" \
|
|
81
|
+
HYPERPROBE_SERVICE_ID="<service-uuid-from-dashboard>" \
|
|
82
|
+
HYPERPROBE_ENVIRONMENT="development" \
|
|
83
|
+
GIT_COMMIT=$(git rev-parse HEAD) \
|
|
84
|
+
hyperprobe-run python app.py
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Configuration Environment Variables
|
|
88
|
+
|
|
89
|
+
Configure the agent using the following environment variables:
|
|
90
|
+
|
|
91
|
+
| Variable | Description | Default |
|
|
92
|
+
| --- | --- | --- |
|
|
93
|
+
| `HYPERPROBE_BROKER_URL` | The URL of the HyperProbe Telemetry Broker. | *Required* |
|
|
94
|
+
| `HYPERPROBE_SERVICE_ID` | A unique name identifying this service. | *Required* |
|
|
95
|
+
| `HYPERPROBE_ENVIRONMENT` | Deployment environment name (e.g., `production`, `staging`). | *Required* |
|
|
96
|
+
| `HYPERPROBE_COMMIT_SHA` or `GIT_COMMIT` | Git commit SHA of the running application version. | *Required* |
|
|
97
|
+
| `HYPERPROBE_DISABLED` | Set to `YES` to explicitly disable the agent. | *(unset)* |
|
|
98
|
+
| `HYPERPROBE_SYNC_INTERVAL_MS` | Rate at which the agent syncs probe definitions from the broker. | `60000` (1 min) |
|
|
99
|
+
| `HYPERPROBE_FLUSH_INTERVAL_MS` | Delay before sending telemetry events to the broker. | `1000` (1 sec) |
|
|
100
|
+
| `HYPERPROBE_MAX_QUEUE_SIZE` | Maximum number of telemetry events held before flush. | `100` |
|
|
101
|
+
| `HYPERPROBE_HITS_PER_SEC` | Max snapshot capture requests per second (quota). | `10` |
|
|
102
|
+
| `HYPERPROBE_BANDWIDTH_KB_PER_SEC` | Max bandwidth limit for telemetry transmissions (quota). | `1024` (1 MB) |
|
|
103
|
+
| `HYPERPROBE_RPC_TIMEOUT_SEC` | Deadline for broker RPCs. | `10` |
|
|
104
|
+
| `HYPERPROBE_COOLDOWN_SEC` | Tracing suspension duration after a RED safety state. | `10` |
|
|
105
|
+
| `HYPERPROBE_MAX_LAG_MS` | Execution-thread lag threshold for the safety monitor. | `50` |
|
|
106
|
+
| `HYPERPROBE_PAUSE_BUDGET_MS` | Per-second capture pause budget for the safety monitor. | `15` |
|
|
107
|
+
| `HYPERPROBE_REDACT_KEYS` | Comma-separated key patterns to redact. | `password,secret,token,authorization,cookie,key,signature` |
|
|
108
|
+
| `HYPERPROBE_REDACT_VALUES` | Comma-separated value patterns to redact. | *(empty)* |
|
|
109
|
+
| `HYPERPROBE_MAX_OBJECT_DEPTH` | Maximum serialized object depth. | `3` |
|
|
110
|
+
| `HYPERPROBE_MAX_ARRAY_LENGTH` | Maximum serialized array length. | `3` |
|
|
111
|
+
| `HYPERPROBE_STACK_FRAME_DEPTH` | Maximum captured stack-frame depth. | `3` |
|
|
112
|
+
| `HYPERPROBE_MAX_OBJECT_PROPERTIES` | Maximum serialized properties per object. | `50` |
|
|
113
|
+
| `HYPERPROBE_MAX_STRING_LENGTH` | Maximum serialized string length. | `1024` |
|
|
114
|
+
|
|
115
|
+
### Debug logging
|
|
116
|
+
|
|
117
|
+
Set `DEBUG` to a comma- or space-separated list of namespaces. Patterns accept
|
|
118
|
+
`*`, and exclusions begin with `-`:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
DEBUG=hyperprobe* # all HyperProbe SDK logs
|
|
122
|
+
DEBUG=hyperprobe:broker,hyperprobe:monitor # selected components
|
|
123
|
+
DEBUG=hyperprobe*,-hyperprobe:evaluator # exclude a component
|
|
124
|
+
DEBUG_COLORS=1 # force ANSI colors
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Without `*`, a selector is exact: `DEBUG=hyperprobe` does not match
|
|
128
|
+
`hyperprobe:agent`. Use `DEBUG=hyperprobe*` to enable every component.
|
|
129
|
+
Set `DEBUG_COLORS=0` to disable colors. Logging configuration is read during
|
|
130
|
+
SDK initialization, so set these variables before starting the process.
|
|
131
|
+
|
|
132
|
+
## Programmatic Usage (Inside Your Code)
|
|
133
|
+
|
|
134
|
+
If you prefer to start the agent directly inside your Python script instead of using the `hyperprobe-run` launcher, you can do so by importing the package and calling `HyperProbe.start()` programmatically.
|
|
135
|
+
|
|
136
|
+
This is useful for applications where you want to control exactly when the agent boots up or configure the agent dynamically at runtime:
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
import os
|
|
140
|
+
from hyperprobe import HyperProbe
|
|
141
|
+
|
|
142
|
+
# Start the agent programmatically at your application's entrypoint
|
|
143
|
+
agent = HyperProbe.start({
|
|
144
|
+
"service_id": "<service-uuid-from-dashboard>",
|
|
145
|
+
"environment": os.getenv("PYTHON_ENV"), # Your environment name (e.g. dev, staging, production). Use whatever variable contains the env value.
|
|
146
|
+
"broker_url": "https://logger.app.hyperprobe.co",
|
|
147
|
+
"commit_sha": os.getenv("GIT_COMMIT"), # CI-injected commit SHA (reads os.getenv("GIT_COMMIT") by default)
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
# Your application code goes here...
|
|
151
|
+
|
|
152
|
+
# To cleanly shut down the agent when your app stops:
|
|
153
|
+
HyperProbe.shutdown()
|
|
154
|
+
```
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# HyperProbe Python Agent
|
|
2
|
+
|
|
3
|
+
Production-grade, non-breaking live debugger and telemetry agent for Python.
|
|
4
|
+
|
|
5
|
+
HyperProbe allows you to debug running Python applications in real-time without breaking them, restarting them, or altering production traffic. It leverages modern Python's fast, low-overhead monitoring APIs (`sys.monitoring`) to securely and dynamically extract stack frames, local variables, and logs at targeted lines.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Non-Breaking Snapshot Probes:** Capture local variables and stack traces dynamically at any line of code.
|
|
10
|
+
- **Dynamic Log Probes:** Inject live log templates to print formatted output without redeploying code.
|
|
11
|
+
- **Counter Probes:** Emit a value of `1` whenever a configured source line is reached.
|
|
12
|
+
- **Metric Probes:** Safely evaluate a numerical Python expression and emit its value.
|
|
13
|
+
- **Duration Probes:** Measure elapsed monotonic time in milliseconds between two source lines, with optional request correlation.
|
|
14
|
+
- **Zero-Code-Change Auto-Instrumentation:** Prepend our bootstrap runtime to any Python process without editing your application's code.
|
|
15
|
+
- **Circular Reference & Deep Object Protection:** Memory-safe serialization of deeply nested or cyclic variables.
|
|
16
|
+
- **High-Performance Safety Guard:** Automatically pauses monitoring and goes idle if CPU/memory boundaries or pause budgets are exceeded.
|
|
17
|
+
|
|
18
|
+
## Metric-family probes
|
|
19
|
+
|
|
20
|
+
Counter, metric, and duration probes are created through HyperProbe in the same way as snapshot and log probes. No application code changes or additional public SDK calls are required.
|
|
21
|
+
|
|
22
|
+
| Probe | Configuration | Emitted `metric_value` |
|
|
23
|
+
| --- | --- | --- |
|
|
24
|
+
| Counter | `metric_name` and one runtime location | `1` per matching hit |
|
|
25
|
+
| Metric | `metric_name`, `metric_expression`, and one runtime location | The finite numerical expression result |
|
|
26
|
+
| Duration | `metric_name`, primary and secondary runtime locations, and optional `correlation_expression` | Monotonic elapsed milliseconds |
|
|
27
|
+
|
|
28
|
+
Conditions are evaluated at every configured location. Metric expressions use the same restricted, read-only Python evaluator as conditions and watches. Numerical strings follow Node SDK `parseFloat` behavior for compatibility; invalid or non-finite values are exported with `metric_value` set to `0` and a populated `capture_error`.
|
|
29
|
+
|
|
30
|
+
Duration correlation expressions must evaluate to a string or number. When omitted or when they evaluate to `None`, a singleton correlation key is used. Unmatched duration ends are ignored, and pending starts expire after 60 seconds.
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
Install the package via `pip` (or `testpypi` for testing):
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install hyperprobe-agent
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Usage
|
|
41
|
+
|
|
42
|
+
Run your application using the `hyperprobe-run` launcher. This automatically injects the live-debugging runtime before your code executes:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
HYPERPROBE_BROKER_URL="https://logger.app.hyperprobe.co" \
|
|
46
|
+
HYPERPROBE_SERVICE_ID="<service-uuid-from-dashboard>" \
|
|
47
|
+
HYPERPROBE_ENVIRONMENT="development" \
|
|
48
|
+
GIT_COMMIT=$(git rev-parse HEAD) \
|
|
49
|
+
hyperprobe-run python app.py
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Configuration Environment Variables
|
|
53
|
+
|
|
54
|
+
Configure the agent using the following environment variables:
|
|
55
|
+
|
|
56
|
+
| Variable | Description | Default |
|
|
57
|
+
| --- | --- | --- |
|
|
58
|
+
| `HYPERPROBE_BROKER_URL` | The URL of the HyperProbe Telemetry Broker. | *Required* |
|
|
59
|
+
| `HYPERPROBE_SERVICE_ID` | A unique name identifying this service. | *Required* |
|
|
60
|
+
| `HYPERPROBE_ENVIRONMENT` | Deployment environment name (e.g., `production`, `staging`). | *Required* |
|
|
61
|
+
| `HYPERPROBE_COMMIT_SHA` or `GIT_COMMIT` | Git commit SHA of the running application version. | *Required* |
|
|
62
|
+
| `HYPERPROBE_DISABLED` | Set to `YES` to explicitly disable the agent. | *(unset)* |
|
|
63
|
+
| `HYPERPROBE_SYNC_INTERVAL_MS` | Rate at which the agent syncs probe definitions from the broker. | `60000` (1 min) |
|
|
64
|
+
| `HYPERPROBE_FLUSH_INTERVAL_MS` | Delay before sending telemetry events to the broker. | `1000` (1 sec) |
|
|
65
|
+
| `HYPERPROBE_MAX_QUEUE_SIZE` | Maximum number of telemetry events held before flush. | `100` |
|
|
66
|
+
| `HYPERPROBE_HITS_PER_SEC` | Max snapshot capture requests per second (quota). | `10` |
|
|
67
|
+
| `HYPERPROBE_BANDWIDTH_KB_PER_SEC` | Max bandwidth limit for telemetry transmissions (quota). | `1024` (1 MB) |
|
|
68
|
+
| `HYPERPROBE_RPC_TIMEOUT_SEC` | Deadline for broker RPCs. | `10` |
|
|
69
|
+
| `HYPERPROBE_COOLDOWN_SEC` | Tracing suspension duration after a RED safety state. | `10` |
|
|
70
|
+
| `HYPERPROBE_MAX_LAG_MS` | Execution-thread lag threshold for the safety monitor. | `50` |
|
|
71
|
+
| `HYPERPROBE_PAUSE_BUDGET_MS` | Per-second capture pause budget for the safety monitor. | `15` |
|
|
72
|
+
| `HYPERPROBE_REDACT_KEYS` | Comma-separated key patterns to redact. | `password,secret,token,authorization,cookie,key,signature` |
|
|
73
|
+
| `HYPERPROBE_REDACT_VALUES` | Comma-separated value patterns to redact. | *(empty)* |
|
|
74
|
+
| `HYPERPROBE_MAX_OBJECT_DEPTH` | Maximum serialized object depth. | `3` |
|
|
75
|
+
| `HYPERPROBE_MAX_ARRAY_LENGTH` | Maximum serialized array length. | `3` |
|
|
76
|
+
| `HYPERPROBE_STACK_FRAME_DEPTH` | Maximum captured stack-frame depth. | `3` |
|
|
77
|
+
| `HYPERPROBE_MAX_OBJECT_PROPERTIES` | Maximum serialized properties per object. | `50` |
|
|
78
|
+
| `HYPERPROBE_MAX_STRING_LENGTH` | Maximum serialized string length. | `1024` |
|
|
79
|
+
|
|
80
|
+
### Debug logging
|
|
81
|
+
|
|
82
|
+
Set `DEBUG` to a comma- or space-separated list of namespaces. Patterns accept
|
|
83
|
+
`*`, and exclusions begin with `-`:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
DEBUG=hyperprobe* # all HyperProbe SDK logs
|
|
87
|
+
DEBUG=hyperprobe:broker,hyperprobe:monitor # selected components
|
|
88
|
+
DEBUG=hyperprobe*,-hyperprobe:evaluator # exclude a component
|
|
89
|
+
DEBUG_COLORS=1 # force ANSI colors
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Without `*`, a selector is exact: `DEBUG=hyperprobe` does not match
|
|
93
|
+
`hyperprobe:agent`. Use `DEBUG=hyperprobe*` to enable every component.
|
|
94
|
+
Set `DEBUG_COLORS=0` to disable colors. Logging configuration is read during
|
|
95
|
+
SDK initialization, so set these variables before starting the process.
|
|
96
|
+
|
|
97
|
+
## Programmatic Usage (Inside Your Code)
|
|
98
|
+
|
|
99
|
+
If you prefer to start the agent directly inside your Python script instead of using the `hyperprobe-run` launcher, you can do so by importing the package and calling `HyperProbe.start()` programmatically.
|
|
100
|
+
|
|
101
|
+
This is useful for applications where you want to control exactly when the agent boots up or configure the agent dynamically at runtime:
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
import os
|
|
105
|
+
from hyperprobe import HyperProbe
|
|
106
|
+
|
|
107
|
+
# Start the agent programmatically at your application's entrypoint
|
|
108
|
+
agent = HyperProbe.start({
|
|
109
|
+
"service_id": "<service-uuid-from-dashboard>",
|
|
110
|
+
"environment": os.getenv("PYTHON_ENV"), # Your environment name (e.g. dev, staging, production). Use whatever variable contains the env value.
|
|
111
|
+
"broker_url": "https://logger.app.hyperprobe.co",
|
|
112
|
+
"commit_sha": os.getenv("GIT_COMMIT"), # CI-injected commit SHA (reads os.getenv("GIT_COMMIT") by default)
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
# Your application code goes here...
|
|
116
|
+
|
|
117
|
+
# To cleanly shut down the agent when your app stops:
|
|
118
|
+
HyperProbe.shutdown()
|
|
119
|
+
```
|