opentelemetry-java-instrume.../instrumentation/okhttp/okhttp-3.0/library
Trask Stalnaker 1077258263
Add InternalJavadoc custom error prone check (#5277)
* Add InternalJavadoc custom error prone check

* Add example usage

* Move to conventions

* Revert "Move to conventions"

This reverts commit d8a8209b59.

* Just get it working

* Clearer error message

* versions

* Apply almost everywhere

* feedback

* Always at the end of javadoc

* Fix test

* Missed (at least) one

* No longer internal

* Fix NPE

* Spotless

* Convert awslambda Java test to JUnit 5 so can reduce visibility

* Reduce visibility

* Rename the check

* More

* Move into errorprone-convention

* Fix UserExcludedClassesConfigurerTest
2022-02-01 17:54:57 -08:00
..
src Add InternalJavadoc custom error prone check (#5277) 2022-02-01 17:54:57 -08:00
README.md rename `newBuilder()` to `builder()` (#4475) 2021-10-22 20:50:43 -07:00
build.gradle.kts Add Android API-friendliness checks (#4505) 2021-11-24 12:59:11 -08:00

README.md

Manual Instrumentation for OkHttp3 version 3.0.0+

Provides OpenTelemetry instrumentation for okhttp3.

Quickstart

Add these dependencies to your project:

Replace OPENTELEMETRY_VERSION with the latest stable release. Minimum version: 1.5.0

For Maven, add to your pom.xml dependencies:


<dependencies>
  <dependency>
    <groupId>io.opentelemetry.instrumentation</groupId>
    <artifactId>opentelemetry-okhttp-3.0</artifactId>
    <version>OPENTELEMETRY_VERSION</version>
  </dependency>
</dependencies>

For Gradle, add to your dependencies:

implementation("io.opentelemetry.instrumentation:opentelemetry-okhttp-3.0:OPENTELEMETRY_VERSION")

Usage

The instrumentation library provides an OkHttp Call.Factory implementation that wraps an instance of the OkHttpClient to provide OpenTelemetry-based spans and context propagation.

import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.instrumentation.okhttp.v3_0.OkHttpTracing;
import okhttp3.Call;
import okhttp3.OkHttpClient;

import java.util.concurrent.ExecutorService;

public class OkHttpConfiguration {

  //Use this Call.Factory implementation for making standard http client calls.
  public Call.Factory createTracedClient(OpenTelemetry openTelemetry) {
    return OkHttpTracing.builder(openTelemetry).build().newCallFactory(createClient());
  }

  //your configuration of the OkHttpClient goes here:
  private OkHttpClient createClient() {
    return new OkHttpClient.Builder().build();
  }
}