Skip to content

Commit 07b9ab8

Browse files
committed
Ignore rows that have uneven slices
1 parent 00a8754 commit 07b9ab8

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
GOOSARCH=${{matrix.goosarch}}
4848
GOOS=${GOOSARCH%/*}
4949
GOARCH=${GOOSARCH#*/}
50-
BINARY_NAME=explo-$GOOS-$GOARCH
50+
BINARY_NAME=nasdaqbaltic_exporter-$GOOS-$GOARCH
5151
echo "BINARY_NAME=$BINARY_NAME" >> $GITHUB_ENV
5252
echo "GOOS=$GOOS" >> $GITHUB_ENV
5353
echo "GOARCH=$GOARCH" >> $GITHUB_ENV

metrics.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"os"
66
"strconv"
77
"time"
8+
"log"
89

910
"github.com/prometheus/client_golang/prometheus"
1011
)
@@ -29,27 +30,26 @@ func (c *CustomCollector) Collect(ch chan<- prometheus.Metric) {
2930

3031
loc, err := time.LoadLocation("Europe/Tallinn") // Load timezone in the baltics
3132
if err != nil {
32-
fmt.Println("Failed to load location:" + err.Error())
33+
log.Printf("failed to load location: %s", err)
3334
}
3435

3536
checkTime(c, loc)
3637

3738
data := readAllStocks()
3839

3940
for _, row := range data[1:] {
40-
var industry string
41-
var superSector string
41+
42+
if len(row) != 20 { // Ignore companies that have don't have industry and supersector defined
43+
continue
44+
}
4245

46+
industry := row[18]
47+
superSector := row[19]
4348
price, _ := strconv.ParseFloat(row[11], 64)
4449
trades, _ := strconv.ParseFloat(row[15], 64)
4550
volume, _ := strconv.ParseFloat(row[16], 64)
4651
turnover, _ := strconv.ParseFloat(row[17], 64)
4752

48-
if len(row) == 20 { // Some companies might be missing Industry and Supersector
49-
industry = row[18]
50-
superSector = row[19]
51-
}
52-
5353
t := time.Now().In(loc).Add(-15 * time.Minute)
5454
stockPrice := prometheus.NewMetricWithTimestamp(t, prometheus.MustNewConstMetric(c.stockPriceMetric, prometheus.GaugeValue, price, row[0], row[1], row[4], industry, superSector, row[5]))
5555
stockTrades := prometheus.NewMetricWithTimestamp(t, prometheus.MustNewConstMetric(c.stockTradeMetric, prometheus.CounterValue, trades, row[0], row[1], row[4], industry, superSector, row[5]))

0 commit comments

Comments
 (0)