From eaf2cf211d196a79961dffe63ddc665f6480e79e Mon Sep 17 00:00:00 2001 From: Ryan D McGuire Date: Sun, 12 Jan 2025 19:06:45 -0500 Subject: [PATCH] Update wunderground url --- TODO.md | 2 ++ pkg/provider/wunderground/provider.go | 2 +- pkg/provider/wunderground/proxy.go | 8 +++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/TODO.md b/TODO.md index 89fa606..a2f6184 100644 --- a/TODO.md +++ b/TODO.md @@ -4,6 +4,8 @@ - [ ] Add Grafana dashboard - [ ] Add proxy to upstream support - [ ] Add new spans +- [ ] Fix wunderground 401 +- [ ] Perform proxy calls in goroutines ## Done - [x] Configuration for app diff --git a/pkg/provider/wunderground/provider.go b/pkg/provider/wunderground/provider.go index f33b629..6d5ac95 100644 --- a/pkg/provider/wunderground/provider.go +++ b/pkg/provider/wunderground/provider.go @@ -15,7 +15,7 @@ type WUProvider struct{} const ( providerName = "weatherunderground" - wuURL = "http://rtupdate.wunderground.com/weatherstation/updateweatherstation.php" + wuURL = "https://rtupdate.wunderground.com/weatherstation/updateweatherstation.php" ) func (wu *WUProvider) Name() string { diff --git a/pkg/provider/wunderground/proxy.go b/pkg/provider/wunderground/proxy.go index 0bce744..588c117 100644 --- a/pkg/provider/wunderground/proxy.go +++ b/pkg/provider/wunderground/proxy.go @@ -4,7 +4,6 @@ import ( "context" "errors" "net/url" - "time" "github.com/go-resty/resty/v2" "go.opentelemetry.io/otel/attribute" @@ -39,6 +38,9 @@ func (wu *WUProvider) ProxyReq(ctx context.Context, update *weather.WeatherUpdat Get(wuURL) if err != nil { span.SetStatus(codes.Error, err.Error()) + span.SetAttributes( + attribute.String("query", resp.Request.QueryParam.Encode()), + ) span.RecordError(err) } @@ -52,11 +54,11 @@ func (wu *WUProvider) ProxyReq(ctx context.Context, update *weather.WeatherUpdat func updateToWuParams(u *weather.WeatherUpdate) *url.Values { params := &url.Values{} - params.Set("dateutc", time.Now().Format(time.DateTime)) weather.SetURLVal(params, "ID", &u.StationConfig.WundergroundID) weather.SetURLVal(params, "PASSWORD", &u.StationConfig.WundergroundPassword) + params.Set("action", "updateraw") + params.Set("dateutc", "now") weather.SetURLVal(params, "UV", u.UV) - weather.SetURLVal(params, "action", ptr.To("updateraw")) weather.SetURLVal(params, "baromin", u.BaromRelativeIn) weather.SetURLVal(params, "dailyrainin", u.DailyRainIn) weather.SetURLVal(params, "dewptf", u.DewPointF)