#2574: fix(diagnostics-otel): update to @opentelemetry/resources v2.x API
extensions: diagnostics-otel
## 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):
```js
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_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
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 })`.
<h3>Confidence Score: 5/5</h3>
- 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
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#10199: fix(diagnostics-otel): opentelemetry bug fix
by yourtion · 2026-02-06
90.0%
#11530: diagnostics-otel: fix OpenTelemetry v2 resource/logs API compatibility
by erain · 2026-02-07
87.5%
#4255: fix(diagnostics-otel): complete OpenTelemetry v2.x compatibility
by arbgjr · 2026-01-29
87.2%
#19353: fix(diagnostics-otel): fix cross-chunk module isolation breaking even…
by nez · 2026-02-17
76.6%
#21290: feat(diagnostics-otel): OpenTelemetry diagnostics with GenAI semant...
by Baukebrenninkmeijer · 2026-02-19
70.0%
#16865: fix(diagnostics-otel): share listeners/transports across module bun...
by leonnardo · 2026-02-15
68.8%
#18901: feat(diagnostics-otel): add trace context propagation and GenAI sem...
by sergical · 2026-02-17
68.0%
#2556: fix(plugin-install): handle existing plugins and filter workspace deps
by longmaba · 2026-01-27
67.9%
#18182: fix(security): redact sensitive data in OTEL log exports (CWE-532)
by brandonwise · 2026-02-16
67.4%
#22478: fix(diagnostics-otel): wire OTLP exporter to emit traffic to config...
by LuffySama-Dev · 2026-02-21
67.1%