Remove accidentally duped jsongenerator class (#2449)

This commit is contained in:
Anuraag Agrawal 2021-01-08 03:44:09 +09:00 committed by GitHub
parent 80aea4d0b4
commit 32d4715f74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 0 additions and 38 deletions

View File

@ -7,10 +7,8 @@ package io.opentelemetry.exporter.logging.otlp;
import static io.opentelemetry.exporter.logging.otlp.HexEncodingStringJsonGenerator.JSON_FACTORY;
import com.fasterxml.jackson.core.Base64Variant;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.io.SegmentedStringWriter;
import com.fasterxml.jackson.core.util.JsonGeneratorDelegate;
import io.opentelemetry.proto.metrics.v1.ResourceMetrics;
import io.opentelemetry.sdk.common.CompletableResultCode;
import io.opentelemetry.sdk.extension.otproto.MetricAdapter;
@ -70,40 +68,4 @@ public class OtlpJsonLoggingMetricExporter implements MetricExporter {
public CompletableResultCode shutdown() {
return CompletableResultCode.ofSuccess();
}
private static final class HexEncodingStringJsonGenerator extends JsonGeneratorDelegate {
static JsonGenerator create(SegmentedStringWriter stringWriter) {
final JsonGenerator delegate;
try {
delegate = JSON_FACTORY.createGenerator(stringWriter);
} catch (IOException e) {
throw new IllegalStateException(
"Unable to create in-memory JsonGenerator, can't happen.", e);
}
return new HexEncodingStringJsonGenerator(delegate);
}
private HexEncodingStringJsonGenerator(JsonGenerator delegate) {
super(delegate);
}
@Override
public void writeBinary(Base64Variant b64variant, byte[] data, int offset, int len)
throws IOException {
writeString(bytesToHex(data, offset, len));
}
private static final char[] HEX_ARRAY = "0123456789abcdef".toCharArray();
private static String bytesToHex(byte[] bytes, int offset, int len) {
char[] hexChars = new char[len * 2];
for (int i = 0; i < len; i++) {
int v = bytes[offset + i] & 0xFF;
hexChars[i * 2] = HEX_ARRAY[v >>> 4];
hexChars[i * 2 + 1] = HEX_ARRAY[v & 0x0F];
}
return new String(hexChars);
}
}
}