How can we set up a dev environment for step debugging Conduit Connectors? #1724
-
I'd like to make a connector of my own and perhaps even contribute to some existing ones, but I dont know how to step debug the connectors given that you run the conduit binary, which fetches/includes the connector binaries. Could anyone please provide some tips? In fact, I think this would be a very good topic to make an official doc for. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 11 replies
-
Can you clarify this part please? But generally, for built-in (included) plugins, you can use your IDE and simply put breakpoints. As for the standalone plugins: they are, essentially, just compiled that are being run, so you can use remote debugging for them. The instructions for that depend on the IDE. |
Beta Was this translation helpful? Give feedback.
-
I've debugged standalone plugins in the past, I've quickly compiled the approach I used. Note that this is a bit experimental, when I tried it out now, the plugin didn't finish gracefully for some reason and the Conduit process had to be killed. Nevertheless, debugging itself should work.
Full guide: https://github.com/go-delve/delve/tree/master/Documentation/installation TL;DR: go install https://github.com/go-delve/delve@latest
For this I suggest moving the standalone connector binary into a sub-folder in
The contents of #!/usr/bin/env bash
BASEDIR=$(dirname "$0")
dlv --listen=:9876 --headless=true --api-version=2 --accept-multiclient --log-dest=2 exec "$BASEDIR/bin/conduit-connector-file" This will run delve on port 9876 and prepare it for remote debugging.
When starting Conduit, it first scans the $ dlv connect :9876
(dlv) continue
(dlv) exit
Remote process has exited. Would you like to kill the headless instance? [Y/n] y Assuming you have a pipeline configuration file that will use this standalone plugin, you need to attach a second time to actually debug it while the pipeline is running (so again Keep in mind that Conduit waits for a limited amount of time for the plugin to start and do the handshake (I think 1 minute?), after that it will consider it broken and detach from the process, so you need to be relatively quick to attach to the plugin and advance execution. |
Beta Was this translation helpful? Give feedback.
-
It was later suggested that we just include connectors we're developing as built-in connectors rather than standalone. This avoids all of the difficulties with Delve etc... The docs are straightforward: https://conduit.io/docs/connectors/additional-built-in-plugins/ For my use-case of mysql and surrealdb you just do the following:
If you want to step debug the local dev version of these packages, just use
You can then add breakpoints to this main.go file, the core conduit files, or the connector files. And just launch main.go with VS Code's debugger with a launch.json config like this (feel free to change
|
Beta Was this translation helpful? Give feedback.
It was later suggested that we just include connectors we're developing as built-in connectors rather than standalone. This avoids all of the difficulties with Delve etc...
The docs are straightforward: https://conduit.io/docs/connectors/additional-built-in-plugins/
For my use-case of mysql and surrealdb you just do the following: