Skip to content

diagnostics-otel: Resource is not a constructor with @opentelemetry/resources@2.5.0 #9310

@iavankda

Description

@iavankda

Bug Description

The diagnostics-otel plugin fails to load with the following error:

TypeError: _resources.Resource is not a constructor

Root Cause

The plugin code uses:

import { Resource } from "@opentelemetry/resources";
const resource = new Resource({...});

However, in @opentelemetry/resources@2.5.0, Resource is exported as a type only:

export type { Resource } from './Resource';

The actual implementation is exported via factory functions:

export { resourceFromAttributes, defaultResource, emptyResource } from './ResourceImpl';

Expected Behavior

Plugin should load successfully and export telemetry to the configured OTel collector.

Actual Behavior

Plugin fails to load with TypeError, preventing diagnostics from working.

Fix Suggestion

Update extensions/diagnostics-otel/src/service.ts to use the factory functions instead:

import { defaultResource } from "@opentelemetry/resources";
import { SEMRESATTRS_SERVICE_NAME } from "@opentelemetry/semantic-conventions";

// Instead of:
// const resource = new Resource({...});

// Use:
const resource = defaultResource().merge(
  resourceFromAttributes({
    [SEMRESATTRS_SERVICE_NAME]: serviceName,
    // ... other attributes
  })
);

Environment

  • OpenClaw version: 2026.2.3
  • @opentelemetry/resources: 2.5.0
  • @opentelemetry/api: 1.9.0
  • Node.js: 22-bookworm

Steps to Reproduce

  1. Enable diagnostics-otel plugin in openclaw.json
  2. Start gateway
  3. Observe plugin fails to load with TypeError

Workaround

Currently disabling the plugin until a fix is available.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions