-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(promexporter): use
otelRecorder
observer pattern (#2871)
- Loading branch information
1 parent
9332b15
commit e5cd908
Showing
10 changed files
with
655 additions
and
370 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package exporters | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"time" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/synapsecns/sanguine/contrib/promexporter/internal/gql/dfk" | ||
"github.com/synapsecns/sanguine/core" | ||
"github.com/synapsecns/sanguine/core/metrics" | ||
"go.opentelemetry.io/otel/attribute" | ||
"go.opentelemetry.io/otel/trace" | ||
) | ||
|
||
func (e *exporter) stuckHeroCountStats(parentCtx context.Context, owner common.Address, chainName string) (err error) { | ||
ctx, span := e.metrics.Tracer().Start(parentCtx, "dfk_stats", trace.WithAttributes( | ||
attribute.String("chain_name", chainName), | ||
)) | ||
|
||
defer func() { | ||
metrics.EndSpanWithErr(span, err) | ||
}() | ||
|
||
ctx, cancel := context.WithTimeout(ctx, time.Minute) | ||
defer cancel() | ||
|
||
dfkClient := dfk.NewClient(e.client, e.cfg.DFKUrl) | ||
|
||
stuckHeroes, err := dfkClient.StuckHeroes(ctx, core.PtrTo[int64](0), core.PtrTo(owner.String())) | ||
if err != nil { | ||
return fmt.Errorf("could not get stuck hero count: %w", err) | ||
} | ||
|
||
e.otelRecorder.RecordStuckHeroCount(int64(len(stuckHeroes.Heroes)), chainName) | ||
|
||
return nil | ||
} |
Oops, something went wrong.