OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

Product Overview
DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

Product Overview
DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

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

What's New Product Introduction Install OBCI Data types Basic development procedure Development example Load balancing 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 of OBCI Sample code
OceanBase logo

The Unified Distributed Database for the AI Era.

Follow Us
Products
OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
Resources
DocsBlogLive DemosTraining & Certification
Company
About OceanBaseTrust CenterLegalPartnerContact Us
Follow Us

© OceanBase 2026. All rights reserved

Cloud Service AgreementPrivacy PolicySecurity
Contact Us
Document Feedback
  1. Documentation Center
  2. OceanBase Call Interface
  3. V2.1.0
iconOceanBase Call Interface
V 2.1.0Enterprise Edition

Full-link Diagnostic Trace of OBCI

Last Updated:2024-05-14 09:02:08  Updated
share
What is on this page
Enable/Disable Full-link Diagnostic Trace and obprotocol 20
OBCI trace APIs
Functions related to Full-link Diagnostic Trace

folded

share

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
What is on this page
Enable/Disable Full-link Diagnostic Trace and obprotocol 20
OBCI trace APIs
Functions related to Full-link Diagnostic Trace