Search in sources :

Example 6 with LogRecord

use of io.opentelemetry.proto.logs.v1.LogRecord in project opentelemetry-java-instrumentation by open-telemetry.

the class AgentTestingExporterAccess method getExportedLogs.

@SuppressWarnings("unchecked")
public static List<LogData> getExportedLogs() {
    List<byte[]> exportRequests;
    try {
        exportRequests = (List<byte[]>) getLogExportRequests.invokeExact();
    } catch (Throwable t) {
        throw new AssertionError("Could not invoke getMetricExportRequests", t);
    }
    List<ResourceLogs> allResourceLogs = exportRequests.stream().map(serialized -> {
        try {
            return ExportLogsServiceRequest.parseFrom(serialized);
        } catch (InvalidProtocolBufferException e) {
            throw new AssertionError(e);
        }
    }).flatMap(request -> request.getResourceLogsList().stream()).collect(toList());
    List<LogData> logs = new ArrayList<>();
    for (ResourceLogs resourceLogs : allResourceLogs) {
        Resource resource = resourceLogs.getResource();
        for (InstrumentationLibraryLogs ilLogs : resourceLogs.getInstrumentationLibraryLogsList()) {
            InstrumentationLibrary instrumentationLibrary = ilLogs.getInstrumentationLibrary();
            for (LogRecord logRecord : ilLogs.getLogsList()) {
                logs.add(createLogData(logRecord, io.opentelemetry.sdk.resources.Resource.create(fromProto(resource.getAttributesList())), InstrumentationLibraryInfo.create(instrumentationLibrary.getName(), instrumentationLibrary.getVersion())));
            }
        }
    }
    return logs;
}
Also used : TraceFlags(io.opentelemetry.api.trace.TraceFlags) LongPointData(io.opentelemetry.sdk.metrics.data.LongPointData) KeyValue(io.opentelemetry.proto.common.v1.KeyValue) EventData(io.opentelemetry.sdk.trace.data.EventData) Sum(io.opentelemetry.proto.metrics.v1.Sum) StatusCode(io.opentelemetry.api.trace.StatusCode) ImmutableSummaryPointData(io.opentelemetry.sdk.metrics.internal.data.ImmutableSummaryPointData) Attributes(io.opentelemetry.api.common.Attributes) ResourceLogs(io.opentelemetry.proto.logs.v1.ResourceLogs) ResourceSpans(io.opentelemetry.proto.trace.v1.ResourceSpans) Resource(io.opentelemetry.proto.resource.v1.Resource) LogDataBuilder(io.opentelemetry.sdk.logs.data.LogDataBuilder) AttributeKey.stringArrayKey(io.opentelemetry.api.common.AttributeKey.stringArrayKey) ExportLogsServiceRequest(io.opentelemetry.proto.collector.logs.v1.ExportLogsServiceRequest) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) ValueAtPercentile(io.opentelemetry.sdk.metrics.data.ValueAtPercentile) SpanContext(io.opentelemetry.api.trace.SpanContext) SummaryPointData(io.opentelemetry.sdk.metrics.data.SummaryPointData) MethodHandles(java.lang.invoke.MethodHandles) Collection(java.util.Collection) AttributeKey.doubleArrayKey(io.opentelemetry.api.common.AttributeKey.doubleArrayKey) SpanKind(io.opentelemetry.api.trace.SpanKind) Collectors(java.util.stream.Collectors) ArrayValue(io.opentelemetry.proto.common.v1.ArrayValue) List(java.util.List) InstrumentationLibraryMetrics(io.opentelemetry.proto.metrics.v1.InstrumentationLibraryMetrics) ExportTraceServiceRequest(io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest) SpanData(io.opentelemetry.sdk.trace.data.SpanData) AttributeKey.longArrayKey(io.opentelemetry.api.common.AttributeKey.longArrayKey) AnyValue(io.opentelemetry.proto.common.v1.AnyValue) MetricData(io.opentelemetry.sdk.metrics.data.MetricData) Pattern(java.util.regex.Pattern) ImmutableValueAtPercentile(io.opentelemetry.sdk.metrics.internal.data.ImmutableValueAtPercentile) HistogramDataPoint(io.opentelemetry.proto.metrics.v1.HistogramDataPoint) MethodHandle(java.lang.invoke.MethodHandle) StatusData(io.opentelemetry.sdk.trace.data.StatusData) InstrumentationLibrarySpans(io.opentelemetry.proto.trace.v1.InstrumentationLibrarySpans) ImmutableSummaryData(io.opentelemetry.sdk.metrics.internal.data.ImmutableSummaryData) InstrumentationLibraryInfo(io.opentelemetry.sdk.common.InstrumentationLibraryInfo) ArrayList(java.util.ArrayList) TraceState(io.opentelemetry.api.trace.TraceState) Metric(io.opentelemetry.proto.metrics.v1.Metric) DoublePointData(io.opentelemetry.sdk.metrics.data.DoublePointData) HistogramPointData(io.opentelemetry.sdk.metrics.data.HistogramPointData) TraceStateBuilder(io.opentelemetry.api.trace.TraceStateBuilder) LogData(io.opentelemetry.sdk.logs.data.LogData) ImmutableGaugeData(io.opentelemetry.sdk.metrics.internal.data.ImmutableGaugeData) Severity(io.opentelemetry.sdk.logs.data.Severity) ImmutableSumData(io.opentelemetry.sdk.metrics.internal.data.ImmutableSumData) AggregationTemporality(io.opentelemetry.sdk.metrics.data.AggregationTemporality) LogRecord(io.opentelemetry.proto.logs.v1.LogRecord) SeverityNumber(io.opentelemetry.proto.logs.v1.SeverityNumber) ExportMetricsServiceRequest(io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest) Span(io.opentelemetry.proto.trace.v1.Span) AttributesBuilder(io.opentelemetry.api.common.AttributesBuilder) NumberDataPoint(io.opentelemetry.proto.metrics.v1.NumberDataPoint) TimeUnit(java.util.concurrent.TimeUnit) ImmutableHistogramPointData(io.opentelemetry.sdk.metrics.internal.data.ImmutableHistogramPointData) Collectors.toList(java.util.stream.Collectors.toList) MethodType(java.lang.invoke.MethodType) InstrumentationLibrary(io.opentelemetry.proto.common.v1.InstrumentationLibrary) ResourceMetrics(io.opentelemetry.proto.metrics.v1.ResourceMetrics) InstrumentationLibraryLogs(io.opentelemetry.proto.logs.v1.InstrumentationLibraryLogs) AttributeKey.booleanArrayKey(io.opentelemetry.api.common.AttributeKey.booleanArrayKey) ImmutableHistogramData(io.opentelemetry.sdk.metrics.internal.data.ImmutableHistogramData) LinkData(io.opentelemetry.sdk.trace.data.LinkData) SummaryDataPoint(io.opentelemetry.proto.metrics.v1.SummaryDataPoint) Status(io.opentelemetry.proto.trace.v1.Status) TestSpanData(io.opentelemetry.sdk.testing.trace.TestSpanData) LogData(io.opentelemetry.sdk.logs.data.LogData) ResourceLogs(io.opentelemetry.proto.logs.v1.ResourceLogs) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) ArrayList(java.util.ArrayList) Resource(io.opentelemetry.proto.resource.v1.Resource) LogRecord(io.opentelemetry.proto.logs.v1.LogRecord) InstrumentationLibraryLogs(io.opentelemetry.proto.logs.v1.InstrumentationLibraryLogs) InstrumentationLibrary(io.opentelemetry.proto.common.v1.InstrumentationLibrary)

Aggregations

LogRecord (io.opentelemetry.proto.logs.v1.LogRecord)5 ExportLogsServiceRequest (io.opentelemetry.proto.collector.logs.v1.ExportLogsServiceRequest)3 InstrumentationLibraryLogs (io.opentelemetry.proto.logs.v1.InstrumentationLibraryLogs)3 ResourceLogs (io.opentelemetry.proto.logs.v1.ResourceLogs)3 Test (org.junit.jupiter.api.Test)3 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)2 ExportMetricsServiceRequest (io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest)2 ExportTraceServiceRequest (io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest)2 InstrumentationLibraryMetrics (io.opentelemetry.proto.metrics.v1.InstrumentationLibraryMetrics)2 Metric (io.opentelemetry.proto.metrics.v1.Metric)2 ResourceMetrics (io.opentelemetry.proto.metrics.v1.ResourceMetrics)2 LogData (io.opentelemetry.sdk.logs.data.LogData)2 LogDataBuilder (io.opentelemetry.sdk.logs.data.LogDataBuilder)2 ArrayList (java.util.ArrayList)2 ByteString (com.google.protobuf.ByteString)1 Message (com.google.protobuf.Message)1 AttributeKey.booleanArrayKey (io.opentelemetry.api.common.AttributeKey.booleanArrayKey)1 AttributeKey.doubleArrayKey (io.opentelemetry.api.common.AttributeKey.doubleArrayKey)1 AttributeKey.longArrayKey (io.opentelemetry.api.common.AttributeKey.longArrayKey)1 AttributeKey.stringArrayKey (io.opentelemetry.api.common.AttributeKey.stringArrayKey)1