Skip to content

feat(hana): replace @dynatrace/oneagent-sdk with @opentelemetry/api#1535

Draft
hm23 wants to merge 2 commits intomainfrom
feat/replace-dynatrace-oneagent-sdk-with-opentelemetry
Draft

feat(hana): replace @dynatrace/oneagent-sdk with @opentelemetry/api#1535
hm23 wants to merge 2 commits intomainfrom
feat/replace-dynatrace-oneagent-sdk-with-opentelemetry

Conversation

@hm23
Copy link
Contributor

@hm23 hm23 commented Mar 10, 2026

(AI generated)

Motivation

@dynatrace/oneagent-sdk has not been published since February 2023 (v1.5.0), has had no active development in 3+ years, and Dynatrace themselves now direct users to OpenTelemetry for new integrations.

Library comparison

@dynatrace/oneagent-sdk @opentelemetry/api
Last publish Feb 2023 Jun 2024
Release cadence 10 versions over 5 years 240+ versions, monthly
Vendor lock-in Dynatrace only Any OTel-compatible backend
Dynatrace support Dynatrace is moving away from it Dynatrace is a top OTel contributor and picks up OTel spans natively via OneAgent
No-op when absent Yes (try/catch) Yes — the API package is spec'd as a no-op stub when no SDK is registered

What changed

  • hana/lib/drivers/dynatrace.js: replaced the Dynatrace SDK calls (traceSQLDatabaseRequest, startWithContext, tracer.error, tracer.end) with their OpenTelemetry equivalents (tracer.startSpan, context.with, span.recordException, span.setStatus, span.end). The dbInfo object shape changes from Dynatrace-specific fields to OTel semantic convention attributes (db.system, db.name, net.peer.name, net.peer.port). The overall structure, guards (CDS_SKIP_DYNATRACE, the try/catch), and the hana-client Object.defineProperty workaround are all preserved.
  • hana/package.json: @opentelemetry/api ^1 added as an optional peer dependency (mirrors how @dynatrace/oneagent-sdk was treated — undeclared but silently skipped when absent).

No changes to hdb.js or hana-client.js.

Bug fix: broken isDynatraceSupported guard

@sap/hana-client ships a native OpenTelemetry extension (extension/OpenTelemetry.js) that wraps connections automatically at connect time when @opentelemetry/api is installed. It covers more methods than our dynatrace.js wrapping (exec, prepare, executeBatch, executeQuery, commit, rollback, and result-set methods) and follows the current OTel semantic conventions.

The original code had a guard intended to skip our wrapping when the driver handles tracing natively:

if (client.isDynatraceSupported) return client //> client will wrap itself

However, isDynatraceSupported (and isOpenTelemetrySupported) are set on the @sap/hana-client module object, not on connection instances — so client.isDynatraceSupported is always undefined and the guard never fired.

This PR fixes the guard to check require('@sap/hana-client').isOpenTelemetrySupported on the module. When that flag is true (i.e. extension/OpenTelemetry.js loaded successfully, which requires @opentelemetry/api to be installed), hana-client connections are left to the native extension and our wrapping is skipped. For hdb — which has no native OTel extension — the require('@sap/hana-client') throws and our wrapping runs as before.

In summary: after this PR, customers using @sap/hana-client with @opentelemetry/api installed get richer, standards-compliant SQL tracing from the driver itself, with no involvement of @dynatrace/oneagent-sdk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant