🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

com.serviceenabled:dropwizard-request-tracker

Package Overview
Dependencies
Maintainers
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

com.serviceenabled:dropwizard-request-tracker

Track service requests through multiple hops using a UUID

Source
mavenMaven
Version
2.0.0
Version published
Maintainers
4
Source

dropwizard-request-tracker

Track service requests through multiple hops using a UUID.

Build Status

Description

This project uses servlet filters, Jersey client filters, and Logback's MDC to keep track of an ID through multiple hops. The servlet and client filters will intercept a request and automatically generate an ID if none exists. The client filter adds the ID as a request header. The servlet filter intercepts the ID.

There's a Dropwizard bundle that will add in the servlet filter for you. Jersey client filters have to be manually added to your client classes.

Integrating with existing dropwizard project

Add the following dependency into your pom.xml

<dependency>
    <groupId>com.serviceenabled</groupId>
    <artifactId>dropwizard-request-tracker</artifactId>
    <version>0.2.0</version>
</dependency>

Add RequestTrackerConfiguration into your application's configuration class.

public class ExampleConfiguration extends Configuration {

    private RequestTrackerConfiguration requestTrackerConfiguration = new RequestTrackerConfiguration();

    public RequestTrackerConfiguration getRequestTrackerConfiguration() {
        return requestTrackerConfiguration;
    }

    public void setRequestTrackerConfiguration(RequestTrackerConfiguration configuration) {
        this.requestTrackerConfiguration = configuration;
    }
}

Add the RequestTrackerBundle to your application

bootstrap.addBundle(new RequestTrackerBundle<ExampleConfiguration>() {
    @Override
    public RequestTrackerConfiguration getRequestTrackerConfiguration(BundleConfiguration configuration) {
        return configuration.getRequestTrackerConfiguration();
    }
});

Add the client filter to your client classes

client.addFilter(new RequestTrackerClientFilter(configuration.getRequestTrackerConfiguration()));

If you'd like the ID to be output in your logs, add %X{Request-Tracker} to your logFormat.

and mvn clean install

Defaults

The RequestTrackerConfiguration sets the HTTP header name to X-Request-Tracker and the MDC key to Request-Tracker by default. These can be overridden in your YAML configuration.

By default UuidSupplier is used by the bundle and filters. The provided bundle and filters provide constructors for you to pass in your own custom ID supplier. Your custom ID supplier must implement Guava's Supplier<String>. Here's an example ID supplier:

import com.google.common.base.Supplier;

public class CustomIdSupplier implements Supplier<String> {
	@Override
	public String get() {
		return "12345";
	}
}

License

MIT

FAQs

Package last updated on 10 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts