Sends tracing information about Apache HttpClient calls to Sentry:
- Creates a http.client span that shows the HTTP method and the full target URL
- Adds a breadcrumb containing the HTTP URL, HTTP method and the HTTP response status code
- Includes Sentry trace and baggage headers to requests made with Apache HttpClient
- Supports version 4 and version 5 of Apache HttpClient
- Easy to use
- Well documented with Javadoc
You need to provide your Apache HTTP Client 4 or 5 dependency on your own like this. For example for Apache HttpClient 4:
Maven
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.14</version>
</dependency>
Groovy
implementation 'org.apache.httpcomponents:httpclient:4.5.14'
Kotlin
implementation("org.apache.httpcomponents:httpclient:4.5.14")
or Apache HttpClient 5:
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>5.2.1</version>
</dependency>
Groovy
implementation 'org.apache.httpcomponents.client5:httpclient5:5.2.1'
Kotlin
implementation("org.apache.httpcomponents.client5:httpclient5:5.2.1")
Then include the dependency
Maven
<dependency>
<groupId>org.drjekyll</groupId>
<artifactId>sentry-http-interceptors</artifactId>
<version>6.28.0</version>
</dependency>
Groovy
implementation 'org.drjekyll:sentry-http-interceptors:6.28.0'
Kotlin
implementation("org.drjekyll:sentry-http-interceptors:6.28.0")
Run your build tool and add the interceptors like in the following example:
Apache Http Client 5:
CloseableHttpClient client=HttpClientBuilder.create()
.addRequestInterceptorFirst(new SentryHttpRequestInterceptor(HubAdapter.getInstance()))
.addResponseInterceptorLast(new SentryHttpResponseInterceptor(HubAdapter.getInstance()))
.build();
Apache Http Client 4:
CloseableHttpClient client=HttpClientBuilder.create()
.addInterceptorFirst(new SentryHttpRequestInterceptor(HubAdapter.getInstance()))
.addResponseInterceptorLast(new SentryHttpResponseInterceptor(HubAdapter.getInstance()))
.build();
After that the requests will be traced by Sentry, if Sentry is correctly configured in your application.
To build and locally install the library and run the tests, just call
mvn install
Please read the contribution document for details on our code of conduct, and the process for submitting pull requests to us.
We use SemVer for versioning. For the versions available, see the tags on this repository.
This project is licensed under the LGPL License - see the license file for details.
Added support for Apache HttpClient versions 4 and 5 simultaneously.
Using Apache HttpClient version 5 now. Java 11 is required.
Upgrade dependencies
Use Sentry version number to let consumer find the correct version more easily
Dependency updates
First public version