Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
Merge pull request #39 from bancodobrasil/feat/enable-tracing
Browse files Browse the repository at this point in the history
Feat/enable tracing
  • Loading branch information
ralphg6 authored Aug 5, 2022
2 parents e7b3207 + 51ce9ca commit c743974
Show file tree
Hide file tree
Showing 10 changed files with 366 additions and 64 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ _data/
.env
.env.local
.json
.vscode

data/
33 changes: 13 additions & 20 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
{
// Use o IntelliSense para saber mais sobre os atributos possíveis.
// Focalizar para exibir as descrições dos atributos existentes.
// Para obter mais informações, acesse: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch file",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${file}"
},
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}"
}
]
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}",
}
]
}
11 changes: 6 additions & 5 deletions controllers/v1/rulesheets.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ func (rc *rulesheets) CreateRulesheet() gin.HandlerFunc {

return func(c *gin.Context) {

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
// Pass the context of gin Request
ctx, cancel := context.WithTimeout(c.Request.Context(), 10*time.Second)
var payload payloads.Rulesheet
defer cancel()

Expand Down Expand Up @@ -119,7 +120,7 @@ func (rc *rulesheets) GetRulesheets() gin.HandlerFunc {

return func(c *gin.Context) {

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
ctx, cancel := context.WithTimeout(c.Request.Context(), 10*time.Second)
defer cancel()

query := c.Request.URL.Query()
Expand Down Expand Up @@ -222,7 +223,7 @@ func (rc *rulesheets) GetRulesheet() gin.HandlerFunc {

return func(c *gin.Context) {

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
ctx, cancel := context.WithTimeout(c.Request.Context(), 100*time.Second)
defer cancel()
id, exists := c.Params.Get("id")

Expand Down Expand Up @@ -274,7 +275,7 @@ func (rc *rulesheets) UpdateRulesheet() gin.HandlerFunc {

return func(c *gin.Context) {

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
ctx, cancel := context.WithTimeout(c.Request.Context(), 10*time.Second)
defer cancel()

id, exists := c.Params.Get("id")
Expand Down Expand Up @@ -361,7 +362,7 @@ func (rc *rulesheets) DeleteRulesheet() gin.HandlerFunc {

return func(c *gin.Context) {

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
ctx, cancel := context.WithTimeout(c.Request.Context(), 10*time.Second)
defer cancel()

id, exists := c.Params.Get("id")
Expand Down
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ services:
MYSQL_DATABASE: "api"
MYSQL_USER: "api"
MYSQL_PASSWORD: "api"
TELEMETRY_HTTPCLIENT_TLS: "false"
TELEMETRY_EXPORTER_JAEGER_AGENT_HOST: "localhost"
TELEMETRY_ENVIRONMENT: local

adminer:
image: adminer
Expand All @@ -28,4 +31,3 @@ services:
restart: always
ports:
- 8080:8080

16 changes: 9 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@ go 1.18

require (
github.com/bancodobrasil/gin-monitor v1.0.0-rc1
github.com/bancodobrasil/gin-telemetry v0.0.1-rc1
github.com/bancodobrasil/gin-telemetry v0.0.1-rc5
github.com/bancodobrasil/healthcheck v0.0.2-rc1
github.com/gin-contrib/cors v1.3.1
github.com/gin-gonic/gin v1.7.7
github.com/go-playground/validator/v10 v10.10.1
github.com/gsdenys/healthcheck v0.0.0-20220412001953-64e5089fa0bc
github.com/prometheus/client_golang v1.12.1
github.com/sirupsen/logrus v1.8.1
github.com/sirupsen/logrus v1.9.0
github.com/spf13/viper v1.11.0
github.com/stretchr/testify v1.7.1
github.com/swaggo/gin-swagger v1.4.2
github.com/swaggo/swag v1.7.9
github.com/toorop/gin-logrus v0.0.0-20210225092905-2c785434f26f
github.com/xanzy/go-gitlab v0.63.0
go.opentelemetry.io/otel/trace v1.8.0
gorm.io/driver/mysql v1.3.3
gorm.io/gorm v1.23.5
)
Expand Down Expand Up @@ -70,14 +71,15 @@ require (
github.com/stretchr/objx v0.1.1 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/ugorji/go/codec v1.2.7 // indirect
go.opentelemetry.io/otel v1.6.3 // indirect
go.opentelemetry.io/otel/exporters/jaeger v1.6.3 // indirect
go.opentelemetry.io/otel/sdk v1.6.3 // indirect
go.opentelemetry.io/otel/trace v1.6.3 // indirect
github.com/uptrace/opentelemetry-go-extra/otellogrus v0.1.15 // indirect
github.com/uptrace/opentelemetry-go-extra/otelutil v0.1.15 // indirect
go.opentelemetry.io/otel v1.8.0 // indirect
go.opentelemetry.io/otel/exporters/jaeger v1.8.0 // indirect
go.opentelemetry.io/otel/sdk v1.8.0 // indirect
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
golang.org/x/net v0.0.0-20220412020605-290c469a71a5 // indirect
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect
golang.org/x/tools v0.1.7 // indirect
Expand Down
Loading

0 comments on commit c743974

Please sign in to comment.