fix recorder
This commit is contained in:
parent
42eea2346b
commit
1f097b1fd7
@ -42,8 +42,9 @@ type AmbientWeather struct {
|
|||||||
|
|
||||||
func New(appCtx context.Context, awConfig *config.AmbientLocalExporterConfig) *AmbientWeather {
|
func New(appCtx context.Context, awConfig *config.AmbientLocalExporterConfig) *AmbientWeather {
|
||||||
return &AmbientWeather{
|
return &AmbientWeather{
|
||||||
Config: awConfig,
|
Config: awConfig,
|
||||||
appCtx: appCtx,
|
appCtx: appCtx,
|
||||||
|
RWMutex: &sync.RWMutex{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ func (w *WeatherRecorder) Get(ctx context.Context, last int) (
|
|||||||
span.SetAttributes(
|
span.SetAttributes(
|
||||||
attribute.Int("last", last),
|
attribute.Int("last", last),
|
||||||
attribute.Int("keep", w.keep),
|
attribute.Int("keep", w.keep),
|
||||||
attribute.Int("currentSize", w.Count()),
|
attribute.Int("currentSize", w.Count(ctx)),
|
||||||
)
|
)
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ func (w *WeatherRecorder) get(ctx context.Context, last int) (
|
|||||||
span := trace.SpanFromContext(ctx)
|
span := trace.SpanFromContext(ctx)
|
||||||
|
|
||||||
w.RLock()
|
w.RLock()
|
||||||
defer w.Unlock()
|
defer w.RUnlock()
|
||||||
|
|
||||||
span.AddEvent("acquired lock on recorder cache")
|
span.AddEvent("acquired lock on recorder cache")
|
||||||
|
|
||||||
@ -70,8 +70,8 @@ func (w *WeatherRecorder) get(ctx context.Context, last int) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns count of retained weather updates
|
// Returns count of retained weather updates
|
||||||
func (w *WeatherRecorder) Count() int {
|
func (w *WeatherRecorder) Count(ctx context.Context) int {
|
||||||
_, span := w.tracer.Start(w.ctx, "countWeatherRecorder")
|
_, span := w.tracer.Start(ctx, "countWeatherRecorder")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
count := w.count()
|
count := w.count()
|
||||||
|
@ -10,9 +10,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (w *WeatherRecorder) Set(ctx context.Context, u *weather.WeatherUpdate) error {
|
func (w *WeatherRecorder) Set(ctx context.Context, u *weather.WeatherUpdate) error {
|
||||||
_, span := w.tracer.Start(ctx, "recordWeatherUpdate")
|
ctx, span := w.tracer.Start(ctx, "recordWeatherUpdate")
|
||||||
span.SetAttributes(
|
span.SetAttributes(
|
||||||
attribute.Int("countWeatherUpdates", w.Count()),
|
attribute.Int("countWeatherUpdates", w.Count(ctx)),
|
||||||
attribute.Int("keepUpdates", w.keep),
|
attribute.Int("keepUpdates", w.keep),
|
||||||
)
|
)
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user