forked from elastic/apm-agent-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes elastic#35 Signed-off-by: Felix Barnsteiner <felix.barnsteiner@elastic.co>
- Loading branch information
1 parent
274b42c
commit 883d650
Showing
16 changed files
with
573 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...enchmarks/src/main/java/co/elastic/apm/benchmark/ElasticApmActiveContinuousBenchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/*- | ||
* #%L | ||
* Elastic APM Java agent | ||
* %% | ||
* Copyright (C) 2018 the original author or authors | ||
* %% | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* #L% | ||
*/ | ||
package co.elastic.apm.benchmark; | ||
|
||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.runner.RunnerException; | ||
|
||
import javax.servlet.ServletException; | ||
import java.io.IOException; | ||
|
||
public class ElasticApmActiveContinuousBenchmark extends ElasticApmContinuousBenchmark { | ||
|
||
public ElasticApmActiveContinuousBenchmark() { | ||
super(true); | ||
} | ||
|
||
public static void main(String[] args) throws RunnerException { | ||
run(ElasticApmActiveContinuousBenchmark.class); | ||
} | ||
|
||
@Benchmark | ||
public int benchmarkWithApm() throws IOException, ServletException { | ||
httpServlet.service(request, response); | ||
return response.getStatus(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...hmarks/src/main/java/co/elastic/apm/benchmark/ElasticApmNotActiveContinuousBenchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/*- | ||
* #%L | ||
* Elastic APM Java agent | ||
* %% | ||
* Copyright (C) 2018 the original author or authors | ||
* %% | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* #L% | ||
*/ | ||
package co.elastic.apm.benchmark; | ||
|
||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.runner.RunnerException; | ||
|
||
import javax.servlet.ServletException; | ||
import java.io.IOException; | ||
|
||
public class ElasticApmNotActiveContinuousBenchmark extends ElasticApmContinuousBenchmark { | ||
public ElasticApmNotActiveContinuousBenchmark() { | ||
super(false); | ||
} | ||
|
||
public static void main(String[] args) throws RunnerException { | ||
run(ElasticApmNotActiveContinuousBenchmark.class); | ||
} | ||
|
||
@Benchmark | ||
public int benchmarkWithoutApm() throws IOException, ServletException { | ||
httpServlet.service(request, response); | ||
return response.getStatus(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
apm-agent-core/src/test/java/co/elastic/apm/AbstractInstrumentationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/*- | ||
* #%L | ||
* Elastic APM Java agent | ||
* %% | ||
* Copyright (C) 2018 the original author or authors | ||
* %% | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* #L% | ||
*/ | ||
package co.elastic.apm; | ||
|
||
import co.elastic.apm.bci.ElasticApmAgent; | ||
import co.elastic.apm.configuration.SpyConfiguration; | ||
import co.elastic.apm.impl.ElasticApmTracer; | ||
import net.bytebuddy.agent.ByteBuddyAgent; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.BeforeEach; | ||
|
||
public abstract class AbstractInstrumentationTest { | ||
protected static ElasticApmTracer tracer; | ||
protected static MockReporter reporter; | ||
|
||
@BeforeAll | ||
static void beforeAll() { | ||
reporter = new MockReporter(); | ||
tracer = ElasticApmTracer.builder() | ||
.configurationRegistry(SpyConfiguration.createSpyConfig()) | ||
.reporter(reporter) | ||
.build(); | ||
ElasticApmAgent.initInstrumentation(tracer, ByteBuddyAgent.install()); | ||
} | ||
|
||
@AfterAll | ||
static void afterAll() { | ||
ElasticApmAgent.reset(); | ||
} | ||
|
||
@BeforeEach | ||
final void resetReporter() { | ||
reporter.reset(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# JDBC plugin | ||
|
||
This plugin creates spans for JDBC queries. | ||
|
||
## Implementation Notes: | ||
|
||
The JDBC API itself is loaded by the bootstrap class loader. | ||
|
||
The implementations are however mostly loaded by | ||
* The application server class loader (or a module class loader), if the server bundles the implementation | ||
* The web app class loader, if the application bundles the JDBC driver | ||
* The `SystemClassLoader`, when starting a simple `main` method Java program | ||
|
||
As a consequence, | ||
there are not lots of class loader issues, | ||
as the implementations are loaded by a child of the `SystemClassLoader` or the `SystemClassLoader` itself, | ||
which also loads the agent code. | ||
But as we don't need to refer to implementation specific classes, | ||
but only the JDBC API, | ||
which is loaded by the bootstrap class loader, | ||
which is a parent class loader of both the agent and the JDBC implementation, | ||
we can fully reference it even in helper classes. | ||
|
Oops, something went wrong.