-
Notifications
You must be signed in to change notification settings - Fork 551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(oracledb): Add support for Oracle DB instrumentation #2612
base: main
Are you sure you want to change the base?
Conversation
Add Oracledb instrumentation
|
I have fixed this discrepancy. |
@sudarshan12s as we discussed during SIG meeting yesterday, please review the requirements here for component ownership, as well as our preferred approach for long-term maintenance of instrumentation libraries. |
To @JamieDanielson Hi Jamie, All, To become a member of CNCF, @sudarshan12s will need two sponsors for his application. I am myself an Oracle employee, one of the maintainers of the opentelemetry-cpp repository, and can sponsor Sudarshan. Could you, or someone in javascript-maintainers, be the second sponsor ? Regards, |
@@ -0,0 +1,55 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this content be moved under constants.ts
?
Hi @sudarshan12s. I was absent during last week's SIG meeting so I'm not sure if there was an agreement made to not apply the current guidelines, but there are rules and guidelines for new instrumentations. These were introduced since many instrumentations were abandoned in this repository and we would like to avoid this in the future as it diverts resources from development of OTel core components. Before opening a PR, the following questions should be answered, see Jamie's link:
This is done in the form of an instrumentation request. |
Thanks @pichlermarc , Yes we were informed on the guidelines/procedure to be followed in the last SIG. I have updated the instrumentation request here with more details. Let me know if this looks fine. For becoming members of OTel org, @marcalff has agreed for first sponsor. Can someone from javascript-maintainers be the second sponsor. |
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* Copyright (c) 2024, Oracle and/or its affiliates. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dyladan @open-telemetry/javascript-maintainers
is it ok to have copyright in opentelemetry files? just making sure...
plugins/node/opentelemetry-instrumentation-oracledb/src/instrumentation.ts
Outdated
Show resolved
Hide resolved
* Copyright (c) 2024, Oracle and/or its affiliates. | ||
* */ | ||
|
||
// Oracle specific attributes not covered by semantic conventions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: add a comment about these attributes being added to semconv as a different effort + link to PR if you have it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am working on the PR for oracledb semconv.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link is also added in the code for the same.
additionalConfig?: any; // custom key/values associated with a function. | ||
fn: Function; // Replaced with bind function associating the active context. | ||
args?: any[]; // input arguments passed to the exported function. | ||
userContext: InstrumentationContext; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a short comment about this field, and how the driver uses it, so it's documented for future maintainers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added following:
/**
* This value is filled by instrumented module inside 'onEnterFn',
* 'onBeginRoundTrip' hook functions, which is passed back by oracledb module
* in 'onExitFn' and 'onEndRoundTrip' hook functions respectively.
*/
span: api.Span; | ||
} | ||
|
||
// Captures the entire span data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can add a short comment documenting that this interface correlates to a js object that is exported from the instrumented package. preferably with a link
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added following:
// This corresponds to js object filled by the 'oracledb' module
// See: https://github.com/oracle/node-oracledb/blob/main/lib/traceHandler.js
ORACLE_IMPLICIT_RELEASE = 'db.oracle.implicit_release', | ||
} | ||
|
||
// Contains span names produced by instrumentation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These span names actually correlates to the values being produced by the instrumented package itself, let's add it as a comment so people will know it's not arbitrary and will break if changed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment is added as below
// These constants need to be in sync with what is generated by the
// 'oracledb' module.
plugins/node/opentelemetry-instrumentation-oracledb/src/utils.ts
Outdated
Show resolved
Hide resolved
); | ||
} | ||
if (traceContext.error) { | ||
span.setStatus({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider:
span.recordException(traceContext.error);
which will log a span event for this error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added it. Thanks.
tests are also modified to verify the event.
Add Oracledb instrumentation
Which problem is this PR solving?
Adding instrumentation support for node-oracledb applications connecting to Oracle database.
Short description of the changes
From node-oracledb version 6.7 onwards, oracledb module exports a class,
TraceHandlerBase
which simulates interface kind of functionality with abstract methods to be overwritten by the derived class.The current OT module derives this class
TraceHandlerBase
and implements abstract methods; It usessetTraceInstance
method oforacledb
module to register this new derived classOracleTelemetryTraceHandler
These methods are invoked by
oracledb
module providing thetraceContext
which is used to dump the data in to the span after converting to standard span attributes.Following are the abstract methods implemented:
oracledb
module when application invokesgetConnection
to create a connection todatabase or
execute
method to run a sql. It is invoked before invoking the public API calls made by application.Note: