Skip to content

Commit

Permalink
add time window for storage grpc plugin
Browse files Browse the repository at this point in the history
Signed-off-by: rim99 <[email protected]>
  • Loading branch information
rim99 committed Nov 23, 2024
1 parent c00931f commit 306fd2c
Show file tree
Hide file tree
Showing 6 changed files with 260 additions and 108 deletions.
7 changes: 4 additions & 3 deletions Makefile.Protobuf.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
# instead of the go_package's declared by the imported protof files.
#

DOCKER_PROTOBUF_VERSION=0.5.0
DOCKER_PROTOBUF=jaegertracing/protobuf:$(DOCKER_PROTOBUF_VERSION)
PROTOC := docker run --rm -u ${shell id -u} -v${PWD}:${PWD} -w${PWD} ${DOCKER_PROTOBUF} --proto_path=${PWD}
CTR_MANAGER=docker
CONTAINER_PROTOBUF_VERSION=0.5.0
CONTAINER_PROTOBUF=jaegertracing/protobuf:$(CONTAINER_PROTOBUF_VERSION)
PROTOC := ${CTR_MANAGER} run --rm -u ${shell id -u} -v${PWD}:${PWD} -w${PWD} ${CONTAINER_PROTOBUF} --proto_path=${PWD}

PATCHED_OTEL_PROTO_DIR = proto-gen/.patched-otel-proto

Expand Down
8 changes: 8 additions & 0 deletions plugin/storage/grpc/proto/storage.proto
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ message GetTraceRequest {
(gogoproto.customtype) = "github.com/jaegertracing/jaeger/model.TraceID",
(gogoproto.customname) = "TraceID"
];
google.protobuf.Timestamp start_time = 2 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false
];
google.protobuf.Timestamp end_time = 3 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false
];
}

message GetServicesRequest {}
Expand Down
4 changes: 4 additions & 0 deletions plugin/storage/grpc/proto/storage_test.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ package storageprototest;

option go_package = "./storageprototest";

import "google/protobuf/timestamp.proto";

message GetTraceRequest {
bytes trace_id = 1;
google.protobuf.Timestamp start_time = 2;
google.protobuf.Timestamp end_time = 3;
}
11 changes: 9 additions & 2 deletions plugin/storage/grpc/proto/storage_v1/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/gogo/protobuf/proto"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/types/known/timestamppb"

"github.com/jaegertracing/jaeger/model"
"github.com/jaegertracing/jaeger/pkg/testutils"
Expand All @@ -31,9 +32,15 @@ func TestGetTraceRequestMarshalProto(t *testing.T) {
}
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
ref1 := storage_v1.GetTraceRequest{TraceID: model.NewTraceID(2, 3)}
ref1 := storage_v1.GetTraceRequest{
TraceID: model.NewTraceID(2, 3),
StartTime: time.Unix(1, 2).UTC(),
EndTime: time.Unix(3, 4).UTC(),
}
ref2 := storageprototest.GetTraceRequest{
TraceId: []byte{0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3},
TraceId: []byte{0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3},
StartTime: timestamppb.New(time.Unix(1, 2).UTC()),
EndTime: timestamppb.New(time.Unix(3, 4).UTC()),
}
d1, err := testCase.marshal(&ref1)
require.NoError(t, err)
Expand Down
55 changes: 42 additions & 13 deletions plugin/storage/grpc/proto/storageprototest/storage_test.pb.go

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

Loading

0 comments on commit 306fd2c

Please sign in to comment.