This commit is contained in:
parent
042fd221c4
commit
b4412a461f
@ -81,9 +81,9 @@ func (aw *AmbientWeather) handleProviderRequest(
|
||||
l := zerolog.Ctx(aw.appCtx)
|
||||
tracer := otel.GetTracer(aw.appCtx, p.Name()+".http.handler")
|
||||
|
||||
ctx, span := tracer.Start(r.Context(), p.Name()+".update")
|
||||
span.SetAttributes(attribute.String("provider", p.Name()))
|
||||
defer span.End()
|
||||
ctx, updateSpan := tracer.Start(r.Context(), p.Name()+".update")
|
||||
updateSpan.SetAttributes(attribute.String("provider", p.Name()))
|
||||
defer updateSpan.End()
|
||||
|
||||
l.Trace().Str("p", p.Name()).
|
||||
Any("query", r.URL.Query()).Send()
|
||||
@ -92,8 +92,8 @@ func (aw *AmbientWeather) handleProviderRequest(
|
||||
update, err := p.ReqToWeather(ctx, r)
|
||||
if err != nil {
|
||||
l.Err(err).Send()
|
||||
span.RecordError(err)
|
||||
span.SetStatus(codes.Error,
|
||||
updateSpan.RecordError(err)
|
||||
updateSpan.SetStatus(codes.Error,
|
||||
fmt.Sprintf("failed to handle %s update: %s",
|
||||
p.Name(), err.Error()))
|
||||
|
||||
@ -106,13 +106,7 @@ func (aw *AmbientWeather) handleProviderRequest(
|
||||
aw.enrichUpdate(ctx, p, update)
|
||||
|
||||
// Update metrics
|
||||
ctx, updateSpan := tracer.Start(ctx, p.Name()+".update.metrics")
|
||||
if aw.metrics == nil {
|
||||
aw.InitMetrics()
|
||||
}
|
||||
aw.metrics.Update(update)
|
||||
updateSpan.SetStatus(codes.Ok, "")
|
||||
updateSpan.End()
|
||||
aw.metricsUpdate(ctx, p, update)
|
||||
|
||||
l.Debug().
|
||||
Str("provider", p.Name()).
|
||||
@ -128,6 +122,24 @@ func (aw *AmbientWeather) handleProviderRequest(
|
||||
}
|
||||
}
|
||||
|
||||
func (aw *AmbientWeather) metricsUpdate(
|
||||
ctx context.Context,
|
||||
p provider.AmbientProvider,
|
||||
update *weather.WeatherUpdate,
|
||||
) {
|
||||
tracer := otel.GetTracer(aw.appCtx, p.Name()+".http.handler")
|
||||
_, metricsSpan := tracer.Start(ctx, p.Name()+".update.metrics")
|
||||
|
||||
if aw.metrics == nil {
|
||||
aw.InitMetrics()
|
||||
}
|
||||
|
||||
aw.metrics.Update(update)
|
||||
|
||||
metricsSpan.SetStatus(codes.Ok, "")
|
||||
metricsSpan.End()
|
||||
}
|
||||
|
||||
func (aw *AmbientWeather) enrichUpdate(
|
||||
ctx context.Context,
|
||||
p provider.AmbientProvider,
|
||||
@ -137,7 +149,7 @@ func (aw *AmbientWeather) enrichUpdate(
|
||||
|
||||
// Calculate any fields that may be missing
|
||||
// such as dew point and wind chill
|
||||
ctx, enrichSpan := tracer.Start(ctx, p.Name()+".update.enrich")
|
||||
_, enrichSpan := tracer.Start(ctx, p.Name()+".update.enrich")
|
||||
defer enrichSpan.End()
|
||||
|
||||
update.Enrich()
|
||||
@ -161,7 +173,7 @@ func (aw *AmbientWeather) proxyUpdate(
|
||||
tracer := otel.GetTracer(aw.appCtx, p.Name()+".http.handler")
|
||||
station := update.StationConfig
|
||||
|
||||
ctx, proxySpan := tracer.Start(ctx, p.Name()+".update.proxy", trace.WithAttributes(
|
||||
_, proxySpan := tracer.Start(ctx, p.Name()+".update.proxy", trace.WithAttributes(
|
||||
attribute.Bool("proxyToWunderground", station.ProxyToWunderground),
|
||||
attribute.Bool("proxyToAWN", station.ProxyToAWN),
|
||||
))
|
||||
|
Loading…
x
Reference in New Issue
Block a user