Skip to content

Commit

Permalink
Bring zipkin-finagle up to date
Browse files Browse the repository at this point in the history
Signed-off-by: Andriy Redko <drreta@gmail.com>
  • Loading branch information
reta committed Jun 20, 2024
1 parent 1bbe014 commit ba7f141
Show file tree
Hide file tree
Showing 62 changed files with 243 additions and 183 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ on:

jobs:
test:
runs-on: ubuntu-20.04 # newest available distribution, aka focal
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'maven-release-plugin')"
steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup java
uses: actions/setup-java@v4
with:
fetch-depth: 0 # full git history for license check
distribution: 'zulu' # zulu as it supports a wide version range
java-version: 17
- name: Cache local Maven repository
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
Expand Down
2 changes: 1 addition & 1 deletion .settings.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2016-2020 The OpenZipkin Authors
Copyright 2016-2024 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
Expand Down
4 changes: 4 additions & 0 deletions build-bin/configure_deploy
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/sh -ue
#
# Copyright The OpenZipkin Authors
# SPDX-License-Identifier: Apache-2.0
#

# This script sets up anything needed for `./deploy`. Do not assume `configure_test` was called.
#
Expand Down
4 changes: 4 additions & 0 deletions build-bin/configure_test
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/sh -ue
#
# Copyright The OpenZipkin Authors
# SPDX-License-Identifier: Apache-2.0
#

# This script sets up anything needed for `./test`. This should not login to anything, as that
# should be done in `configure_deploy`.
Expand Down
4 changes: 4 additions & 0 deletions build-bin/deploy
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/sh -ue
#
# Copyright The OpenZipkin Authors
# SPDX-License-Identifier: Apache-2.0
#

# This script deploys a master or release version.
#
Expand Down
2 changes: 1 addition & 1 deletion build-bin/git/login_git
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright 2016-2020 The OpenZipkin Authors
# Copyright 2016-2024 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
Expand Down
2 changes: 1 addition & 1 deletion build-bin/git/version_from_trigger_tag
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright 2016-2020 The OpenZipkin Authors
# Copyright 2016-2024 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
Expand Down
2 changes: 1 addition & 1 deletion build-bin/gpg/configure_gpg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright 2016-2020 The OpenZipkin Authors
# Copyright 2016-2024 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
Expand Down
2 changes: 1 addition & 1 deletion build-bin/maven/maven_deploy
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright 2016-2020 The OpenZipkin Authors
# Copyright 2016-2024 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
Expand Down
2 changes: 1 addition & 1 deletion build-bin/maven/maven_go_offline
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright 2016-2020 The OpenZipkin Authors
# Copyright 2016-2024 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
Expand Down
2 changes: 1 addition & 1 deletion build-bin/maven/maven_opts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright 2016-2020 The OpenZipkin Authors
# Copyright 2016-2024 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
Expand Down
2 changes: 1 addition & 1 deletion build-bin/maven/maven_release
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright 2016-2020 The OpenZipkin Authors
# Copyright 2016-2024 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
Expand Down
4 changes: 4 additions & 0 deletions build-bin/test
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/sh -ue
#
# Copyright The OpenZipkin Authors
# SPDX-License-Identifier: Apache-2.0
#

# This script runs the tests of the project.
#
Expand Down
10 changes: 5 additions & 5 deletions core/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2016-2022 The OpenZipkin Authors
Copyright 2016-2024 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
Expand All @@ -19,12 +19,12 @@

<parent>
<groupId>io.zipkin.finagle2</groupId>
<artifactId>zipkin-finagle-parent_2.12</artifactId>
<version>22.4.0</version>
<artifactId>zipkin-finagle-parent_2.13</artifactId>
<version>23.0.0</version>
</parent>

<artifactId>zipkin-finagle_2.12</artifactId>
<version>22.4.0</version>
<artifactId>zipkin-finagle_2.13</artifactId>
<version>23.0.0</version>
<name>Zipkin Finagle: Core</name>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/zipkin/initialSampleRate$.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2021 The OpenZipkin Authors
* Copyright 2016-2024 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
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/zipkin/localServiceName$.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2021 The OpenZipkin Authors
* Copyright 2016-2024 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
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/zipkin2/finagle/Endpoints.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2021 The OpenZipkin Authors
* Copyright 2016-2024 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
Expand Down
19 changes: 4 additions & 15 deletions core/src/main/java/zipkin2/finagle/FinagleSender.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 The OpenZipkin Authors
* Copyright 2016-2024 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
Expand All @@ -18,13 +18,12 @@
import com.twitter.util.Future;
import com.twitter.util.Try;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import scala.runtime.AbstractFunction1;
import scala.runtime.BoxedUnit;
import zipkin2.Call;
import zipkin2.Callback;
import zipkin2.CheckResult;
import zipkin2.reporter.Callback;
import zipkin2.reporter.Call;
import zipkin2.reporter.BytesMessageSender;
import zipkin2.reporter.Sender;

