Code Monkey home page Code Monkey logo

Comments (7)

sebastianistoblame avatar sebastianistoblame commented on June 22, 2024

I just noticed the zorka logfile gets a new entry every time a filter applies/matches:
2015-03-26 11:44:26 INFO DispatchingSubmitter Submission thread local stack mismatch (ctx=com.jitlogic.zorka.core.spy.SpyContext@6dc65da5, stage=2, submitFlags=2)

Then, I saw some TODO comment in the DispatchingSubmitter:
"TODO what happens to submission stack when spy context disappears when some method is executing ?"

Does that mean, there's no implementation for this case yet?
Is it safe to just uncomment the logging code for now (to prevent spammy entries in the logs) or are there other consequences of this behaviour?

from zorka.

jitlogic avatar jitlogic commented on June 22, 2024

Ah thank you. Unfortunately when I was implementing ComparatorProcessor I tried to be "clever" and this resulted in unreadable mess that is now bringing such nasty bugs you've discovered. Now I'm integrating your fix into mainline codebase, maybe later on I'll try to rethink and rewrite this piece into a more decent form :)

Thanks (and sorry for delayed answer).

from zorka.

jitlogic avatar jitlogic commented on June 22, 2024

Regarding DispatchingSubmitter: in principle this situation should not happen. At the beginning of each instrumented method [.onEnter()] a newly created context object is put onto stack. On return [.onReturn(),.onError(),.onSubmit()] context is popped out of the stack, so information grabbed at method entry can be reused after method execution. There is a bunch of corner cases as well, for example you can have only .onEnter() chain defined, so only method entry will be instrumented. This is somewhat delicate situation as one needs to keep context stack in sync with instrumented code execution. Agent tries to handle such cases as well (at least those I've envisioned or encountered) but no one says there are no additional ones. In order not to break monitored code, spy cannot just crash - it handles such 'unexpected' situations (that shouldn't happen) by issuing log message. It might be either a bug in intrumentation engine itself or beanshell instrumentation definitions (or even BSH functions when used inside instrumentation chains). For me this indicates that the particular case you've encountered should be isolated and debugged. Ignoring these messages will lead to a number of dropped (or only partially executed) monitorings of instrumented method.

from zorka.

sebastianistoblame avatar sebastianistoblame commented on June 22, 2024

Thanks for your reply.
In my case, this log message shows up, every time my vcmp filter matches:

.onEnter(
spy.fetchArg("THIS", 0),
spy.get( "CLASSNAME", "THIS", "class", "name"),
//vcmp code below causes log entry, if filter matches
spy.vcmp( "CLASSNAME", spy.NE, "com.sun.jersey.spi.container.servlet.ServletContainer"),
//some more code here...
)

I am instrumenting:
.include(spy.byMethod( "javax.servlet.http.HttpServlet", "service"))

from zorka.

jitlogic avatar jitlogic commented on June 22, 2024

So here we are. If spy.vcmp(...) stops .onEnter() chain (and that's how filters work - they stop chain execution), it will result in context not being pushed onto stack. Try something like this:

.onEnter(
spy.fetchArg("THIS", 0),
spy.get( "CLASSNAME", "THIS", "class", "name"),
spy.subchain(
//vcmp code below causes log entry, if filter matches
spy.vcmp( "CLASSNAME", spy.NE, "com.sun.jersey.spi.container.servlet.ServletContainer"),
//some more code here...
)
)

Function spy.subchain() will group another elements into a (sub-)chain that will return context even if chain execution will be stopped.

from zorka.

jitlogic avatar jitlogic commented on June 22, 2024

Every time you do some kind of filtering in .onEnter() and then have either .onReturn(), .onError() or .onSubmit() defined, you need to be careful about always returning something. Maybe I should handle this case more gracefuly (eg. push null into stack - to ensure that exit chains won't execute in more controlled way).

from zorka.

sebastianistoblame avatar sebastianistoblame commented on June 22, 2024

Works like a charm, thank you!

from zorka.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.