com.undefinedlabs.scope.rules.propagation.carriers.RequestBuilderInjectAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scope-rule-okhttp3 Show documentation
Show all versions of scope-rule-okhttp3 Show documentation
Scope is a APM for tests to give engineering teams unprecedented visibility into their CI process to quickly
identify, troubleshoot and fix failed builds.
This artifact contains the classes to instrument OkHttp3 library.
package com.undefinedlabs.scope.rules.propagation.carriers;
import io.opentracing.propagation.TextMap;
import java.util.Iterator;
import java.util.Map;
import okhttp3.Request;
import org.apache.commons.lang3.StringUtils;
public class RequestBuilderInjectAdapter implements TextMap {
private final Request.Builder requestBuilder;
public RequestBuilderInjectAdapter(final Request.Builder request) {
requestBuilder = request;
}
@Override
public Iterator> iterator() {
throw new UnsupportedOperationException("Should be used only with tracer#inject()");
}
@Override
public void put(final String key, final String value) {
if (StringUtils.isNotEmpty(value)) {
requestBuilder.addHeader(key, value);
}
}
}