|
83 | 83 | _(periodic_metric_reader.instance_variable_get(:@thread).alive?).must_equal false
|
84 | 84 | end
|
85 | 85 |
|
86 |
| - it 'is restarted after forking' do |
87 |
| - OpenTelemetry::SDK.configure |
| 86 | + unless Gem.win_platform? || Gem.java_platform? # skip as forking is not available on these platforms |
| 87 | + it 'is restarted after forking' do |
| 88 | + OpenTelemetry::SDK.configure |
88 | 89 |
|
89 |
| - metric_exporter = OpenTelemetry::SDK::Metrics::Export::InMemoryMetricPullExporter.new |
90 |
| - periodic_metric_reader = OpenTelemetry::SDK::Metrics::Export::PeriodicMetricReader.new(export_interval_millis: 5000, export_timeout_millis: 5000, exporter: metric_exporter) |
| 90 | + metric_exporter = OpenTelemetry::SDK::Metrics::Export::InMemoryMetricPullExporter.new |
| 91 | + periodic_metric_reader = OpenTelemetry::SDK::Metrics::Export::PeriodicMetricReader.new(export_interval_millis: 5000, export_timeout_millis: 5000, exporter: metric_exporter) |
91 | 92 |
|
92 |
| - OpenTelemetry.meter_provider.add_metric_reader(periodic_metric_reader) |
| 93 | + OpenTelemetry.meter_provider.add_metric_reader(periodic_metric_reader) |
93 | 94 |
|
94 |
| - read, write = IO.pipe |
| 95 | + read, write = IO.pipe |
95 | 96 |
|
96 |
| - pid = fork do |
97 |
| - meter = OpenTelemetry.meter_provider.meter('test') |
98 |
| - counter = meter.create_counter('counter', unit: 'smidgen', description: 'a small amount of something') |
| 97 | + pid = fork do |
| 98 | + meter = OpenTelemetry.meter_provider.meter('test') |
| 99 | + counter = meter.create_counter('counter', unit: 'smidgen', description: 'a small amount of something') |
99 | 100 |
|
100 |
| - counter.add(1) |
101 |
| - counter.add(2, attributes: { 'a' => 'b' }) |
102 |
| - counter.add(2, attributes: { 'a' => 'b' }) |
103 |
| - counter.add(3, attributes: { 'b' => 'c' }) |
104 |
| - counter.add(4, attributes: { 'd' => 'e' }) |
| 101 | + counter.add(1) |
| 102 | + counter.add(2, attributes: { 'a' => 'b' }) |
| 103 | + counter.add(2, attributes: { 'a' => 'b' }) |
| 104 | + counter.add(3, attributes: { 'b' => 'c' }) |
| 105 | + counter.add(4, attributes: { 'd' => 'e' }) |
105 | 106 |
|
106 |
| - sleep(8) |
107 |
| - snapshot = metric_exporter.metric_snapshots |
| 107 | + sleep(8) |
| 108 | + snapshot = metric_exporter.metric_snapshots |
108 | 109 |
|
109 |
| - json = snapshot.map { |reading| { name: reading.name } }.to_json |
110 |
| - write.puts json |
111 |
| - end |
| 110 | + json = snapshot.map { |reading| { name: reading.name } }.to_json |
| 111 | + write.puts json |
| 112 | + end |
112 | 113 |
|
113 |
| - Timeout.timeout(10) do |
114 |
| - Process.waitpid(pid) |
115 |
| - end |
| 114 | + Timeout.timeout(10) do |
| 115 | + Process.waitpid(pid) |
| 116 | + end |
116 | 117 |
|
117 |
| - periodic_metric_reader.shutdown |
118 |
| - snapshot = JSON.parse(read.gets.chomp) |
119 |
| - _(snapshot.size).must_equal(1) |
120 |
| - _(snapshot[0]).must_equal('name' => 'counter') |
121 |
| - _(periodic_metric_reader.instance_variable_get(:@thread).alive?).must_equal false |
| 118 | + periodic_metric_reader.shutdown |
| 119 | + snapshot = JSON.parse(read.gets.chomp) |
| 120 | + _(snapshot.size).must_equal(1) |
| 121 | + _(snapshot[0]).must_equal('name' => 'counter') |
| 122 | + _(periodic_metric_reader.instance_variable_get(:@thread).alive?).must_equal false |
| 123 | + end |
122 | 124 | end
|
123 | 125 | end
|
124 | 126 | end
|
0 commit comments