-
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial metrics and traces providers.
- Loading branch information
Showing
12 changed files
with
152 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
# Released under the MIT License. | ||
# Copyright, 2024, by Samuel Williams. | ||
|
||
def prepare | ||
require "metrics/provider/async/task" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
# Released under the MIT License. | ||
# Copyright, 2024, by Samuel Williams. | ||
|
||
def prepare | ||
require "traces/provider/async/task" | ||
require "traces/provider/async/scheduler" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# frozen_string_literal: true | ||
|
||
# Released under the MIT License. | ||
# Copyright, 2024, by Samuel Williams. | ||
|
||
require_relative "async/task" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
# Released under the MIT License. | ||
# Copyright, 2024, by Samuel Williams. | ||
|
||
require_relative "../../../async/task" | ||
require "metrics/provider" | ||
|
||
Metrics::Provider(Async::Task) do | ||
ASYNC_TASK_SCHEDULED = Metrics.metric("async.task.scheduled", :counter, description: "The number of tasks scheduled.") | ||
|
||
def schedule(&block) | ||
ASYNC_TASK_SCHEDULED.emit(1) | ||
|
||
super(&block) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# frozen_string_literal: true | ||
|
||
# Released under the MIT License. | ||
# Copyright, 2024, by Samuel Williams. | ||
|
||
require_relative "async/task" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# frozen_string_literal: true | ||
|
||
# Released under the MIT License. | ||
# Copyright, 2024, by Samuel Williams. | ||
|
||
require_relative "../../../async/scheduler" | ||
require "traces/provider" | ||
|
||
# Traces::Provider(Async::Scheduler) do | ||
# def yield | ||
# Traces.trace("async.scheduler.yield") {super} | ||
# end | ||
|
||
# def block(blocker, timeout) | ||
# attributes = { | ||
# blocker: blocker.to_s, | ||
# timeout: timeout | ||
# } | ||
|
||
# Traces.trace("async.scheduler.block", attributes: attributes) {super} | ||
# end | ||
|
||
# def transfer | ||
# Traces.trace("async.scheduler.transfer") {super} | ||
# end | ||
|
||
# # @asynchronous May be non-blocking.. | ||
# def address_resolve(hostname) | ||
# attributes = { | ||
# hostname: hostname | ||
# } | ||
|
||
# Traces.trace("async.scheduler.address_resolve", attributes: attributes) {super} | ||
# end | ||
|
||
# def process_wait(pid, flags) | ||
# attributes = { | ||
# pid: pid, | ||
# flags: flags | ||
# } | ||
|
||
# Traces.trace("async.scheduler.process_wait", attributes: attributes) {super} | ||
# end | ||
|
||
# def with_timeout(duration, exception = Async::TimeoutError, message = "execution expired", &block) | ||
# attributes = { | ||
# duration: duration, | ||
# } | ||
|
||
# Traces.trace("async.scheduler.with_timeout", attributes: attributes) {super} | ||
# end | ||
# end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
# Released under the MIT License. | ||
# Copyright, 2022, by Samuel Williams. | ||
|
||
require_relative "../../../async/task" | ||
require "traces/provider" | ||
|
||
Traces::Provider(Async::Task) do | ||
def schedule(&block) | ||
unless self.transient? | ||
trace_context = Traces.trace_context | ||
end | ||
|
||
super do | ||
Traces.trace_context = trace_context | ||
|
||
if annotation = self.annotation | ||
attributes = { | ||
"annotation" => annotation | ||
} | ||
end | ||
|
||
Traces.trace("async.task", attributes: attributes) do | ||
yield | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters