feat(hana): replace @dynatrace/oneagent-sdk with @opentelemetry/api#1535
Draft
feat(hana): replace @dynatrace/oneagent-sdk with @opentelemetry/api#1535
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(AI generated)
Motivation
@dynatrace/oneagent-sdkhas 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/apiWhat 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). ThedbInfoobject 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 thehana-clientObject.definePropertyworkaround are all preserved.hana/package.json:@opentelemetry/api ^1added as an optional peer dependency (mirrors how@dynatrace/oneagent-sdkwas treated — undeclared but silently skipped when absent).No changes to
hdb.jsorhana-client.js.Bug fix: broken
isDynatraceSupportedguard@sap/hana-clientships a native OpenTelemetry extension (extension/OpenTelemetry.js) that wraps connections automatically at connect time when@opentelemetry/apiis installed. It covers more methods than ourdynatrace.jswrapping (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:
However,
isDynatraceSupported(andisOpenTelemetrySupported) are set on the@sap/hana-clientmodule object, not on connection instances — soclient.isDynatraceSupportedis alwaysundefinedand the guard never fired.This PR fixes the guard to check
require('@sap/hana-client').isOpenTelemetrySupportedon the module. When that flag istrue(i.e.extension/OpenTelemetry.jsloaded successfully, which requires@opentelemetry/apito be installed),hana-clientconnections are left to the native extension and our wrapping is skipped. Forhdb— which has no native OTel extension — therequire('@sap/hana-client')throws and our wrapping runs as before.In summary: after this PR, customers using
@sap/hana-clientwith@opentelemetry/apiinstalled get richer, standards-compliant SQL tracing from the driver itself, with no involvement of@dynatrace/oneagent-sdk.