Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:katharsis-project/katharsis-fram…
Browse files Browse the repository at this point in the history
…ework into develop
  • Loading branch information
chb0github committed Nov 14, 2016
2 parents 1f04312 + e689445 commit 348949e
Show file tree
Hide file tree
Showing 177 changed files with 7,518 additions and 2,665 deletions.
14 changes: 7 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Contributing to the katharsis project, and to any open-source project for that m
Reporting Bugs & Requesting for Features
=========================

Before you raise a new issue you must be able to narrow it down to a minimal test case against a clean code base that can be used for reproduction when submitting the issue. And, naturally, to make sure it's not an "undiscovered fearture" on your side :). Once you have a reproducable case in a clean code base please check the list of [project issues](https://github.com/katharsis-project/katharsis-framework/issues). There may already be a discussion in progress that you can contribute to or at least follow for a resolution. You should also ask in [gitter](https://gitter.im/katharsis-project) first. However, if you have discovered an issue then please follow these rules:
Before you raise a new issue you must be able to narrow it down to a minimal test case against a clean code base that can be used for reproduction when submitting the issue. And, naturally, to make sure it's not an "undiscovered feature" on your side :). Once you have a reproducable case in a clean code base please check the list of [project issues](https://github.com/katharsis-project/katharsis-framework/issues). There may already be a discussion in progress that you can contribute to or at least follow for a resolution. You should also ask in [gitter](https://gitter.im/katharsis-project) first. However, if you have discovered an issue then please follow these rules:

1. Include **version of katharsis** you are using
2. Use labels to tell us in which **module** problem occures
2. Use labels to tell us in which **module** problem occurs
3. Wait for **feedback** from our developers in response to your issue. We are volunteers so please be patient.
4. Make a coffee and feel proud of yourself (or tea, or whatever the hot relaxing beverage in your part of the world is)!

Expand All @@ -17,10 +17,10 @@ Fixing Bugs & Extending the Library

So you have added a feature to a library or you have created something new. Maybe you just have some bit of code that you use all the time in your projects and now you want to give that to the community and let them enjoy the same benefits you have? Great! This is how open source projects begin, grow, thrive and reach new users. Here is how to proceed with a pull request:

