Golem enable otlp ts

From golemcloud/golem · View interactive version

Golem enable otlp ts is an AI agent skill from the GitHub repository golemcloud/golem. Enabling the OpenTelemetry (OTLP) plugin for a TypeScript Golem agent — exporting traces, logs, and metrics to an OTLP collector, adding custom spans with the invocation context API or node:diagnostics_channel.

How to use this skill

Skill file

Enabling OpenTelemetry for a TypeScript Agent

The golem-otlp-exporter is a built-in plugin that exports agent telemetry (traces, logs, metrics) to any OTLP-compatible collector via OTLP/HTTP. No plugin installation is needed — just enable it in the application manifest.

Step 1 — Enable the Plugin in golem.yaml

Add the plugin to the component (or agent) that should emit telemetry:

components:
  my-app:service:
    plugins:
      - name: golem-otlp-exporter
        version: "1.5.8"
        parameters:
          endpoint: "http://localhost:4318"
          signals: "traces,logs,metrics"

Plugin Parameters

| Parameter | Required | Description |

|-----------|----------|-------------|

| endpoint | Yes | OTLP collector base URL (e.g., http://localhost:4318) |

| signals | No | Comma-separated: traces, logs, metrics. Default: traces |

| headers | No | Comma-separated key=value HTTP headers (e.g., x-api-key=secret) |

| service-name-mode | No | agent-id (default) or agent-type |

Step 2 — Deploy

golem deploy --yes

After deployment, newly created agents from this component automatically send telemetry to the configured collector.

What Gets Exported

Traces

Spans are created automatically for:

Trace and span IDs propagate from inbound HTTP requests (via code-first routes) and are included in outgoing HTTP request headers automatically.

Custom Spans

Use the golem:api/context API to create custom spans:

import { startSpan, currentContext } from 'golem:api/context@1.5.0';

const span = startSpan('my-operation');
span.setAttribute('env', { tag: 'string', val: 'production' });
span.setAttributes([
  { key: 'service', value: { tag: 'string', val: 'my-service' } },
  { key: 'version', value: { tag: 'string', val: '1.0' } },
]);

// ... do work ...

const ctx = currentContext();
console.log(`trace_id: ${ctx.traceId()}`);
span.finish();

Custom Spans via node:diagnostics_channel

TypeScript also supports the Node.js diagnostics_channel API, which automatically creates Golem spans:

import { tracingChannel } from 'node:diagnostics_channel';

const dc = tracingChannel('my-operation');
const result = dc.traceSync(
  () => {
    // ... do work ...
    return 42;
  },
  { method: 'GET', url: '/api/data', env: 'production' } // become span attributes
);

Logs

When logs is included in signals, all log output is forwarded to the OTLP collector. See the golem-logging-ts skill for full logging guidance.

console.log("Hello from TypeScript!");
console.debug("This is a debug log entry");

Metrics

When metrics is included in signals, exported metrics include the following non-exhaustive list:

| Metric | Type | Description |

|--------|------|-------------|

| golem.invocation.count | Counter | Number of agent method invocations |

| golem.invocation.duration_ns | Counter | Invocation duration |

| golem.invocation.fuel_consumed | Counter | Fuel consumed by invocations |

| golem.invocation.pending_count | Counter | Number of invocation requests queued (not current queue depth) |

| golem.host_call.count | Counter | Number of internal host calls |

| golem.log.count | Counter | Number of log entries emitted |

| golem.memory.initial_bytes | Gauge | Initially allocated memory |

| golem.memory.total_bytes | Gauge | Total allocated memory |

| golem.memory.growth_bytes | Counter | Memory growth since start |

| golem.component.size_bytes | Gauge | Component size in bytes |

| golem.error.count | Counter | Number of recorded errors |

| golem.interruption.count | Counter | Number of interrupt requests |

| golem.exit.count | Counter | Number of process exit signals |

| golem.restart.count | Counter | Number of times a fresh state was created |

| golem.resources.created | Counter | Number of internal resources created |

| golem.resources.dropped | Counter | Number of internal resources dropped |

| golem.resources.active | Gauge | Number of active internal resources |

| golem.update.success_count | Counter | Number of successful updates |

| golem.update.failure_count | Counter | Number of failed updates |

| golem.transaction.committed | Counter | Number of committed remote transaction events |

| golem.transaction.rolled_back | Counter | Number of rolled back remote transaction events |

| golem.snapshot.size_bytes | Counter | Snapshot size in bytes |

| golem.oplog_processor.lag | Gauge | Oplog processor delivery lag |

These are emitted OTLP names. A backend such as Prometheus may normalize dots to underscores and add suffixes; use that backend's mapping when writing queries.

Each metric includes service.name, golem.agent.id (the agent ID, a UUID), golem.agent.type (when the agent has a type), and golem.component.version attributes.

Export Semantics

Local Observability Stack

The Golem repository includes a ready-made Docker Compose setup at docker-examples/otlp-collector/:

docker compose -f docker-examples/otlp-collector/docker-compose.yml up -d

This starts:

Configure the plugin with endpoint: "http://localhost:4318" to use this stack.

Per-Environment Configuration

Use the environment preset app-env:production to change only the production

endpoint. A plain production custom preset can become the default when it is the

only custom preset, applying that endpoint in every environment:

components:
  my-app:service:
    plugins:
      - name: golem-otlp-exporter
        version: "1.5.8"
        parameters:
          endpoint: "http://localhost:4318"
          signals: "traces,logs,metrics"
    presets:
      app-env:production:
        pluginsMergeMode: replace
        plugins:
          - name: golem-otlp-exporter
            version: "1.5.8"
            parameters:
              endpoint: "https://otel.prod.example.com:4318"
              headers: "x-api-key={{ OTLP_API_KEY }}"
              signals: "traces,logs,metrics"

Key Points

Related Skills

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.