Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions src/guide/develop/client_design.md
Original file line number Diff line number Diff line change
Expand Up @@ -411,3 +411,59 @@ $operation failed, error: $error_details
# example:
writePoint failed, unmarshall response body error: json: cannot unmarshal number ...
```
# OpenTelemetry integration design
Comment thread
chenhuansome marked this conversation as resolved.
Outdated
To enhance the observability of the OpenGemini Go client and facilitate tracking of performance metrics, errors, and other information related to query and write operations, this solution adopts the interceptor pattern to integrate OpenTelemetry, enabling full-link tracing. The design supports non-intrusive extensions, allowing coexistence with other interceptors (such as logging and authentication interceptors) while minimizing modifications to the original client.

## Define the interceptor interface

```mermaid
interface Interceptor {
Comment thread
chenhuansome marked this conversation as resolved.
Outdated
+ context.Context QueryBefore(context.Context, string)
+ void QueryAfter(context.Context, string, error)
+ context.Context WriteBefore(context.Context, []byte)
+ void WriteAfter(context.Context, []byte, error)
}
```

## Define the base client class,associated with the Interceptor interface

```mermaid
class Client {
- []Interceptor interceptors
Comment thread
chenhuansome marked this conversation as resolved.
Outdated
+ Client(interceptors ...Interceptor)
+ AddInterceptor(interceptors ...Interceptor)
+ context.Context doQueryBefore(context.Context, string)
+ void doQueryAfter(context.Context, string, error)
+ context.Context doWriteBefore(context.Context, []byte)
+ void doWriteAfter(context.Context, []byte, error)
}
```

## Define the interceptor implementation class integrating OpenTelemetry,implementing the Interceptor interface

```mermaid
class OtelClient {
Comment thread
chenhuansome marked this conversation as resolved.
Outdated
- trace.Tracer tracer
+ OtelClient()
+ context.Context QueryBefore(context.Context, string)
+ void QueryAfter(context.Context, string, error)
+ context.Context WriteBefore(context.Context, []byte)
+ void WriteAfter(context.Context, []byte, error)
}
```

## Define processes related to main function usage examples (simplified to show invocation relationships)
Comment thread
chenhuansome marked this conversation as resolved.
Outdated

```mermaid
class Main {
+ static func initOtel() func()
+ static func main()
+ static func performQuery(context.Context, string) error
}

The implementation and association relationships between interfaces and classes
Client --> Interceptor : contains multiple
OtelClient --> Interceptor : implement
Main --> Client : use
Main --> OtelClient : initialize and add to client
```