Skip to content

Conversation

@chenhuansome
Copy link
Contributor

@chenhuansome chenhuansome commented Sep 29, 2025

What problem does this PR solve?

This PR implements OpenTelemetry distributed tracing functionality within the OpenGemini Java client. Through an interceptor mechanism, it automatically adds trace spans for all database operations (queries, writes, etc.) and exports the trace data to Jaeger for visualization and analysis.

Main Changes

  1. New Tracing Interceptor Implementation
  • Created the OtelInterceptor class to handle OpenTelemetry trace propagation
  • Creates spans for each database operation and records relevant attributes
  • Supports context propagation for asynchronous operations
  1. New Integration Test Class
  • TracingIntegrationTest: Comprehensive end-to-end integration tests
  • Tests scenarios including database creation, query operations, write operations
  • Verifies that trace data is correctly generated and exported
  1. CI/CD Integration
  • Automatically starts the ts-trace service in GitHub Actions
  • Ensures integration tests run correctly in the CI environment
  1. Configuration Management
  • Supports enabling/disabling tracing functionality via configuration
  • Configurable Jaeger export endpoint and other OpenTelemetry parameters

Technical Features

  • Non-intrusive Integration: Uses the interceptor pattern; business code gains tracing capability without modifications
  • Async Support: Full support for the client's asynchronous operation mode
  • Error Handling: Includes fallback mechanism; automatically reverts to no-op implementation if tracing components are unavailable
  • ·Performance Optimization: Uses batch span processing to minimize impact on business performance

Test Verification

  • [✓ ] Trace for database creation operations

  • [✓ ] Trace for query operations

  • [✓ ] Trace for write operations

  • [✓ ] End-to-end integration process tracing

  • [✓ ] Exception handling

Architecture Diagram:

OpenGemini Client → OtelInterceptor → BatchSpanProcessor → JaegerExporter → Jaeger UI

Usage

// Create configuration
Configuration config = Configuration.builder()
    .addresses(Collections.singletonList(new Address("127.0.0.1", 8086)))
    .build();

// Create client and add tracing interceptor
OpenGeminiClient client = new OpenGeminiClient(config);
OtelInterceptor otelInterceptor = new OtelInterceptor();
otelInterceptor.setTracer(getTracer());
client.addInterceptors(otelInterceptor);

// All subsequent operations will be automatically traced
client.query(new Query("SHOW DATABASES"));

*related documents:
openGemini/openGemini.github.io#163

@dosubot
Copy link

dosubot bot commented Sep 29, 2025

Documentation Updates

Checked 2 published document(s). No updates required.

How did I do? Any feedback?  Join Discord

@chenhuansome chenhuansome changed the title Otel integration tests feat: integrate Otel tests Sep 29, 2025
@chenhuansome chenhuansome force-pushed the otel-integration-tests branch 5 times, most recently from dab050b to 7ec78f3 Compare October 20, 2025 14:01
@chenhuansome chenhuansome force-pushed the otel-integration-tests branch from 7ec78f3 to 2ddc3c2 Compare October 21, 2025 13:02
Signed-off-by: chenhuan <xiangyuyu_2024@qq.com>
@chenhuansome chenhuansome force-pushed the otel-integration-tests branch from 2ddc3c2 to b477f7a Compare October 21, 2025 13:07
@weiping-code weiping-code merged commit 450fce8 into openGemini:main Oct 21, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants