riffer 0.35.0 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.release-please-manifest.json +1 -1
- data/CHANGELOG.md +18 -0
- data/README.md +0 -1
- data/docs/01_OVERVIEW.md +0 -1
- data/docs/03_AGENTS.md +3 -7
- data/docs/10_CONFIGURATION.md +0 -17
- data/docs/providers/07_CUSTOM_PROVIDERS.md +4 -19
- data/lib/riffer/agent/run.rb +11 -35
- data/lib/riffer/agent.rb +1 -1
- data/lib/riffer/config.rb +0 -45
- data/lib/riffer/guardrails/runner.rb +7 -32
- data/lib/riffer/providers/anthropic.rb +1 -1
- data/lib/riffer/providers/base.rb +11 -75
- data/lib/riffer/providers/repository.rb +44 -4
- data/lib/riffer/tools/runtime.rb +8 -29
- data/lib/riffer/version.rb +1 -1
- data/sig/_private/opentelemetry.rbs +3 -6
- data/sig/generated/riffer/agent/run.rbs +4 -8
- data/sig/generated/riffer/agent.rbs +1 -1
- data/sig/generated/riffer/config.rbs +0 -33
- data/sig/generated/riffer/guardrails/runner.rbs +0 -8
- data/sig/generated/riffer/providers/base.rbs +2 -20
- data/sig/generated/riffer/providers/repository.rbs +30 -2
- data/sig/generated/riffer/tools/runtime.rbs +2 -6
- metadata +7 -18
- data/docs/17_METRICS.md +0 -155
- data/lib/riffer/metrics/instruments.rb +0 -31
- data/lib/riffer/metrics/no_op.rb +0 -14
- data/lib/riffer/metrics/otel.rb +0 -80
- data/lib/riffer/metrics.rb +0 -94
- data/sig/generated/riffer/metrics/instruments.rbs +0 -15
- data/sig/generated/riffer/metrics/no_op.rbs +0 -10
- data/sig/generated/riffer/metrics/otel.rbs +0 -48
- data/sig/generated/riffer/metrics.rbs +0 -72
- data/sig/manual/riffer/metrics/no_op.rbs +0 -5
- data/sig/manual/riffer/metrics.rbs +0 -5
data/lib/riffer/metrics.rb
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
# rbs_inline: enabled
|
|
3
|
-
|
|
4
|
-
# Internal metrics port — records OTEL metric instruments when the host bundles
|
|
5
|
-
# the OpenTelemetry metrics API and no-ops otherwise, so riffer never declares
|
|
6
|
-
# an OTEL dependency.
|
|
7
|
-
module Riffer::Metrics # :nodoc: all
|
|
8
|
-
extend self
|
|
9
|
-
|
|
10
|
-
# @rbs @backend: untyped
|
|
11
|
-
|
|
12
|
-
MUTEX = Mutex.new #: Mutex
|
|
13
|
-
|
|
14
|
-
# The Ruby API cannot attach a schema URL to a meter, so the semconv pin
|
|
15
|
-
# lives here as the documented contract version.
|
|
16
|
-
SCHEMA_URL = "https://opentelemetry.io/schemas/1.37.0" #: String
|
|
17
|
-
|
|
18
|
-
# A handle to a named histogram, safe to hold as a constant: it defers backend
|
|
19
|
-
# resolution to record time, so it survives a meter-provider swap or a runtime
|
|
20
|
-
# +enabled+ flip.
|
|
21
|
-
class Histogram
|
|
22
|
-
# @rbs @name: String
|
|
23
|
-
# @rbs @unit: String?
|
|
24
|
-
# @rbs @description: String?
|
|
25
|
-
|
|
26
|
-
#--
|
|
27
|
-
#: (String, ?unit: String?, ?description: String?) -> void
|
|
28
|
-
def initialize(name, unit: nil, description: nil)
|
|
29
|
-
@name = name
|
|
30
|
-
@unit = unit
|
|
31
|
-
@description = description
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
#--
|
|
35
|
-
#: (Numeric, ?attributes: Hash[String, untyped]?) -> void
|
|
36
|
-
def record(value, attributes: nil)
|
|
37
|
-
Riffer::Metrics.record_histogram(@name, value, unit: @unit, description: @description, attributes: attributes)
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# Returns a handle to the named histogram.
|
|
42
|
-
#--
|
|
43
|
-
#: (String, ?unit: String?, ?description: String?) -> Riffer::Metrics::Histogram
|
|
44
|
-
def create_histogram(name, unit: nil, description: nil)
|
|
45
|
-
Histogram.new(name, unit: unit, description: description)
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
# Records a value onto the named histogram.
|
|
49
|
-
#--
|
|
50
|
-
#: (String, Numeric, ?unit: String?, ?description: String?, ?attributes: Hash[String, untyped]?) -> void
|
|
51
|
-
def record_histogram(name, value, unit: nil, description: nil, attributes: nil)
|
|
52
|
-
return unless Riffer.config.metrics.enabled
|
|
53
|
-
backend.record_histogram(name, value, unit: unit, description: description, attributes: attributes)
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
# Mirrors a span's +recording?+ so a caller can skip work that exists only to
|
|
57
|
-
# feed a metric. True for any live backend — the OTEL backend or a
|
|
58
|
-
# consumer-supplied one — so a custom metrics sink still gets fed.
|
|
59
|
-
#--
|
|
60
|
-
#: () -> bool
|
|
61
|
-
def recording?
|
|
62
|
-
Riffer.config.metrics.enabled && !backend.equal?(NoOp)
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
# Reads the monotonic clock in seconds — the time source for duration metrics,
|
|
66
|
-
# immune to wall-clock adjustments.
|
|
67
|
-
#--
|
|
68
|
-
#: () -> Float
|
|
69
|
-
def monotonic_now
|
|
70
|
-
Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
# Discards the resolved backend so the next record re-resolves it; cached
|
|
74
|
-
# instruments live on that backend, so this clears them too.
|
|
75
|
-
#--
|
|
76
|
-
#: () -> void
|
|
77
|
-
def reset!
|
|
78
|
-
MUTEX.synchronize { @backend = nil }
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
private
|
|
82
|
-
|
|
83
|
-
#--
|
|
84
|
-
#: () -> untyped
|
|
85
|
-
def backend
|
|
86
|
-
@backend || MUTEX.synchronize { @backend ||= resolve_backend }
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
#--
|
|
90
|
-
#: () -> untyped
|
|
91
|
-
def resolve_backend
|
|
92
|
-
Riffer.config.metrics.backend || NoOp
|
|
93
|
-
end
|
|
94
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# Generated from lib/riffer/metrics/instruments.rb with RBS::Inline
|
|
2
|
-
|
|
3
|
-
# The catalog of metric instruments riffer records. Each handle is a constant
|
|
4
|
-
# that resolves its backend at record time, so it survives a meter-provider swap
|
|
5
|
-
# or a runtime +enabled+ flip.
|
|
6
|
-
module Riffer::Metrics::Instruments
|
|
7
|
-
# :nodoc: all
|
|
8
|
-
OPERATION_DURATION: Riffer::Metrics::Histogram
|
|
9
|
-
|
|
10
|
-
TOKEN_USAGE: Riffer::Metrics::Histogram
|
|
11
|
-
|
|
12
|
-
COST: Riffer::Metrics::Histogram
|
|
13
|
-
|
|
14
|
-
GUARDRAIL_DURATION: Riffer::Metrics::Histogram
|
|
15
|
-
end
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# Generated from lib/riffer/metrics/no_op.rb with RBS::Inline
|
|
2
|
-
|
|
3
|
-
# No-op metrics backend, used when the OpenTelemetry metrics API is unavailable
|
|
4
|
-
# or metrics are disabled.
|
|
5
|
-
module Riffer::Metrics::NoOp
|
|
6
|
-
# Ignores the measurement; there is no meter without the OTEL metrics API.
|
|
7
|
-
# --
|
|
8
|
-
# : (String, Numeric, unit: String?, description: String?, attributes: Hash[String, untyped]?) -> void
|
|
9
|
-
def record_histogram: (String, Numeric, unit: String?, description: String?, attributes: Hash[String, untyped]?) -> void
|
|
10
|
-
end
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
# Generated from lib/riffer/metrics/otel.rb with RBS::Inline
|
|
2
|
-
|
|
3
|
-
# OTEL-backed metrics backend. <tt>::OpenTelemetry</tt> constants appear only
|
|
4
|
-
# inside method bodies here, so the gem loads and eager-loads cleanly when the
|
|
5
|
-
# OpenTelemetry metrics API is absent.
|
|
6
|
-
class Riffer::Metrics::Otel
|
|
7
|
-
# :nodoc: all
|
|
8
|
-
SUPPORTED_API_VERSIONS: Gem::Requirement
|
|
9
|
-
|
|
10
|
-
# Builds a backend when the OpenTelemetry metrics API is loadable at a
|
|
11
|
-
# supported version; returns +nil+ so resolution falls back to NoOp.
|
|
12
|
-
# +provider+ defaults to the global <tt>OpenTelemetry.meter_provider</tt>.
|
|
13
|
-
# --
|
|
14
|
-
# : (?provider: untyped) -> Riffer::Metrics::Otel?
|
|
15
|
-
def self.build: (?provider: untyped) -> Riffer::Metrics::Otel?
|
|
16
|
-
|
|
17
|
-
# Whether the OpenTelemetry metrics API gem is loadable at a supported
|
|
18
|
-
# version.
|
|
19
|
-
# --
|
|
20
|
-
# : () -> bool
|
|
21
|
-
def self.available?: () -> bool
|
|
22
|
-
|
|
23
|
-
# Whether the given opentelemetry-metrics-api version is one riffer codes
|
|
24
|
-
# against. The gem is undeclared, so this guard is the only protection
|
|
25
|
-
# against an incompatible, still-pre-1.0 API.
|
|
26
|
-
# --
|
|
27
|
-
# : (Gem::Version) -> bool
|
|
28
|
-
def self.supported?: (Gem::Version) -> bool
|
|
29
|
-
|
|
30
|
-
# --
|
|
31
|
-
# : () -> Gem::Version?
|
|
32
|
-
private def self.api_version: () -> Gem::Version?
|
|
33
|
-
|
|
34
|
-
@meter: untyped
|
|
35
|
-
|
|
36
|
-
@instruments: Hash[String, untyped]
|
|
37
|
-
|
|
38
|
-
@mutex: Mutex
|
|
39
|
-
|
|
40
|
-
# --
|
|
41
|
-
# : (provider: untyped) -> void
|
|
42
|
-
def initialize: (provider: untyped) -> void
|
|
43
|
-
|
|
44
|
-
# Records a value onto the named histogram.
|
|
45
|
-
# --
|
|
46
|
-
# : (String, Numeric, unit: String?, description: String?, attributes: Hash[String, untyped]?) -> void
|
|
47
|
-
def record_histogram: (String, Numeric, unit: String?, description: String?, attributes: Hash[String, untyped]?) -> void
|
|
48
|
-
end
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
# Generated from lib/riffer/metrics.rb with RBS::Inline
|
|
2
|
-
|
|
3
|
-
# Internal metrics port — records OTEL metric instruments when the host bundles
|
|
4
|
-
# the OpenTelemetry metrics API and no-ops otherwise, so riffer never declares
|
|
5
|
-
# an OTEL dependency.
|
|
6
|
-
module Riffer::Metrics
|
|
7
|
-
@backend: untyped
|
|
8
|
-
|
|
9
|
-
MUTEX: Mutex
|
|
10
|
-
|
|
11
|
-
# The Ruby API cannot attach a schema URL to a meter, so the semconv pin
|
|
12
|
-
# lives here as the documented contract version.
|
|
13
|
-
SCHEMA_URL: String
|
|
14
|
-
|
|
15
|
-
# A handle to a named histogram, safe to hold as a constant: it defers backend
|
|
16
|
-
# resolution to record time, so it survives a meter-provider swap or a runtime
|
|
17
|
-
# +enabled+ flip.
|
|
18
|
-
class Histogram
|
|
19
|
-
@name: String
|
|
20
|
-
|
|
21
|
-
@unit: String?
|
|
22
|
-
|
|
23
|
-
@description: String?
|
|
24
|
-
|
|
25
|
-
# --
|
|
26
|
-
# : (String, ?unit: String?, ?description: String?) -> void
|
|
27
|
-
def initialize: (String, ?unit: String?, ?description: String?) -> void
|
|
28
|
-
|
|
29
|
-
# --
|
|
30
|
-
# : (Numeric, ?attributes: Hash[String, untyped]?) -> void
|
|
31
|
-
def record: (Numeric, ?attributes: Hash[String, untyped]?) -> void
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
# Returns a handle to the named histogram.
|
|
35
|
-
# --
|
|
36
|
-
# : (String, ?unit: String?, ?description: String?) -> Riffer::Metrics::Histogram
|
|
37
|
-
def create_histogram: (String, ?unit: String?, ?description: String?) -> Riffer::Metrics::Histogram
|
|
38
|
-
|
|
39
|
-
# Records a value onto the named histogram.
|
|
40
|
-
# --
|
|
41
|
-
# : (String, Numeric, ?unit: String?, ?description: String?, ?attributes: Hash[String, untyped]?) -> void
|
|
42
|
-
def record_histogram: (String, Numeric, ?unit: String?, ?description: String?, ?attributes: Hash[String, untyped]?) -> void
|
|
43
|
-
|
|
44
|
-
# Mirrors a span's +recording?+ so a caller can skip work that exists only to
|
|
45
|
-
# feed a metric. True for any live backend — the OTEL backend or a
|
|
46
|
-
# consumer-supplied one — so a custom metrics sink still gets fed.
|
|
47
|
-
# --
|
|
48
|
-
# : () -> bool
|
|
49
|
-
def recording?: () -> bool
|
|
50
|
-
|
|
51
|
-
# Reads the monotonic clock in seconds — the time source for duration metrics,
|
|
52
|
-
# immune to wall-clock adjustments.
|
|
53
|
-
# --
|
|
54
|
-
# : () -> Float
|
|
55
|
-
def monotonic_now: () -> Float
|
|
56
|
-
|
|
57
|
-
# Discards the resolved backend so the next record re-resolves it; cached
|
|
58
|
-
# instruments live on that backend, so this clears them too.
|
|
59
|
-
# --
|
|
60
|
-
# : () -> void
|
|
61
|
-
def reset!: () -> void
|
|
62
|
-
|
|
63
|
-
private
|
|
64
|
-
|
|
65
|
-
# --
|
|
66
|
-
# : () -> untyped
|
|
67
|
-
def backend: () -> untyped
|
|
68
|
-
|
|
69
|
-
# --
|
|
70
|
-
# : () -> untyped
|
|
71
|
-
def resolve_backend: () -> untyped
|
|
72
|
-
end
|