Compare commits
	
		
			2 Commits
		
	
	
		
			v0.3.0
			...
			3af1cc40a5
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 3af1cc40a5 | |||
| 4ff684abe3 | 
							
								
								
									
										2
									
								
								TODO.md
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								TODO.md
									
									
									
									
									
								
							@@ -1,10 +1,12 @@
 | 
				
			|||||||
# TODO
 | 
					# TODO
 | 
				
			||||||
- [ ] Configuration for app
 | 
					- [ ] Configuration for app
 | 
				
			||||||
 | 
					- [ ] Configurable metric prefix
 | 
				
			||||||
- [ ] Helm Chart
 | 
					- [ ] Helm Chart
 | 
				
			||||||
- [ ] Update README
 | 
					- [ ] Update README
 | 
				
			||||||
- [ ] Add Grafana dashboard
 | 
					- [ ] Add Grafana dashboard
 | 
				
			||||||
- [ ] Add device name field with ID/Key mappings
 | 
					- [ ] Add device name field with ID/Key mappings
 | 
				
			||||||
- [ ] Add device type field with ID/Key mappings
 | 
					- [ ] Add device type field with ID/Key mappings
 | 
				
			||||||
 | 
					- [ ] Move EVERYTHING to pointers to support nil
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Done
 | 
					## Done
 | 
				
			||||||
