001package io.prometheus.metrics.expositionformats.internal; 002 003import com.google.protobuf.MessageOrBuilder; 004import com.google.protobuf.TextFormat; 005import com.google.protobuf.Timestamp; 006 007public class ProtobufUtil { 008 009 static Timestamp timestampFromMillis(long timestampMillis) { 010 return Timestamp.newBuilder() 011 .setSeconds(timestampMillis / 1000L) 012 .setNanos((int) (timestampMillis % 1000L * 1000000L)) 013 .build(); 014 } 015 016 public static String shortDebugString(MessageOrBuilder protobufData) { 017 return TextFormat.printer().emittingSingleLine(true).printToString(protobufData); 018 } 019}