Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
64ca321c3a | |||
3329c980a9 |
@ -105,6 +105,11 @@ func (aw *AmbientWeather) handleProviderRequest(
|
|||||||
// Perform enrichment
|
// Perform enrichment
|
||||||
aw.enrichUpdate(ctx, p, update)
|
aw.enrichUpdate(ctx, p, update)
|
||||||
|
|
||||||
|
// We may know which station this was for now
|
||||||
|
if update.StationConfig != nil {
|
||||||
|
updateSpan.SetAttributes(attribute.String("stationName", update.StationConfig.Name))
|
||||||
|
}
|
||||||
|
|
||||||
// Update metrics
|
// Update metrics
|
||||||
aw.metricsUpdate(ctx, p, update)
|
aw.metricsUpdate(ctx, p, update)
|
||||||
|
|
||||||
@ -122,6 +127,30 @@ func (aw *AmbientWeather) handleProviderRequest(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (aw *AmbientWeather) enrichUpdate(
|
||||||
|
ctx context.Context,
|
||||||
|
p provider.AmbientProvider,
|
||||||
|
update *weather.WeatherUpdate,
|
||||||
|
) {
|
||||||
|
tracer := otel.GetTracer(aw.appCtx, p.Name()+".http.handler")
|
||||||
|
|
||||||
|
// Calculate any fields that may be missing
|
||||||
|
// such as dew point and wind chill
|
||||||
|
_, enrichSpan := tracer.Start(ctx, p.Name()+".update.enrich")
|
||||||
|
defer enrichSpan.End()
|
||||||
|
|
||||||
|
// Metric enrichment
|
||||||
|
update.Enrich()
|
||||||
|
|
||||||
|
// Enrich station if configured
|
||||||
|
aw.enrichStation(update)
|
||||||
|
|
||||||
|
// Map sensor names
|
||||||
|
update.MapSensors()
|
||||||
|
|
||||||
|
enrichSpan.SetStatus(codes.Ok, "")
|
||||||
|
}
|
||||||
|
|
||||||
func (aw *AmbientWeather) metricsUpdate(
|
func (aw *AmbientWeather) metricsUpdate(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
p provider.AmbientProvider,
|
p provider.AmbientProvider,
|
||||||
@ -140,29 +169,6 @@ func (aw *AmbientWeather) metricsUpdate(
|
|||||||
metricsSpan.End()
|
metricsSpan.End()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (aw *AmbientWeather) enrichUpdate(
|
|
||||||
ctx context.Context,
|
|
||||||
p provider.AmbientProvider,
|
|
||||||
update *weather.WeatherUpdate,
|
|
||||||
) {
|
|
||||||
tracer := otel.GetTracer(aw.appCtx, p.Name()+".http.handler")
|
|
||||||
|
|
||||||
// Calculate any fields that may be missing
|
|
||||||
// such as dew point and wind chill
|
|
||||||
_, enrichSpan := tracer.Start(ctx, p.Name()+".update.enrich")
|
|
||||||
defer enrichSpan.End()
|
|
||||||
|
|
||||||
update.Enrich()
|
|
||||||
|
|
||||||
// Enrich station if configured
|
|
||||||
aw.enrichStation(update)
|
|
||||||
|
|
||||||
// Map sensor names
|
|
||||||
update.MapSensors()
|
|
||||||
|
|
||||||
enrichSpan.SetStatus(codes.Ok, "")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (aw *AmbientWeather) proxyUpdate(
|
func (aw *AmbientWeather) proxyUpdate(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
p provider.AmbientProvider,
|
p provider.AmbientProvider,
|
||||||
@ -173,7 +179,7 @@ func (aw *AmbientWeather) proxyUpdate(
|
|||||||
tracer := otel.GetTracer(aw.appCtx, p.Name()+".http.handler")
|
tracer := otel.GetTracer(aw.appCtx, p.Name()+".http.handler")
|
||||||
station := update.StationConfig
|
station := update.StationConfig
|
||||||
|
|
||||||
_, proxySpan := tracer.Start(ctx, p.Name()+".update.proxy", trace.WithAttributes(
|
ctx, proxySpan := tracer.Start(ctx, p.Name()+".update.proxy", trace.WithAttributes(
|
||||||
attribute.Bool("proxyToWunderground", station.ProxyToWunderground),
|
attribute.Bool("proxyToWunderground", station.ProxyToWunderground),
|
||||||
attribute.Bool("proxyToAWN", station.ProxyToAWN),
|
attribute.Bool("proxyToAWN", station.ProxyToAWN),
|
||||||
))
|
))
|
||||||
|
Reference in New Issue
Block a user