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

Commit

Permalink
Implement TracerFactory
Browse files Browse the repository at this point in the history
Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
  • Loading branch information
jpkrohling committed Aug 21, 2018
1 parent 4934922 commit 120d833
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ext.apacheThriftVersion = getProperty('apacheThriftVersion','0.11.0')
ext.jerseyVersion = getProperty('jerseyVersion','2.22.2')
ext.slf4jVersion = getProperty('slf4jVersion','1.7.25')
ext.gsonVersion = getProperty('gsonVersion','2.8.2')
ext.tracerResolverVersion = getProperty('tracerResolverVersion','0.1.4')
ext.tracerResolverVersion = getProperty('tracerResolverVersion','0.1.5')
ext.micrometerVersion = getProperty('micrometerVersion','1.0.0')
ext.okhttpVersion = getProperty('okhttpVersion','3.9.0')

Expand Down
5 changes: 2 additions & 3 deletions jaeger-tracerresolver/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Jaeger Tracer Resolver

This module provides a Jaeger implementation for the [TracerResolver](https://github.com/opentracing-contrib/java-tracerresolver). This mechanism provides a vendor neutral approach for obtaining a `Tracer` using the JDK
`ServiceLoader`.

This module provides a Jaeger implementation for the [TracerResolver](https://github.com/opentracing-contrib/java-tracerresolver).
This mechanism provides a vendor neutral approach for obtaining a `Tracer` using the JDK `ServiceLoader`.

## Maven Dependency
```xml
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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.tracerresolver.internal;

import io.jaegertracing.Configuration;
import io.jaegertracing.internal.JaegerTracer;
import io.opentracing.Tracer;
import io.opentracing.contrib.tracerresolver.TracerFactory;

public class JaegerTracerFactory implements TracerFactory {
@Override
public Tracer getTracer() {
return getJaegerTracer();
}

public JaegerTracer getJaegerTracer() {
return Configuration.fromEnv().getTracer();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@

package io.jaegertracing.tracerresolver.internal;

import io.jaegertracing.Configuration;
import io.jaegertracing.internal.JaegerTracer;
import io.opentracing.contrib.tracerresolver.TracerResolver;

public class JaegerTracerResolver extends TracerResolver {

@Override
protected JaegerTracer resolve() {
return Configuration.fromEnv().getTracer();
return new JaegerTracerFactory().getJaegerTracer();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
io.jaegertracing.tracerresolver.internal.JaegerTracerFactory
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@
import io.jaegertracing.Configuration;
import io.jaegertracing.internal.JaegerTracer;
import io.opentracing.Tracer;
import io.opentracing.contrib.tracerresolver.TracerFactory;
import io.opentracing.contrib.tracerresolver.TracerResolver;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.util.ServiceLoader;

public class JaegerTracerResolverTest {

@Before
Expand All @@ -48,4 +51,12 @@ public void testResolveTracerDefault() {
assertTrue(tracer instanceof JaegerTracer);
}

@Test
public void canFindTracerFactory() {
System.setProperty(Configuration.JAEGER_SERVICE_NAME, "canFindTracerFactory");
Tracer tracer = ServiceLoader.load(TracerFactory.class).iterator().next().getTracer();
assertNotNull(tracer);
assertTrue(tracer instanceof JaegerTracer);
}

}

0 comments on commit 120d833

Please sign in to comment.