Skip to content

Commit

Permalink
updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Shashi Ranjan committed Jun 24, 2015
1 parent ffa9a9b commit 8f90c6d
Showing 1 changed file with 42 additions and 88 deletions.
130 changes: 42 additions & 88 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
# Mashape Analytics Java Agent

> for more information on Mashape Analytics, please visit [apianalytics.com](https://www.apianalytics.com)
Java Agent to report HTTP traffic to [MashapeAPI Analytics](https://www.apianalytics.com/) using [API Log Format](https://github.com/Mashape/api-log-format/).Analytics Java Agent is a custom servlet filter which intercepts the request and response and sends it to API Analytics server asynchronously to generate analytics information. It needs a web container to run, to send data from a app running in Java SE environment please use our standalone proxy or use one of our data collection APIs.
## About

The agent is a custom servlet filter which intercepts the request and response and sends it to API Analytics server asynchronously to generate analytics information. It needs a web container to run, to send data from a app running in Java SE environment please use our standalone proxy or use one of our data collection APIs.

## Installation
## Dependencies


### With Maven
- `javax.servlet-api-3.0.1`
- `jeromq-0.3.4`
- `gson-1.2.17`
- `log4j-1.2.17`
- `guava-14.0.1`

### Testing Dependencies

- `jmockit-1.7`
- `junit-4.12`
- `unirest-java-1.4.5`
- Jetty

*see [pom.xml](https://github.com/Mashape/analytics-agent-java/blob/master/pom.xml#L48-L117) for dependencies*

## Installation

### With Maven

```xml
<dependency>
Expand All @@ -20,96 +37,27 @@ Java Agent to report HTTP traffic to [MashapeAPI Analytics](https://www.apianaly

### Without Maven

- Download the [jar](https://oss.sonatype.org/content/repositories/releases/com/mashape/analytics/agent/analytics-java-agent/)
- clone from [Github](https://github.com/Mashape/analytics-agent-java)


Application depends on `javax.servlet-api-3.0.1`, `jeromq-0.3.4`, `gson-1.2.17`, `log4j-1.2.17` and `guava-14.0.1`. For testing it depends on `jmockit-1.7`, `junit-4.12`, `unirest-java-1.4.5` and embedded Jetty

You can download the analytics jar from: <https://oss.sonatype.org/content/repositories/releases/com/mashape/analytics/agent/mashape-analytics/1.0.0/mashape-analytics-1.0.0.jar>
or clone the project from github: <https://github.com/Mashape/analytics-agent-java>

Dependencies

```xml
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.zeromq</groupId>
<artifactId>jeromq</artifactId>
<version>0.3.4</version>
</dependency>
<dependency>
<artifactId>guava</artifactId>
<groupId>com.google.guava</groupId>
<type>jar</type>
<version>14.0.1</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>com.googlecode.jmockit</groupId>
<artifactId>jmockit</artifactId>
<version>1.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>9.3.0.M1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>9.3.0.M1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.mashape.unirest</groupId>
<artifactId>unirest-java</artifactId>
<version>1.4.5</version>
<scope>test</scope>
</dependency>
```


## Configuration for Server
## Usage

Filter has been tested on tomcat and should work with Jetty, Jboss and other servers supporting http servlet api.
To use the filter you would need to add Analytics filter to web descriptor and set few VM arguments in the server.

Add following arguments to the server

Property | Value
-------- | ------
analytics.token | Api analytics token from https://analytics.mashape.com
analytics.socket.min |Minimum number of threads/sockets to opened for connection to analytics server, default is 10
analytics.socket.max | Maximum number of threads/sockets allowed to live in pool, default is 20
analytics.socket.keepalivetime | When the number of threads are greater than the min, this is the maximum time in second that excess idle threads will wait for new tasks before terminating. Default is 30 seconds.
analytics.queue.size | Size of the queue for holding the tasks of transferring data to analytics server, default is 100
analytics.enabled.flag | Set it true to enable analytics
analytics.environment | Server environment name, default is a empty string
Update web.xml on server
| Property | Value | Default |
| --------------------------------- | --------------------------------------------------------------------------------- | ------- |
| `analytics.token` | Mashape Analytics Access Token | `-` |
| `analytics.socket.min` | Minimum number of threads/sockets to opened for connection to analytics server | `10` |
| `analytics.socket.max` | Maximum number of threads/sockets allowed to live in pool | `20` |
| `analytics.socket.keepalivetime` | When the number of threads are greater than the min, this is the maximum time that excess idle threads will wait for new tasks before terminating | `-` |
| `analytics.queue.size` | Size of the queue for holding the tasks of transferring data to analytics server | `100` |
| `analytics.enabled.flag` | Set to `true` to enable analytics | `-` |
| `analytics.environment` | Server environment name | `""` |
Update `web.xml`:

```xml
<filter>
Expand All @@ -121,11 +69,17 @@ Update web.xml on server
</init-param>
<init-param>
<param-name>analytics.server.port</param-name>
<param-value>5000</param-value>
<param-value>5500</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>apianalytics-filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
```

## Copyright and license

Copyright Mashape Inc, 2015.

Licensed under [the MIT License](https://github.com/mashape/analytics-agent-java/blob/master/LICENSE)

0 comments on commit 8f90c6d

Please sign in to comment.