Commit Graph

2569 Commits

Author SHA1 Message Date
Andrei Chugunov 506ca93699
webflux 5.0 groovy to java tests part 2 (#7776)
@trask @mateuszrzeszutek hello, what do you think about
SingleThreadedSpringWebfluxTest, the test contains dependencies on new
reactor netty classes in testLatestDeps case. I tried use reflection for
rewriting the test to java but it was not trivial and I not reach the
result

---------

Co-authored-by: Lauri Tulmin <ltulmin@splunk.com>
2023-04-05 19:33:23 -07:00
Lauri Tulmin 8aeffa5e80
Rename package.json to avoid dependabot alert (#8219)
This `package.json` contains outdated dependences, it is only used in a
test.

---------

Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
2023-04-05 11:00:24 -07:00
Lauri Tulmin 856d521f0a
Update testcontainers and selenium (#8218) 2023-04-05 08:24:53 -07:00
Lauri Tulmin d87f40c9c7
Instrument akka-http bindAndHandle (#8174)
Resolves
https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/8143
Resolves
https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/6081
Resolves
https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/5137
Using the same approach as in
https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/6243
and as used by DataDog. Unlike in #6243 this pr does not attempt to
prevent leaking scopes into actors but rather instruments the actor to
reset context to get rid of the leaked scopes (DataDog does the same).
2023-04-05 17:11:05 +03:00
Lauri Tulmin 8fba02e391
Skip spotless and other checks in CI test step (#8142)
Currently we run spotless and other checks for each of the parallel test
steps which seems wasteful. Here is an attempt to run only the tests in
given partition without any extra checks in the `test` step and run all
the checks in the `build` step.
2023-04-04 10:43:12 -07:00
Lauri Tulmin 34bca4ba10
Pulsar batch receive instrumentation (#8173) 2023-04-04 10:19:08 -07:00
Lauri Tulmin 4d21d45f3d
Verify that server span ends after child spans in java tests (#8208)
Currently server span end time verification is only implemented for
groovy tests.
2023-04-04 09:54:10 -07:00
jason plumb 32b6bd2a71
Ensure that parsed container ID is 64 chars. (#8206)
Resolves #7437.

A few caveats about this. The TL;DR on #7437 is that a non-containerized
process was reporting a `container.id` attribute. The submitter narrowed
it down and I was able to confirm with the test case in this PR.

I hunted for other means for code to determine if it's containerized
with the idea to not even do the parsing if not containerized, but I
couldn't find anything useful. In fact, most approaches of detecting
containerization at all do involve parsing cgroups. Wacky.

So I attempted to verify that container IDs should always be 64
characters. I found:
* podman - docs
[here](https://docs.podman.io/en/latest/markdown/podman-container-inspect.1.html)
"Container ID (full 64-char hash)"
* docker - UID generator source
[here](634a848b8e/pkg/stringid/stringid.go (L36))
shows 32 bytes (and even guards against fully numeric!)
* lxc [man page
](https://linuxcontainers.org/lxc/manpages/man1/lxc-info.1.html)says
"container identifier format is an alphanumeric string". If this maps
into cgroups (no idea!), it would have already been broken in some cases
because we enforce hex.

I'm a little concerned about this approach because the [otel
spec](94c9c75c4f/specification/resource/semantic_conventions/container.md)
suggests that "The UUID might be abbreviated.", but it's
unclear/non-specific about the circumstances that might cause this.

Open to hearing about why the approach presented here is a bad idea. 🙃
2023-04-04 09:37:23 -07:00
Mateusz Rzeszutek 04f2e3e9e5
Bridge agent logs into application's slf4j logger (#7339)
Related discussion #7257
Resolves #3413
Resolves #5059
Resolves #6258
Resolves #7179

Adds a logging implementation that'll collect agent logs in memory until
slf4j is detected in the instrumented application; and when that happens
will dump all the logs into the application slf4j and log directly to
the application logger from that time on.

It's still in a POC state, unfortunately: while it works fine with an
app that uses & initializes slf4j directly, Spring Boot applications
actually reconfigure the logging implementation (e.g. logback) a while
after slf4j is loaded; which causes all the startup agent logs (debug
included) to be dumped with the default logback pattern.

Future work:
* ~~Make sure all logs produces by the agent are sent to loggers named
`io.opentelemetry...`
(https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/7446)~~
DONE
* Make this work on Spring Boot
* Documentation
* Smoke test?
2023-04-04 17:29:43 +02:00
Lauri Tulmin 402635bb64
Remove aws-sdk-2.2 latest dep restriction (#8207) 2023-04-04 10:03:19 +03:00
Lauri Tulmin 00dfd99519
Alternative fix for flaky jfr telemetry test (#8203)
Reverts
https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/8183
Perhaps the problem is that the gc happens before reading jfr events is
started.
2023-04-03 13:09:37 -07:00
Lauri Tulmin 08236a710f
Add library instrumentation for java http client (#8138)
Resolves
https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/8069
The javaagent instrumentation also supports propagating context into
[BodyHandler](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpResponse.BodyHandler.html)
implemented in
https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/java-http-client/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpclient/BodyHandlerWrapper.java
I think the initial idea behind it was that this allowed propagating
context into callbacks. Because this didn't work for
`connectionErrorUnopenedPortWithCallback` test later we also added
wrapping completable future to take care of propagating context into
callbacks. Should I also implement context propagation for `BodyHandler`
in library instrumentation or should I just delete it? I guess it could
come handy if someone builds a custom `BodyHandler` and wants to emit
spans from there, though this doesn't feel too likely. I'd like deleting
it more.

---------

Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
2023-04-03 13:08:29 -07:00
Nitesh S f7d74f5daa
convert gwt tests from groovy to java (#8201)
Related to #7195
2023-04-03 11:30:33 -07:00
Lauri Tulmin 1393604118
Add option to capture logback key value pairs (#8074)
Resolves
https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/8059
2023-04-03 11:30:04 -07:00
Trask Stalnaker b01996e12f
Rename apache-pulsar to pulsar and apache-camel to camel (#8195)
Closes #8004
2023-04-03 11:26:23 -07:00
Nitesh S 8704510619
convert spark tests from groovy to java (#8200)
Related to #7195
2023-04-03 13:38:02 +02:00
pellmont 5db149e1fa
fix order of cxf handlers to enable symmetric tracing around jaxws handler chain (#8160)
the current implementation of Start and End around the invocation of a
Jax WS is asymmetric around the JAX-WS Handler Chain.

Current behavior:
(execution of incoming MessageHandlers) -> (TracingStartInInterceptor)
-> (WebService Invocation) -> (execution of outgoing MessageHandlers) ->
(TracingEndInInterceptor)

if I understood the code of this cxf instrumentation correctly, the
intent was to build the span close around the WebService Invocation
(without Handler Chains).

So the desired behavior would look like this:
(execution of incoming MessageHandlers) -> (TracingStartInInterceptor)
-> (WebService Invocation) -> (TracingEndInInterceptor) -> (execution of
outgoing MessageHandlers)

Unfortunately CXF is calling the Outgoing Chain inside the POST_INVOKE
Phase of Cxf (so the outgoing chain is technically a sub-chain in the
incoming chain... which is documented but quite surprising...).

So the solution in the fix at least guarantees the the outgoing chain is
invoked AFTER end of tracing. For any extra Interceptors in the
POST_INVOKE Phase there is still no guarantee of ordering, but I think
this is not a opentelemetry issue but a design-flaw of CXF...

---------

Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
Co-authored-by: Lauri Tulmin <ltulmin@splunk.com>
2023-04-03 13:06:51 +03:00
Lauri Tulmin 8c7a8e1dfb
Fix flaky jfr metrics test (#8183)
https://ge.opentelemetry.io/s/svewzdm7cppaa/tests/:instrumentation:runtime-telemetry-jfr:library:testPS/io.opentelemetry.instrumentation.runtimetelemetryjfr.PsGcMemoryMetricTest/shouldHaveGcDurationMetrics()?top-execution=1
2023-04-03 11:48:46 +02:00
Trask Stalnaker 70cd8464e2
Fix possible NPE (#8199)
this is a follow-up to #7043

I tried to add a test when that PR was opened:

*
d2c6399a6e

but it doesn't really verify anything, since the NPE is throw/caught and
same behavior occurs
2023-04-03 09:24:14 +02:00
Mateusz Rzeszutek 46e5219f19
Remove some Optional usages (#8190)
I applied [this
comment](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/8131#discussion_r1151076724)
to the whole codebase and removed some `Optional`s that were used in the
hot path
2023-04-03 09:13:59 +02:00
adamleantech d6271cccc7
Spring boot service name (#8006)
resolves #7998

---------

Co-authored-by: Mateusz Rzeszutek <mrzeszutek@splunk.com>
Co-authored-by: Lauri Tulmin <ltulmin@splunk.com>
2023-04-01 18:58:43 -07:00
Lauri Tulmin a9905a22ca
Fix hibernate 6 latest dep test (#8189) 2023-03-31 15:39:02 +03:00
Lauri Tulmin 5a14788fc1
Use .service instead of .getService() to get testcontainersBuildService (#8188) 2023-03-31 08:32:24 +00:00
Lauri Tulmin 9e0d177d88
Add testcontainersBuildService to r2dbc tests (#8184) 2023-03-31 10:31:48 +02:00
Lauri Tulmin d007ccce82
Rename r2dbc library instrumentation package (#8185)
Library instrumentation shouldn't be in `javaagent` package
2023-03-31 10:31:25 +02:00
Lauri Tulmin a9fa5aacea
Add testcontainersBuildService to spring kafka tests that don't have it (#8186) 2023-03-31 10:26:06 +02:00
Lauri Tulmin d8b0771929
Use the same kafka docker image in all kafka tests (#8187)
currently we use `confluentinc/cp-kafka:5.4.3` and
`confluentinc/cp-kafka:6.1.9`
2023-03-31 10:25:38 +02:00
Abhinandan Seshadri b23af1bcfe
Convert spring-core tests from groovy to java (#8166)
Related to #7195.

Converts spring core instrumentation tests from groovy to java.

---------

Co-authored-by: Mateusz Rzeszutek <mrzeszutek@splunk.com>
2023-03-31 10:09:31 +02:00
Jean Bisutti c5ef8ffd60
Add GraalVM native tests (#8163)
This PR allows:
* Executing the OTel Logback appender tests as GraalVM native
executables
* Executing the native tests once a day on Github

---------

Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
2023-03-30 14:10:48 -07:00
Nitesh S 2d8ba003e3
convert Log4j mdc test from groovy to java (#8170)
Related to #7195
2023-03-30 17:31:51 +02:00
Lauri Tulmin 1adc5d3571
Instrument addition pulsar receive methods (#8171)
Resolves
https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/8162
Instrument Consumer#receiveAsync() and Consumer#receive(). Although
comments in code indicate that batch receiving was instrumented it
didn't really work as far as I can tell.
2023-03-30 16:30:12 +03:00
Lauri Tulmin f624562705
Remove info logging from JfrTelemetry (#8158) 2023-03-29 11:41:56 -07:00
Lauri Tulmin aceb5b2ee9
Disable jfr telemetry test on openj9 (#8161) 2023-03-29 10:51:08 +00:00
Lauri Tulmin f0749de66f
Disable JfrTelemetryTest when JFR is not present (#8159) 2023-03-29 11:02:05 +02:00
Lauri Tulmin 0638f983a6
Fix jfr metrics on openj9 and aws-sdk muzzle failure (#8157)
Resolves
https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/8156
Resolves
https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/8155
2023-03-29 10:49:17 +03:00
Robert Toyonaga 03b983ad41
Add JFR streaming metrics gatherer (#7886) 2023-03-28 20:26:08 -07:00
Nitesh S cfc0ff71dc
Convert Geode test from Groovy to Java (#8141)
Related to #7195 

Converts Geode test from Groovy to Java.
2023-03-28 13:39:57 +02:00
Mateusz Rzeszutek 07335c807c
Add `classLoaderOptimization()` to `@WithSpan` instrumentations (#7996) 2023-03-28 12:34:30 +02:00
Lauri Tulmin d24d7986ad
Make spring boot service name detector handle BOOT-INF/classes (#8101)
When spring boot application is packaged in one jar
`application.properties` and `application.yml` are under
`BOOT-INF/classes/`.
2023-03-28 12:32:40 +02:00
Abhinandan Seshadri aa2c2436c2
Convert spring-data tests from groovy to java (#8124)
Related to #7195.

Converts spring data instrumentation tests from groovy to java.
2023-03-27 13:58:15 +02:00
Lauri Tulmin 8deaaaedbf
Avoid duplicate instrumentation in jdk http client sendAsyncMethod (#8127)
There are 2 `sendAsync` methods
https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.html#sendAsync(java.net.http.HttpRequest,java.net.http.HttpResponse.BodyHandler)
and one of them calls the other.
2023-03-25 13:08:40 +02:00
Lauri Tulmin 178bfd4856
Add http client metrics to apache http library instrumentation (#8128) 2023-03-24 14:36:18 +01:00
Phil a6bc3b197d
Add R2dbc statement javaagent instrumentation (#7977)
This PR resolves #2515 .
It adds javaagent instrumentation for
[r2dbc-spi](https://github.com/r2dbc/r2dbc-spi) >= v1.0

As suggested by @mp911de in
https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/2515#issuecomment-1141723561
I used the [r2dbc-proxy](https://github.com/r2dbc/r2dbc-proxy)
`ProxyConnectionFactory` to intercept Database query executions and
create according spans.

Example span from example project using
[spring-boot-starter-data-r2dbc](https://github.com/spring-projects/spring-data-relational)
Application:

![r2dbc-example](https://user-images.githubusercontent.com/39240633/222902361-a3878ecd-a8d0-4d33-b0c0-e410d908e05e.png)

---------

Co-authored-by: Lauri Tulmin <ltulmin@splunk.com>
2023-03-23 12:52:53 +01:00
Lauri Tulmin bd3117b165
Fix flaky spring rabbit test (#8015)
https://ge.opentelemetry.io/scans/tests?search.buildOutcome=success&search.relativeStartTime=P28D&search.tags=CI&search.timeZoneId=Europe/Tallinn&tests.container=ContextPropagationTest&tests.sortField=FLAKY&tests.test=should%20propagate%20context%20to%20consumer%2C%20test%20headers:%20true&tests.unstableOnly=true
On jdk8 we can have 2 spans starting on the same millisecond.
2023-03-23 13:50:55 +02:00
Ago Allikmaa e466dc439a
Add HttpServerResponseCustomizer support for Servlet and Jetty (#8095)
Add `HttpServerResponseCustomizer` support for Servlet 2.2/3.0/5.0 and
Jetty 8/11 instrumentations. Enabled testing for it in JaxRs tests as
well since those should now all be covered due to servlet
instrumentations. Fixed Jetty 11 test source set directory name.

Known limitation - response headers do not work on Jetty 8 for internal
exception pages caused by throwing an exception that is handled outside
of instrumentation scope, working around this would require an
additional instrumentation and/or keeping an expired `Context` instance
referenced by the response object. This does not appear to be an issue
on Jetty 11. Additionally, calling `ServletResponse#reset` can wipe
headers as well, for which there is no workaround (yet?) in this PR.
2023-03-23 12:01:07 +01:00
Ago Allikmaa 079e0faa2d
Add HttpServerResponseCustomizer support for Netty (#8094)
Add `HttpServerResponseCustomizer` support for Netty 3.8, 4.0 and 4.1
instrumentations and enable testing for it in their respective
`HttpServerTest` tests.
2023-03-23 11:11:24 +01:00
Shelby Huang 2ebed6c466
Fix the shardingsphere display the error tag #8109 (#8110)
Adding shardingsphere related classes to the
`JdbcIgnoredTypesConfigurer` allows the actual execution of the
statement to be captured
2023-03-23 09:19:20 +01:00
Lauri Tulmin eac75a1d0b
Prefix baggage key not value when adding it to logback mdc (#8066) 2023-03-22 13:14:10 +01:00
Lauri Tulmin b110a38d81
Remove unneeded dependsOn (#8067)
Should have been removed with test sets to test suites migration. There
already is
```
tasks {
  check {
    dependsOn(testing.suites)
  }
}
```
2023-03-22 13:00:34 +01:00
Lauri Tulmin 4a87d6b0fd
Remove reference to Tracer bean from javadoc (#8104) 2023-03-22 12:59:51 +01:00