OceanBase
English日本語简体中文
Docs Home
Products
Integrations
Release Notes

Databases

OceanBase DatabaseOceanBase AI DatabaseOceanBase Cloud OceanSeekOceanBase Best Practices

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog ServiceOceanBase DataPilotOceanBase OAgent

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Databases

OceanBase DatabaseOceanBase AI DatabaseOceanBase Cloud OceanSeekOceanBase Best Practices

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog ServiceOceanBase DataPilotOceanBase OAgent
OceanBase DatabaseOceanBase Cloud ToolsConnectors and MiddlewareLifecycle Support Policy

OceanBase Call Interface

V2.1.0Enterprise Edition
  • What's New
  • Product Introduction
  • Install OBCI
  • Data types
  • Basic development procedure
  • Development example
  • Load balancing
  • Reference Functions
    • Connect, authorize, and initialize functions
    • Handle and descriptor functions
    • Bind, define, and describe functions
    • Statement functions
    • LOB functions
    • Transaction functions
    • Miscellaneous functions
    • String functions
    • Date and Datetime functions
    • Interval functions
    • Number functions
    • Terminate functions
    • Describe functions
    • Locale functions
    • Define functions
  • Full-link Diagnostic Trace
    • Full-link Diagnostic Trace
    • Full-link Diagnostic Trace of OBCI
    • Sample code

Download PDF

Document Feedback
  1. Documentation Center
  2. OceanBase Call Interface
  3. V2.1.0

Full-link Diagnostic Trace of OBCI

Last Updated:2026-09-04 08:28:32

Enable/Disable Full-link Diagnostic Trace and obprotocol 20
OBCI trace APIs
Functions related to Full-link Diagnostic Trace

Note

Before you read this topic, read Full-link Diagnostic Trace to understand Full-link Diagnostic Trace.

Enable/Disable Full-link Diagnostic Trace and obprotocol 20

By default, obprotocol 20 and Full-link Diagnostic Trace are enabled. You can use the following environment variables to forcibly disable the two features:

  • obprotocol 20

    • Disable obprotocol 20: export ENABLE_PROTOCOL_OB20=0

    • Enable obprotocol 20: export ENABLE_PROTOCOL_OB20=1

    Notice

    Full-link Diagnostic Trace is based on obprotocol 20. If you disable obprotocol 20, Full-link Diagnostic Trace is disabled by default.

  • Full-link Diagnostic Trace

    • Disable Full-link Diagnostic Trace: export ENABLE_TRACE=0

    • Enable Full-link Diagnostic Trace: export ENABLE_TRACE=1

OBCI trace APIs

OceanBase Call Interface (OBCI) calls OCIAttrSet and OCIAttrGet to set and obtain user information. API definitions:

sword OCIAttrSet(void *trgthndlp, ub4 trghndltyp, void *attributep,
                 ub4 size, ub4 attrtype, OCIError *errhp);

sword OCIAttrGet(const void *trgthndlp, ub4 trghndltyp, void *attributep,
                 ub4 *sizep, ub4 attrtype, OCIError *errhp);

For more information, see Handle and descriptor functions.

You can set client_info for the OCISession handle to obtain different trace configurations.

// Set client_info.
const char *client_info = "your_client_info";
OCIAttrSet((dvoid *) *authp, (ub4) OCI_HTYPE_SESSION,
                 (dvoid *) client_info, (ub4) strlen((char *)client_info),
                 (ub4) OCI_ATTR_CLIENT_INFO, *errhp);

// Set the module name.
const char *mod_name = "your_mod_name";
OCIAttrSet((dvoid *) *authp, (ub4) OCI_HTYPE_SESSION,
                 (dvoid *) mod_name, (ub4) strlen((char *)mod_name),
                 (ub4) OCI_ATTR_MODULE, *errhp)

// Set the action name.
const char *action_name = "your_action_name";
OCIAttrSet((dvoid *) *authp, (ub4) OCI_HTYPE_SESSION,
                 (dvoid *) action_name, (ub4) strlen((char *)action_name),
                 (ub4) OCI_ATTR_ACTION, *errhp)

