-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds ability to specify zipkin http path relative to host (#80)
- Loading branch information
1 parent
caf771a
commit 0197e96
Showing
6 changed files
with
152 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright 2016-2020 The OpenZipkin 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 zipkin.http; | ||
|
||
import com.twitter.app.Flag; | ||
import com.twitter.app.Flaggable; | ||
import com.twitter.app.JavaGlobalFlag; | ||
|
||
public final class path$ extends JavaGlobalFlag<String> { | ||
public static String DEFAULT_PATH = "/api/v2/spans"; | ||
|
||
private path$() { | ||
super(DEFAULT_PATH, | ||
"The path to the spans endpoint", | ||
Flaggable.ofString()); | ||
} | ||
|
||
public static final Flag<String> Flag = new path$(); | ||
|
||
public static Flag<?> globalFlagInstance() { | ||
return Flag; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright 2016-2020 The OpenZipkin 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 zipkin.http; | ||
|
||
import com.twitter.app.Flag; | ||
import com.twitter.app.GlobalFlag$; | ||
import java.util.Collection; | ||
import java.util.concurrent.atomic.AtomicBoolean; | ||
import org.junit.After; | ||
import org.junit.Test; | ||
import scala.Function0; | ||
import scala.Option; | ||
import scala.runtime.AbstractFunction0; | ||
import scala.runtime.BoxedUnit; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static scala.collection.JavaConverters.asJavaCollection; | ||
|
||
public class pathTest { | ||
|
||
@After public void resetGlobalFlags() { | ||
for (Flag<?> globalFlag: globalFlags()) globalFlag.reset(); | ||
} | ||
|
||
@Test public void defaultValue() { | ||
Option<Flag<?>> flagOption = GlobalFlag$.MODULE$.get("zipkin.http.path"); | ||
assertThat(flagOption.get().apply()).isEqualTo("/api/v2/spans"); | ||
} | ||
|
||
@Test public void letOverridesDefault() { | ||
final String override = "/custom/api/v2/spans"; | ||
|
||
final AtomicBoolean ran = new AtomicBoolean(); | ||
Function0<BoxedUnit> fn0 = new AbstractFunction0<BoxedUnit>() { | ||
@Override public BoxedUnit apply() { | ||
ran.set(true); // used to verify this block is executed. | ||
assertThat(path$.Flag.isDefined()).isTrue(); | ||
assertThat(path$.Flag.apply()).isEqualTo(override); | ||
return BoxedUnit.UNIT; | ||
} | ||
}; | ||
path$.Flag.let(override, fn0); | ||
|
||
assertThat(ran.get()).isTrue(); | ||
} | ||
|
||
@Test | ||
public void registersGlobal() { | ||
assertThat(globalFlags()) | ||
.extracting(f -> f.name()) | ||
.containsOnlyOnce("zipkin.http.path"); | ||
} | ||
|
||
Collection<Flag<?>> globalFlags() { | ||
return asJavaCollection(GlobalFlag$.MODULE$.getAll(getClass().getClassLoader())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters