Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugging Plugins #546

Closed
patrickserrano opened this issue Jul 29, 2021 · 6 comments
Closed

Debugging Plugins #546

patrickserrano opened this issue Jul 29, 2021 · 6 comments

Comments

@patrickserrano
Copy link

This is more of a question than an issue, but is there any documentation available or tips you can provide for debugging plugin code? Using VS Code, I can get Monstache running with a plugin and can set breakpoints in the Monstache code but I can't figure out how to step into the plugin code.

Any tips or advice would be extremely helpful, thanks!

@patrickserrano
Copy link
Author

I'm going to close this as I assume my issues are related to go-delve/delve#1628

@hikrr
Copy link

hikrr commented Nov 22, 2021

@patrickserrano
How did you set your launch.json to include -buildmode=plugin.
Or if you have an .so plugin, how will you set your 'launch.json' like you mentioned before. (I puts xxx.so in "args" in launch.json. And after debugging, it said 2021/11/23 00:26:33 cannot load plugin wc.so)

Did you have sample launch.json file for reference?

Thanks in advance!

@patrickserrano
Copy link
Author

@stagmoose I can post one tomorrow when I'm on my work laptop.

With that said, as of this summer there was a limitation with the debugger on macOS that prevents stepping through code inside a Go plugin.

We worked around that by just littering our plugin with print statements while we did our dev work and taking them out when we pushed to production ¯_(ツ)_/¯

@hikrr
Copy link

hikrr commented Nov 23, 2021

@patrickserrano
Great! Thanks for your reply!

@patrickserrano
Copy link
Author

@stagmoose here's the launch.json file. It looks like it's calling a pre-launch task which was building the plugin, but oddly enough I cannot find that task anywhere in the commit history of the repo :/ With that said, you should be fine if you just replace that with a task that build the plugin for you.

A few things to note, we passed a .env file with the connection strings and we were logging to a file because VS Code was very unhappy when we had verbose logging turned on in Monstache.

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Launch Monstache with Plugin",
      "type": "go",
      "request": "launch",
      "preLaunchTask": "Build Plugin",
      "mode": "auto",
      "program": "${workspaceFolder}/src/monstache",
      "env": {
        "MONSTACHE_LOG_DIR": "${workspaceFolder}/logs"
      },
      "envFile": "${workspaceFolder}/debug.env",
      "args": [
        "-mapper-plugin-path",
        "./plugin.so",
        "-f",
        "../../config/config.toml",
        "--enable-http-server"
      ],
      "showLog": false,
      "trace": "error"
    }
  ]
}

I should also note that we're not really using launch.json for this project anymore, and instead have rolled a set of custom tasks to build and run a container with monstache. We're deploying to k8s, so building and testing in the container locally is closer to how it would run when deployed. So far it's been great, just took some time to get our ES cluster configured to handle the load generated by the plugin.

@hikrr
Copy link

hikrr commented Nov 25, 2021

@patrickserrano
Thanks for your long explanation! You're so kind~
I'll try things out!

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

No branches or pull requests

2 participants