Generator
provide.foundation.cli.commands.logs.generator
¶
TODO: Add module docstring.
Classes¶
LogGenerator
¶
Generates log entries for testing OpenObserve integration.
This class encapsulates log generation logic with support for: - Multiple message styles (normal, Burroughs-inspired) - Configurable error rates - Thread-safe trace and span ID generation - Rate-controlled log emission
Functions¶
generate_continuous
¶
generate_continuous(
rate: float,
enable_rate_limit: bool,
logs_rate_limited: int,
) -> tuple[int, int, int]
Generate logs in continuous mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rate
|
float
|
Target logs per second |
required |
enable_rate_limit
|
bool
|
Whether rate limiting is enabled |
required |
logs_rate_limited
|
int
|
Initial rate-limited counter |
required |
Returns:
| Type | Description |
|---|---|
tuple[int, int, int]
|
Final counters tuple (logs_sent, logs_failed, logs_rate_limited) |
Source code in provide/foundation/cli/commands/logs/generator.py
generate_fixed_count
¶
Generate a fixed number of logs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
count
|
int
|
Number of logs to generate |
required |
rate
|
float
|
Target logs per second (0 for unlimited) |
required |
Returns:
| Type | Description |
|---|---|
tuple[int, int, int]
|
Final counters tuple (logs_sent, logs_failed, logs_rate_limited) |
Source code in provide/foundation/cli/commands/logs/generator.py
generate_log_entry
¶
Generate a single log entry with optional error simulation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int
|
Log entry index |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict containing log entry data |
Source code in provide/foundation/cli/commands/logs/generator.py
generate_span_id
¶
Generate a unique span ID.
Returns:
| Type | Description |
|---|---|
str
|
Formatted span ID string |
Source code in provide/foundation/cli/commands/logs/generator.py
generate_trace_id
¶
Generate a unique trace ID.
Returns:
| Type | Description |
|---|---|
str
|
Formatted trace ID string |
Source code in provide/foundation/cli/commands/logs/generator.py
send_log_entry
¶
send_log_entry(
entry: dict[str, Any],
logs_sent: int,
logs_failed: int,
logs_rate_limited: int,
) -> tuple[int, int, int]
Send a log entry and update counters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entry
|
dict[str, Any]
|
Log entry dictionary to send |
required |
logs_sent
|
int
|
Current count of successfully sent logs |
required |
logs_failed
|
int
|
Current count of failed logs |
required |
logs_rate_limited
|
int
|
Current count of rate-limited logs |
required |
Returns:
| Type | Description |
|---|---|
tuple[int, int, int]
|
Updated counters tuple (logs_sent, logs_failed, logs_rate_limited) |