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

ByteBuddy agent #69

Merged
merged 6 commits into from
Aug 13, 2019
Merged

ByteBuddy agent #69

merged 6 commits into from
Aug 13, 2019

Conversation

wsargent
Copy link
Contributor

@wsargent wsargent commented Aug 12, 2019

Set up byte buddy agent to instrument built in classes.

public class PreloadedInstrumentationExample {
    public static void main(String[] args) throws Exception {
        Thread thread = Thread.currentThread();
        thread.run();
    }
}

application.conf:

logback.bytebuddy {
  classNames = ["java.lang.Thread"]

  methodNames = ["run"]
}

and logback-test.xml:

<configuration>
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%-5relative %-5level %logger{35} - %msg%n</pattern>
        </encoder>
    </appender>

    <root level="TRACE">
        <appender-ref ref="STDOUT" />
    </root>
</configuration>

Then running with the java agent loaded:

'-Dconfig.file=/home/wsargent/work/terse-logback/logback-bytebuddy/src/test/resources/application.conf',
'-Dlogback.configurationFile=/home/wsargent/work/terse-logback/logback-bytebuddy/src/test/resources/logback-test.xml',
'-javaagent:lib/logback-bytebuddy-0.0.0.jar',

results in:

[Byte Buddy] DISCOVERY java.lang.Thread [null, null, loaded=true]
[Byte Buddy] TRANSFORM java.lang.Thread [null, null, loaded=true]
[Byte Buddy] COMPLETE java.lang.Thread [null, null, loaded=true]
92    TRACE java.lang.Thread - entering: java.lang.Thread.run() with arguments=[]
93    TRACE java.lang.Thread - exiting: java.lang.Thread.run() with arguments=[] => returnType=void

@wsargent wsargent merged commit fb7599e into tersesystems:master Aug 13, 2019
@wsargent wsargent deleted the bytebuddy-agent branch August 13, 2019 02:23
wsargent added a commit to wsargent/terse-logback that referenced this pull request Aug 13, 2019
* ByteBuddy agent

* Update byte buddy agent to include preloaded data

* Update docs

* Update with licenses

* Rename, add more javadoc

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

Successfully merging this pull request may close these issues.

1 participant