diff --git a/tracing/README.md b/tracing/README.md index 2629363..f615b82 100644 --- a/tracing/README.md +++ b/tracing/README.md @@ -124,6 +124,8 @@ There is a `docker-compose.yaml` in this directory.
Change your terminal to this folder and run: ``` +cd tracing + docker-compose build docker-compose up diff --git a/tracing/applications-go/playlists-api/app.go b/tracing/applications-go/playlists-api/app.go index 03815b4..d5d6850 100644 --- a/tracing/applications-go/playlists-api/app.go +++ b/tracing/applications-go/playlists-api/app.go @@ -82,7 +82,6 @@ func main() { span, _ := opentracing.StartSpanFromContext(ctx, "videos-api GET") - v := videos{} req, err := http.NewRequest("GET", "http://videos-api:10010/" + playlists[pi].Videos[vi].Id, nil) diff --git a/tracing/applications-go/videos-api/app.go b/tracing/applications-go/videos-api/app.go index 600075b..9ad8ec8 100644 --- a/tracing/applications-go/videos-api/app.go +++ b/tracing/applications-go/videos-api/app.go @@ -7,9 +7,10 @@ import ( "github.com/go-redis/redis/v8" "fmt" "context" + "time" + "strings" "os" "math/rand" - "github.com/opentracing/opentracing-go" "github.com/uber/jaeger-client-go" "github.com/uber/jaeger-client-go/config" @@ -25,6 +26,7 @@ var environment = os.Getenv("ENVIRONMENT") var redis_host = os.Getenv("REDIS_HOST") var redis_port = os.Getenv("REDIS_PORT") var flaky = os.Getenv("FLAKY") +var delay = os.Getenv("DELAY") var ctx = context.Background() var rdb *redis.Client @@ -66,7 +68,7 @@ func main() { span := tracer.StartSpan("/id GET", ext.RPCServerOption(spanCtx)) defer span.Finish() - if flaky == "true"{ + if flaky == "true" { if rand.Intn(90) < 30 { panic("flaky error occurred ") } @@ -75,6 +77,10 @@ func main() { ctx := opentracing.ContextWithSpan(context.Background(), span) video := video(w,r,p, ctx) + if strings.Contains(video, "jM36M39MA3I") && delay == "true" { + time.Sleep(6 * time.Second) + } + cors(w) fmt.Fprintf(w, "%s", video) diff --git a/tracing/docker-compose.yaml b/tracing/docker-compose.yaml index 73dbfd7..bf4c649 100644 --- a/tracing/docker-compose.yaml +++ b/tracing/docker-compose.yaml @@ -22,6 +22,14 @@ services: - 81:10010 networks: - tracing + playlists-db: + container_name: playlists-db + image: redis:6.0-alpine + command: [ "redis-server" , "--dir", "/tmp", "--appendonly", "yes"] + volumes: + - ./applications-go/playlists-db/appendonly.aof:/tmp/appendonly.aof + networks: + - tracing videos-api: container_name: videos-api image: aimvector/jaeger-tracing:videos-api-1.0.0 @@ -31,6 +39,8 @@ services: - "ENVIRONMENT=DEBUG" - "REDIS_HOST=videos-db" - "REDIS_PORT=6379" + - "DELAY=true" + #- "FLAKY=true" ports: - 82:10010 networks: @@ -43,14 +53,6 @@ services: - ./applications-go/videos-db/appendonly.aof:/tmp/appendonly.aof networks: - tracing - playlists-db: - container_name: playlists-db - image: redis:6.0-alpine - command: [ "redis-server" , "--dir", "/tmp", "--appendonly", "yes"] - volumes: - - ./applications-go/playlists-db/appendonly.aof:/tmp/appendonly.aof - networks: - - tracing jaeger: container_name: jaeger image: jaegertracing/all-in-one:latest