Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add timestamps to log lines #1675

Merged
merged 9 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

246 changes: 129 additions & 117 deletions api/golang/engine/kurtosis_engine_rpc_api_bindings/engine_service.pb.go

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion api/protobuf/engine/engine_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,10 @@ message GetServiceLogsResponse {
map<string, bool> not_found_service_uuid_set = 2;
}

// TODO add timestamp as well, for when we do timestamp-handling on the client side
message LogLine {
repeated string line = 1;

google.protobuf.Timestamp timestamp = 2;
}

message LogLineFilter {
Expand Down
3 changes: 2 additions & 1 deletion api/rust/src/engine_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,13 @@ pub struct GetServiceLogsResponse {
bool,
>,
}
/// TODO add timestamp as well, for when we do timestamp-handling on the client side
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LogLine {
#[prost(string, repeated, tag = "1")]
pub line: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(message, optional, tag = "2")]
pub timestamp: ::core::option::Option<::prost_types::Timestamp>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -719,8 +719,6 @@ export declare class GetServiceLogsResponse extends Message<GetServiceLogsRespon
}

/**
* TODO add timestamp as well, for when we do timestamp-handling on the client side
*
* @generated from message engine_api.LogLine
*/
export declare class LogLine extends Message<LogLine> {
Expand All @@ -729,6 +727,11 @@ export declare class LogLine extends Message<LogLine> {
*/
line: string[];

/**
* @generated from field: google.protobuf.Timestamp timestamp = 2;
*/
timestamp?: Timestamp;

constructor(data?: PartialMessage<LogLine>);

static readonly runtime: typeof proto3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,14 +279,13 @@ export const GetServiceLogsResponse = proto3.makeMessageType(
);

/**
* TODO add timestamp as well, for when we do timestamp-handling on the client side
*
* @generated from message engine_api.LogLine
*/
export const LogLine = proto3.makeMessageType(
"engine_api.LogLine",
() => [
{ no: 1, name: "line", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true },
{ no: 2, name: "timestamp", kind: "message", T: Timestamp },
],
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,11 @@ export class LogLine extends jspb.Message {
clearLineList(): LogLine;
addLine(value: string, index?: number): LogLine;

getTimestamp(): google_protobuf_timestamp_pb.Timestamp | undefined;
setTimestamp(value?: google_protobuf_timestamp_pb.Timestamp): LogLine;
hasTimestamp(): boolean;
clearTimestamp(): LogLine;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): LogLine.AsObject;
static toObject(includeInstance: boolean, msg: LogLine): LogLine.AsObject;
Expand All @@ -475,6 +480,7 @@ export class LogLine extends jspb.Message {
export namespace LogLine {
export type AsObject = {
lineList: Array<string>,
timestamp?: google_protobuf_timestamp_pb.Timestamp.AsObject,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3594,7 +3594,8 @@ proto.engine_api.LogLine.prototype.toObject = function(opt_includeInstance) {
*/
proto.engine_api.LogLine.toObject = function(includeInstance, msg) {
var f, obj = {
lineList: (f = jspb.Message.getRepeatedField(msg, 1)) == null ? undefined : f
lineList: (f = jspb.Message.getRepeatedField(msg, 1)) == null ? undefined : f,
timestamp: (f = msg.getTimestamp()) && google_protobuf_timestamp_pb.Timestamp.toObject(includeInstance, f)
};

if (includeInstance) {
Expand Down Expand Up @@ -3635,6 +3636,11 @@ proto.engine_api.LogLine.deserializeBinaryFromReader = function(msg, reader) {
var value = /** @type {string} */ (reader.readString());
msg.addLine(value);
break;
case 2:
var value = new google_protobuf_timestamp_pb.Timestamp;
reader.readMessage(value,google_protobuf_timestamp_pb.Timestamp.deserializeBinaryFromReader);
msg.setTimestamp(value);
break;
default:
reader.skipField();
break;
Expand Down Expand Up @@ -3671,6 +3677,14 @@ proto.engine_api.LogLine.serializeBinaryToWriter = function(message, writer) {
f
);
}
f = message.getTimestamp();
if (f != null) {
writer.writeMessage(
2,
f,
google_protobuf_timestamp_pb.Timestamp.serializeBinaryToWriter
);
}
};


Expand Down Expand Up @@ -3711,6 +3725,43 @@ proto.engine_api.LogLine.prototype.clearLineList = function() {
};


/**
* optional google.protobuf.Timestamp timestamp = 2;
* @return {?proto.google.protobuf.Timestamp}
*/
proto.engine_api.LogLine.prototype.getTimestamp = function() {
return /** @type{?proto.google.protobuf.Timestamp} */ (
jspb.Message.getWrapperField(this, google_protobuf_timestamp_pb.Timestamp, 2));
};


/**
* @param {?proto.google.protobuf.Timestamp|undefined} value
* @return {!proto.engine_api.LogLine} returns this
*/
proto.engine_api.LogLine.prototype.setTimestamp = function(value) {
return jspb.Message.setWrapperField(this, 2, value);
};


/**
* Clears the message field making it undefined.
* @return {!proto.engine_api.LogLine} returns this
*/
proto.engine_api.LogLine.prototype.clearTimestamp = function() {
return this.setTimestamp(undefined);
};


/**
* Returns whether this field is set.
* @return {boolean}
*/
proto.engine_api.LogLine.prototype.hasTimestamp = function() {
return jspb.Message.getField(this, 2) != null;
};





Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"io"
"strings"
"sync"
"time"
)

const (
Expand Down Expand Up @@ -192,7 +193,8 @@ func streamServiceLogLines(
return
}

logLine := logline.NewLogLine(logLineStr)
// TODO: Parse out the timestamp from docker container logs string instead of time.Now
tedim52 marked this conversation as resolved.
Show resolved Hide resolved
logLine := logline.NewLogLine(logLineStr, time.Now())
tedim52 marked this conversation as resolved.
Show resolved Hide resolved

//filtering it
shouldReturnLogLine, err := logLine.IsValidLogLineBaseOnFilters(conjunctiveLogLinesFiltersWithRegex)
Expand Down