Compare commits

...

5 Commits

Author SHA1 Message Date
e1ff48a262 bump chart
All checks were successful
Build and Publish / check-chart (push) Successful in 14s
Build and Publish / helm-release (push) Successful in 33s
Build and Publish / release (push) Successful in 5m10s
2025-04-19 12:29:46 -04:00
be629e3d00 correct lightning distance unit
All checks were successful
Build and Publish / release (push) Has been skipped
Build and Publish / check-chart (push) Successful in 10s
Build and Publish / helm-release (push) Has been skipped
2025-04-19 12:29:14 -04:00
f2fd297218 bump helm chart
All checks were successful
Build and Publish / release (push) Has been skipped
Build and Publish / check-chart (push) Successful in 10s
Build and Publish / helm-release (push) Successful in 24s
2025-04-03 16:17:04 -04:00
ac000112c3 implement redis key ttl
All checks were successful
Build and Publish / check-chart (push) Successful in 12s
Build and Publish / helm-release (push) Has been skipped
Build and Publish / release (push) Successful in 3m33s
2025-04-03 16:00:57 -04:00
21a4165489 implement redis key ttl
All checks were successful
Build and Publish / check-chart (push) Successful in 12s
Build and Publish / helm-release (push) Has been skipped
Build and Publish / release (push) Successful in 3m52s
2025-04-03 15:51:52 -04:00
6 changed files with 29 additions and 6 deletions

View File

@ -121,6 +121,10 @@
"default": "127.0.0.1", "default": "127.0.0.1",
"type": "string" "type": "string"
}, },
"redisKeyTTL": {
"default": "24h",
"type": "string"
},
"redisPassword": { "redisPassword": {
"type": "string" "type": "string"
}, },

View File

@ -15,13 +15,13 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes # This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version. # to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/) # Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.10 version: 0.1.12
# This is the version number of the application being deployed. This version number should be # This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to # incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using. # follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes. # It is recommended to use it with quotes.
appVersion: "v0.15.6" appVersion: "v0.18.1"
dependencies: dependencies:
- name: hull - name: hull

View File

@ -22,4 +22,5 @@ type RedisConfig struct {
RedisDB int `yaml:"redisDB" env:"REDIS_DB" default:"0" json:"redisDB,omitempty"` RedisDB int `yaml:"redisDB" env:"REDIS_DB" default:"0" json:"redisDB,omitempty"`
RedisTLS bool `yaml:"redisTLS" env:"REDIS_TLS" default:"false" json:"redisTLS,omitempty"` RedisTLS bool `yaml:"redisTLS" env:"REDIS_TLS" default:"false" json:"redisTLS,omitempty"`
RedisTLSInsecure bool `yaml:"redisTLSInsecure" env:"REDIS_TLS_INSECURE" default:"false" json:"redisTLSInsecure,omitempty"` RedisTLSInsecure bool `yaml:"redisTLSInsecure" env:"REDIS_TLS_INSECURE" default:"false" json:"redisTLSInsecure,omitempty"`
RedisKeyTTL string `yaml:"redisKeyTTL" env:"REDIS_KEY_TTL" default:"24h" json:"redisKeyTTL,omitempty"`
} }

View File

@ -71,7 +71,7 @@ func MustInitMetrics(appCtx context.Context) *WeatherMetrics {
metric.WithDescription("Count of lightning strikes for current day")) metric.WithDescription("Count of lightning strikes for current day"))
wm.LightningLastDistance, _ = wm.meter.Int64Gauge(MetricPrefix+"_lightning_last_distance", wm.LightningLastDistance, _ = wm.meter.Int64Gauge(MetricPrefix+"_lightning_last_distance",
metric.WithDescription("Last measured lightning distance"), metric.WithDescription("Last measured lightning distance"),
metric.WithUnit("kph")) metric.WithUnit("km"))
wm.LightningLastTime, _ = wm.meter.Int64Gauge(MetricPrefix+"_lightning_last_time", wm.LightningLastTime, _ = wm.meter.Int64Gauge(MetricPrefix+"_lightning_last_time",
metric.WithDescription("Last lightning time (epoch)"), metric.WithDescription("Last lightning time (epoch)"),
metric.WithUnit("s")) metric.WithUnit("s"))

View File

