1

I'm trying to use this snippet https://github.com/Dynatrace/OneAgent-SDK-Ruby-Sample-Binding/blob/master/oneagentsdk_demo.rb as a part of monitoring of ruby application. The issue is that on example app I have on my computer I have no problems with making it work, but when I use app that we would like to monitor that runs in docker ubuntu image, I have segmentation faults:

stub_version: 1.5.1
initializing OneAgentSdk
> onesdk_initialize returned 0 --> ONESDK_SUCCESS
> onesdk_agent_get_current_state  = 0 (ONESDK_AGENT_STATE_ACTIVE)
> onesdk_agent_get_version_string = '1.197.133.20200723-114512'
[120] Puma starting in cluster mode...
[120] * Version 3.8.2 (ruby 2.5.8-p224), codename: Sassy Salamander
[120] * Min threads: 0, max threads: 16
[120] * Environment: production
[120] * Process workers: 4
[120] * Preloading application
[120] * Listening on tcp://0.0.0.0:9293
[120] Use Ctrl-C to stop
[120] - Worker 0 (pid: 238) booted, phase: 0
[120] - Worker 3 (pid: 250) booted, phase: 0
[120] - Worker 1 (pid: 242) booted, phase: 0
[120] - Worker 2 (pid: 244) booted, phase: 0
/app/lib/one-agent/oneagentsdk.rb:175: [BUG] Segmentation fault at 0x0000000000000000
ruby 2.5.8p224 (2020-03-31 revision 67882) [x86_64-linux-gnu]

For those that doesn't know what OneAgent is, it's part of Dynatrace monitoring solution. Because of that this ruby binding is not supported by producent I cannot get any extra feedback from their side. But I don't suppose this is issue related to binding itself.

In general what is happening there, is execution of this C method: onesdk_webapplicationinfo_create_p. It's not accepting strings, we need pointers. In oneagentsdk.rb there are some methods that are checking if string is ASCII or UTF8 and they are building this pointers. I've checked that none of those elements is nil so in general I should have proper values that are passed into this method.

I'm invoking this scripts as middleware because I'm passing some info from requests (uri, response time, http method, http response code) inside this binding to have request tracing. I've run sample application on my environment on the same ruby version and everything is working fine, but app I've got from client that runs in docker does not work properly. I was thinking that may be there is problems with strings encoding which results extra bytes, but byte array size has proper length and everything seems to be fine. I'm not ruby expert, but maybe some of you would have some extra ideas about what I can check? :)

Kind regards, Sebastian

skrystos
  • 107
  • 8
  • You likely need to ask the folks at Dynatrace Support for help as it sounds like some glitch when the OneAgent SDK for Ruby is running inside Docker. – centic Sep 17 '20 at 19:20
  • 1
    I’ve asked but it’s not supported in context of ruby (they’ve made it in hackathon). In general OneAgent SDK for other technologies is working fine in docker, problem is only on Alpine linux. I suppose that problem is in place when FFI is making pointer, cpp is not able to access this memory block and I have segmentation fault. The question is what is difference between addressing memory in Docker and without containers – skrystos Sep 18 '20 at 20:24
  • I've checked with support and OneAgent SDK for C/C++ which is wrapped by FFI binding is working properly in containers. So still the question is how is that possible that when I use exact same code without container, it works and with not. Are there any options I can check according to memory pointers? – skrystos Sep 26 '20 at 20:18
  • 1
    I left FFI implementation and I'm using native extension. Now it's working fine. – skrystos Oct 05 '20 at 11:09

0 Answers0