Liking cljdoc? Tell your friends :D

Dropwizard Hystrix Tracker

Build Status Coverage Status Apache V2 License Clojars Project

A Bundle that can be used to track API-Paths / Resources

A precompiled bundle for tracking/monitoring your favourite API-Paths/Resources.
There are 2 features here:

  1. Client Restriction for certain API Paths within your Resource - using annotation @ClientRestriction
  2. Hystrix tracking of APIs - using annotation @TrackPath

Usage

Build instructions

  • Cloning source code:

    git clone github.com/Tushar-Naik/dropwizard-hystrix-tracker.git
    
  • Building code

    mvn install
    

Repository

<repository>
    <id>clojars</id>
    <name>Clojars repository</name>
    <url>https://clojars.org/repo</url>
</repository>

Maven Dependency

  • Use the following maven dependency for path tracker:
<dependency>
    <groupId>io.dropwizard.tracker</groupId>
    <artifactId>dropwizard-hystrix-path-tracker</artifactId>
    <version>1.3.12-1</version>
</dependency>
  • Use the following maven dependency for client filter:
<dependency>
    <groupId>io.dropwizard.tracker</groupId>
    <artifactId>dropwizard-client-filter</artifactId>
    <version>1.3.12-1</version>
</dependency>

1. Using Path Tracker Bundle

Use this to track a particular API endpoint.
Hystrix metrics will be emitted based on the name of the API.

Bootstrap

    @Override
    public void initialize(final Bootstrap...) {
        bootstrap.addBundle(new TrackerBundle());
    }

Tracking your Resource

@Path("/service/v1")
@Slf4j
public class MyResource{
    
    @Path("/api1")
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @TrackPath("/service/*")
    public Response getResponse() {
        ...    
    }
    ...
}

alt tag

2. Using Client Restriction Bundle

Depending on the ClientFilterConfig provided,
if a Resource Path is marked with the annotation @ClientRestriction,
API will return a STATUS:403 FORBIDDEN if header in the incoming Request is not present,
or does not match the ones present in ClientFilterConfig.validClients

Bootstrap

    @Override
    public void initialize(final Bootstrap<XYZConfiguration> bootstrap) {
        bootstrap.addBundle(new ClientFilterBundle<XYZConfiguration>() {
                    @Override
                    public ClientFilterConfig getClientFilterConfig(XYZConfiguration xYZConfiguration) {
                        return xYZConfiguration.getClientFilterConfig();
                    }
                });
    }

Adding client header restriction for a resource

@Path("/service/v1")
@Slf4j
public class MyResource{
    
    @Path("/api/{path}/search")
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @ClientRestriction
    public Response getResponse() {
        ...    
    }
    ...
}

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close