Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependency io.zipkin.reporter2:zipkin-sender-okhttp3 to v3 - autoclosed #748

Closed

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Jan 31, 2024

Mend Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
io.zipkin.reporter2:zipkin-sender-okhttp3 2.17.2 -> 3.3.0 age adoption passing confidence

Release Notes

openzipkin/zipkin-reporter-java (io.zipkin.reporter2:zipkin-sender-okhttp3)

v3.3.0: Zipkin Reporter 3.3

Compare Source

Zipkin Reporter 3.3 adds a BaseHttpSender type, which eases http library integration. It also adds HttpEndpointSupplier which supports dynamic endpoint discovery such as from Eureka, as well utilities to create constants or rate-limit suppliers. Finally, brave users get a native PROTO3 encoder through the new MutableSpanBytesEncoder type.

These features were made in support of spring-boot, but available to any user with no new dependencies. For example, the PROTO encoder adds no library dependency, even if it increases the size of zipkin-reporter-brave by a couple dozen KB. A lion's share of thanks goes to @​reta and @​anuraaga who were on design and review duty for several days leading to this.

Here's an example of pulling most of these things together, integrating a sender with spring-cloud-loadbalancer (a client-side loadbalancer library).

This endpoint supplier will get the configuration endpoint value and look up the next target to use with the loadBalancerClient. The rate limiter will ensure a gap of 30 seconds between queries. While below is hard-coded, it covers some routine advanced features formerly only available in spring-cloud-sleuth. Now, anyone can use them!

@​Configuration(proxyBeanMethods = false)
public class ZipkinDiscoveryConfiguration {
  @​Bean HttpEndpointSupplier.Factory loadbalancerEndpoints(LoadBalancerClient loadBalancerClient) {
    LoadBalancerHttpEndpointSupplier.Factory httpEndpointSupplierFactory =
        new LoadBalancerHttpEndpointSupplier.Factory(loadBalancerClient);
    // don't ask more than 30 seconds (just to show)
    return HttpEndpointSuppliers.newRateLimitedFactory(httpEndpointSupplierFactory, 30);
  }

  record LoadBalancerHttpEndpointSupplier(LoadBalancerClient loadBalancerClient, URI virtualURL)
      implements HttpEndpointSupplier {
    record Factory(LoadBalancerClient loadBalancerClient) implements HttpEndpointSupplier.Factory {

      @​Override public HttpEndpointSupplier create(String endpoint) {
        return new LoadBalancerHttpEndpointSupplier(loadBalancerClient, URI.create(endpoint));
      }
    }

    @​Override public String get() {
      ServiceInstance instance = loadBalancerClient.choose(virtualURL.getHost());
      if (instance != null) {
        return instance.getUri() + virtualURL.getPath();
      }
      throw new IllegalArgumentException(virtualURL.getHost() + " is not registered");
    }

    @​Override public void close() {
    }

    @​Override public String toString() {
      return "LoadBalancer{" + virtualURL + "}";
    }
  }
}

Full Changelog: https://github.com/openzipkin/zipkin-reporter-java/compare/3.2.1..3.3.0

v3.2.1: Zipkin Reporter 3.2

Compare Source

Zipkin Reporter 3.2 deprecates Sender for a simpler type BytesMessageSender. This only supports synchronous invocation (as used by the async reporters in the reporting thread) and requires senders to pass an empty list vs a complicated and usually implemented check() function. The result is being able to implement a custom sender in less than 50 lines including imports like below! Thank a lot to @​anuraaga and @​reta for the review on this.

package brave.example;

import com.linecorp.armeria.client.WebClient;
import com.linecorp.armeria.common.AggregatedHttpResponse;
import com.linecorp.armeria.common.HttpData;
import com.linecorp.armeria.common.HttpMethod;
import com.linecorp.armeria.common.HttpRequest;
import com.linecorp.armeria.common.MediaType;
import java.io.IOException;
import java.util.List;
import zipkin2.reporter.BytesMessageEncoder;
import zipkin2.reporter.BytesMessageSender;
import zipkin2.reporter.ClosedSenderException;
import zipkin2.reporter.Encoding;