@ -5,6 +5,7 @@ import (
"crypto/tls" "crypto/tls"
"fmt" "fmt"
"sync" "sync"
"time"
"gitea.libretechconsulting.com/rmcguire/go-app/pkg/otel" "gitea.libretechconsulting.com/rmcguire/go-app/pkg/otel"
"go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/attribute"
@ -20,6 +21,7 @@ import (
) )
const ( const (
DEF_TTL = "24h"
DEF_RETAIN = 120 DEF_RETAIN = 120
UPDATES_KEY = "weatherUpdates" UPDATES_KEY = "weatherUpdates"
NAME = "redis recorder" NAME = "redis recorder"
@ -27,6 +29,7 @@ const (
type RedisRecorder struct { type RedisRecorder struct {
baseCtx context.Context baseCtx context.Context
keyTTL time.Duration
tracer trace.Tracer tracer trace.Tracer
redis *redis.Client redis *redis.Client
config *config.AmbientLocalExporterConfig config *config.AmbientLocalExporterConfig
@ -42,8 +45,11 @@ func (r *RedisRecorder) Ping(ctx context.Context) error {
} }
func (r *RedisRecorder) Init(ctx context.Context, opts *recorders.RecorderOpts) { func (r *RedisRecorder) Init(ctx context.Context, opts *recorders.RecorderOpts) {
r.baseCtx = opts.BaseCtx
r.log = zerolog.Ctx(r.baseCtx)
if opts.AppConfig.RecorderConfig.RedisConfig == nil { if opts.AppConfig.RecorderConfig.RedisConfig == nil {
panic("refusing to init redis recorder with no redisConfig") r.log.Panic().Msg("refusing to init redis recorder with no redisConfig")
} }
if opts.RetainLast < 1 { if opts.RetainLast < 1 {
@ -53,8 +59,18 @@ func (r *RedisRecorder) Init(ctx context.Context, opts *recorders.RecorderOpts)
r.config = opts.AppConfig r.config = opts.AppConfig
r.keep = opts.RetainLast r.keep = opts.RetainLast
r.RWMutex = &sync.RWMutex{} r.RWMutex = &sync.RWMutex{}
r.baseCtx = opts.BaseCtx
r.log = zerolog.Ctx(r.baseCtx) keyTTL := opts.AppConfig.RecorderConfig.RedisConfig.RedisKeyTTL
if keyTTL == "" {
keyTTL = DEF_TTL
}
var err error
r.keyTTL, err = time.ParseDuration(keyTTL)
if err != nil {
r.log.Panic().Str("redisKeyTTL", keyTTL).Err(err).
Msg("invalid redis key ttl provided")
}
r.tracer = otel.GetTracer(r.baseCtx, "redisRecorder") r.tracer = otel.GetTracer(r.baseCtx, "redisRecorder")
ctx, span := r.tracer.Start(ctx, "redisRecorder.init", trace.WithAttributes( ctx, span := r.tracer.Start(ctx, "redisRecorder.init", trace.WithAttributes(
@ -62,6 +78,7 @@ func (r *RedisRecorder) Init(ctx context.Context, opts *recorders.RecorderOpts)
attribute.Int("retainLast", opts.RetainLast), attribute.Int("retainLast", opts.RetainLast),
attribute.Int("redisPort", opts.AppConfig.RecorderConfig.RedisConfig.RedisPort), attribute.Int("redisPort", opts.AppConfig.RecorderConfig.RedisConfig.RedisPort),
attribute.Bool("tls", opts.AppConfig.RecorderConfig.RedisConfig.RedisTLS), attribute.Bool("tls", opts.AppConfig.RecorderConfig.RedisConfig.RedisTLS),
attribute.String("keyTTL", r.keyTTL.String()),
)) ))
defer span.End() defer span.End()

View File

@ -48,6 +48,7 @@ func (r *RedisRecorder) set(ctx context.Context, data []byte) error {
pipe.LPush(ctx, r.Key(), data) pipe.LPush(ctx, r.Key(), data)
pipe.LTrim(ctx, r.Key(), 0, int64(r.keep)-1) pipe.LTrim(ctx, r.Key(), 0, int64(r.keep)-1)
count = pipe.LLen(ctx, r.Key()) count = pipe.LLen(ctx, r.Key())
pipe.Expire(ctx, r.Key(), r.keyTTL)
return nil return nil
}) })
if err != nil { if err != nil {