Skip to content

Commit

Permalink
Merge pull request #44 from zalando/feature/docker-generator
Browse files Browse the repository at this point in the history
Added phrase generator implementation
  • Loading branch information
AlexanderYastrebov authored Jun 23, 2016
2 parents 20bfc4a + 05c9e9f commit 3ae8eee
Show file tree
Hide file tree
Showing 5 changed files with 530 additions and 16 deletions.
32 changes: 19 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![Release](https://img.shields.io/github/release/zalando/tracer.svg)](https://github.com/zalando/tracer/releases)
[![Maven Central](https://img.shields.io/maven-central/v/org.zalando/tracer-parent.svg)](https://maven-badges.herokuapp.com/maven-central/org.zalando/tracer-parent)

*Tracer* is a library that manages custom trace identifiers and carries them through distributed systems. Traditionally traces are transported as custom HTTP headers, usually generated by clients on the very first request. Traces are added to any subsequent requests and responses, especially to transitive dependencies. Having a consistent trace across different services in a system allows to correlate requests and responses beyond the traditional single client-server communication.
*Tracer* is a library that manages custom trace identifiers and carries them through distributed systems. Traditionally traces are transported as custom HTTP headers, usually generated by clients on the very first request. Traces are added to any subsequent requests and responses, especially to transitive dependencies. Having a consistent trace across different services in a system allows to correlate requests and responses beyond the traditional single client-server communication.

This library historically originates from a closed-source implementation called *Flow-ID*. The goal was to create a clean open source version in which we could get rid of all the drawbacks of the old implementation, e.g. strong-coupling to internal libraries, single hard-coded header and limited testability.

Expand Down Expand Up @@ -93,6 +93,12 @@ Tracer tracer = Tracer.builder()

For legacy reasons we use a different generator internally, the `FlowIDGenerator`. It basically renders a UUID as a base64-encoded byte array, e.g. `REcCvlqMSReeo7adheiYFA`.

There is also `PhraseGenerator` provided which generates over 10^9 different phrases like:

tender_goodall_likes_evil_panini
nostalgic_boyd_helps_agitated_noyce
pensive_allen_tells_fervent_einstein

### Listeners

For some use cases, e.g. integration with other frameworks and libraries, it might be useful to register a listener that gets notified every time a trace is either started or stopped.
Expand Down Expand Up @@ -129,7 +135,7 @@ You have to register the `TracerFilter` as a `Filter` in your filter chain:

```java
context.addFilter("TracerFilter", new TracerFilter(tracer))
.addMappingForUrlPatterns(EnumSet.of(REQUEST, ASYNC, ERROR), true, "/*");
.addMappingForUrlPatterns(EnumSet.of(REQUEST, ASYNC, ERROR), true, "/*");
```

## Apache HTTP Client
Expand Down Expand Up @@ -178,16 +184,16 @@ try {

Tracer comes with a convenient auto configuration for Spring Boot users that sets up aspect, servlet filter and MDC support automatically with sensible defaults:

| Configuration | Description | Default |
|-----------------------------|------------------------------------------------------------------------------------|-----------------------------|
| `tracer.aspect.enabled` | Enables the [`TracedAspect`](#aspect) | `true` |
| `tracer.async.enabled` | Enables for asynchronous tasks, i.e. `@Async` | `true` |
| `tracer.filter.enabled` | Enables the [`TracerFilter`](#servlet) | `true` |
| `tracer.logging.enabled` | Enables the [`LoggingTraceListener`](#logging) | `false` |
| `tracer.logging.category` | Changes the category of the [`LoggingTraceListener`](#logging) | `org.zalando.tracer.Tracer` |
| `tracer.mdc.enabled` | Enables the [`MdcTraceListener`](#logging) | `true` |
| `tracer.scheduling.enabled` | Enables support for Task Scheduling, i.e. `@Scheduled` | `true` |
| `tracer.traces` | Configures actual traces, mapping from name to generator type (`uuid` or`flow-id`) | |
| Configuration | Description | Default |
|-----------------------------|-----------------------------------------------------------------------------------------------|-----------------------------|
| `tracer.aspect.enabled` | Enables the [`TracedAspect`](#aspect) | `true` |
| `tracer.async.enabled` | Enables for asynchronous tasks, i.e. `@Async` | `true` |
| `tracer.filter.enabled` | Enables the [`TracerFilter`](#servlet) | `true` |
| `tracer.logging.enabled` | Enables the [`LoggingTraceListener`](#logging) | `false` |
| `tracer.logging.category` | Changes the category of the [`LoggingTraceListener`](#logging) | `org.zalando.tracer.Tracer` |
| `tracer.mdc.enabled` | Enables the [`MdcTraceListener`](#logging) | `true` |
| `tracer.scheduling.enabled` | Enables support for Task Scheduling, i.e. `@Scheduled` | `true` |
| `tracer.traces` | Configures actual traces, mapping from name to generator type (`uuid`, `flow-id` or `phrase`) | |

```yaml
tracer:
Expand All @@ -206,7 +212,7 @@ tracer:
The `TracerAutoConfiguration` will automatically pick up any `TraceListener` bound in the application context.

**Be aware**: The TracerAutoConfiguration will, as long as `tracer.async.enabled` is set to `true`, register a
**Be aware**: The TracerAutoConfiguration will, as long as `tracer.async.enabled` is set to `true`, register a
`AsyncConfigurer` and Spring only allows one per Application Context. If this turns out to be a problem please disable
the async support and configure it manually. Let us know if you think this needs to be improved.

Expand Down
Loading

0 comments on commit 3ae8eee

Please sign in to comment.