odigos-io / opentelemetry-go-instrumentation

OpenTelemetry auto-instrumentation for Go applications
Apache License 2.0
292 stars 44 forks source link

Can't find find keyval map in analyze findKeyvalMmap #36

Closed yfractal closed 2 years ago

yfractal commented 2 years ago

Expected Behavior

Read memory maps.

Actual Behavior

Can't find memory mapping as as all mapping has been filtered out.

Steps to Reproduce the Problem

The maps of the go lang program as below

00400000-00623000 r-xp 00000000 fd:00 1048990                            /home/vagrant/go-http-demo/main
00623000-00822000 r--p 00223000 fd:00 1048990                            /home/vagrant/go-http-demo/main
00822000-00860000 rw-p 00422000 fd:00 1048990                            /home/vagrant/go-http-demo/main
00860000-00899000 rw-p 00000000 00:00 0
02061000-02082000 rw-p 00000000 00:00 0                                  [heap]
c000000000-c000400000 rw-p 00000000 00:00 0
...
7f32e948f000-7f32e94b7000 r--p 00000000 fd:00 525141                     /usr/lib/x86_64-linux-gnu/libc.so.6
...
7f32e96aa000-7f32e96b7000 rw-p 00000000 00:00 0
7f32e96be000-7f32e96c0000 rw-p 00000000 00:00 0
7f32e96c0000-7f32e96c2000 r--p 00000000 fd:00 524900                     /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
...
7ffe501e6000-7ffe50207000 rw-p 00000000 00:00 0                          [stack]
7ffe50311000-7ffe50315000 r--p 00000000 00:00 0                          [vvar]
7ffe50315000-7ffe50317000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 --xp 00000000 00:00 0                  [vsyscall]

so no map will be fond as m.Perms != nil && m.Perms.Read && m.Perms.Write && m.Perms.Execute required in findKeyvalMmap.

Additional Info

https://app.vagrantup.com/bento/boxes/ubuntu-22.04

edeNFed commented 2 years ago

Did you launch your application with the launcher binary as shown in this example yaml? https://github.com/keyval-dev/opentelemetry-go-instrumentation/blob/13805d935d31fe521cec9a4800346e58c057e55c/docs/getting-started/emojivoto-instrumented.yaml#L44-L46

yfractal commented 2 years ago

I wrote a simple http server and start it through it's binary. I didn't follow the demo.

I guess /odigos-launcher/launch or /usr/local/bin/emojivoto-emoji-svc may create some memory area for the target process.

edeNFed commented 2 years ago

Yes, please try to invoke your process with the /odigos-launcher/launch /path/to/your/app

yfractal commented 2 years ago

Thanks edeNFed, I will try this.

vasiliy-grinko commented 2 years ago

@edeNFed can you tell what this /odigos-launcher/launch is for? What it does?

yfractal commented 2 years ago

I guess /odigos-launcher/launch will allocate an area for the application(emojivoto-emoji-svc)

And the area is used for eBPF program writing data to user process(emojivoto-emoji-svc), see alloc.h.

but it's my guess, not sure it's right :joy:

edeNFed commented 2 years ago

Yes exactly. As this instrumentation adds trace id / span id to requests we need to allocate some memory so Go can access those before sending the request. The launcher does exactly that - it allocates about 2Mb of memory off heap and then executes the application. Later when the instrumentation generates those ids they will be written to the area allocated by the launcher.