Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Add jaeger-client module #479

Merged
merged 1 commit into from
Jul 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ Please see [CONTRIBUTING.md](CONTRIBUTING.md).

Click through for more detailed docs on specific modules.

* [jaeger-client](./jaeger-client): the module that instrumented applications should usually include
* [jaeger-core](./jaeger-core): the core implementation of the OpenTracing API [![Java Docs][javadoc-badge]][javadoc]
* [jaeger-thrift](./jaeger-thrift): the main dependency to include in your project, sending data to the backend using Thrift (default)
* [jaeger-thrift](./jaeger-thrift): set of components that send data to the backend

## Add-on Modules

Expand All @@ -34,16 +35,17 @@ Follow these [instructions][sonatype-snapshot-instructions] to add the snapshot

**Please use the latest version:** [![Released Version][maven-img]][maven]

In the usual case, you just need to include the dependency with the concrete components sending data to the backend. Currently,
the only such dependency is `jaeger-thrift`. It transitively brings the `jaeger-core` dependency.
In the usual case, you just need to include the following dependency to your project:
```xml
<dependency>
<groupId>io.jaegertracing</groupId>
<artifactId>jaeger-thrift</artifactId>
<artifactId>jaeger-client</artifactId>
<version>$jaegerVersion</version>
</dependency>
```

This will bring a concrete sender, such as `jaeger-thrift`, as well as the `jaeger-tracerresolver` and `jaeger-core`.

### Thrift version conflicts
The Jaeger Java Client uses `org.apache.thrift:libthrift:0.11.0`. By default, declaring a dependency on the
`jaeger-thrift` module will bring a shaded version of Thrift (and others), making it safe to use your own versions of
Expand Down
28 changes: 28 additions & 0 deletions jaeger-client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[![Released Version][maven-img]][maven]

# Client
This module brings the necessary modules in order for an instrumented application to start
capturing spans. It currently brings:

* `jaeger-core`
* `jaeger-thrift`
* `jaeger-tracerresolver`

With this set, an instrumented application using OpenTracing's TracerResolver can just use
the Jaeger Java Client without any hard code dependency, configuring it via environment variables.

This set might change without warning in the future, so, this module is suitable only for applications
with a simple usage of the Jaeger Tracer. If you require access to classes inside any of those modules,
make sure to add such module as a direct dependency to your module.

## Maven coordinates
```xml
<dependency>
<groupId>io.jaegertracing</groupId>
<artifactId>jaeger-client</artifactId>
<version>$jaegerVersion</version>
</dependency>
```

[maven-img]: https://img.shields.io/maven-central/v/io.jaegertracing/jaeger-client.svg?maxAge=2000
[maven]: http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22io.jaegertracing%22%20a%3A%22jaeger-client%22
15 changes: 15 additions & 0 deletions jaeger-client/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
description = 'Convenience module to be used by instrumented applications'

dependencies {
// otherwise, we get the non-shaded version, which will fail at runtime due to missing classes
compile group: 'io.jaegertracing', name: 'jaeger-thrift', version: developmentVersion

// for the other projects, we can add the dependency on the projects themselves
compile project(':jaeger-core')
compile project(':jaeger-thrift')
compile project(':jaeger-tracerresolver')

testCompile group: 'junit', name: 'junit', version: junitVersion
testCompile group: 'org.apache.thrift', name: 'libthrift', version: apacheThriftVersion
testCompile group: 'com.squareup.okhttp3', name: 'okhttp', version: okhttpVersion
}
32 changes: 32 additions & 0 deletions jaeger-client/src/main/java/io/jaegertracing/client/Version.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2018, The Jaeger Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/

package io.jaegertracing.client;

import io.jaegertracing.internal.JaegerTracer;

/**
* Exposes the Jaeger Client version to consuming applications.
*/
public class Version {
private Version() {
}

/**
* @return the version string for the Jaeger Client, like "0.30.1"
*/
public static String get() {
return JaegerTracer.getVersionFromProperties();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2018, The Jaeger Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/

package io.jaegertracing.client;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;

import io.jaegertracing.Configuration;
import io.jaegertracing.internal.JaegerTracer;
import org.junit.Test;

public class VersionTest {

@Test
public void testVersionGet() {
assertEquals(
"Version should be the same as the properties file",
JaegerTracer.getVersionFromProperties(),
Version.get()
);

assertNotEquals(
"The version from the tracer should not be the same string as Version.get()",
new Configuration("testVersionGet").getTracer().getVersion(),
Version.get()
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,10 @@ public static String checkValidServiceName(String serviceName) {
}

private static String loadVersion() {
return "Java-" + getVersionFromProperties();
}

public static String getVersionFromProperties() {
String version;
try {
InputStream is = JaegerTracer.class.getResourceAsStream("jaeger.properties");
Expand All @@ -616,7 +620,7 @@ private static String loadVersion() {
if (version == null) {
throw new RuntimeException("Cannot read " + Constants.JAEGER_CLIENT_VERSION_TAG_KEY + " from jaeger.properties");
}
return "Java-" + version;
return version;
}

String getHostName() {
Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ include 'jaeger-crossdock'
include 'jaeger-thrift'
include 'jaeger-tracerresolver'
include 'jaeger-micrometer'
include 'jaeger-client'