final class WebClientSender extends BytesMessageSender.Base {
  final WebClient zipkinApiV2SpansClient;
  volatile boolean closeCalled; // volatile as not called from the reporting thread.

  WebClientSender(WebClient zipkinApiV2SpansClient) {
    super(Encoding.JSON);
    this.zipkinApiV2SpansClient = zipkinApiV2SpansClient;
  }

  @​Override public int messageMaxBytes() {
    return 500_000; // Use the most common HTTP default
  }

  @&#8203;Override public void send(List<byte[]> encodedSpans) throws IOException {
    if (closeCalled) throw new ClosedSenderException();
    byte[] body = BytesMessageEncoder.JSON.encode(encodedSpans);
    HttpRequest request =
        HttpRequest.of(HttpMethod.POST, "", MediaType.JSON, HttpData.wrap(body));
    AggregatedHttpResponse response = zipkinApiV2SpansClient.blocking().execute(request);
    try (HttpData content = response.content()) {
      if (!response.status().isSuccess()) {
        if (content.isEmpty()) {
          throw new IOException("response failed: " + response);
        }
        throw new IOException("response failed: " + content.toStringAscii());
      }
    }
  }

  @&#8203;Override public void close() {
    closeCalled = true;
  }

Full Changelog: https://github.com/openzipkin/zipkin-reporter-java/compare/3.1.1..3.2.1

v3.2.0

Compare Source

v3.1.1: Zipkin Reporter 3.1

Compare Source

Zipkin Reporter 3.1 adds custom encoding (non-JSON) support for zipkin-reporter-brave's AsyncZipkinSpanHandler.

This was first used in encoder-stackdriver-brave) to allow traced apps to send spans to stackdriver without a zipkin core jar dependency

spanHandler = AsyncZipkinSpanHandler.newBuilder(sender).build(new StackdriverV2Encoder(Tags.ERROR));

Full Changelog: openzipkin/zipkin-reporter-java@3.0.1...3.1.1

v3.1.0

Compare Source

v3.0.2

Compare Source

v3.0.1: Zipkin Reporter 3.0.1

Compare Source

Zipkin Reporter 3.0.1 fixes a problem where classpath scanners such as spring would trigger a zipkin2.Span class load on AsyncZipkinSpanHandler in zipkin-reporter-brave, which intentionally has no dependency on that.

v3.0.0: Zipkin Reporter 3.0.0

Compare Source

Zipkin Reporter 3.0.0 makes the io.zipkin.zipkin2:zipkin dependency of io.zipkin.reporter2:zipkin-reporter-brave optional. This means those using the AsyncZipkinSpanHandler will have no dependencies except any sender they configure. In particular, this allows those using Brave for things besides zipkin (e.g. wavefront) to avoid a dependency. Also, those sending spans zipkin have simpler dependency configuration and save a couple hundred KB, as well.

Those using types from the core io.zipkin.reporter2:zipkin-reporter artifact should depend on this directly, possibly using our bom to align deps. io.zipkin.reporter2:zipkin-reporter still defaults to depend on io.zipkin.zipkin2:zipkin, but it can be excluded if you know what you are doing.

Technically, some base classes to accommodate this, but they don't have affect on call sites except those implementing a custom Reporter or Sender. Due to these type changes, this is a major version change. However, must users will have a drop-in experience, except possibly dependency configuration changes.

Thanks a lot to @​anuraaga and @​reta who helped think through this!


Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Mend Renovate. View repository job log here.

@renovate renovate bot requested review from a team as code owners January 31, 2024 16:46
@renovate renovate bot force-pushed the renovate/io.zipkin.reporter2-zipkin-sender-okhttp3-3.x branch from 2fe2bc0 to 9172d2c Compare February 14, 2024 13:15
@renovate renovate bot changed the title Update dependency io.zipkin.reporter2:zipkin-sender-okhttp3 to v3 Update dependency io.zipkin.reporter2:zipkin-sender-okhttp3 to v3 - autoclosed Feb 15, 2024
@renovate renovate bot closed this Feb 15, 2024
@renovate renovate bot deleted the renovate/io.zipkin.reporter2-zipkin-sender-okhttp3-3.x branch February 15, 2024 16:21
@github-actions github-actions bot locked and limited conversation to collaborators Feb 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants