Render a shader on top of a specific shader

Hi fellow devs,
I have been working on a very specific feature of my game. The situation is:
I have two lines in the shape of cylinders and I need where the first one is in the middle of the other one. The idea is to have a flowing animation along the line in the center (look at the laser). In fact the laser in the picture is 2D but I am working on a 3D situation.

I was trying to use depth but it seems to be quite expensive as I read in another thread.
Any help or idea is appreciated.

[EDIT] I tried setting depth but didn’t have any effect(see answer).

Im not exactly sure what you want,
Perhaps you can just do a distance test from the fragment to the linesegment of the cylinder and if its close enough then render flowing animation