- [x] Consolidate battery status into one metric with device label
 | 
					- [x] Consolidate battery status into one metric with device label
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -43,6 +43,8 @@ type WeatherMetrics struct {
 | 
				
			|||||||
	meter           metric.Meter
 | 
						meter           metric.Meter
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var MetricPrefix = "weather"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func MustInitMetrics(appCtx context.Context) *WeatherMetrics {
 | 
					func MustInitMetrics(appCtx context.Context) *WeatherMetrics {
 | 
				
			||||||
	wm := &WeatherMetrics{
 | 
						wm := &WeatherMetrics{
 | 
				
			||||||
		appCtx: appCtx,
 | 
							appCtx: appCtx,
 | 
				
			||||||
@@ -52,55 +54,55 @@ func MustInitMetrics(appCtx context.Context) *WeatherMetrics {
 | 
				
			|||||||
	wm.meter = otel.GetMeter(appCtx, "weather", "metrics")
 | 
						wm.meter = otel.GetMeter(appCtx, "weather", "metrics")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Weather Metrics
 | 
						// Weather Metrics
 | 
				
			||||||
	wm.TempOutdoorF, _ = wm.meter.Float64Gauge("weather_temp_outdoor_f",
 | 
						wm.TempOutdoorF, _ = wm.meter.Float64Gauge(MetricPrefix+"_temp_outdoor_f",
 | 
				
			||||||
		metric.WithDescription("Outdoor Temperature in Faherenheit"))
 | 
							metric.WithDescription("Outdoor Temperature in Faherenheit"))
 | 
				
			||||||
	wm.TempIndoorF, _ = wm.meter.Float64Gauge("weather_temp_indoor_f",
 | 
						wm.TempIndoorF, _ = wm.meter.Float64Gauge(MetricPrefix+"_temp_indoor_f",
 | 
				
			||||||
		metric.WithDescription("Indoor Temperature in Faherenheit"))
 | 
							metric.WithDescription("Indoor Temperature in Faherenheit"))
 | 
				
			||||||
	wm.HumidityOudoor, _ = wm.meter.Int64Gauge("weather_humidity_outdoor",
 | 
						wm.HumidityOudoor, _ = wm.meter.Int64Gauge(MetricPrefix+"_humidity_outdoor",
 | 
				
			||||||
		metric.WithDescription("Outdoor Humidity %"))
 | 
							metric.WithDescription("Outdoor Humidity %"))
 | 
				
			||||||
	wm.HumidityIndoor, _ = wm.meter.Int64Gauge("weather_humidity_indoor",
 | 
						wm.HumidityIndoor, _ = wm.meter.Int64Gauge(MetricPrefix+"_humidity_indoor",
 | 
				
			||||||
		metric.WithDescription("Indoor Humidity %"))
 | 
							metric.WithDescription("Indoor Humidity %"))
 | 
				
			||||||
	wm.WindSpeedMPH, _ = wm.meter.Float64Gauge("weather_wind_speed_mph",
 | 
						wm.WindSpeedMPH, _ = wm.meter.Float64Gauge(MetricPrefix+"_wind_speed_mph",
 | 
				
			||||||
		metric.WithDescription("Wind Speed in MPH"))
 | 
							metric.WithDescription("Wind Speed in MPH"))
 | 
				
			||||||
	wm.WindGustMPH, _ = wm.meter.Float64Gauge("weather_wind_gust_mph",
 | 
						wm.WindGustMPH, _ = wm.meter.Float64Gauge(MetricPrefix+"_wind_gust_mph",
 | 
				
			||||||
		metric.WithDescription("Wind Gust in MPH"))
 | 
							metric.WithDescription("Wind Gust in MPH"))
 | 
				
			||||||
	wm.MaxDailyGust, _ = wm.meter.Float64Gauge("weather_max_daily_gust",
 | 
						wm.MaxDailyGust, _ = wm.meter.Float64Gauge(MetricPrefix+"_max_daily_gust",
 | 
				
			||||||
		metric.WithDescription("Max Daily Wind Gust"))
 | 
							metric.WithDescription("Max Daily Wind Gust"))
 | 
				
			||||||
	wm.WindDir, _ = wm.meter.Int64Gauge("weather_wind_dir",
 | 
						wm.WindDir, _ = wm.meter.Int64Gauge(MetricPrefix+"_wind_dir",
 | 
				
			||||||
		metric.WithDescription("Wind Direction in Degrees"))
 | 
							metric.WithDescription("Wind Direction in Degrees"))
 | 
				
			||||||
	wm.WindDirAvg10m, _ = wm.meter.Int64Gauge("weather_wind_dir_avg_10m",
 | 
						wm.WindDirAvg10m, _ = wm.meter.Int64Gauge(MetricPrefix+"_wind_dir_avg_10m",
 | 
				
			||||||
		metric.WithDescription("Wind Direction 10m Average"))
 | 
							metric.WithDescription("Wind Direction 10m Average"))
 | 
				
			||||||
	wm.UV, _ = wm.meter.Int64Gauge("weather_uv",
 | 
						wm.UV, _ = wm.meter.Int64Gauge(MetricPrefix+"_uv",
 | 
				
			||||||
		metric.WithDescription("UV Index"))
 | 
							metric.WithDescription("UV Index"))
 | 
				
			||||||
	wm.SolarRadiation, _ = wm.meter.Float64Gauge("weather_solar_radiation",
 | 
						wm.SolarRadiation, _ = wm.meter.Float64Gauge(MetricPrefix+"_solar_radiation",
 | 
				
			||||||
		metric.WithDescription("Solar Radiation in W/㎡"))
 | 
							metric.WithDescription("Solar Radiation in W/㎡"))
 | 
				
			||||||
	wm.HourlyRainIn, _ = wm.meter.Float64Gauge("weather_hourly_rain_in",
 | 
						wm.HourlyRainIn, _ = wm.meter.Float64Gauge(MetricPrefix+"_hourly_rain_in",
 | 
				
			||||||
		metric.WithDescription("Hourly Rain in Inches"))
 | 
							metric.WithDescription("Hourly Rain in Inches"))
 | 
				
			||||||
	wm.EventRainIn, _ = wm.meter.Float64Gauge("weather_event_rain_in",
 | 
						wm.EventRainIn, _ = wm.meter.Float64Gauge(MetricPrefix+"_event_rain_in",
 | 
				
			||||||
		metric.WithDescription("Event Rain in Inches"))
 | 
							metric.WithDescription("Event Rain in Inches"))
 | 
				
			||||||
	wm.DailyRainIn, _ = wm.meter.Float64Gauge("weather_daily_rain_in",
 | 
						wm.DailyRainIn, _ = wm.meter.Float64Gauge(MetricPrefix+"_daily_rain_in",
 | 
				
			||||||
		metric.WithDescription("Daily Rain in Inches"))
 | 
							metric.WithDescription("Daily Rain in Inches"))
 | 
				
			||||||
	wm.WeeklyRainIn, _ = wm.meter.Float64Gauge("weather_weekly_rain_in",
 | 
						wm.WeeklyRainIn, _ = wm.meter.Float64Gauge(MetricPrefix+"_weekly_rain_in",
 | 
				
			||||||
		metric.WithDescription("Weekly Rain in Inches"))
 | 
							metric.WithDescription("Weekly Rain in Inches"))
 | 
				
			||||||
	wm.MonthlyRainIn, _ = wm.meter.Float64Gauge("weather_monthly_rain_in",
 | 
						wm.MonthlyRainIn, _ = wm.meter.Float64Gauge(MetricPrefix+"_monthly_rain_in",
 | 
				
			||||||
		metric.WithDescription("Monthly Rain in Inches"))
 | 
							metric.WithDescription("Monthly Rain in Inches"))
 | 
				
			||||||
	wm.YearlyRainIn, _ = wm.meter.Float64Gauge("weather_yearly_rain_in",
 | 
						wm.YearlyRainIn, _ = wm.meter.Float64Gauge(MetricPrefix+"_yearly_rain_in",
 | 
				
			||||||
		metric.WithDescription("Yearly Rain in Inches"))
 | 
							metric.WithDescription("Yearly Rain in Inches"))
 | 
				
			||||||
	wm.TotalRainIn, _ = wm.meter.Float64Gauge("weather_total_rain_in",
 | 
						wm.TotalRainIn, _ = wm.meter.Float64Gauge(MetricPrefix+"_total_rain_in",
 | 
				
			||||||
		metric.WithDescription("Total Rain in Inches"))
 | 
							metric.WithDescription("Total Rain in Inches"))
 | 
				
			||||||
	wm.BatteryStatus, _ = wm.meter.Int64Gauge("battery_status",
 | 
						wm.BatteryStatus, _ = wm.meter.Int64Gauge(MetricPrefix+"_battery_status",
 | 
				
			||||||
		metric.WithDescription("Per-component battery status"))
 | 
							metric.WithDescription("Per-component battery status"))
 | 
				
			||||||
	wm.BaromRelativeIn, _ = wm.meter.Float64Gauge("weather_barometric_pressure_relative_in",
 | 
						wm.BaromRelativeIn, _ = wm.meter.Float64Gauge(MetricPrefix+"_barometric_pressure_relative_in",
 | 
				
			||||||
		metric.WithDescription("Relative Pressure in Inches of Mercury"))
 | 
							metric.WithDescription("Relative Pressure in Inches of Mercury"))
 | 
				
			||||||
	wm.BaromAbsoluteIn, _ = wm.meter.Float64Gauge("weather_barometric_pressure_absolute_in",
 | 
						wm.BaromAbsoluteIn, _ = wm.meter.Float64Gauge(MetricPrefix+"_barometric_pressure_absolute_in",
 | 
				
			||||||
		metric.WithDescription("Absolute Pressure in Inches of Mercury"))
 | 
							metric.WithDescription("Absolute Pressure in Inches of Mercury"))
 | 
				
			||||||
	wm.DewPointF, _ = wm.meter.Float64Gauge("weather_dew_point_f",
 | 
						wm.DewPointF, _ = wm.meter.Float64Gauge(MetricPrefix+"_dew_point_f",
 | 
				
			||||||
		metric.WithDescription("Dew Point in Faherenheit"))
 | 
							metric.WithDescription("Dew Point in Faherenheit"))
 | 
				
			||||||
	wm.WindChillF, _ = wm.meter.Float64Gauge("weather_wind_chill_f",
 | 
						wm.WindChillF, _ = wm.meter.Float64Gauge(MetricPrefix+"_wind_chill_f",
 | 
				
			||||||
		metric.WithDescription("Wind Chill in Faherenheit"))
 | 
							metric.WithDescription("Wind Chill in Faherenheit"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Internal Telemetry
 | 
						// Internal Telemetry
 | 
				
			||||||
	wm.UpdatesReceived, _ = wm.meter.Int64Counter("weather_updates_received",
 | 
						wm.UpdatesReceived, _ = wm.meter.Int64Counter(MetricPrefix+"_updates_received",
 | 
				
			||||||
		metric.WithDescription("Metric Updates Processed by Exporter"))
 | 
							metric.WithDescription("Metric Updates Processed by Exporter"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return wm
 | 
						return wm
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user