Correlation ids for Dropwizard applications. They are useful to match requests between different components.
X-Correlation-Id
.correlationId
.This project is available in the Central Repository. To add it to your project simply add the following dependency to your POM:
<dependency>
<groupId>org.dhatim</groupId>
<artifactId>dropwizard-correlation-id</artifactId>
<version>4.0.0</version>
</dependency>
The default values are as follows:
correlationId:
headerName: X-Correlation-Id
mdcKey: correlationId
Without configuration:
public void initialize(Bootstrap<MyApplicationConfiguration> bootstrap) {
bootstrap.addBundle(CorrelationIdBundle.getDefault());
}
With configuration:
public void initialize(Bootstrap<MyApplicationConfiguration> bootstrap) {
bootstrap.addBundle(CorrelationIdBundle.withConfigurationSupplier(MyAppConfiguration::getCorrelationId));
}
Just register the provided filter into your Jersey client:
JerseyClientBuilder builder = new JerseyClientBuilder(...)...;
Client client = builder.build(...);
client.register(new CorrelationIdClientFilter(configuration));
If configuration
is omitted, default values apply.
Replace your HttpClientBuilder
by CorrelationIdHttpClientBuilder
this way:
HttpClientBuilder builder = new CorrelationIdHttpClientBuilder(..., configuration)...;
CloseableHttpClient cient = builder.build(...);
If configuration
is omitted, default values apply.
Please file bug reports and feature requests in GitHub issues.