Skip to content

Commit f359687

Browse files
Ivan Senicpbouillet
Ivan Senic
authored andcommitted
INSPECTIT-1921: Implementation of the opentracing.io API and support for HTTP and JMS tracing
1 parent 88d28ca commit f359687

File tree

189 files changed

+11754
-141
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

189 files changed

+11754
-141
lines changed

dependencies.gradle

+13
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ configurations {
3131
sharedCsProd {
3232
extendsFrom configurations.sharedAllProd
3333
}
34+
agentJavaSdkProd
3435
agentJavaProd {
3536
extendsFrom configurations.sharedAllProd
37+
extendsFrom configurations.agentJavaSdkProd
3638
}
3739
serverProd {
3840
extendsFrom configurations.sharedAllProd
@@ -56,6 +58,9 @@ configurations {
5658
agentJavaTest {
5759
extendsFrom configurations.testbase
5860
}
61+
agentJavaSdkTest {
62+
extendsFrom configurations.testbase
63+
}
5964
serverTest {
6065
extendsFrom configurations.testbase
6166
extendsFrom configurations.classmexer
@@ -85,6 +90,7 @@ configurations {
8590
configurations.sharedAllProd.transitive = false
8691
configurations.sharedCsProd.transitive = false
8792
configurations.agentJavaProd.transitive = false
93+
configurations.agentJavaSdkProd.transitive = false
8894
configurations.serverProd.transitive = false
8995
configurations.serverDiagnosisProd.transitive = false
9096
configurations.uiRcpProd.transitive = false
@@ -93,6 +99,7 @@ configurations.classmexer.transitive = false
9399
configurations.sharedAllTest.transitive = false
94100
configurations.sharedCsTest.transitive = false
95101
configurations.agentJavaTest.transitive = false
102+
configurations.agentJavaSdkTest.transitive = false
96103
configurations.serverTest.transitive = false
97104
configurations.serverDiagnosisTest.transitive = false
98105
configurations.uiRcpTest.transitive = false
@@ -147,6 +154,12 @@ dependencies {
147154
sharedCsTest (
148155
'nl.jqno.equalsverifier:equalsverifier:1.0.2'
149156
)
157+
158+
/** inspectit.agent.java.sdk */
159+
agentJavaSdkProd (
160+
'io.opentracing:opentracing-api:0.20.9',
161+
'io.opentracing:opentracing-noop:0.20.9',
162+
)
150163

151164
/** inspectit.agent.java */
152165
agentJavaProd (

inspectit.agent.java.sdk/.checkstyle

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
4+
<local-check-config name="inspectIT" location="/inspectit.root/resources/config/checkstyle/inspectit-checkstyle.xml" type="project" description="">
5+
<additional-data name="protect-config-file" value="false"/>
6+
</local-check-config>
7+
<fileset name="all" enabled="true" check-config-name="inspectIT" local="true">
8+
<file-match-pattern match-pattern="." include-pattern="true"/>
9+
</fileset>
10+
<filter name="FilesFromPackage" enabled="true">
11+
<filter-data value="src/test/java"/>
12+
</filter>
13+
</fileset-config>

inspectit.agent.java.sdk/.classpath

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src/main/java">
4+
<attributes>
5+
<attribute name="FROM_GRADLE_MODEL" value="true"/>
6+
</attributes>
7+
</classpathentry>
8+
<classpathentry kind="src" path="src/test/java">
9+
<attributes>
10+
<attribute name="FROM_GRADLE_MODEL" value="true"/>
11+
</attributes>
12+
</classpathentry>
13+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6/"/>
14+
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
15+
<classpathentry kind="output" path="bin"/>
16+
</classpath>

inspectit.agent.java.sdk/.eclipse-pmd

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<analysis enabled="true" />
4+
<rulesets>
5+
<ruleset name="Custom ruleset" ref="../resources/config/pmd/pmd_rules.xml" refcontext="project" />
6+
</rulesets>
7+
</eclipse-pmd>

inspectit.agent.java.sdk/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/bin
2+
/build
3+
/test-output

inspectit.agent.java.sdk/.project

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>inspectit.agent.java.sdk</name>
4+
<comment>Project inspectit.agent.java.sdk created by Buildship.</comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
<buildCommand>
24+
<name>ch.acanda.eclipse.pmd.builder.PMDBuilder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
28+
</buildSpec>
29+
<natures>
30+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
31+
<nature>org.eclipse.jdt.core.javanature</nature>
32+
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
33+
<nature>ch.acanda.eclipse.pmd.builder.PMDNature</nature>
34+
</natures>
35+
</projectDescription>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
build.commands=org.eclipse.jdt.core.javabuilder
2+
connection.arguments=
3+
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
4+
connection.java.home=null
5+
connection.jvm.arguments=
6+
connection.project.dir=..
7+
containers=org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6/
8+
derived.resources=.gradle,build
9+
eclipse.preferences.version=1
10+
natures=org.eclipse.jdt.core.javanature
11+
project.path=\:inspectit.agent.java.sdk
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
eclipse.preferences.version=1
2+
instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true
3+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
4+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
5+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
6+
org.eclipse.jdt.core.compiler.compliance=1.6
7+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
8+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
9+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
10+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
11+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
12+
org.eclipse.jdt.core.compiler.source=1.6
13+
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/**
2+
* Gradle build file for the inspectit.agent.java.sdk project.
3+
*
4+
* @author Ivan Senic
5+
*/
6+
defaultTasks 'releaseAndAnalyze'
7+
8+
/** used by the eclipse buildship plugin */
9+
sourceCompatibility = '1.6'
10+
targetCompatibility = '1.6'
11+
12+
/** defined to have it included in Eclipse as source */
13+
sourceSets {
14+
externalResources {
15+
resources {
16+
srcDir mainExtResources
17+
}
18+
}
19+
}
20+
21+
/** Some agent specific properties */
22+
ext {
23+
distJarName = 'inspectit-agent-java-sdk'
24+
}
25+
26+
/** Setting compile configuration as plugin in Eclipse needs it */
27+
configurations {
28+
compile {
29+
extendsFrom configurations.agentJavaSdkProd
30+
}
31+
testCompile {
32+
extendsFrom configurations.agentJavaSdkTest
33+
extendsFrom configurations.jmhbase
34+
}
35+
}
36+
37+
/** Must depend on shared all test sources because of TestBase class */
38+
dependencies {
39+
testCompile project (path: ':inspectit.shared.all', configuration: 'testArchives')
40+
}
41+
42+
/** Compile compatibility to 1.6 for all compile tasks */
43+
tasks.withType(JavaCompile) { t ->
44+
sourceCompatibility = '1.6'
45+
targetCompatibility = '1.6'
46+
47+
options.bootClasspath = configurations.java16rt.asPath
48+
}
49+
50+
/**
51+
* Creates the jar.
52+
*/
53+
jar {
54+
archivesBaseName = distJarName
55+
56+
manifest {}
57+
}
58+
59+
task releaseAndAnalyze {
60+
description = "Runs all unit tests, all checks and releases the jar."
61+
group = 'Release'
62+
dependsOn(analyze, jar)
63+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package rocks.inspectit.agent.java.sdk.opentracing;
2+
3+
import io.opentracing.Tracer;
4+
import io.opentracing.propagation.Format;
5+
import rocks.inspectit.agent.java.sdk.opentracing.propagation.Propagator;
6+
7+
/**
8+
* This interface defines additional methods that inspectIT tracer provides for usage.
9+
* <p>
10+
* There are additional two methods for creating a {@link SpanBuilder} where user can choose if
11+
* current thread context should be referenced or not.
12+
* <p>
13+
* The tracer allows registration of the {@link Propagator} for a specific format. This method
14+
* allows overwriting of the tracer default propagators. Note that inspectIT tracer by default uses
15+
* {@link rocks.inspectit.agent.java.sdk.opentracing.internal.propagation.TextMapPropagator} for the
16+
* <code>io.opentracing.propagation.Format.Builtin.TEXT_MAP</code> and
17+
* {@link rocks.inspectit.agent.java.sdk.opentracing.internal.propagation.UrlEncodingPropagator} for
18+
* the <code>io.opentracing.propagation.Format.Builtin.HTTP_HEADERS</code> format.
19+
*
20+
* @author Ivan Senic
21+
*
22+
*/
23+
public interface ExtendedTracer extends Tracer {
24+
25+
/**
26+
* Registers propagator. This method allows overwriting of the tracer default propagators. Note
27+
* that inspectIT tracer by default uses
28+
* {@link rocks.inspectit.agent.java.sdk.opentracing.internal.propagation.TextMapPropagator} for
29+
* the <code>io.opentracing.propagation.Format.Builtin.TEXT_MAP</code> and
30+
* {@link rocks.inspectit.agent.java.sdk.opentracing.internal.propagation.UrlEncodingPropagator}
31+
* for the <code>io.opentracing.propagation.Format.Builtin.HTTP_HEADERS</code> format.
32+
*
33+
* @param <C>
34+
* format type
35+
* @param format
36+
* opentracing {@link Format}
37+
* @param propagator
38+
* {@link Propagator}
39+
*/
40+
<C> void registerPropagator(Format<C> format, Propagator<C> propagator);
41+
42+
/**
43+
* Sets the implementation of the {@link Timer} to use.
44+
* <p>
45+
* By default inspectIT tracer uses
46+
* {@link rocks.inspectit.agent.java.sdk.opentracing.util.SystemTimer} that has millisecond
47+
* start time precision. This done so inspectIT can be compatible with Java 6. Users can provide
48+
* better timers if they run on higher Java versions or have third party dependencies that could
49+
* do better.
50+
*
51+
* @param timer
52+
* {@link Timer} to set. Must not be <code>null</code>.
53+
* @throws IllegalArgumentException
54+
* If timer provided is <code>null</code>.
55+
*/
56+
void setTimer(Timer timer) throws IllegalArgumentException;
57+
58+
/**
59+
* Builds span with no operation name. The thread context reference will added if the one exists
60+
* as the CHILD_OF reference.
61+
*
62+
* @return {@link SpanBuilder}.
63+
*/
64+
SpanBuilder buildSpan();
65+
66+
/**
67+
* Creates {@link SpanBuilder} that optionally adds the reference to the current thread context
68+
* span.
69+
*
70+
* @param operationName
71+
* Operation name of the span.
72+
* @param referenceType
73+
* Reference type to the current context. Can be <code>null</code> if
74+
* <code>useThreadContext=false</code>
75+
* @param useThreadContext
76+
* If thread context should be used.
77+
* @return {@link SpanBuilder}.
78+
*/
79+
SpanBuilder buildSpan(String operationName, String referenceType, boolean useThreadContext);
80+
81+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package rocks.inspectit.agent.java.sdk.opentracing;
2+
3+
import rocks.inspectit.agent.java.sdk.opentracing.internal.impl.SpanImpl;
4+
5+
/**
6+
* Reporter serves as class handling finished spans.
7+
* <p>
8+
* This SDK only provides the {@link rocks.inspectit.agent.java.sdk.opentracing.noop.NoopReporter}
9+
* as the implementation. However, if the inspectit agent is active on the target application, the
10+
* "real" reporter will be used which sends spans to the inspectIT CMR. In this case the
11+
* initialization of the reported and the tracer is done by inspectIT and can be obtained in
12+
* {@link rocks.inspectit.agent.java.sdk.opentracing.TracerProvider}.
13+
*
14+
* @author Ivan Senic
15+
*
16+
*/
17+
public interface Reporter {
18+
19+
/**
20+
* Reports span once it's finished. Spans that are started, but not finished are not reported.
21+
*
22+
* @param span
23+
* Span to report.
24+
*/
25+
void report(SpanImpl span);
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package rocks.inspectit.agent.java.sdk.opentracing;
2+
3+
/**
4+
* Timer interface for measuring.
5+
*
6+
* @author Ivan Senic
7+
*
8+
*/
9+
public interface Timer {
10+
11+
/**
12+
* Returns current time in microseconds (microseconds since epoch).
13+
*
14+
* @return Returns current time in microseconds (microseconds since epoch).
15+
*/
16+
long getCurrentTimeMicroseconds();
17+
18+
/**
19+
* Returns the current nano time. Simple implementation can use
20+
* {@link java.lang.System#nanoTime()}.
21+
*
22+
* @return Returns the current nano time.
23+
*/
24+
long getCurrentNanoTime();
25+
}

0 commit comments

Comments
 (0)