All Downloads are FREE. Search and download functionalities are using the official Maven repository.

zipkin2.internal.V1JsonSpanWriter Maven / Gradle / Ivy

There is a newer version: 3.4.2
Show newest version
/*
 * Copyright The OpenZipkin Authors
 * SPDX-License-Identifier: Apache-2.0
 */
package zipkin2.internal;

import zipkin2.Span;
import zipkin2.v1.V1Span;
import zipkin2.v1.V2SpanConverter;

/** This type isn't thread-safe: it re-uses state to avoid re-allocations in conversion loops. */
// @Immutable
public final class V1JsonSpanWriter implements WriteBuffer.Writer {
  final V2SpanConverter converter = V2SpanConverter.create();
  final V1SpanWriter v1SpanWriter = new V1SpanWriter();

  @Override public int sizeInBytes(Span value) {
    V1Span v1Span = converter.convert(value);
    return v1SpanWriter.sizeInBytes(v1Span);
  }

  @Override public void write(Span value, WriteBuffer b) {
    V1Span v1Span = converter.convert(value);
    v1SpanWriter.write(v1Span, b);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy