Skip to content

Commit

Permalink
randomize distance points
Browse files Browse the repository at this point in the history
  • Loading branch information
efumagal committed Aug 6, 2023
1 parent 9fa4f21 commit 8064829
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/ghcr-build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ jobs:
- name: Check out the repo
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to GitHub container registry
uses: docker/login-action@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion k6-load/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const options = {
},
};

const BASE_URL = "http://localhost:8099/hello";
const BASE_URL = "http://localhost:8099/distance";

export default () => {
check(http.get(BASE_URL), {
Expand Down
11 changes: 8 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"log"
"math/rand"
"net/http"

_ "github.com/joho/godotenv/autoload"
Expand All @@ -27,6 +28,10 @@ func init() {
tracer = otel.Tracer("github.com/efumagal/geo-3d-otel")
}

func randFloat(min, max float64) float64 {
return rand.Float64()*(max-min) + min
}

func main() {
ctx := context.Background()

Expand Down Expand Up @@ -63,13 +68,13 @@ func main() {
app.Get("/distance", func(c *fiber.Ctx) error {
// Create a child span
_, childSpan := tracer.Start(c.UserContext(), "distance_computation")
start := geo.NewCoord3d(51.39674, -0.36148, 1104.9)
end := geo.NewCoord3d(51.38463, -0.36819, 1219.2)
start := geo.NewCoord3d(randFloat(-90, 90), randFloat(-180, 180), randFloat(0, 10000))
end := geo.NewCoord3d(randFloat(-90, 90), randFloat(-180, 180), randFloat(0, 10000))

// Distance in metres between two 3D coordinates
distance := geo.Distance3D(start, end)
childSpan.End()

return c.JSON(map[string]any{"distance": distance})
})

Expand Down

0 comments on commit 8064829

Please sign in to comment.