gatewayd-io / gatewayd

☁️ Cloud-native database gateway and framework for building data-driven applications ✨ Like API gateways, but for databases ✨
https://gatewayd.io
GNU Affero General Public License v3.0
228 stars 19 forks source link

Use separate traces for each E2E client connection #249

Open mostafa opened 1 year ago

mostafa commented 1 year ago

Currently, the traces are all published under the same context, which is GatewayD, hence a single trace object with many spans across different parts of the system. The single-trace-multiple-spans approach makes it hard to debug individual connections between each client and database server. By creating a new trace with random UUID, we can easily track separate connections, without trying hard to find it inside the vast amount of spans produced by GatewayD in a single trace.

eabasir commented 3 days ago

@mostafa If the goal is to separate the traces of clients to better observe them, cannot we just create a trace with a new root at this line:

clientCtx, span := otel.Tracer(config.TracerName).Start(ctx, "NewClient", trace.WithNewRoot(), trace.WithNewRoot())

It must be enough to split traces of clients. Right?

mostafa commented 3 days ago

@eabasir This only shows half the traces, namely those that happened between GatewayD and postgres (DB), and not the ones between the client (e.g. psql) and GatewayD.

eabasir commented 3 days ago

@eabasir This only shows half the traces, namely those that happened between GatewayD and postgres (DB), and not the ones between the client (e.g. psql) and GatewayD.

Gotcha! Okay. I'll take this!

mostafa commented 3 days ago

Basically you should trace when the client connects until it disconnects and observe and compare the changes before it. This way you can see what is important to an E2E trace.