🎛️ Instrument-style client that sends metrics immediately.

This provides a more traditional OpenTelemetry experience where you create instrument objects once and then use them multiple times. It's built on top of the RednetClient but provides a more convenient API for repeated measurements.

Perfect when you want to create instruments once at startup and then use them throughout your application lifecycle without repeating metric metadata.

const client = new RednetClient(42, "my-service");
const instruments = new RednetInstrumentClient(client);

// Create instruments once
const requestsTotal = instruments.createCounter(
"requests_total",
"Total HTTP requests",
"requests"
);
const activeConnections = instruments.createGauge(
"active_connections",
"Currently active connections",
"connections"
);

// Use them many times
requestsTotal.add(1, { "method": "GET" });
activeConnections.set(42);

Constructors

Methods

  • 📈 Create a counter instrument.

    Returns a counter that you can use to track cumulative values. The counter remembers its metadata so you don't have to repeat it.

    Parameters

    • name: string

      Counter name

    • description: string = ""

      Human-readable description (optional)

    • unit: string = ""

      Unit of measurement (optional)

    Returns RednetCounter

    A counter instrument

    const blocksMinedCounter = instruments.createCounter(
    "blocks_mined_total",
    "Total blocks mined by this turtle",
    "blocks"
    );

    // Use it in your mining loop
    while (mining) {
    if (turtle.dig()) {
    blocksMinedCounter.add(1, { "block.type": getBlockType() });
    }
    }
  • 📊 Create a gauge instrument.

    Returns a gauge that you can use to track current values. The gauge remembers its metadata so you don't have to repeat it.

    Parameters

    • name: string

      Gauge name

    • description: string = ""

      Human-readable description (optional)

    • unit: string = ""

      Unit of measurement (optional)

    Returns RednetGauge

    A gauge instrument

    const fuelGauge = instruments.createGauge(
    "fuel_level",
    "Current turtle fuel level",
    "units"
    );

    // Update it periodically
    setInterval(() => {
    fuelGauge.set(turtle.getFuelLevel());
    }, 5000);