Skip to content

Commit

Permalink
refactor: using tracer directly instead of passing app
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <[email protected]>
  • Loading branch information
ViBiOh committed Aug 20, 2022
1 parent c12d07b commit 4326191
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
6 changes: 3 additions & 3 deletions cmd/fibr/fibr.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func main() {
storageProvider, err := absto.New(abstoConfig, tracerApp.GetTracer("storage"))
logger.Fatal(err)

eventBus, err := provider.NewEventBus(10, prometheusRegisterer, tracerApp)
eventBus, err := provider.NewEventBus(10, prometheusRegisterer, tracerApp.GetTracer("bus"))
logger.Fatal(err)

amqpClient, err := amqp.New(amqpConfig, prometheusApp.Registerer())
Expand All @@ -137,7 +137,7 @@ func main() {
rendererApp, err := renderer.New(rendererConfig, content, fibr.FuncMap, tracerApp.GetTracer("renderer"))
logger.Fatal(err)

exifApp, err := exif.New(exifConfig, storageProvider, prometheusRegisterer, tracerApp, amqpClient, redisClient)
exifApp, err := exif.New(exifConfig, storageProvider, prometheusRegisterer, tracerApp.GetTracer("exif"), amqpClient, redisClient)
logger.Fatal(err)

webhookApp, err := webhook.New(webhookConfig, storageProvider, prometheusRegisterer, amqpClient, rendererApp, thumbnailApp)
Expand All @@ -155,7 +155,7 @@ func main() {
amqpWebhookApp, err := amqphandler.New(amqpWebhookConfig, amqpClient, webhookApp.AMQPHandler)
logger.Fatal(err)

crudApp, err := crud.New(crudConfig, storageProvider, rendererApp, shareApp, webhookApp, thumbnailApp, exifApp, eventBus.Push, amqpClient, tracerApp)
crudApp, err := crud.New(crudConfig, storageProvider, rendererApp, shareApp, webhookApp, thumbnailApp, exifApp, eventBus.Push, amqpClient, tracerApp.GetTracer("crud"))
logger.Fatal(err)

var middlewareApp provider.Auth
Expand Down
5 changes: 2 additions & 3 deletions pkg/crud/crud.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/ViBiOh/httputils/v4/pkg/amqp"
"github.com/ViBiOh/httputils/v4/pkg/logger"
"github.com/ViBiOh/httputils/v4/pkg/renderer"
"github.com/ViBiOh/httputils/v4/pkg/tracer"
"go.opentelemetry.io/otel/trace"
"golang.org/x/crypto/bcrypt"
)
Expand Down Expand Up @@ -72,14 +71,14 @@ func Flags(fs *flag.FlagSet, prefix string) Config {
}
}

func New(config Config, storage absto.Storage, rendererApp renderer.App, shareApp provider.ShareManager, webhookApp provider.WebhookManager, thumbnailApp thumbnail.App, exifApp exif.App, eventProducer provider.EventProducer, amqpClient *amqp.Client, tracerApp tracer.App) (App, error) {
func New(config Config, storage absto.Storage, rendererApp renderer.App, shareApp provider.ShareManager, webhookApp provider.WebhookManager, thumbnailApp thumbnail.App, exifApp exif.App, eventProducer provider.EventProducer, amqpClient *amqp.Client, tracer trace.Tracer) (App, error) {
app := App{
sanitizeOnStart: *config.sanitizeOnStart,

chunkUpload: *config.chunkUpload,
temporaryFolder: strings.TrimSpace(*config.temporaryFolder),

tracer: tracerApp.GetTracer("crud"),
tracer: tracer,
pushEvent: eventProducer,

rawStorageApp: storage,
Expand Down
5 changes: 2 additions & 3 deletions pkg/exif/exif.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
prom "github.com/ViBiOh/httputils/v4/pkg/prometheus"
"github.com/ViBiOh/httputils/v4/pkg/redis"
"github.com/ViBiOh/httputils/v4/pkg/request"
"github.com/ViBiOh/httputils/v4/pkg/tracer"
"github.com/prometheus/client_golang/prometheus"
"go.opentelemetry.io/otel/trace"
)
Expand Down Expand Up @@ -67,7 +66,7 @@ func Flags(fs *flag.FlagSet, prefix string) Config {
}
}

func New(config Config, storageApp absto.Storage, prometheusRegisterer prometheus.Registerer, tracerApp tracer.App, amqpClient *amqpclient.Client, redisClient redis.App) (App, error) {
func New(config Config, storageApp absto.Storage, prometheusRegisterer prometheus.Registerer, tracer trace.Tracer, amqpClient *amqpclient.Client, redisClient redis.App) (App, error) {
var amqpExchange string
if amqpClient != nil {
amqpExchange = strings.TrimSpace(*config.amqpExchange)
Expand All @@ -88,7 +87,7 @@ func New(config Config, storageApp absto.Storage, prometheusRegisterer prometheu
amqpExchange: amqpExchange,
amqpRoutingKey: strings.TrimSpace(*config.amqpRoutingKey),

tracer: tracerApp.GetTracer("exif"),
tracer: tracer,
storageApp: storageApp,
listStorageApp: storageApp.WithIgnoreFn(func(item absto.Item) bool {
return !strings.HasSuffix(item.Name, ".json")
Expand Down
4 changes: 2 additions & 2 deletions pkg/provider/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ type EventBus struct {
done chan struct{}
}

func NewEventBus(size uint, prometheusRegisterer prometheus.Registerer, tracerApp tracer.App) (EventBus, error) {
func NewEventBus(size uint, prometheusRegisterer prometheus.Registerer, tracer trace.Tracer) (EventBus, error) {
var counter *prometheus.CounterVec

if prometheusRegisterer != nil {
Expand All @@ -290,7 +290,7 @@ func NewEventBus(size uint, prometheusRegisterer prometheus.Registerer, tracerAp
done: make(chan struct{}),
bus: make(chan Event, size),
counter: counter,
tracer: tracerApp.GetTracer("event"),
tracer: tracer,
}, nil
}

Expand Down

0 comments on commit 4326191

Please sign in to comment.