Skip to content

Commit

Permalink
- Make the new types TitleCase aligning to rest of the code
Browse files Browse the repository at this point in the history
  • Loading branch information
sudarshan12s committed Jan 7, 2025
1 parent 90db232 commit c299caa
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,27 @@

import * as oracledbTypes from 'oracledb';
import type * as api from '@opentelemetry/api';
import { spanConnectionConfig } from './types';
import { SpanConnectionConfig } from './types';

// Captures the context associated with onEnterFn, onExitFn hooks.
export interface instrumentationContext {
export interface InstrumentationContext {
span: api.Span;
}

// Captures the entire span data
export interface traceSpanData {
export interface TraceSpanData {
operation: string;
error?: oracledbTypes.DBError;
connectLevelConfig?: spanConnectionConfig;
callLevelConfig?: spanCallLevelConfig;
connectLevelConfig?: SpanConnectionConfig;
callLevelConfig?: SpanCallLevelConfig;
additionalConfig?: any;
fn: Function;
args?: any[];
userContext: instrumentationContext;
userContext: InstrumentationContext;
}

// Captures call level related span data
export interface spanCallLevelConfig {
export interface SpanCallLevelConfig {
statement?: string;
operation?: string;
values?: any[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import type * as api from '@opentelemetry/api';
import { InstrumentationConfig } from '@opentelemetry/instrumentation';

// Captures connection related span data
export interface spanConnectionConfig {
export interface SpanConnectionConfig {
serviceName?: string;
connectString?: string;
hostName?: string;
Expand All @@ -36,7 +36,7 @@ export interface spanConnectionConfig {

export interface OracleRequestHookInformation {
inputArgs: any;
connection: spanConnectionConfig | undefined;
connection: SpanConnectionConfig | undefined;
}

export interface OracleInstrumentationExecutionRequestHook {
Expand All @@ -55,12 +55,15 @@ export interface OracleInstrumentationConfig extends InstrumentationConfig {
/**
* If true, an attribute containing the execute method
* bind values will be attached the spans generated.
*
* @default false
*/
enhancedDatabaseReporting?: boolean;

/**
* If true, db.statement will have sql in the spans generated.
* default value is false/undefined.
*
* @default false
*/
dbStatementDump?: boolean;

Expand Down
22 changes: 11 additions & 11 deletions plugins/node/opentelemetry-instrumentation-oracledb/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ import {
DBSYSTEMVALUES_ORACLE,
} from '@opentelemetry/semantic-conventions';
import * as oracledbTypes from 'oracledb';
import { OracleInstrumentationConfig, spanConnectionConfig } from './types';
import { traceSpanData, spanCallLevelConfig } from './internal-types';
import { OracleInstrumentationConfig, SpanConnectionConfig } from './types';
import { TraceSpanData, SpanCallLevelConfig } from './internal-types';
import { SpanNames } from './constants';

const newmoduleExports: any = oracledbTypes;
Expand Down Expand Up @@ -72,7 +72,7 @@ export class OracleTelemetryTraceHandler extends newmoduleExports.traceHandler

// Returns the connection related Attributes for
// semantic standards and module custom keys.
private _getConnectionSpanAttributes(config: spanConnectionConfig) {
private _getConnectionSpanAttributes(config: SpanConnectionConfig) {
return {
[SEMATTRS_DB_SYSTEM]: DBSYSTEMVALUES_ORACLE,
[SEMATTRS_NET_TRANSPORT]: config.protocol,
Expand Down Expand Up @@ -124,7 +124,7 @@ export class OracleTelemetryTraceHandler extends newmoduleExports.traceHandler
// internal roundtrip spans generated for oracledb exported functions.
private _setCallLevelAttributes(
span: Span,
callConfig?: spanCallLevelConfig,
callConfig?: SpanCallLevelConfig,
roundTrip = false
) {
if (!callConfig) return;
Expand All @@ -150,7 +150,7 @@ export class OracleTelemetryTraceHandler extends newmoduleExports.traceHandler
}
}

private _handleExecuteCustomRequest(span: Span, traceContext: traceSpanData) {
private _handleExecuteCustomRequest(span: Span, traceContext: TraceSpanData) {
if (typeof this._instrumentConfig.requestHook === 'function') {
safeExecuteInTheMiddle(
() => {
Expand All @@ -169,7 +169,7 @@ export class OracleTelemetryTraceHandler extends newmoduleExports.traceHandler
}
}

private _handleExecuteCustomResult(span: Span, traceContext: traceSpanData) {
private _handleExecuteCustomResult(span: Span, traceContext: TraceSpanData) {
if (typeof this._instrumentConfig.responseHook === 'function') {
safeExecuteInTheMiddle(
() => {
Expand All @@ -192,7 +192,7 @@ export class OracleTelemetryTraceHandler extends newmoduleExports.traceHandler
// roundTrip flag will skip dumping bind values for
// internal roundtrip spans generated for exported functions.
private _updateFinalSpanAttributes(
traceContext: traceSpanData,
traceContext: TraceSpanData,
roundTrip = false
) {
const span = traceContext.userContext.span;
Expand Down Expand Up @@ -230,7 +230,7 @@ export class OracleTelemetryTraceHandler extends newmoduleExports.traceHandler

// This method is invoked before calling an exported function
// from oracledb module.
onEnterFn(traceContext: traceSpanData) {
onEnterFn(traceContext: TraceSpanData) {
if (this._shouldSkipInstrumentation()) {
return;
}
Expand Down Expand Up @@ -272,7 +272,7 @@ export class OracleTelemetryTraceHandler extends newmoduleExports.traceHandler

// This method is invoked after exported function from oracledb module
// completes.
onExitFn(traceContext: traceSpanData) {
onExitFn(traceContext: TraceSpanData) {
if (
this._shouldSkipInstrumentation() ||
!traceContext.userContext ||
Expand All @@ -296,7 +296,7 @@ export class OracleTelemetryTraceHandler extends newmoduleExports.traceHandler

// This method is invoked before a round trip call to DB is done
// from the oracledb module as part of sql execution.
onBeginRoundTrip(traceContext: traceSpanData) {
onBeginRoundTrip(traceContext: TraceSpanData) {
if (this._shouldSkipInstrumentation()) {
return;
}
Expand All @@ -312,7 +312,7 @@ export class OracleTelemetryTraceHandler extends newmoduleExports.traceHandler

// This method is invoked after a round trip call to DB is done
// from the oracledb module as part of sql execution.
onEndRoundTrip(traceContext: traceSpanData) {
onEndRoundTrip(traceContext: TraceSpanData) {
if (
this._shouldSkipInstrumentation() ||
!traceContext.userContext ||
Expand Down

0 comments on commit c299caa

Please sign in to comment.