Skip to content

Commit

Permalink
Rename spawn_sticky_periodic_task to spawn_interactive_periodic_task
Browse files Browse the repository at this point in the history
We always wanted to do that now that it's using the new thread pools, we
just never did. And now seems like a good time to do that
  • Loading branch information
NHDaly committed Nov 3, 2023
1 parent 09bc5c0 commit a278726
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/StatsdExport/StatsdExport.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using Dates: now, Period, Millisecond, Second
using ProductionMonitoring.Metrics
using ProductionMonitoring.Metrics: NumericMetric
using Sockets
using ProductionMonitoring.ThreadingUtils: PeriodicTask, @spawn_sticky_periodic_task, stop_periodic_task!
using ProductionMonitoring.ThreadingUtils: PeriodicTask, @spawn_interactive_periodic_task, stop_periodic_task!

# Environment variable names for configuring dogstatsd backend.
const ENV_DD_DOGSTATSD_HOST = "DD_DOGSTATSD_HOST"
Expand Down Expand Up @@ -105,7 +105,7 @@ background thread will be stored in `data.exporter_thread`.
"""
function start_statsd_exporter!(data::StatsdExporter)
if Dates.value(data.send_interval) > 0
data.periodic_task = @spawn_sticky_periodic_task(
data.periodic_task = @spawn_interactive_periodic_task(
"StatsdExporter",
data.send_interval,
send_metric_updates(data),
Expand Down
2 changes: 1 addition & 1 deletion src/ThreadingUtils/ThreadingUtils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ macro spawn_periodic_task(period, expr, name="Unnamed", ending_expr=nothing)
end
end

macro spawn_sticky_periodic_task(name, period, expr, ending_expr=nothing)
macro spawn_interactive_periodic_task(name, period, expr, ending_expr=nothing)
return quote
n = $(esc(name))
p = $(esc(period))
Expand Down
10 changes: 5 additions & 5 deletions src/ThreadingUtils/ThreadingUtils_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# end
#
# accumulator = Atomic{Int64}(0)
# t = ThreadingUtils.@spawn_sticky_periodic_task "Adder" Dates.Millisecond(9) atomic_add!(accumulator, 1)
# t = ThreadingUtils.@spawn_interactive_periodic_task "Adder" Dates.Millisecond(9) atomic_add!(accumulator, 1)
# sleep(0.1)
# @test istaskstarted(t)
# @test istaskstarted(t.task)
Expand All @@ -41,7 +41,7 @@
# @test accumulator[] == curr_value
#end

@testitem "spawn_sticky_periodic_task on correct threadpool" begin
@testitem "spawn_interactive_periodic_task on correct threadpool" begin
using ProductionMonitoring.ThreadingUtils
using Dates
@static if Threads.nthreads(:interactive) > 0
Expand All @@ -51,7 +51,7 @@
task_executed = Dict{Int,Int}()
Threads.@threads :static for i in 1:Threads.nthreads()
@lock tlock begin
t = ThreadingUtils.@spawn_sticky_periodic_task "T-$i" Dates.Millisecond(100) begin
t = ThreadingUtils.@spawn_interactive_periodic_task "T-$i" Dates.Millisecond(100) begin
scheduled_at[i] = Threads.threadpool()
task_executed[i] = 1
end
Expand Down Expand Up @@ -85,7 +85,7 @@ end
end

acc = Atomic{Int64}(0)
t = ThreadingUtils.@spawn_sticky_periodic_task "Exceptional" Dates.Millisecond(10) increment_up_to_five(acc)
t = ThreadingUtils.@spawn_interactive_periodic_task "Exceptional" Dates.Millisecond(10) increment_up_to_five(acc)
sleep(0.1)
@test istaskstarted(t)
@test istaskstarted(t.task)
Expand Down Expand Up @@ -113,7 +113,7 @@ end
@testitem "spawn named sticky periodic task" begin
using ProductionMonitoring.ThreadingUtils
using Dates
t = ThreadingUtils.@spawn_sticky_periodic_task "Named" Dates.Millisecond(10) sleep(0.01)
t = ThreadingUtils.@spawn_interactive_periodic_task "Named" Dates.Millisecond(10) sleep(0.01)
@test t.name == "Named"
ThreadingUtils.stop_periodic_task!(t)
end
Expand Down
2 changes: 1 addition & 1 deletion src/ThreadingUtils/micrometrics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function MicrometricManager()
mm = MicrometricManager(ReentrantLock(), Micrometric[])
# The theory was that this commented-out line would ensure that metrics are reported
# every two seconds, but I could never get it to work properly.
# @spawn_sticky_periodic_task "ThreadingUtils.MicrometricManager" Dates.Second(2) mm_thread()
# @spawn_interactive_periodic_task "ThreadingUtils.MicrometricManager" Dates.Second(2) mm_thread()
return mm
end

Expand Down
6 changes: 3 additions & 3 deletions src/Tracing/TracingConfig.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Tracing Configuration

using ProductionMonitoring.ThreadingUtils: PeriodicTask, @spawn_sticky_periodic_task, stop_periodic_task!
using ProductionMonitoring.ThreadingUtils: PeriodicTask, @spawn_interactive_periodic_task, stop_periodic_task!

# AbstractThreshold is the super types of all the available span thresholds.
# Each of the subtype is solely used by a should_span_be_filtered method.
Expand Down Expand Up @@ -86,7 +86,7 @@ end
function start_datadog_exporter!()
if isnothing(tracing_config.datadog_bg)
tracing_config.datadog_bg =
@spawn_sticky_periodic_task "DatadogTraceUploader" Dates.Second(
@spawn_interactive_periodic_task "DatadogTraceUploader" Dates.Second(
DEFAULT_BATCH_DELAY,
) datadog_buffer_spans_and_send!() datadog_buffer_spans_and_send!()
@info "Datadog tracing will send spans to $(get_datadog_trace_backend_url())"
Expand All @@ -96,7 +96,7 @@ end
function start_zipkin_exporter!()
if isnothing(tracing_config.zipkin_bg)
tracing_config.zipkin_bg =
@spawn_sticky_periodic_task "ZipkinTraceUploader" Dates.Second(
@spawn_interactive_periodic_task "ZipkinTraceUploader" Dates.Second(
DEFAULT_BATCH_DELAY,
) zipkin_buffer_spans_and_send() zipkin_buffer_spans_and_send()
end
Expand Down

0 comments on commit a278726

Please sign in to comment.