Skip to content

Commit

Permalink
INSPECTIT-1921: Implementation of the opentracing.io API and support …
Browse files Browse the repository at this point in the history
…for HTTP and JMS tracing
  • Loading branch information
Ivan Senic authored and pbouillet committed Apr 21, 2017
1 parent 88d28ca commit f359687
Show file tree
Hide file tree
Showing 189 changed files with 11,754 additions and 141 deletions.
13 changes: 13 additions & 0 deletions dependencies.gradle
Expand Up @@ -31,8 +31,10 @@ configurations {
sharedCsProd {
extendsFrom configurations.sharedAllProd
}
agentJavaSdkProd
agentJavaProd {
extendsFrom configurations.sharedAllProd
extendsFrom configurations.agentJavaSdkProd
}
serverProd {
extendsFrom configurations.sharedAllProd
Expand All @@ -56,6 +58,9 @@ configurations {
agentJavaTest {
extendsFrom configurations.testbase
}
agentJavaSdkTest {
extendsFrom configurations.testbase
}
serverTest {
extendsFrom configurations.testbase
extendsFrom configurations.classmexer
Expand Down Expand Up @@ -85,6 +90,7 @@ configurations {
configurations.sharedAllProd.transitive = false
configurations.sharedCsProd.transitive = false
configurations.agentJavaProd.transitive = false
configurations.agentJavaSdkProd.transitive = false
configurations.serverProd.transitive = false
configurations.serverDiagnosisProd.transitive = false
configurations.uiRcpProd.transitive = false
Expand All @@ -93,6 +99,7 @@ configurations.classmexer.transitive = false
configurations.sharedAllTest.transitive = false
configurations.sharedCsTest.transitive = false
configurations.agentJavaTest.transitive = false
configurations.agentJavaSdkTest.transitive = false
configurations.serverTest.transitive = false
configurations.serverDiagnosisTest.transitive = false
configurations.uiRcpTest.transitive = false
Expand Down Expand Up @@ -147,6 +154,12 @@ dependencies {
sharedCsTest (
'nl.jqno.equalsverifier:equalsverifier:1.0.2'
)

/** inspectit.agent.java.sdk */
agentJavaSdkProd (
'io.opentracing:opentracing-api:0.20.9',
'io.opentracing:opentracing-noop:0.20.9',
)

/** inspectit.agent.java */
agentJavaProd (
Expand Down
13 changes: 13 additions & 0 deletions inspectit.agent.java.sdk/.checkstyle
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>

<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
<local-check-config name="inspectIT" location="/inspectit.root/resources/config/checkstyle/inspectit-checkstyle.xml" type="project" description="">
<additional-data name="protect-config-file" value="false"/>
</local-check-config>
<fileset name="all" enabled="true" check-config-name="inspectIT" local="true">
<file-match-pattern match-pattern="." include-pattern="true"/>
</fileset>
<filter name="FilesFromPackage" enabled="true">
<filter-data value="src/test/java"/>
</filter>
</fileset-config>
16 changes: 16 additions & 0 deletions inspectit.agent.java.sdk/.classpath
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java">
<attributes>
<attribute name="FROM_GRADLE_MODEL" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src/test/java">
<attributes>
<attribute name="FROM_GRADLE_MODEL" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin"/>
</classpath>
7 changes: 7 additions & 0 deletions inspectit.agent.java.sdk/.eclipse-pmd
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<eclipse-pmd xmlns="http://acanda.ch/eclipse-pmd/0.8" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://acanda.ch/eclipse-pmd/0.8 http://acanda.ch/eclipse-pmd/eclipse-pmd-0.8.xsd">
<analysis enabled="true" />
<rulesets>
<ruleset name="Custom ruleset" ref="../resources/config/pmd/pmd_rules.xml" refcontext="project" />
</rulesets>
</eclipse-pmd>
3 changes: 3 additions & 0 deletions inspectit.agent.java.sdk/.gitignore
@@ -0,0 +1,3 @@
/bin
/build
/test-output
35 changes: 35 additions & 0 deletions inspectit.agent.java.sdk/.project
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>inspectit.agent.java.sdk</name>
<comment>Project inspectit.agent.java.sdk created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>ch.acanda.eclipse.pmd.builder.PMDBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
<nature>ch.acanda.eclipse.pmd.builder.PMDNature</nature>
</natures>
</projectDescription>
@@ -0,0 +1,11 @@
build.commands=org.eclipse.jdt.core.javabuilder
connection.arguments=
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
connection.java.home=null
connection.jvm.arguments=
connection.project.dir=..
containers=org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6/
derived.resources=.gradle,build
eclipse.preferences.version=1
natures=org.eclipse.jdt.core.javanature
project.path=\:inspectit.agent.java.sdk
13 changes: 13 additions & 0 deletions inspectit.agent.java.sdk/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,13 @@
eclipse.preferences.version=1
instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
63 changes: 63 additions & 0 deletions inspectit.agent.java.sdk/inspectit.agent.java.sdk.gradle
@@ -0,0 +1,63 @@
/**
* Gradle build file for the inspectit.agent.java.sdk project.
*
* @author Ivan Senic
*/
defaultTasks 'releaseAndAnalyze'

/** used by the eclipse buildship plugin */
sourceCompatibility = '1.6'
targetCompatibility = '1.6'

/** defined to have it included in Eclipse as source */
sourceSets {
externalResources {
resources {
srcDir mainExtResources
}
}
}

/** Some agent specific properties */
ext {
distJarName = 'inspectit-agent-java-sdk'
}

/** Setting compile configuration as plugin in Eclipse needs it */
configurations {
compile {
extendsFrom configurations.agentJavaSdkProd
}
testCompile {
extendsFrom configurations.agentJavaSdkTest
extendsFrom configurations.jmhbase
}
}

/** Must depend on shared all test sources because of TestBase class */
dependencies {
testCompile project (path: ':inspectit.shared.all', configuration: 'testArchives')
}

/** Compile compatibility to 1.6 for all compile tasks */
tasks.withType(JavaCompile) { t ->
sourceCompatibility = '1.6'
targetCompatibility = '1.6'

options.bootClasspath = configurations.java16rt.asPath
}

/**
* Creates the jar.
*/
jar {
archivesBaseName = distJarName

manifest {}
}

task releaseAndAnalyze {
description = "Runs all unit tests, all checks and releases the jar."
group = 'Release'
dependsOn(analyze, jar)
}
@@ -0,0 +1,81 @@
package rocks.inspectit.agent.java.sdk.opentracing;

import io.opentracing.Tracer;
import io.opentracing.propagation.Format;
import rocks.inspectit.agent.java.sdk.opentracing.propagation.Propagator;

/**
* This interface defines additional methods that inspectIT tracer provides for usage.
* <p>
* There are additional two methods for creating a {@link SpanBuilder} where user can choose if
* current thread context should be referenced or not.
* <p>
* The tracer allows registration of the {@link Propagator} for a specific format. This method
* allows overwriting of the tracer default propagators. Note that inspectIT tracer by default uses
* {@link rocks.inspectit.agent.java.sdk.opentracing.internal.propagation.TextMapPropagator} for the
* <code>io.opentracing.propagation.Format.Builtin.TEXT_MAP</code> and
* {@link rocks.inspectit.agent.java.sdk.opentracing.internal.propagation.UrlEncodingPropagator} for
* the <code>io.opentracing.propagation.Format.Builtin.HTTP_HEADERS</code> format.
*
* @author Ivan Senic
*
*/
public interface ExtendedTracer extends Tracer {

/**
* Registers propagator. This method allows overwriting of the tracer default propagators. Note
* that inspectIT tracer by default uses
* {@link rocks.inspectit.agent.java.sdk.opentracing.internal.propagation.TextMapPropagator} for
* the <code>io.opentracing.propagation.Format.Builtin.TEXT_MAP</code> and
* {@link rocks.inspectit.agent.java.sdk.opentracing.internal.propagation.UrlEncodingPropagator}
* for the <code>io.opentracing.propagation.Format.Builtin.HTTP_HEADERS</code> format.
*
* @param <C>
* format type
* @param format
* opentracing {@link Format}
* @param propagator
* {@link Propagator}
*/
<C> void registerPropagator(Format<C> format, Propagator<C> propagator);

/**
* Sets the implementation of the {@link Timer} to use.
* <p>
* By default inspectIT tracer uses
* {@link rocks.inspectit.agent.java.sdk.opentracing.util.SystemTimer} that has millisecond
* start time precision. This done so inspectIT can be compatible with Java 6. Users can provide
* better timers if they run on higher Java versions or have third party dependencies that could
* do better.
*
* @param timer
* {@link Timer} to set. Must not be <code>null</code>.
* @throws IllegalArgumentException
* If timer provided is <code>null</code>.
*/
void setTimer(Timer timer) throws IllegalArgumentException;

/**
* Builds span with no operation name. The thread context reference will added if the one exists
* as the CHILD_OF reference.
*
* @return {@link SpanBuilder}.
*/
SpanBuilder buildSpan();

/**
* Creates {@link SpanBuilder} that optionally adds the reference to the current thread context
* span.
*
* @param operationName
* Operation name of the span.
* @param referenceType
* Reference type to the current context. Can be <code>null</code> if
* <code>useThreadContext=false</code>
* @param useThreadContext
* If thread context should be used.
* @return {@link SpanBuilder}.
*/
SpanBuilder buildSpan(String operationName, String referenceType, boolean useThreadContext);

}
@@ -0,0 +1,26 @@
package rocks.inspectit.agent.java.sdk.opentracing;

import rocks.inspectit.agent.java.sdk.opentracing.internal.impl.SpanImpl;

/**
* Reporter serves as class handling finished spans.
* <p>
* This SDK only provides the {@link rocks.inspectit.agent.java.sdk.opentracing.noop.NoopReporter}
* as the implementation. However, if the inspectit agent is active on the target application, the
* "real" reporter will be used which sends spans to the inspectIT CMR. In this case the
* initialization of the reported and the tracer is done by inspectIT and can be obtained in
* {@link rocks.inspectit.agent.java.sdk.opentracing.TracerProvider}.
*
* @author Ivan Senic
*
*/
public interface Reporter {

/**
* Reports span once it's finished. Spans that are started, but not finished are not reported.
*
* @param span
* Span to report.
*/
void report(SpanImpl span);
}
@@ -0,0 +1,25 @@
package rocks.inspectit.agent.java.sdk.opentracing;

/**
* Timer interface for measuring.
*
* @author Ivan Senic
*
*/
public interface Timer {

/**
* Returns current time in microseconds (microseconds since epoch).
*
* @return Returns current time in microseconds (microseconds since epoch).
*/
long getCurrentTimeMicroseconds();

/**
* Returns the current nano time. Simple implementation can use
* {@link java.lang.System#nanoTime()}.
*
* @return Returns the current nano time.
*/
long getCurrentNanoTime();
}

0 comments on commit f359687

Please sign in to comment.