// Set the client ID.
const char *client_id = "your_client_id"
OCIAttrSet((dvoid *) *authp, (ub4) OCI_HTYPE_SESSION,
                 (dvoid *) client_id, (ub4) strlen((char *)client_id),
                 (ub4) OCI_ATTR_CLIENT_IDENTIFIER, *errhp)

Notice

The maximum length is 64 bytes for the client ID, 64 bytes for the client information, 48 bytes for the module name, and 32 bytes for the action name. The value will be automatically truncated when its length exceeds the limit.

The preceding APIs are used together with the following DBMS APIs. After you use the DBMS package to set related information and then use OBCI to set required information, you can use the corresponding full-link diagnostic configurations.

DBMS_SESSION.SET_IDENTIFIER(client_id VARCHAR2);

DBMS_MONITOR.OB_CLIENT_ID_TRACE_ENABLE(
 client_id IN VARCHAR2,
 level IN INT,
 sample_pct IN NUMBER,
 record_policy IN VARCHAR2);

DBMS_MONITOR.OB_CLIENT_ID_TRACE_DISABLE(client_id IN VARCHAR2);



DBMS_APPLICATION_INFO.SET_MODULE (module_name IN VARCHAR2, action_name IN VARCHAR2);

DBMS_APPLICATION_INFO.SET_ACTION (action_name IN VARCHAR2);

DBMS_MONITOR.OB_MOD_ACT_TRACE_ENABLE(
  module_name IN VARCHAR2 DEFAULT ANY_MODULE,
  action_name IN VARCHAR2 DEFAULT ANY_ACTION,
  level IN INT,
  sample_pct IN NUMBER,
  record_policy IN VARCHAR2);

Notice

If you directly enable trace collection at the session or tenant level, you can directly use OBCI and Full-link Diagnostic Trace, without the need to set corresponding information.

Functions related to Full-link Diagnostic Trace

Functions related to Full-link Diagnostic Trace:

