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
Update guava-cache,jedis,memcached,ehcache plugins to adopt uniform tags #303
Conversation
@@ -49,6 +49,7 @@ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allAr | |||
if (element != null) { | |||
Tags.DB_STATEMENT.set(span, element.toString()); | |||
} | |||
Tags.DB_TYPE.set(span, "Ehcache"); |
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.
How about we add a Tags.CACHE_TYPE
? As we have agreed that, database and cache are different.
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.
Must modify all cache plugin , such as jedis .
And DB_STATEMENT
?
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.
I found the comment about DB _TYPE
/**
* DB_TYPE records database type, such as sql, redis, cassandra and so on.
*/
public static final StringTag DB_TYPE = new StringTag(3, "db.type");
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.
I think we didn't analyze spans from those plugins, so, changing new tags for analyzing is not an issue. I noticed plugins like Jedis using database statement
and type
.
Also, how about we add a new cache.key
(key for reading and writing) and cache.op
(read/write/general) tags for those plugins too?
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.
We could modify these tag , since they haven't be used.
We don't have clear way to extract cache.key , cache.op .
We can't guarantee developers must write code to provide correct op
,key
at least .
in order to get correct op
,key
,Plugins must know java method which is involved by user , it's very difficult ,and ugly
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.
We could provide a mapping mechanism in OAP The plugin only send statement to OAP , and OAP could parse the statement to op/key or other flag . So , user could know how it work clearly
How about this . I like
BTW , fat-plugin shoudn't exist
If you searched closed issues, you will find a SQL parser PoC, powered by Apache ShardingSphere. It failed due to perf impact, can't analyze SQL fast enough to get table read/write metrics.
I don't think we could win this for cache. SQL is much better formated than No SQL or cache statements.
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.
I see , I don't work for a company .HaHa .
Le's talk about providing mapping mechanism in OAP for op/key
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.
We could provide a mapping mechanism in OAP The plugin only send statement to OAP , and OAP could parse the statement to op/key or other flag . So , user could know how it work clearly
How about this . I like
BTW , fat-plugin shoudn't existIf you searched closed issues, you will find a SQL parser PoC, powered by Apache ShardingSphere. It failed due to perf impact, can't analyze SQL fast enough to get table read/write metrics.
I don't think we could win this for cache. SQL is much better formated than No SQL or cache statements.
Yes , it maybe slow . Let me think about this conversation.
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.
At first I wanted to try something , but I always want to finish it as possible as soon , even if no one is urging me . Sorry for my mood .
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.
At least in SkyWalking, we don't push contributors. You are already self driven, so we can have you as volunteers to build this. It is not fair we asked a volunteer to promise something must be done.
We have plans to release every 2 or 3 months, you could set a plan to finish this in one or two milestones, which means you could have half a year buffer.
So, don't hurry, and don't worry. And more ,Git is a time machine, we could revert halfly done things to keep release work, and revert the revert back to continue.
Let's start from listed all relative plugins, which are cache plugins.
|
redis commands : https://github.com/redis/jedis/blob/master/src/main/java/redis/clients/jedis/Protocol.java#L218 |
Look like this public class OperatorParser {
private static final Map<Command, String> MAPPING = new HashMap<>();
static {
MAPPING.put(Command.GET, "READ");
MAPPING.put(Command.HGET, "READ");
MAPPING.put(Command.MGET, "READ");
MAPPING.put(Command.ZCARD, "READ");
MAPPING.put(Command.ZCOUNT, "READ");
// ....
// ....
}
public static String parse(Command command) {
return Optional.ofNullable(command).map(MAPPING::get).orElse("Other");
}
} Do you have better way ? |
We could provide a tag named
Actually , business application just use a few command in cache system |
To easy the configurations, I think we only need read/write and default(cmd in your configuration?). Then the worst case when we missed something, is that, we don't treat it as a read/write command. |
Yes, we just need READ or WRITE tag if we could identify them. |
How about we provide mechanism for mapping command to op in OAP . we support two group (read/write) analysis . |
It is better we don't do this at the backend. It is not a preference, this is a math theory. When you only cost 0.001 ms for every request to identify the type, you need to cost 0.001 ms * N request * M threads per JVM * Y JVM processes, which means you need at least 10-20 more CPUs at the OAP side to make this works. |
So, We put the mapping configure to plugin side . |
I have done a demo for plugin . I add a module named |
Where does this class place? I think this is plugin specific only? |
|
Why we need to share? I think the command is tech stack relative. |
|
Why? Their command should be different, I think we could have their own? It is better we don't set plugin dependencies. This would be more friendly. |
Every cache plugin should have own config for Write/Read mapping , even if their command is different . This module only convert command to operation . |
Every plugin commands are different, I think copying the codes into various plugins under different package names is fine. Jedis has nothing to share with Ehcache commands, right? |
I didn't read this from my cellphone at this night. I just checked I think you made things too complex. |
No problem , Just need a config . |
Update ,define following tag for all cache plugin
Provide following config for all cache plugin (Java filed format)
|
Make sense to me, please go ahead. We need to find a place to doc these tags and meanings in Java agent and backend. I will back to this thread later. |
Could you send a pull request to here https://skywalking.apache.org/docs/skywalking-java/latest/en/setup/service-agent/java-agent/java-plugin-development-guide/#advanced-apis (after the whole We should add reserved tags, the new added tags and database relative tags should be defined here. A new backend doc for |
OK. |
Let's finish |
d7b6a74
to
b0849d1
Compare
b0849d1
to
7200ffa
Compare
/** | ||
* CACHE_TYPE records cache type, such as jedis | ||
*/ | ||
public static final StringTag CACHE_TYPE = new StringTag(15, "cache.type"); | ||
|
||
/** | ||
* CACHE_OP represent a command is used for "write" or "read" | ||
* It's better that adding this tag to span , so OAP would analysis write/read metric accurately | ||
* Reference org.apache.skywalking.apm.plugin.jedis.v4.AbstractConnectionInterceptor#parseOperation | ||
* BTW "op" means Operation | ||
*/ | ||
public static final StringTag CACHE_OP = new StringTag(16, "cache.op"); | ||
|
||
/** | ||
* CACHE_TYPE records the cache command | ||
*/ | ||
public static final StringTag CACHE_CMD = new StringTag(17, "cache.cmd"); | ||
|
||
/** | ||
* CACHE_TYPE records the cache key | ||
*/ | ||
public static final StringTag CACHE_KEY = new StringTag(18, "cache.key"); |
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.
@apache/skywalking-committers Please notice, these new tags would be significant for virtual cache analysis, which would be added in 9.3.0.
If you want your cache framework relative plugins would work like these Java plugin, please follow the tag format protocol.
I think this PR would not be merged until the work in OAP finished , it's better wait I finish the test of OAP and plugin . |
I will review the change, I think this PR doesn't have side effects. Users could use it for previous OAP, as we don't analysis anything before. We could add v8.13.0 Java agent and required tags in the OAP doc. |
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.
LGTM
I would like to help with docs writing if you have any trouble. |
CHANGES
log.First , Add db .type for guava , encache which miss the tag
related issue apache/skywalking#9556