Skip to content

Commit

Permalink
Merge branch 'main' into new-api
Browse files Browse the repository at this point in the history
  • Loading branch information
federicotdn committed Dec 13, 2024
2 parents c34bf2c + 73eb7fd commit 5d5dd51
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 8 deletions.
30 changes: 30 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: 2
updates:
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 10
commit-message:
prefix: "chore(deps): "
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 10
commit-message:
prefix: "chore(deps): "
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 10
commit-message:
prefix: "chore(deps): "
- package-ecosystem: 'npm'
directory: '/pkg/web/'
schedule:
interval: 'daily'
open-pull-requests-limit: 10
commit-message:
prefix: "chore(deps): "
22 changes: 22 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Check Formatting & Build
on: [push]

jobs:
runner-job:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5

- name: Setup Goimports
run: go install golang.org/x/tools/cmd/goimports@latest

- name: Check Formatting
run: make format-check

- name: Build Binary
run: make build
8 changes: 4 additions & 4 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and push Docker images
name: Build and Push Docker Images
on:
release:
types:
Expand All @@ -10,7 +10,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Login to the registry
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
Expand All @@ -20,7 +20,7 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set version
uses: actions/github-script@v6
uses: actions/github-script@v7
id: set_version
with:
script: |
Expand All @@ -29,7 +29,7 @@ jobs:
core.setOutput('tag', tag)
core.setOutput('tag-no-v', tag_no_v)
- name: Build Docker image and push to the Registry
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
Expand Down
18 changes: 15 additions & 3 deletions .github/workflows/k6-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
name: k6 - Test Suite
on: [push]
name: Run k6 Test Suite
on:
push:
paths:
- 'scripts/**'
- 'k6/**'
release:
types:
- created

# Important: The k6 test suite will only be run against the latest
# release of the Quickpizza service, not against the code in the
# commit itself. Therefore, we only run this Action when the test
# files themselves are modified (or on a new release).

jobs:
runner-job:
Expand All @@ -22,7 +34,7 @@ jobs:

- name: Cache k6
id: cache-k6
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: /usr/bin/k6
key: ${{ runner.os }}-k6
Expand Down
2 changes: 1 addition & 1 deletion k6/foundations/16.grpc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Client, StatusOK } from 'k6/net/grpc';
import { check, sleep } from 'k6';

const BASE_URL = 'localhost:3334';
const BASE_URL = __ENV.BASE_URL || 'http://localhost:3334';

const client = new Client();
client.load(['definitions'], '../../../proto/quickpizza.proto');
Expand Down
18 changes: 18 additions & 0 deletions pkg/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,28 @@ var (
Buckets: []float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20},
})

numberOfIngredientsPerPizzaNativeHistogram = promauto.NewHistogram(prometheus.HistogramOpts{
Name: "number_of_ingredients_per_pizza_alternate",
Help: "The number of ingredients per pizza (Native Histogram)",
NativeHistogramBucketFactor: 1.1,
NativeHistogramMaxBucketNumber: 100,
NativeHistogramMinResetDuration: 1 * time.Hour,
})

pizzaCaloriesPerSlice = promauto.NewHistogram(prometheus.HistogramOpts{
Name: "pizza_calories_per_slice",
Help: "The number of calories per slice of pizza",
Buckets: []float64{100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000},
})

pizzaCaloriesPerSliceNativeHistogram = promauto.NewHistogram(prometheus.HistogramOpts{
Name: "pizza_calories_per_slice_alternate",
Help: "The number of calories per slice of pizza (Native Histogram)",
NativeHistogramBucketFactor: 1.1,
NativeHistogramMaxBucketNumber: 100,
NativeHistogramMinResetDuration: 1 * time.Hour,
})

httpRequests = promauto.NewCounterVec(prometheus.CounterOpts{
Name: "http_requests_total",
Help: "The total number of HTTP requests",
Expand Down Expand Up @@ -699,7 +715,9 @@ func (s *Server) WithRecommendations(catalogClient CatalogClient, copyClient Cop
}).Inc()

numberOfIngredientsPerPizza.Observe(float64(len(p.Ingredients)))
numberOfIngredientsPerPizzaNativeHistogram.Observe(float64(len(p.Ingredients)))
pizzaCaloriesPerSlice.Observe(float64(pizzaRecommendation.Calories))
pizzaCaloriesPerSliceNativeHistogram.Observe(float64(pizzaRecommendation.Calories))

s.log.InfoContext(r.Context(), "New pizza recommendation", "pizza", pizzaRecommendation.Pizza.Name)

Expand Down

0 comments on commit 5d5dd51

Please sign in to comment.