Skip to content
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

ttl agent not working when i both use our own javaagent #207

Closed
ffiredom opened this issue Sep 23, 2020 · 6 comments
Closed

ttl agent not working when i both use our own javaagent #207

ffiredom opened this issue Sep 23, 2020 · 6 comments
Assignees
Labels

Comments

@ffiredom
Copy link

ffiredom commented Sep 23, 2020

when i use our own javaagent to enhance the code ,both, i could use ttl in some sence to enhance threadpool class. so i nested ttl agent in our own agent, expecting both agent to take affect.

but only using ttl agent alone will work. Below are my application startup parameters...

-javaagent:/Users/xxx/IdeaProjects/env-sniffer/env-agent/target/env-agent-1.0-SNAPSHOT.jar

The ttl jar has imported in the env-sniffer jar

and premain is like that

public static void premain(String agentArgs, Instrumentation instrumentation)
      throws PluginException {
    final PluginFinder pluginFinder;
    loadTtlAgent(agentArgs, instrumentation);
@ffiredom ffiredom reopened this Sep 23, 2020
@oldratlee
Copy link
Member

oldratlee commented Oct 12, 2020

@ffiredom
Would you please provide an demo runnable project that can reproduce the problem,
so I can troubleshoot your problem. ♥️

PS: Sorry for my procrastinated reply...

@oldratlee oldratlee added the ❓question Further information is requested label Oct 12, 2020
@ffiredom
Copy link
Author

ffiredom commented Oct 15, 2020

Because this problem occurs in the company's internal projects, we may not be able to provide specific projects, but we are based on the sky-walking agent for transformation, the reason is also very simple, that is, when our own agent wants to integrate ttlagent, we found The agent started successfully, and ttl related logs are also output, but the thread enhancement does not take effect.

premain method like that:

public static void premain(String agentArgs, Instrumentation instrumentation)
      throws PluginException {
    final PluginFinder pluginFinder;
    loadTtlAgent(agentArgs, instrumentation);
    try {

      pluginFinder = new PluginFinder(new PluginBootstrap().loadPlugins());

    } catch (Exception e) {
      logger.error("enn agent initialized failure. Shutting down.", e);
      return;
    }

    final ByteBuddy byteBuddy = new ByteBuddy()
        .with(TypeValidation.of(Config.Agent.IS_OPEN_DEBUGGING_CLASS));

    AgentBuilder agentBuilder = new AgentBuilder.Default(byteBuddy).ignore(
        nameStartsWith("net.bytebuddy.").or(nameStartsWith("org.slf4j."))
            .or(nameStartsWith("org.groovy."))
            .or(nameContains("javassist"))
            .or(nameContains(".asm."))
            .or(nameContains(".reflectasm."))
            .or(nameStartsWith("sun.reflect"))
            .or(allEnvAgentExcludeToolkit())
            .or(ElementMatchers.isSynthetic()));

    if (Config.Agent.IS_CACHE_ENHANCED_CLASS) {
      try {
        agentBuilder = agentBuilder
            .with(new CacheableTransformerDecorator(Config.Agent.CLASS_CACHE_MODE));
        logger.info("Env agent class cache [{}] activated.", Config.Agent.CLASS_CACHE_MODE);
      } catch (Exception e) {
        logger.error("Env agent can't active class cache.", e);
      }
    }
    System.out.println("start env sniffer agent");

    agentBuilder.type(pluginFinder.buildMatch())
        .transform(new Transformer(pluginFinder))
        .with(AgentBuilder.RedefinitionStrategy.RETRANSFORMATION)
        .with(new Listener())
        .installOn(instrumentation);
    System.out.println("env sniffer agent load success");
  }

@oldratlee
Copy link
Member

oldratlee commented Jan 17, 2021

@ffiredom similar/related problem about agent, see the discussion in issue:

TTL agent 与 其他agent的兼容性问题 #226

Quote from @liauraljl

我们目前的解决方案是

TTL agent放在最前位置,可以保证TTL agent 正常工作。
已在开发、测试环境得到验证。

@oldratlee
Copy link
Member

@ffiredom is your problem resolved?

@oldratlee oldratlee self-assigned this Jan 10, 2022
@guofeiwu
Copy link

我遇到一样的问题 先执行ttlagent.premain

然后在有bytebuddy的应用 增强失败

@guofeiwu
Copy link

找到问题了 是slf4j的问题 logger.getlogger 导致的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants