Search in sources :

Example 1 with ResourceLogsMarshaler

use of io.opentelemetry.exporter.internal.otlp.logs.ResourceLogsMarshaler in project opentelemetry-java by open-telemetry.

the class OtlpJsonLoggingLogExporter method export.

@Override
public CompletableResultCode export(Collection<LogData> logs) {
    ResourceLogsMarshaler[] allResourceLogs = ResourceLogsMarshaler.create(logs);
    for (ResourceLogsMarshaler resourceLogs : allResourceLogs) {
        SegmentedStringWriter sw = new SegmentedStringWriter(JSON_FACTORY._getBufferRecycler());
        try (JsonGenerator gen = JsonUtil.create(sw)) {
            resourceLogs.writeJsonTo(gen);
        } catch (IOException e) {
            // Shouldn't happen in practice, just skip it.
            continue;
        }
        logger.log(Level.INFO, sw.getAndClear());
    }
    return CompletableResultCode.ofSuccess();
}
Also used : JsonGenerator(com.fasterxml.jackson.core.JsonGenerator) ResourceLogsMarshaler(io.opentelemetry.exporter.internal.otlp.logs.ResourceLogsMarshaler) IOException(java.io.IOException) SegmentedStringWriter(com.fasterxml.jackson.core.io.SegmentedStringWriter)

Aggregations

JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)1 SegmentedStringWriter (com.fasterxml.jackson.core.io.SegmentedStringWriter)1 ResourceLogsMarshaler (io.opentelemetry.exporter.internal.otlp.logs.ResourceLogsMarshaler)1 IOException (java.io.IOException)1