Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
Move metrics tracker to plugins, closes #583 (#581)
Browse files Browse the repository at this point in the history
* Initial commit

* Add new file
  • Loading branch information
debnil authored Nov 12, 2020
1 parent 31d5520 commit 10f017f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
6 changes: 3 additions & 3 deletions cmd/server_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ import (
"github.com/stellar/go/support/errors"
"github.com/stellar/kelp/gui"
"github.com/stellar/kelp/gui/backend"
"github.com/stellar/kelp/plugins"
"github.com/stellar/kelp/support/kelpos"
"github.com/stellar/kelp/support/logger"
"github.com/stellar/kelp/support/metrics"
"github.com/stellar/kelp/support/networking"
"github.com/stellar/kelp/support/prefs"
"github.com/stellar/kelp/support/sdk"
Expand Down Expand Up @@ -290,7 +290,7 @@ func init() {
}
}

var metricsTracker *metrics.MetricsTracker
var metricsTracker *plugins.MetricsTracker
if isLocalDevMode {
log.Printf("metric - not sending data metrics in dev mode")
} else {
Expand All @@ -300,7 +300,7 @@ func init() {
}

httpClient := &http.Client{}
metricsTracker, e = metrics.MakeMetricsTrackerGui(
metricsTracker, e = plugins.MakeMetricsTrackerGui(
deviceID,
deviceID,
amplitudeAPIKey,
Expand Down
11 changes: 5 additions & 6 deletions cmd/trade.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/stellar/kelp/plugins"
"github.com/stellar/kelp/support/database"
"github.com/stellar/kelp/support/logger"
"github.com/stellar/kelp/support/metrics"
"github.com/stellar/kelp/support/monitoring"
"github.com/stellar/kelp/support/networking"
"github.com/stellar/kelp/support/prefs"
Expand Down Expand Up @@ -374,7 +373,7 @@ func makeStrategy(
options inputs,
threadTracker *multithreading.ThreadTracker,
db *sql.DB,
metricsTracker *metrics.MetricsTracker,
metricsTracker *plugins.MetricsTracker,
) api.Strategy {
// setting the temp hack variables for the sdex price feeds
e := plugins.SetPrivateSdexHack(client, plugins.MakeIEIF(true), network)
Expand Down Expand Up @@ -423,7 +422,7 @@ func makeBot(
fillTracker api.FillTracker,
threadTracker *multithreading.ThreadTracker,
options inputs,
metricsTracker *metrics.MetricsTracker,
metricsTracker *plugins.MetricsTracker,
botStart time.Time,
) *trader.Trader {
timeController := plugins.MakeIntervalTimeController(
Expand Down Expand Up @@ -567,7 +566,7 @@ func runTradeCmd(options inputs) {

isTestnet := strings.Contains(botConfig.HorizonURL, "test") && botConfig.IsTradingSdex()

metricsTracker, e := metrics.MakeMetricsTrackerCli(
metricsTracker, e := plugins.MakeMetricsTrackerCli(
userID,
deviceID,
amplitudeAPIKey,
Expand Down Expand Up @@ -871,7 +870,7 @@ func makeFillTracker(
db *sql.DB,
threadTracker *multithreading.ThreadTracker,
accountID string,
metricsTracker *metrics.MetricsTracker,
metricsTracker *plugins.MetricsTracker,
) api.FillTracker {
strategyFillHandlers, e := strategy.GetFillHandlers()
if e != nil {
Expand Down Expand Up @@ -966,7 +965,7 @@ func deleteAllOffersAndExit(
sdex *plugins.SDEX,
exchangeShim api.ExchangeShim,
threadTracker *multithreading.ThreadTracker,
metricsTracker *metrics.MetricsTracker,
metricsTracker *plugins.MetricsTracker,
) {
// synchronous event to guarantee execution. we want to know whenever we enter the delete all offers logic. this function
// waits for all threads to be synchronous, which is equivalent to sending synchronously. we use
Expand Down
6 changes: 3 additions & 3 deletions gui/backend/api_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"time"

"github.com/stellar/go/clients/horizonclient"
"github.com/stellar/kelp/plugins"
"github.com/stellar/kelp/support/kelpos"
"github.com/stellar/kelp/support/metrics"
)

// APIServer is an instance of the API service
Expand All @@ -28,7 +28,7 @@ type APIServer struct {
apiPubNet *horizonclient.Client
noHeaders bool
quitFn func()
metricsTracker *metrics.MetricsTracker
metricsTracker *plugins.MetricsTracker

cachedOptionsMetadata metadata
}
Expand All @@ -45,7 +45,7 @@ func MakeAPIServer(
ccxtRestUrl string,
noHeaders bool,
quitFn func(),
metricsTracker *metrics.MetricsTracker,
metricsTracker *plugins.MetricsTracker,
) (*APIServer, error) {
kelpBinPath := kos.GetBinDir().Join(filepath.Base(os.Args[0]))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package metrics
package plugins

import (
"encoding/json"
Expand Down
5 changes: 2 additions & 3 deletions trader/trader.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/stellar/kelp/api"
"github.com/stellar/kelp/model"
"github.com/stellar/kelp/plugins"
"github.com/stellar/kelp/support/metrics"
"github.com/stellar/kelp/support/utils"
)

Expand Down Expand Up @@ -45,7 +44,7 @@ type Trader struct {
fixedIterations *uint64
dataKey *model.BotKey
alert api.Alert
metricsTracker *metrics.MetricsTracker
metricsTracker *plugins.MetricsTracker
startTime time.Time

// initialized runtime vars
Expand Down Expand Up @@ -83,7 +82,7 @@ func MakeTrader(
fixedIterations *uint64,
dataKey *model.BotKey,
alert api.Alert,
metricsTracker *metrics.MetricsTracker,
metricsTracker *plugins.MetricsTracker,
startTime time.Time,
) *Trader {
return &Trader{
Expand Down

0 comments on commit 10f017f

Please sign in to comment.