/** Receives the Finagle generated traces and sends them off. */
Expand All @@ -50,16 +49,6 @@ protected FinagleSender(C config) {

protected abstract Req makeRequest(List<byte[]> spans) throws Exception;

/** sends an empty message to the configured host. */
@Override public CheckResult check() {
try {
sendSpans(Collections.emptyList()).execute();
return CheckResult.OK;
} catch (Exception e) {
return CheckResult.failed(e);
}
}

@Override public void close() {
closeFuture();
}
Expand Down
3 changes: 1 addition & 2 deletions core/src/main/java/zipkin2/finagle/MutableSpan.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 The OpenZipkin Authors
* Copyright 2016-2024 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
Expand All @@ -25,7 +25,6 @@
import zipkin2.v1.V1Span;

import static com.twitter.finagle.thrift.thrift.Constants.CLIENT_RECV;
import static com.twitter.finagle.thrift.thrift.Constants.CLIENT_SEND;
import static com.twitter.finagle.thrift.thrift.Constants.SERVER_SEND;

final class MutableSpan {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 The OpenZipkin Authors
* Copyright 2016-2024 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
Expand All @@ -20,7 +20,6 @@
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicLong;
import scala.collection.Seq;
import scala.collection.immutable.Seq$;
import zipkin2.reporter.ReporterMetrics;

public final class ReporterMetricsAdapter implements ReporterMetrics {
Expand Down Expand Up @@ -58,7 +57,7 @@ public static ReporterMetrics create(StatsReceiver stats) {
Seq<String> causes = Throwables.mkString(cause);

// Manually implement inits() as Traversable was replaced with Iterable in 2.13
messagesDropped.counter(Seq$.MODULE$.empty()).incr();
messagesDropped.counter().incr();
int causeCount = causes.size();
for (int i = 1; i <= causeCount; i++) {
messagesDropped.counter(causes.slice(0, i).toSeq()).incr();
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/zipkin2/finagle/SpanRecorder.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2021 The OpenZipkin Authors
* Copyright 2016-2024 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
Expand Down
14 changes: 11 additions & 3 deletions core/src/main/java/zipkin2/finagle/ZipkinTracer.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2021 The OpenZipkin Authors
* Copyright 2016-2024 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
Expand Down Expand Up @@ -128,7 +128,7 @@ protected ZipkinTracer(Sender sender, Config config, StatsReceiver stats) {
}

ZipkinTracer(Reporter<Span> reporter, Config config, StatsReceiver stats) {
this(reporter, new RawZipkinTracer(reporter, stats, config.localServiceName()), config);
this(reporter, new RawZipkinTracer(reporter, stats, config.localServiceName(), config.initialSampleRate()), config);
}

private ZipkinTracer(Reporter<Span> reporter, RawZipkinTracer underlying, Config config) {
Expand Down Expand Up @@ -176,13 +176,16 @@ protected interface Config {

static final class RawZipkinTracer implements Tracer {
private final SpanRecorder recorder;
private final float sampleRate;

/**
* @param stats We generate stats to keep track of traces sent, failures and so on
* @param sampleRate
*/
RawZipkinTracer(Reporter<Span> reporter, StatsReceiver stats, String localServiceName) {
RawZipkinTracer(Reporter<Span> reporter, StatsReceiver stats, String localServiceName, float sampleRate) {
this.recorder =
new SpanRecorder(reporter, stats, DefaultTimer.getInstance(), localServiceName);
this.sampleRate = sampleRate;
}

@Override public Option<Object> sampleTrace(TraceId traceId) {
Expand All @@ -204,6 +207,11 @@ static final class RawZipkinTracer implements Tracer {
@Override public void record(Record record) {
recorder.record(record);
}

@Override
public float getSampleRate() {
return sampleRate;
}
}

public static final class Builder {
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/java/zipkin/initialSampleRateTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2021 The OpenZipkin Authors
* Copyright 2016-2024 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
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/java/zipkin/localServiceNameTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2021 The OpenZipkin Authors
* Copyright 2016-2024 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
Expand Down
17 changes: 5 additions & 12 deletions core/src/test/java/zipkin2/finagle/FakeSender.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2021 The OpenZipkin Authors
* Copyright 2016-2024 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
Expand All @@ -16,18 +16,16 @@
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import zipkin2.Call;
import zipkin2.CheckResult;
import zipkin2.Span;
import zipkin2.codec.BytesDecoder;
import zipkin2.codec.BytesEncoder;
import zipkin2.codec.Encoding;
import zipkin2.codec.SpanBytesDecoder;
import zipkin2.codec.SpanBytesEncoder;
import zipkin2.reporter.BytesMessageEncoder;
import zipkin2.reporter.Sender;
import zipkin2.reporter.BytesMessageSender;
import zipkin2.reporter.Encoding;

public final class FakeSender extends Sender {
public final class FakeSender implements BytesMessageSender {
static FakeSender create() {
return new FakeSender(
Encoding.THRIFT,
Expand Down Expand Up @@ -93,17 +91,12 @@ FakeSender onSpans(Consumer<List<Span>> onSpans) {
/** close is typically called from a different thread */
volatile boolean closeCalled;

@Override public Call<Void> sendSpans(List<byte[]> encodedSpans) {
@Override public void send(List<byte[]> encodedSpans) {
if (closeCalled) throw new IllegalStateException("closed");
List<Span> decoded = encodedSpans.stream()
.map(decoder::decodeOne)
.collect(Collectors.toList());
onSpans.accept(decoded);
return Call.create(null);
}

@Override public CheckResult check() {
return CheckResult.OK;
}

@Override public void close() {
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/java/zipkin2/finagle/FinagleTestObjects.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 The OpenZipkin Authors
* Copyright 2016-2024 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
Expand Down
Loading

0 comments on commit ba7f141

Please sign in to comment.