Skip to content

fix(diagnostics-otel): update to @opentelemetry/resources v2.x API#2574

Closed
dillera wants to merge 1 commit intoopenclaw:mainfrom
dillera:fix/otel-resources-v2-api
Closed

fix(diagnostics-otel): update to @opentelemetry/resources v2.x API#2574
dillera wants to merge 1 commit intoopenclaw:mainfrom
dillera:fix/otel-resources-v2-api

Conversation

@dillera
Copy link
Copy Markdown

@dillera dillera commented Jan 27, 2026

Summary

The diagnostics-otel plugin fails to load with:

TypeError: _resources.Resource is not a constructor

Root Cause

The @opentelemetry/resources package v2.x removed the Resource class export. The new API uses resourceFromAttributes() function instead.

From the package's index.js (v2.5.0):

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

Note: No Resource class is exported.

Fix

  • Replace import { Resource } with import { resourceFromAttributes }
  • Replace new Resource({...}) with resourceFromAttributes({...})

Testing

Tested locally on macOS with Node 22.22.0 — plugin now loads successfully and exports telemetry to Honeycomb.


Found while debugging with Clawdbot 🤖

Greptile Overview

Greptile Summary

Updates the diagnostics-otel plugin to match @opentelemetry/resources v2.x by switching from the removed Resource class to the new resourceFromAttributes() API, fixing the runtime TypeError: Resource is not a constructor when the plugin starts.

Change is localized to extensions/diagnostics-otel/src/service.ts, where the constructed resource passed into NodeSDK/LoggerProvider now uses resourceFromAttributes({ [SemanticResourceAttributes.SERVICE_NAME]: serviceName }).

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk.
  • The change is a straightforward API migration (import + constructor → function call) confined to a single location, and it directly addresses the reported runtime failure. No behavioral changes beyond resource construction were introduced.
  • No files require special attention

(2/5) Greptile learns from your feedback when you react with thumbs up/down!

The Resource class was removed in @opentelemetry/resources v2.x.
Use resourceFromAttributes() function instead of new Resource().

Fixes TypeError: _resources.Resource is not a constructor
@openclaw-barnacle openclaw-barnacle Bot added the extensions: diagnostics-otel Extension: diagnostics-otel label Jan 27, 2026
@dillera
Copy link
Copy Markdown
Author

dillera commented Jan 27, 2026

bots helping bots

@vincentkoc
Copy link
Copy Markdown
Member

Created a new PR at #12897

@steipete
Copy link
Copy Markdown
Contributor

AI-assisted stale triage closure (2026-02-23).

Closing this PR as superseded.

Why this is being closed:

  • This OpenTelemetry v2 migration path has already landed via a newer PR (#12897, merged 2026-02-19).
  • This PR is now conflicted and no longer the active integration path.

This is AI-closed housekeeping, not a rejection of the contribution.

If any missing pieces remain, please open a fresh PR from latest main and reference both this PR and #12897.

@steipete steipete closed this Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: diagnostics-otel Extension: diagnostics-otel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants