Search in sources :

Example 1 with ChannelTraceEvent

use of io.grpc.channelz.v1.ChannelTraceEvent in project grpc-java by grpc.

the class ChannelzProtoUtilTest method channelTrace_withEvents.

@Test
public void channelTrace_withEvents() {
    Event event1 = new Event.Builder().setDescription("event1").setSeverity(Severity.CT_ERROR).setTimestampNanos(12).setSubchannelRef(subchannel).build();
    Event event2 = new Event.Builder().setDescription("event2").setTimestampNanos(34).setSeverity(Severity.CT_INFO).setChannelRef(channel).build();
    ChannelStats stats = toBuilder(channel.stats).setChannelTrace(new InternalChannelz.ChannelTrace.Builder().setNumEventsLogged(1234).setCreationTimeNanos(1000).setEvents(Arrays.asList(event1, event2)).build()).build();
    ChannelTraceEvent protoEvent1 = ChannelTraceEvent.newBuilder().setDescription("event1").setTimestamp(Timestamps.fromNanos(12)).setSeverity(ChannelTraceEvent.Severity.CT_ERROR).setSubchannelRef(subchannelRef).build();
    ChannelTraceEvent protoEvent2 = ChannelTraceEvent.newBuilder().setDescription("event2").setTimestamp(Timestamps.fromNanos(34)).setSeverity(ChannelTraceEvent.Severity.CT_INFO).setChannelRef(channelRef).build();
    ChannelData protoStats = channelData.toBuilder().setTrace(channelTrace.toBuilder().addAllEvents(Arrays.asList(protoEvent1, protoEvent2)).build()).build();
    assertEquals(ChannelzProtoUtil.extractChannelData(stats), protoStats);
}
Also used : ChannelStats(io.grpc.InternalChannelz.ChannelStats) ChannelData(io.grpc.channelz.v1.ChannelData) InternalChannelz(io.grpc.InternalChannelz) ChannelTraceEvent(io.grpc.channelz.v1.ChannelTraceEvent) Event(io.grpc.InternalChannelz.ChannelTrace.Event) ChannelTraceEvent(io.grpc.channelz.v1.ChannelTraceEvent) Test(org.junit.Test)

Example 2 with ChannelTraceEvent

use of io.grpc.channelz.v1.ChannelTraceEvent in project grpc-java by grpc.

the class ChannelzProtoUtil method toChannelTraceEvents.

private static List<ChannelTraceEvent> toChannelTraceEvents(List<Event> events) {
    List<ChannelTraceEvent> channelTraceEvents = new ArrayList<>();
    for (Event event : events) {
        ChannelTraceEvent.Builder builder = ChannelTraceEvent.newBuilder().setDescription(event.description).setSeverity(Severity.valueOf(event.severity.name())).setTimestamp(Timestamps.fromNanos(event.timestampNanos));
        if (event.channelRef != null) {
            builder.setChannelRef(toChannelRef(event.channelRef));
        }
        if (event.subchannelRef != null) {
            builder.setSubchannelRef(toSubchannelRef(event.subchannelRef));
        }
        channelTraceEvents.add(builder.build());
    }
    return Collections.unmodifiableList(channelTraceEvents);
}
Also used : ChannelTraceEvent(io.grpc.channelz.v1.ChannelTraceEvent) ArrayList(java.util.ArrayList) Event(io.grpc.InternalChannelz.ChannelTrace.Event) ChannelTraceEvent(io.grpc.channelz.v1.ChannelTraceEvent)

Aggregations

Event (io.grpc.InternalChannelz.ChannelTrace.Event)2 ChannelTraceEvent (io.grpc.channelz.v1.ChannelTraceEvent)2 InternalChannelz (io.grpc.InternalChannelz)1 ChannelStats (io.grpc.InternalChannelz.ChannelStats)1 ChannelData (io.grpc.channelz.v1.ChannelData)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1