Skip to content

Commit c4a3079

Browse files
committed
use utils/tracing/go
Signed-off-by: Bora M. Alper <[email protected]>
1 parent 1e83de2 commit c4a3079

File tree

6 files changed

+83
-24
lines changed

6 files changed

+83
-24
lines changed

function-images/tests/chained-function-eventing/Dockerfile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,22 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
# SOFTWARE.
2222

23-
FROM vhiveease/golang:latest AS builder
23+
FROM golang:1.16-buster AS builder
2424
WORKDIR /app
25-
RUN apk add --no-cache make
25+
# RUN apk add --no-cache make
2626
# We use ARG and ENV to have a single Dockerfile for the all three programs.
2727
# https://vsupalov.com/docker-build-pass-environment-variables/
2828
ARG target_arg
2929
ENV target=$target_arg
30-
COPY . ./
30+
COPY . .
31+
WORKDIR /app/function-images/tests/chained-function-eventing
3132
# This is required if the final image is FROM scratch
3233
# See https://forums.docker.com/t/standard-init-linux-go-195-exec-user-process-caused-no-such-file-or-directory/43777/7
33-
ENV CGO_ENABLED=0
34+
ENV CGO_ENABLED=0 GOOS=linux GOARCH=amd64
3435
RUN make bin/${target}
3536

36-
FROM scratch
37+
FROM golang:1.16-buster
3738
WORKDIR /app
3839
ARG target_arg
39-
COPY --from=builder /app/bin/${target_arg} /app/exe
40+
COPY --from=builder /app/function-images/tests/chained-function-eventing/bin/${target_arg} /app/exe
4041
ENTRYPOINT [ "/app/exe" ]

function-images/tests/chained-function-eventing/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ bin/producer: producer/* producer/helloworld_grpc.pb.go producer/helloworld.pb.g
3737

3838
TAG_PRODUCER = vhiveease/chained-functions-eventing-producer:latest
3939
image-producer: Dockerfile bin/producer
40-
docker build --tag ${TAG_PRODUCER} --build-arg target_arg=producer .
40+
docker build --tag ${TAG_PRODUCER} --build-arg target_arg=producer -f ./Dockerfile ../../..
4141

4242
push-producer: image-producer
4343
docker push ${TAG_PRODUCER}
@@ -48,7 +48,7 @@ bin/consumer: consumer/*
4848

4949
TAG_CONSUMER = vhiveease/chained-functions-eventing-consumer:latest
5050
image-consumer: Dockerfile bin/consumer
51-
docker build --tag ${TAG_CONSUMER} --build-arg target_arg=consumer .
51+
docker build --tag ${TAG_CONSUMER} --build-arg target_arg=consumer -f ./Dockerfile ../../..
5252

5353
push-consumer: image-consumer
5454
docker push ${TAG_CONSUMER}

function-images/tests/chained-function-eventing/consumer/main.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ package main
2424

2525
import (
2626
"context"
27+
"flag"
2728
"fmt"
2829
"log"
2930
"reflect"
@@ -32,6 +33,7 @@ import (
3233
cloudevents "github.com/cloudevents/sdk-go/v2"
3334

3435
. "eventing/eventschemas"
36+
tracing "github.com/ease-lab/vhive/utils/tracing/go"
3537
)
3638

3739
func printContextInternals(ctx interface{}, inner bool) {
@@ -62,7 +64,9 @@ func printContextInternals(ctx interface{}, inner bool) {
6264
}
6365

6466
func callback(ctx context.Context, event cloudevents.Event) (*cloudevents.Event, cloudevents.Result) {
65-
printContextInternals(ctx, false)
67+
span := tracing.Span{SpanName: "SayHello", TracerName: "consumer"}
68+
ctx = span.StartSpan(ctx)
69+
defer span.EndSpan()
6670

6771
var body GreetingEventBody
6872
if err := event.DataAs(&body); err != nil {
@@ -80,10 +84,19 @@ func callback(ctx context.Context, event cloudevents.Event) (*cloudevents.Event,
8084
}
8185

8286
func main() {
87+
zipkinURL := flag.String("zipkin", "http://zipkin.istio-system.svc.cluster.local:9411/api/v2/spans", "zipkin url")
88+
flag.Parse()
89+
8390
log.SetPrefix("Consumer: ")
8491
log.SetFlags(log.Lmicroseconds | log.LUTC)
8592
log.Println("started")
8693

94+
shutdown, err := tracing.InitBasicTracer(*zipkinURL, "consumer")
95+
if err != nil {
96+
log.Fatalln(err)
97+
}
98+
defer shutdown()
99+
87100
ceClient, err := cloudevents.NewClientHTTP()
88101
if err != nil {
89102
log.Fatalf("failed to create a CloudEvents client, %s", err)

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@ module eventing
22

33
go 1.16
44

5+
replace github.com/ease-lab/vhive/utils/tracing/go => ../../../utils/tracing/go
6+
57
require (
6-
github.com/cloudevents/sdk-go/observability/opencensus/v2 v2.4.1 // indirect
8+
github.com/cloudevents/sdk-go/observability/opencensus/v2 v2.4.1
79
github.com/cloudevents/sdk-go/v2 v2.4.1
810
github.com/containerd/containerd v1.5.2
11+
github.com/ease-lab/vhive/utils/tracing/go v0.0.0-00010101000000-000000000000
912
github.com/golang/protobuf v1.5.2 // indirect
1013
github.com/google/uuid v1.2.0
1114
github.com/kelseyhightower/envconfig v1.4.0
15+
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.20.0
1216
google.golang.org/grpc v1.38.0
1317
google.golang.org/protobuf v1.26.0
1418
)

0 commit comments

Comments
 (0)