-
Notifications
You must be signed in to change notification settings - Fork 199
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
Fixing reliability issue with JedisMethodVisitor. #423
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,9 +30,12 @@ | |
import org.objectweb.asm.Opcodes; | ||
import org.objectweb.asm.Type; | ||
|
||
|
||
/** | ||
* Created by gupele on 8/6/2015. | ||
* @deprecated Replaced with JedisMethodVisitorV2 | ||
*/ | ||
@Deprecated | ||
final class JedisMethodVisitor extends DefaultMethodVisitor { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @grlima just was thinking about the design decision. Wouldn't it be nice if we implement an interface like MethodVisitorInterface which has methods like getOnEnterMethod() and getOnEnterMethodSignature(). I believe this will provide extensibility and atleast in theory "Favor composition over inherritance" is true. Let me know your thoughts. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's a debatable design discussion and I do think it's a good idea, but since the existing functionality is based on inheritance (there are other methods in the super classes besides the getOn methods I introduced), I don't want to get into it at this time. We can track this and revisit the discussion at a later point. |
||
private final static String FINISH_DETECT_METHOD_NAME = "methodFinished"; | ||
private final static String FINISH_METHOD_DEFAULT_SIGNATURE = "(Ljava/lang/String;J[Ljava/lang/Object;Ljava/lang/Throwable;)V"; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* ApplicationInsights-Java | ||
* Copyright (c) Microsoft Corporation | ||
* All rights reserved. | ||
* | ||
* MIT License | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this | ||
* software and associated documentation files (the ""Software""), to deal in the Software | ||
* without restriction, including without limitation the rights to use, copy, modify, merge, | ||
* publish, distribute, sublicense, and/or sell copies of the Software, and to permit | ||
* persons to whom the Software is furnished to do so, subject to the following conditions: | ||
* The above copyright notice and this permission notice shall be included in all copies or | ||
* substantial portions of the Software. | ||
* THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE | ||
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
* DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
package com.microsoft.applicationinsights.agent.internal.agent.redis; | ||
|
||
import com.microsoft.applicationinsights.agent.internal.agent.DefaultMethodVisitor; | ||
import com.microsoft.applicationinsights.agent.internal.agent.ClassToMethodTransformationData; | ||
|
||
import org.objectweb.asm.MethodVisitor; | ||
|
||
/** | ||
* The class is responsible for instrumenting Jedis client methods. | ||
*/ | ||
final class JedisMethodVisitorV2 extends DefaultMethodVisitor { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have unit tests of test infra for the other Method Visitors or There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately, we don't. There are some tests for other "config" related classes such as ClassInstrumentationData and MethodInstrumentationDecision, but those test basic object assignments. For visitors, there seems to have been an attempt before to unit test those (see EnterExitClassVisitorTest), but the tests are commented out. I imagine any kind of test would have to verify the bytecode is actually instrumented after the visitor was executed, which might be a cumbersome thing to do. |
||
private final static String ON_ENTER_METHOD_NAME = "jedisMethodStarted"; | ||
private final static String ON_ENTER_METHOD_SIGNATURE = "(Ljava/lang/String;)V"; | ||
|
||
public JedisMethodVisitorV2(int access, | ||
String desc, | ||
String owner, | ||
String methodName, | ||
MethodVisitor methodVisitor, | ||
ClassToMethodTransformationData additionalData) { | ||
super(false, true, 0, access, desc, owner, methodName, methodVisitor, additionalData); | ||
} | ||
|
||
@Override | ||
protected String getOnEnterMethodName() { | ||
return ON_ENTER_METHOD_NAME; | ||
} | ||
|
||
@Override | ||
protected String getOnEnterMethodSignature() { | ||
return ON_ENTER_METHOD_SIGNATURE; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,5 +27,6 @@ | |
public enum InstrumentedClassType { | ||
SQL, | ||
HTTP, | ||
OTHER | ||
OTHER, | ||
Redis | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From this Wiki entry it looks like agent already supports types other than
Other
though the configuration (and later though some method in Notification Handler or in Default Method Visitor) usingType
filed rather thanKind
field.Since we are using
DefaultMethodVisitor
here and are changing Notification Handler as well - should we consider using existing type handling mechanism as Wiki suggests?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand this comment correctly, then you're asking for the ability to override the type via config. For Redis, I'm in favor of having the type being set out-of-box. Doing this via AI-Agent.xml would mean yet another piece of config the customer needs to set. It makes sense for generic cases classes, but since we want to support Redis out-of-box with minimal config, I would say this is not needed.