This commit is contained in:
parent
b4412a461f
commit
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,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user