|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | 3 | RSpec.describe Sentry::Metrics do |
| 4 | + let(:aggregator) { Sentry.metrics_aggregator } |
| 5 | + let(:fake_time) { Time.new(2024, 1, 1, 1, 1, 3) } |
| 6 | + let(:string_io) { StringIO.new } |
| 7 | + let(:sdk_logger) { Logger.new(string_io) } |
| 8 | + |
4 | 9 | before do |
5 | 10 | perform_basic_setup do |config| |
6 | 11 | config.metrics.enabled = true |
| 12 | + config.sdk_logger = sdk_logger |
7 | 13 | end |
8 | 14 | end |
9 | 15 |
|
10 | | - let(:aggregator) { Sentry.metrics_aggregator } |
11 | | - let(:fake_time) { Time.new(2024, 1, 1, 1, 1, 3) } |
12 | | - |
13 | 16 | describe '.increment' do |
14 | 17 | it 'passes default value of 1.0 with only key' do |
15 | 18 | expect(aggregator).to receive(:add).with( |
|
36 | 39 |
|
37 | 40 | described_class.increment('foo', 5.0, unit: 'second', tags: { fortytwo: 42 }, timestamp: fake_time) |
38 | 41 | end |
| 42 | + |
| 43 | + it 'logs deprecation warning' do |
| 44 | + described_class.increment('foo') |
| 45 | + |
| 46 | + expect(string_io.string).to include( |
| 47 | + "WARN -- sentry: `Sentry::Metrics` is now deprecated and will be removed in the next major." |
| 48 | + ) |
| 49 | + end |
39 | 50 | end |
40 | 51 |
|
41 | 52 | describe '.distribution' do |
|
51 | 62 |
|
52 | 63 | described_class.distribution('foo', 5.0, unit: 'second', tags: { fortytwo: 42 }, timestamp: fake_time) |
53 | 64 | end |
| 65 | + |
| 66 | + it 'logs deprecation warning' do |
| 67 | + described_class.distribution('foo', 5.0, unit: 'second', tags: { fortytwo: 42 }, timestamp: fake_time) |
| 68 | + |
| 69 | + expect(string_io.string).to include( |
| 70 | + "WARN -- sentry: `Sentry::Metrics` is now deprecated and will be removed in the next major." |
| 71 | + ) |
| 72 | + end |
54 | 73 | end |
55 | 74 |
|
56 | 75 | describe '.set' do |
|
66 | 85 |
|
67 | 86 | described_class.set('foo', 'jane', tags: { fortytwo: 42 }, timestamp: fake_time) |
68 | 87 | end |
| 88 | + |
| 89 | + it 'logs deprecation warning' do |
| 90 | + described_class.set('foo', 'jane', tags: { fortytwo: 42 }, timestamp: fake_time) |
| 91 | + |
| 92 | + expect(string_io.string).to include( |
| 93 | + "WARN -- sentry: `Sentry::Metrics` is now deprecated and will be removed in the next major." |
| 94 | + ) |
| 95 | + end |
69 | 96 | end |
70 | 97 |
|
71 | 98 | describe '.gauge' do |
|
81 | 108 |
|
82 | 109 | described_class.gauge('foo', 5.0, unit: 'second', tags: { fortytwo: 42 }, timestamp: fake_time) |
83 | 110 | end |
| 111 | + |
| 112 | + it 'logs deprecation warning' do |
| 113 | + described_class.gauge('foo', 5.0, unit: 'second', tags: { fortytwo: 42 }, timestamp: fake_time) |
| 114 | + |
| 115 | + expect(string_io.string).to include( |
| 116 | + "WARN -- sentry: `Sentry::Metrics` is now deprecated and will be removed in the next major." |
| 117 | + ) |
| 118 | + end |
84 | 119 | end |
85 | 120 |
|
86 | 121 | describe '.timing' do |
|
109 | 144 | expect(result).to eq(42) |
110 | 145 | end |
111 | 146 |
|
| 147 | + it 'logs deprecation warning' do |
| 148 | + described_class.timing('foo', unit: 'millisecond', tags: { fortytwo: 42 }, timestamp: fake_time) { sleep(0.1); 42 } |
| 149 | + |
| 150 | + expect(string_io.string).to include( |
| 151 | + "WARN -- sentry: `Sentry::Metrics` is now deprecated and will be removed in the next major." |
| 152 | + ) |
| 153 | + end |
| 154 | + |
112 | 155 | context 'with running transaction' do |
113 | 156 | let(:transaction) { transaction = Sentry.start_transaction(name: 'metrics') } |
114 | 157 |
|
|
0 commit comments