brainzlab 0.1.4 → 0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf91a415760bc97688aa6d97c80fc4aa0c2677d0f299799eaf6a52ed5762b0b7
4
- data.tar.gz: fc11f28cd6e93ff15430ca2a33d2068c19a0605cc27cac1232b23b730d36f1c2
3
+ metadata.gz: 612fc535ff22f4fb1edb3d986ca4200f6fbbcb32e82718619a6f711d11e0d98b
4
+ data.tar.gz: 665fefbcba13cfb7c14395b37dc8157c0938c3cc52935fe5fd7767b7cff3a3f5
5
5
  SHA512:
6
- metadata.gz: '09ae587f4463bd67d19f5d059c4fd810ce337099ad7bbe4bd3eea586d01294f22c904298aa121668329a995be3df9682624fa2b01dd57e00d6e2b8243eaf6a85'
7
- data.tar.gz: 93da1a25704e85ac769c686509d98cfd950620304f4c5d90b18fa9c14cb542c6696eab29a056eaecf125dad992607f4a3050e1009c81976650226b08f34924b7
6
+ metadata.gz: 06e2a33185951e80bd102e6aee4d4e8417750be993949822983ceb66fd807394924e0546a3769ab6ffd0f30d1055c0f213fdc7458a66304bea89b9d304ad34a0
7
+ data.tar.gz: 4675a166a98ed230885fae6926d7949c235ca1ab75c129702a643955089a130dddbe445351bfac0331247204083b0ce7223c7b1f1b9c4759ca2e73482f2c06b6
@@ -100,6 +100,16 @@ module BrainzLab
100
100
  buffer.add(:metric, metric)
101
101
  end
102
102
 
103
+ # Histogram: Alias for distribution (for compatibility with brainzlab-rails)
104
+ def histogram(name, value, tags: {})
105
+ distribution(name, value, tags: tags)
106
+ end
107
+
108
+ # Timing: Record duration in milliseconds (alias for distribution)
109
+ def timing(name, value_ms, tags: {})
110
+ distribution(name, value_ms, tags: tags.merge(unit: 'ms'))
111
+ end
112
+
103
113
  # Set: Unique count (cardinality)
104
114
  def set(name, value, tags: {})
105
115
  return unless enabled?
@@ -40,6 +40,12 @@ module BrainzLab
40
40
  post('/api/v1/metrics', payload)
41
41
  end
42
42
 
43
+ def send_span(payload)
44
+ return unless @config.pulse_enabled && @config.pulse_valid?
45
+
46
+ post('/api/v1/spans', payload)
47
+ end
48
+
43
49
  def flush
44
50
  traces_to_send = nil
45
51
 
@@ -85,6 +85,33 @@ module BrainzLab
85
85
  record_metric(name, value: value, kind: 'histogram', tags: tags)
86
86
  end
87
87
 
88
+ # Record a standalone span (used by brainzlab-rails for Rails instrumentation)
89
+ # @param name [String] span name (e.g., "sql.SELECT", "cache.read")
90
+ # @param duration_ms [Float] span duration in milliseconds
91
+ # @param category [String] span category (e.g., "db.sql", "cache.read", "http.request")
92
+ # @param attributes [Hash] additional span attributes
93
+ # @param timestamp [String] ISO8601 timestamp
94
+ def record_span(name:, duration_ms:, category:, attributes: {}, timestamp: nil)
95
+ return unless enabled?
96
+
97
+ ensure_provisioned!
98
+ return unless BrainzLab.configuration.pulse_valid?
99
+
100
+ span_data = {
101
+ name: name,
102
+ category: category,
103
+ duration_ms: duration_ms,
104
+ timestamp: timestamp || Time.now.utc.iso8601(3),
105
+ attributes: attributes,
106
+ environment: BrainzLab.configuration.environment,
107
+ service: BrainzLab.configuration.service,
108
+ host: BrainzLab.configuration.host,
109
+ request_id: Context.current.request_id
110
+ }.compact
111
+
112
+ client.send_span(span_data)
113
+ end
114
+
88
115
  def ensure_provisioned!
89
116
  return if @provisioned
90
117
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BrainzLab
4
- VERSION = '0.1.4'
4
+ VERSION = '0.1.5'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brainzlab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brainz Lab