Skip to content

Commit 0ca4141

Browse files
committed
Metrics were not that useful.
1 parent 930370c commit 0ca4141

File tree

2 files changed

+34
-21
lines changed

2 files changed

+34
-21
lines changed

async-pool.gemspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,5 @@ Gem::Specification.new do |spec|
2626
spec.required_ruby_version = ">= 3.1"
2727

2828
spec.add_dependency "async", ">= 1.25"
29-
spec.add_dependency "metrics", "~> 0.11"
3029
spec.add_dependency "traces"
3130
end

lib/async/pool/controller.rb

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
require "async/semaphore"
1313

1414
require "traces"
15-
require "metrics"
1615

1716
module Async
1817
module Pool
@@ -39,7 +38,7 @@ def initialize(constructor, limit: nil, concurrency: (limit || 1), policy: nil,
3938
@policy = policy
4039
@gardener = nil
4140

42-
@tags = Metrics::Tags.normalize(tags)
41+
@tags = tags
4342

4443
# All available resources:
4544
@resources = {}
@@ -393,43 +392,58 @@ def create_resource(...)
393392
concurrency: @guard.limit,
394393
size: @resources.size,
395394
limit: @limit,
396-
tags: @tags,
397395
}
398396

399-
Traces.trace("async.pool.create", attributes: attributes) {super}
397+
@attributes.merge!(@tags) if @tags
398+
399+
Traces.trace('async.pool.create', attributes: attributes) {super}
400400
end
401401

402402
def drain(...)
403403
attributes = {
404404
size: @resources.size,
405-
tags: @tags,
406405
}
407406

408-
Traces.trace("async.pool.drain", attributes: attributes) {super}
407+
@attributes.merge!(@tags) if @tags
408+
409+
Traces.trace('async.pool.drain', attributes: attributes) {super}
409410
end
410-
end
411-
412-
Metrics::Provider(self) do
413-
ACQUIRE_COUNT = Metrics.metric("async.pool.acquire", :counter, description: "Number of times a resource was invoked.")
414-
RELEASE_COUNT = Metrics.metric("async.pool.release", :counter, description: "Number of times a resource was released.")
415-
RETIRE_COUNT = Metrics.metric("async.pool.retire", :counter, description: "Number of times a resource was retired.")
416411

417412
def acquire(...)
418-
ACQUIRE_COUNT.emit(1, tags: @tags)
413+
attributes = {
414+
concurrency: @guard.limit,
415+
size: @resources.size,
416+
limit: @limit,
417+
}
418+
419+
@attributes.merge!(@tags) if @tags
419420

420-
super
421+
Traces.trace('async.pool.acquire', attributes: attributes) {super}
421422
end
422423

423424
def release(...)
424-
super.tap do
425-
RELEASE_COUNT.emit(1, tags: @tags)
426-
end
425+
attributes = {
426+
concurrency: @guard.limit,
427+
size: @resources.size,
428+
limit: @limit,
429+
}
430+
431+
@attributes.merge!(@tags) if @tags
432+
433+
Traces.trace('async.pool.release', attributes: attributes) {super}
427434
end
428435

429436
def retire(...)
430-
super.tap do
431-
RETIRE_COUNT.emit(1, tags: @tags)
432-
end
437+
attributes = {
438+
concurrency: @guard.limit,
439+
size: @resources.size,
440+
limit: @limit,
441+
**@tags,
442+
}
443+
444+
@attributes.merge!(@tags) if @tags
445+
446+
Traces.trace('async.pool.retire', attributes: attributes) {super}
433447
end
434448
end
435449
end

0 commit comments

Comments
 (0)