Files
news.gitea.happylizard.me/bin/gems/traces-0.15.2/lib/traces/provider.rb
T
pizza2d1 4cee170d66
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 9s
Add bin and edit workflow
2026-09-16 13:11:16 -06:00

47 lines
920 B
Ruby

# frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2021-2023, by Samuel Williams.
require_relative 'backend'
module Traces
# @returns [Boolean] Whether there is an active backend.
def self.enabled?
Backend.const_defined?(:Interface)
end
# @namespace
module Provider
end
module Singleton
# A module which contains tracing specific wrappers.
def traces_provider
@traces_provider ||= Module.new
end
end
private_constant :Singleton
# Bail out if there is no backend configured.
if self.enabled?
# Extend the specified class in order to emit traces.
def self.Provider(klass, &block)
klass.extend(Singleton)
provider = klass.traces_provider
klass.prepend(provider)
provider.module_exec(&block) if block_given?
return provider
end
Config::DEFAULT.prepare
else
def self.Provider(klass, &block)
# Tracing disabled.
end
end
end