Skip to content

Commit 049090e

Browse files
Michal Baczunustiugov
authored andcommitted
Updates invoker, enables tracing and curtom port
Signed-off-by: Michal Baczun <[email protected]>
1 parent 8cf89b1 commit 049090e

File tree

8 files changed

+75
-122
lines changed

8 files changed

+75
-122
lines changed

.github/workflows/function-composition-push.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ jobs:
7272
uses: docker/setup-buildx-action@v1
7373

7474
- name: Build and push
75-
working-directory: ./function-images/tests/chained-function-serving
75+
working-directory: .
7676
run: |
77-
make all-image
78-
make all-image-push
77+
make serving-all-image
78+
make serving-all-image-push
7979
8080
push-chained-functions-eventing:
8181
name: Push chained-functions-eventing-*

examples/invoker/client.go

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,29 @@ import (
3636
pb "github.com/ease-lab/vhive/examples/protobuf/helloworld"
3737
log "github.com/sirupsen/logrus"
3838
"google.golang.org/grpc"
39+
40+
tracing "github.com/ease-lab/vhive/utils/tracing/go"
41+
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
3942
)
4043

4144
var (
42-
completed int64
43-
latSlice LatencySlice
45+
completed int64
46+
latSlice LatencySlice
47+
port int
48+
withTracing *bool
4449
)
4550

4651
func main() {
4752
urlFile := flag.String("urlFile", "urls.txt", "File with functions' URLs")
4853
rps := flag.Int("rps", 1, "Target requests per second")
4954
runDuration := flag.Int("time", 5, "Run the benchmark for X seconds")
5055
latencyOutputFile := flag.String("latf", "lat.csv", "CSV file for the latency measurements in microseconds")
56+
portFlag := flag.Int("port", 80, "The port to use for all function invokations")
57+
withTracing = flag.Bool("trace", false, "Enable tracing in the client")
58+
zipkin := flag.String("zipkin", "http://localhost:9411/api/v2/spans", "zipkin url")
5159

5260
flag.Parse()
61+
port = *portFlag
5362

5463
log.Info("Reading the URLs from the file: ", *urlFile)
5564

@@ -58,6 +67,11 @@ func main() {
5867
log.Fatal("Failed to read the URL files: ", err)
5968
}
6069

70+
if *withTracing {
71+
shutdown := tracing.InitBasicTracer(*zipkin, "invoker")
72+
defer shutdown()
73+
}
74+
6175
realRPS := runBenchmark(urls, *runDuration, *rps)
6276

6377
writeLatencies(realRPS, *latencyOutputFile)
@@ -108,9 +122,17 @@ func runBenchmark(urls []string, runDuration, targetRPS int) (realRPS float64) {
108122
func invokeFunction(url string) {
109123
defer getDuration(startMeasurement(url)) // measure entire invocation time
110124

111-
address := fmt.Sprintf("%s:%d", url, 80)
125+
address := fmt.Sprintf("%s:%d", url, port)
112126

113-
conn, err := grpc.Dial(address, grpc.WithInsecure(), grpc.WithBlock())
127+
fmt.Printf("Address used: %v\n", address)
128+
129+
var conn *grpc.ClientConn
130+
var err error
131+
if *withTracing {
132+
conn, err = grpc.Dial(address, grpc.WithInsecure(), grpc.WithUnaryInterceptor(otelgrpc.UnaryClientInterceptor()))
133+
} else {
134+
conn, err = grpc.Dial(address, grpc.WithInsecure(), grpc.WithBlock())
135+
}
114136
if err != nil {
115137
log.Fatalf("did not connect: %v", err)
116138
}

function-images/tests/chained-function-serving/client/client.go

Lines changed: 0 additions & 109 deletions
This file was deleted.

function-images/tests/chained-function-serving/consumer/consumer.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import (
3030
"log"
3131
"net"
3232
"os"
33-
"time"
3433

3534
"google.golang.org/grpc"
3635

function-images/tests/chained-function-serving/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module tests/chained-functions-serving
33
go 1.16
44

55
replace (
6-
github.com/ease-lab/vhive/utils/tracing/go => /app/utils/tracing
6+
github.com/ease-lab/vhive/utils/tracing/go => ./utils/tracing
77
tests/chained-functions-serving/proto => ./proto
88
)
99

function-images/tests/chained-function-serving/producer/producer.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ type producerServer struct {
4949

5050
func (ps *producerServer) SayHello(ctx context.Context, req *pb.HelloRequest) (*pb.HelloReply, error) {
5151
// establish a connection
52-
conn, err := grpc.Dial(fmt.Sprintf("%v:%v", ps.consumerAddr, ps.consumerPort), grpc.WithInsecure(), grpc.WithUnaryInterceptor(otelgrpc.UnaryClientInterceptor()))
52+
addr := fmt.Sprintf("%v:%v", ps.consumerAddr, ps.consumerPort)
53+
conn, err := grpc.Dial(addr, grpc.WithInsecure(), grpc.WithUnaryInterceptor(otelgrpc.UnaryClientInterceptor()))
5354
if err != nil {
5455
log.Fatalf("[producer] fail to dial: %s", err)
5556
}

go.mod

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,24 @@ require (
5151
github.com/containerd/containerd v1.5.2
5252
github.com/davecgh/go-spew v1.1.1
5353
github.com/ease-lab/vhive/examples/protobuf/helloworld v0.0.0-00010101000000-000000000000
54+
github.com/ease-lab/vhive/utils/tracing/go v0.0.0-00010101000000-000000000000
5455
github.com/firecracker-microvm/firecracker-containerd v0.0.0-00010101000000-000000000000
5556
github.com/ftrvxmtrx/fd v0.0.0-20150925145434-c6d800382fff
5657
github.com/go-multierror/multierror v1.0.2
57-
github.com/golang/protobuf v1.4.3
58-
github.com/google/go-cmp v0.5.5 // indirect
58+
github.com/golang/protobuf v1.5.2
5959
github.com/montanaflynn/stats v0.6.5
6060
github.com/pkg/errors v0.9.1
6161
github.com/sirupsen/logrus v1.8.0
6262
github.com/stretchr/testify v1.7.0
6363
github.com/vishvananda/netlink v1.1.1-0.20201029203352-d40f9887b852
6464
github.com/wcharczuk/go-chart v2.0.1+incompatible
65+
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.20.0
6566
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb // indirect
6667
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110
6768
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a
6869
golang.org/x/sys v0.0.0-20210324051608-47abb6519492
6970
gonum.org/v1/gonum v0.9.0
7071
gonum.org/v1/plot v0.9.0
71-
google.golang.org/grpc v1.34.0
72+
google.golang.org/grpc v1.37.0
7273
k8s.io/cri-api v0.20.6
7374
)

0 commit comments

Comments
 (0)