Skip to content

Commit

Permalink
feat: add traces
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyrag committed Sep 8, 2024
1 parent 767f647 commit d2c5f07
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion components/ledger/internal/controller/ledger/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ func (r *Resolver) GetLedger(ctx context.Context, name string) (*Controller, err
return nil, err
}

r.metricsRegistry.ActiveLedgers().Add(ctx, +1)
// todo: add only once
//r.metricsRegistry.ActiveLedgers().Add(ctx, +1)

return New(
name,
Expand Down
4 changes: 4 additions & 0 deletions components/ledger/internal/storage/bucket/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"embed"
_ "embed"
"github.com/formancehq/ledger/internal/opentelemetry/tracer"
"github.com/formancehq/stack/libs/go-libs/migrations"
"github.com/uptrace/bun"
"text/template"
Expand Down Expand Up @@ -32,5 +33,8 @@ func getMigrator(name string) *migrations.Migrator {
}

func Migrate(ctx context.Context, db bun.IDB, name string) error {
ctx, span := tracer.Start(ctx, "Migrate bucket")
defer span.End()

return getMigrator(name).Up(ctx, db)
}
4 changes: 4 additions & 0 deletions components/ledger/internal/storage/ledger/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"embed"
_ "embed"
"fmt"
"github.com/formancehq/ledger/internal/opentelemetry/tracer"
"github.com/formancehq/stack/libs/go-libs/migrations"
"github.com/uptrace/bun"
"text/template"
Expand Down Expand Up @@ -37,5 +38,8 @@ func getMigrator(bucketName, ledgerName string) *migrations.Migrator {
}

func Migrate(ctx context.Context, db bun.IDB, bucketName, ledgerName string) error {
ctx, span := tracer.Start(ctx, "Migrate ledger")
defer span.End()

return getMigrator(bucketName, ledgerName).Up(ctx, db)
}

0 comments on commit d2c5f07

Please sign in to comment.