Git Product home page Git Product logo

pinpoint-plugin-sample's Introduction

Pinpoint Profiler Plugin Sample

You can extend Pinoint's profiling ability by writing a Pinpoint profiler plugin. This sample project shows how to write it. It consists of 3 modules:

  • plugin-sample-target: target library
  • plugin-sample-plugin: sample plugin
  • plugin-sample-agent: agent distribution with sample plugin

Implementing a Profiler Plugin

A Pinpoint profiler plugin have to provide implementations of ProfilerPlugin and TraceMetadataProvider ProfilerPlugin is used by Pinpoint Agent only while TraceMetadataProvider is used by Pinpoint Agent, Collector and Web.

Pinpoint loads these implementations by Java's ServiceLoader. So an plugin JAR must contains two provider-configuration files.

  • META-INF/services/com.navercorp.pinpoint.bootstrap.plugin.ProfilerPlugin
  • META-INF/services/com.navercorp.pinpoint.common.trace.TraceMetadataProvider

Each file should contains fully qualified names of the implementation classes.

TraceMetadataProvider

A TraceMetadataProvider adds ServiceTypes and AnnotationKeys to Pinpoint.

Both ServiceType and AnnotationKey's code value must be unique. If you're writing a private plugin, you can use code values reserved for private usage. Pinpoint will not assign these values to anything. Otherwise you have to contact Pinpoint dev team to allocate codes for the plugin.

  • ServiceType codes for private use

    • Server: 1900 ~ 1999
    • DB client: 2900 ~ 2999
    • Cache client: 8900 ~ 8999
    • RPC client: 9900 ~ 9999
    • Others: 7500 ~ 7999
  • AnnotaionKey codes for private use

    • 900 ~ 999

ProfilerPlugin

A ProfilerPlugin adds TransformCallbacks to Pinpoint.

A TransformCallback transforms a target class by adding interceptors, getters and/or fields. You can find example codes in plugin-sample-plugin project.

Integration Test

You can run plugin integration tests (mvn integration-test) with PinointPluginTestSuite, a JUnit Runner. It downloads required dependencies from maven repositories and launch a new JVM with Pinpoint profiler agent and dependencies. On that JVM, JUnit tests are executed.

To run plugin integration test, it needs a complete agent distribution. That's why integration tests are in plugin-sample-agent module.

In test, you can use PluginTestVerifier to check if traces are recorded correctly.

Test Dependency

PinointPluginTestSuite doesn't use the project's dependencies (configured at pom.xml). It uses dependencies listed by @Dependency. In this way, you can test multiple versions of the target library.

Dependencies are declared like this. You can specify versions or version ranges of a dependency.

@Dependency({"some.group:some-artifact:1.0", "another.group:another-artifact:2.1-RELEASE"})
@Dependency({"some.group:some-artifact:[1.0,)"})
@Dependency({"some.group:some-artifact:[1.0,1.9]"})
@Dependency({"some.group:some-artifact:[1.0],[2.1],[3.2])"})

PinointPluginTestSuite searches dependencies from local repository and maven central repository. You can add repositories by @Repository.

Jvm Version

You can specify the JVM version for a test by @JvmVersion.

Application Test

PinpointPluginTestSuite is not for an application which has to be launched by its own main class. You can extends AbstractPinpointPluginTestSuite and related types to test such applications.

pinpoint-plugin-sample's People

Contributors

emeroad avatar gitter-badger avatar jaehong-kim avatar koo-taejin avatar lioolli avatar nstopkimsk avatar xylus avatar

Watchers

 avatar

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.