Interface JsonLogConverter
- All Superinterfaces:
AutoCloseable
Test utility class which converts JSON in a logger, emitted by the OpenTelemetry
logger_otlp exporter,
into the more convenient JsonLogConverterImpl.LogResourceScopeSpans and
related structures for ease of checking the exported tracing information.
To use this class:
- Set up test configuration similar to this:
Using
telemetry: service: "otel-config-example" signals: tracing: processors: - type: simple exporters: - type: logging_otlpprocessors.type: simpleavoids batching of span data so span data becomes accessible more quickly, and usingexporters.type: logging_otlpdirects the span data to the JUL logger as JSON text. - Invoke the static
create()method on this type (ideally in a try-with-resource block). - Execute test code that causes OTel to create one or more spans
- Invoke the instance
resourceSpans(int)method to wait for and retrieve the expected number of spans.
The OTel io.opentelemetry.exporter.internal.otlp.traces.ResourceSpansMarshaler class organizes the log data into
the JSON structure outlined below. This Javadoc excludes some elements that might appear in the log that this test utility
class does not support.
The logging-otlp exporter seems to emit a JSON block--and therefore this class creates a LogResourceScopeSpans
instance--for each tracing span.
resource(seeio.opentelemetry.exporter.internal.otlp.ResourceMarshaler)attributesarray (seeio.opentelemetry.exporter.internal.otlp.KeyValueMarshaler)Various marshalers (some private to
KeyValueMarshalerdeal with their respective datatypes:stringValueboolValueintValuedoubleValue
scopeSpans(seeio.opentelemetry.exporter.internal.otlp.traces.InstrumentationScopeSpansMarshalerscopenameattributesarray (see above)
spansarray (again, some potential items might appear that this class does not currently support)traceIdspanIdparentSpanIdnamekind(an integer)startTimeUnixNanosendTimeUnixNanosattributesarray (as above)
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceTop-level resource data for emitted span data.static interfaceTop-level aggregation of resource and scope-spans information.static interfaceInformation about a "log scope" in the emitted span data.static interfaceCombined scope and spans information.static interfaceInformation describing a specific span. -
Method Summary
Modifier and TypeMethodDescriptionstatic JsonLogConvertercreate()Creates an instance of the converter that captures spans reported by OTel.resourceSpans(int expectedCount) ReturnsJsonLogConverterImpl.LogResourceScopeSpansinstances corresponding to the data emitted by the log exporter.Methods inherited from interface java.lang.AutoCloseable
close
-
Method Details
-
create
Creates an instance of the converter that captures spans reported by OTel.- Returns:
- new
JsonLogConverterImplinstance
-
resourceSpans
ReturnsJsonLogConverterImpl.LogResourceScopeSpansinstances corresponding to the data emitted by the log exporter.- Parameters:
expectedCount- exact number of spans expected from a given test- Returns:
- info converted from the JSON in the logger
-