Create a new Rednet telemetry client.
Computer ID of the collector to send data to
Name of your service (e.g., "turtle-miner", "factory-controller")
Version of your service (defaults to "1.0.0")
Additional resource attributes to include with all telemetry
Rednet protocol to use (defaults to "otel_telemetry")
📈 Send a counter metric immediately.
Counters track cumulative values that only increase (like total requests, blocks mined, or items produced). Perfect for tracking totals over time!
Metric name (e.g., "http_requests_total", "blocks_mined")
Human-readable description
Unit of measurement (e.g., "requests", "blocks", "bytes")
The counter value (must be positive)
Additional attributes for this measurement
// Track mining progress
client.sendCounter("blocks_mined_total", "Total blocks mined", "blocks", 1, {
"block.type": "minecraft:diamond_ore",
"tool.type": "diamond_pickaxe",
"depth": 12
});
// Track item production
client.sendCounter("items_crafted", "Items crafted", "items", 64, {
"item.type": "minecraft:iron_ingot",
"recipe.type": "smelting"
});
📊 Send a gauge metric immediately.
Gauges track current values that can go up or down (like fuel level, temperature, or queue size). Perfect for monitoring current state!
Metric name (e.g., "fuel_level", "temperature", "queue_size")
Human-readable description
Unit of measurement (e.g., "units", "celsius", "items")
The current gauge value
Additional attributes for this measurement
// Monitor turtle fuel
client.sendGauge("fuel_level", "Current fuel level", "units",
turtle.getFuelLevel(), {
"fuel.type": "minecraft:coal",
"max.fuel": 80000
}
);
// Monitor storage utilization
client.sendGauge("storage_utilization", "Storage space used", "percent",
(usedSlots / totalSlots) * 100, {
"storage.type": "chest",
"location": "main_base"
}
);
📈 Send a histogram metric immediately.
Histograms track distributions of values (like request duration, file sizes, or operation timing). Perfect for understanding performance characteristics!
Metric name (e.g., "request_duration", "file_size")
Human-readable description
Unit of measurement (e.g., "seconds", "bytes", "ms")
Number of observations
Sum of all observed values
Bucket counts for the histogram distribution
Additional attributes for this measurement
// Track mining operation timing
const startTime = os.epoch("utc");
const success = turtle.dig();
const duration = os.epoch("utc") - startTime;
client.sendHistogram(
"mining_duration",
"Time to mine a block",
"ms",
1, // count
duration, // sum
[ // buckets (cumulative counts)
{ bound: 100, count: duration <= 100 ? 1 : 0 },
{ bound: 500, count: duration <= 500 ? 1 : 0 },
{ bound: 1000, count: duration <= 1000 ? 1 : 0 },
{ bound: Infinity, count: 1 }
],
{ "success": success, "block.hardness": "medium" }
);
📝 Send a log immediately.
Send a structured log record with the specified severity level. Use the convenience methods (debug, info, warn, error, fatal) for common cases.
The log message or structured data
Severity level using OpenTelemetry standard
Additional context attributes
🔄 Update resource attributes (e.g., when turtle moves location).
Use this to update resource attributes dynamically, such as when a turtle moves to a new location or changes its operational state.
New attributes to merge with existing ones
🚀 Simple Rednet client - sends metrics and logs immediately to collector.
This is your main interface for sending telemetry data! The client handles all the formatting, metadata, and transmission details so you can focus on what matters - getting insights from your ComputerCraft systems.
The client is designed to be lightweight and fire-and-forget. Each metric and log is sent immediately over Rednet with no local buffering or batching. This makes it perfect for real-time monitoring but means you need a reliable network connection to your collector.
Example: Basic Usage