1. [Fork katharsis-framework](https://github.com/katharsis-project/katharsis-framework/edit/develop/CONTRIBUTING.md#fork-destination-box) repository
2. Implement your new feature or fix on branch `development`
1. [Fork katharsis-framework](https://github.com/katharsis-project/katharsis-framework#fork-destination-box) repository
2. Implement your new feature or fix on branch `develop`
3. Don't forget to **update or add unit tests** and ensure they are passing
4. Submit a pull request to be merged in the `development` of original repo. In your PR please refer to the issue number. Remember, enchancements are "issues" too.
4. Submit a pull request to be merged in the `develop` of original repo. In your PR please refer to the issue number. Remember, enhancements are "issues" too.
5. Your code will be reviewed by at least **two people** from our developers community
6. Wait for **feedback** and in next release you may see your code working on production

Expand All @@ -29,7 +29,7 @@ Join the Conversation

Katharsis gives you a number of ways to discuss features, express concerns or just chat about the project with other people just like you. Feel free to chat with us on [gitter](https://gitter.im/katharsis-project/katharsis-framework) or if your question is strictly involving usage of katharsis create new question on [StackOverflow](http://stackoverflow.com/questions/tagged/katharsis)

Other Ways to Contibute
Other Ways to Contribute
======================

You don't necessarily have to write code to contribute. Telling someone in an effective way what a project is for and how to use it is just as important as providing the code for them to use. And it doesn't end there. From helping to maintain infrastructure to event planning, projects need help in many areas beyond the code.
Expand All @@ -47,7 +47,7 @@ Developer Setup
General Guidelines
===========================
* **Code style.** Cyclomatic complexity must be kept down as well.
this can be done in a variety of ways, but, for example, agressive pre-condition checking will eliminate branching.
this can be done in a variety of ways, but, for example, aggressive pre-condition checking will eliminate branching.

== example: ==

Expand Down
127 changes: 127 additions & 0 deletions katharsis-brave/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.katharsis</groupId>
<artifactId>katharsis-parent</artifactId>
<version>2.8.2-SNAPSHOT</version>
<relativePath>../katharsis-parent</relativePath>
</parent>

<artifactId>katharsis-brave</artifactId>
<packaging>bundle</packaging>
<name>katharsis-brave</name>

<properties>
<brave.version>3.14.1</brave.version>
<jersey.version>2.17</jersey.version>
<javax.ws.rs-api.version>2.0.1</javax.ws.rs-api.version>
<guava.version>15.0</guava.version>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.github.danielflower.mavenplugins</groupId>
<artifactId>gitlog-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Export-Package>io.katharsis.brave.*</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>


<dependencies>
<dependency>
<groupId>io.katharsis</groupId>
<artifactId>katharsis-core</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>io.katharsis</groupId>
<artifactId>katharsis-client</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-okhttp</artifactId>
<version>${brave.version}</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>

<!-- Test Dependencies -->
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<optional>true</optional>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.katharsis</groupId>
<artifactId>katharsis-rs</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>${javax.ws.rs-api.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-grizzly2-http</artifactId>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-grizzly2</artifactId>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.glassfish.jersey.test-framework</groupId>
<artifactId>jersey-test-framework-core</artifactId>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
94 changes: 94 additions & 0 deletions katharsis-brave/src/main/java/io/katharsis/brave/BraveModule.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package io.katharsis.brave;

import com.github.kristofa.brave.Brave;
import com.github.kristofa.brave.BraveExecutorService;
import com.github.kristofa.brave.okhttp.BraveTracingInterceptor;
import com.github.kristofa.brave.okhttp.BraveTracingInterceptor.Builder;

import io.katharsis.brave.internal.BraveRepositoryFilter;
import io.katharsis.client.http.HttpAdapter;
import io.katharsis.client.http.okhttp.OkHttpAdapter;
import io.katharsis.client.http.okhttp.OkHttpAdapterListener;
import io.katharsis.client.module.HttpAdapterAware;
import io.katharsis.module.Module;
import okhttp3.Dispatcher;

/**
* Integrates Brave into katharsis client and server:
*
* <ul>
* <li>On the client-side all requests are traced with the brave-okhttp implementation.</li>
* <li>
* On the server-side all the repository accesses are traced. Keep in mind that a single HTTP request
* can trigger multiple repository accesses if the request contains an inclusion of relations.
* Note that no HTTP calls itself are traced by this module. That is the responsibility of the
* web container and Brave.
* </li>
* </ul>
*/
public class BraveModule implements Module, HttpAdapterAware, OkHttpAdapterListener {

private Brave brave;

private boolean server;

private BraveModule(Brave brave, boolean server) {
this.brave = brave;
this.server = server;
}

public static BraveModule newClientModule(Brave brave) {
return new BraveModule(brave, false);
}

public static BraveModule newServerModule(Brave brave) {
return new BraveModule(brave, true);
}

@Override
public String getModuleName() {
return "brave";
}

@Override
public void setupModule(ModuleContext context) {
// nothing to do
if (server) {
BraveRepositoryFilter filter = new BraveRepositoryFilter(brave, context);
context.addRepositoryFilter(filter);
}
}

@Override
public void setHttpAdapter(HttpAdapter adapter) {
if (!(adapter instanceof OkHttpAdapter)) {
throw new IllegalStateException(adapter.getClass() + " not supported yet");
}
OkHttpAdapter okHttpAdapter = (OkHttpAdapter) adapter;
okHttpAdapter.addListener(this);
}

@Override
public void onBuild(okhttp3.OkHttpClient.Builder builder) {
BraveTracingInterceptor interceptor = buildInterceptor();

BraveExecutorService tracePropagatingExecutor = buildExecutor(builder);

builder.addInterceptor(interceptor);
builder.addNetworkInterceptor(interceptor);
builder.dispatcher(new Dispatcher(tracePropagatingExecutor));
}

protected BraveExecutorService buildExecutor(okhttp3.OkHttpClient.Builder builder) {
return new BraveExecutorService(new Dispatcher().executorService(), brave.serverSpanThreadBinder());
}

protected BraveTracingInterceptor buildInterceptor() {
Builder tracingBuilder = BraveTracingInterceptor.builder(brave);
return tracingBuilder.build();
}

public Brave getBrave() {
return brave;
}
}
Loading

0 comments on commit 348949e

Please sign in to comment.