Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
OpencodeOtelPlugin
✓ import { OpencodeOtelPlugin } from 'opencode-otel'
The plugin class is exported as a named export. No default export.
package (CommonJS require)
✓ const { OpencodeOtelPlugin } = require('opencode-otel')
✗ const OpencodeOtelPlugin = require('opencode-otel')
The package does not have a default export; must destructure from CommonJS require.
OpencodeOtelPlugin (type import)
✓ import type { OpencodeOtelPlugin } from 'opencode-otel'
✗ import { OpencodeOtelPlugin } from 'opencode-otel' // when only type is needed
For TypeScript type-only imports, use import type to avoid runtime side effects. This package ships types.
Demonstrates importing the plugin class and manual configuration with environment variable defaults.
// Ensure @opencode-ai/plugin is installed (peer dep)
// Add to ~/.config/opencode/opencode.json: {"plugin": ["opencode-otel"]}
// Then set OTLP environment variables before starting OpenCode
import { OpencodeOtelPlugin } from 'opencode-otel';
// The plugin is automatically loaded through OpenCode's plugin system.
// Manual instantiation example:
const plugin = new OpencodeOtelPlugin();
// Custom configuration (optional, uses OTEL env vars by default)
// plugin.configure({
// logsEndpoint: process.env.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT ?? 'http://localhost:4318',
// protocol: 'grpc',
// serviceName: 'my-agent',
// resourceAttributes: { 'service.name': 'my-agent' }
// });
Debug
Known issues
breakingPeer dependency @opencode-ai/plugin must be >=1.1.0. Older versions may not support this plugin.fixUpdate @opencode-ai/plugin to >=1.1.0
affects: >=1.0.0 <1.1.0 of @opencode-ai/plugin
gotchaThe plugin monkey-patches process.stderr.write at initialization. If another package also patches stderr, order of plugin loading may cause conflicts or loss of logs.fixEnsure opencode-otel is loaded before other stderr patching plugins, or avoid multiple stderr monkeys.
affects: >=1.0.0
deprecatedOTEL_EXPORTER_OTLP_METRICS_ENDPOINT and related metrics env vars are tolerated but ignored; setting them may cause confusion.fixDo not rely on metrics being forwarded; use a dedicated metrics plugin if needed.
affects: >=1.0.0
gotchaIf no logs endpoint is configured (OTEL_EXPORTER_OTLP_LOGS_ENDPOINT is not set), the plugin remains inactive and does not install the stderr interceptor. This may cause silent log loss.fixEnsure OTEL_EXPORTER_OTLP_LOGS_ENDPOINT is set for the plugin to activate.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module '@opencode-ai/plugin' or its corresponding type declarations.
Missing or outdated peer dependency @opencode-ai/plugin
fixnpm install @opencode-ai/plugin@^1.1.0
TypeError: OpencodeOtelPlugin is not a constructor
CommonJS require without destructuring; package has no default export
fixconst { OpencodeOtelPlugin } = require('opencode-otel'); Cannot read properties of undefined (reading 'write')
Plugin attempted to patch process.stderr before initialization or in an environment without a standard stderr (e.g., certain test runners or headless environments)
fixEnsure the plugin is loaded after process is fully initialized, or check if stderr is available.
Audit
Dependencies
@opencode-ai/pluginoptionalRequired peer dependency for OpenCode plugin compatibility