void mod_act_trace_enable(const char *mod_name, const char *act_name, int level, double sample_pct, const char *record_policy){
    text *trace_enable_sql = (text *)"begin DBMS_MONITOR.OB_MOD_ACT_TRACE_ENABLE(:mod_name, :act_name, :level,:sample_pct,:record_policy);end;";
    OCIBind *bindp[5];
    OCI_CHECK_RET(errhp, OCIStmtPrepare(stmthp, errhp, trace_enable_sql, strlen((char *)trace_enable_sql), OCI_NTV_SYNTAX, OCI_DEFAULT));
    OCI_CHECK_RET(errhp, OCIBindByName(stmthp, &bindp[0], errhp, (text *) ":mod_name", strlen(":mod_name"),(void *)mod_name, strlen(mod_name)+1, SQLT_STR, (dvoid *) 0, (ub2 *) 0, (ub2 *) 0, 0, (ub4 *) 0, OCI_DEFAULT ) );
    OCI_CHECK_RET(errhp, OCIBindByName(stmthp, &bindp[0], errhp, (text *) ":act_name", strlen(":act_name"),(void *)act_name, strlen(act_name)+1, SQLT_STR, (dvoid *) 0, (ub2 *) 0, (ub2 *) 0, 0, (ub4 *) 0, OCI_DEFAULT ) );
    OCI_CHECK_RET(errhp, OCIBindByName(stmthp, &bindp[2], errhp, (text *) ":level", strlen(":level"), &level, sizeof(int), SQLT_INT, (dvoid *) 0, (ub2 *) 0, (ub2 *) 0, 0, (ub4 *) 0, OCI_DEFAULT ) );
    OCI_CHECK_RET(errhp, OCIBindByName(stmthp, &bindp[3], errhp, (text *) ":sample_pct", strlen(":sample_pct"),&sample_pct, sizeof(double), SQLT_FLT, (dvoid *) 0, (ub2 *) 0, (ub2 *) 0, 0, (ub4 *) 0, OCI_DEFAULT ) );
    OCI_CHECK_RET(errhp, OCIBindByName(stmthp, &bindp[4], errhp, (text *) ":record_policy", strlen(":record_policy"), (void *)record_policy, strlen(record_policy)+1, SQLT_STR, (dvoid *) 0, (ub2 *) 0, (ub2 *) 0, 0, (ub4 *) 0, OCI_DEFAULT ) );
    OCI_CHECK_RET(errhp, OCIStmtExecute(svchp, stmthp, errhp, 1, 0, 0, 0, OCI_DEFAULT));
}
void mod_act_trace_disable(const char *mod_name, const char *act_name){
    text* trace_disable_sql = (text *)"begin DBMS_MONITOR.OB_MOD_ACT_TRACE_DISABLE(:mod_name, :act_name);end;";
    OCIBind *bindp[2];
    OCI_CHECK_RET(errhp, OCIStmtPrepare(stmthp, errhp, trace_disable_sql, strlen((char *)trace_disable_sql), OCI_NTV_SYNTAX, OCI_DEFAULT));
    OCI_CHECK_RET(errhp, OCIBindByName(stmthp, &bindp[0], errhp, (text *) ":mod_name", strlen(":mod_name"), (void *)mod_name, strlen(mod_name)+1, SQLT_STR, (dvoid *) 0, (ub2 *) 0, (ub2 *) 0, 0, (ub4 *) 0, OCI_DEFAULT ) );
    OCI_CHECK_RET(errhp, OCIBindByName(stmthp, &bindp[1], errhp, (text *) ":act_name", strlen(":act_name"), (void *)act_name, strlen(act_name)+1, SQLT_STR, (dvoid *) 0, (ub2 *) 0, (ub2 *) 0, 0, (ub4 *) 0, OCI_DEFAULT ) );
    OCI_CHECK_RET(errhp, OCIStmtExecute(svchp, stmthp, errhp, 1, 0, 0, 0, OCI_DEFAULT));
}
void set_module_obci(const char *mod_name){
  int status = OCI_SUCCESS;
  OCI_CHECK_RET(errhp, OCIAttrSet((dvoid *) authp, (ub4) OCI_HTYPE_SESSION,
        (dvoid *) mod_name, (ub4) strlen((char *)mod_name),
        (ub4) OCI_ATTR_MODULE, errhp));
}
void set_action_obci(const char *action_name){
  int status = OCI_SUCCESS;
  OCI_CHECK_RET(errhp, OCIAttrSet((dvoid *) authp, (ub4) OCI_HTYPE_SESSION,
        (dvoid *) action_name, (ub4) strlen((char *)action_name),
        (ub4) OCI_ATTR_ACTION, errhp));
}

The mod_act_trace_enable and mod_act_trace_disable functions are used to enable and disable Full-link Diagnostic Trace based on the client information. Both mod_name and act_name are user identifiers. The function definitions show that DBMS packages are called to enable and disable Full-link Diagnostic Trace.

Note

These two DBMS statements can also be called by using command lines on OBClient.

The set_module_obci and set_action_obci functions are used to set client information in OBCI. The mod_act_trace_enable and mod_act_trace_disable functions are used to determine whether to enable or disable Full-link Diagnostic Trace at the database level. The set_module_obci and set_action_obci functions determine the client information at the driver level.

After all the information is specified, the OBCI driver will map the information with the user information at the database level. If Full-link Diagnostic Trace is enabled for the database level, the OBCI driver obtains corresponding configurations from the database level. If Full-link Diagnostic Trace is not enabled for the database level, the driver level does not enable the corresponding capability.

Previous topic

Full-link Diagnostic Trace
Last

Next topic

Sample code
Next
on this page
Enable/Disable Full-link Diagnostic Trace and obprotocol 20
OBCI trace APIs
Functions related to Full-link Diagnostic Trace