codecov_opentelem 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/codecov_opentelem/coverage_exporter.rb +15 -12
- data/lib/codecov_opentelem/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d385d9be5936bef168660940493430288123e80e7e52ef7cfe3c745d7426dc71
|
4
|
+
data.tar.gz: ee1593d6f7e9b04d964f81d290a6116ea6d460ad65352500cc3b8b0d8c9b813d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 970d7e5aeecdea1689d933bfa78c222b70265345f3c62b62c79220b6ff212832146a41bcff5cc1017987b572c46d49c8a934cf883d3841630056400e1df5796a
|
7
|
+
data.tar.gz: 02fbe4c9bbc6c9e36f346d139dd6c0ea5f82fc4216d75a307a31d79a64ea146775ea06eb8f05d88eff076087f4959b60d97525b744867efb5bf12330dae1017c
|
data/Gemfile.lock
CHANGED
@@ -14,23 +14,22 @@ end
|
|
14
14
|
|
15
15
|
class CodecovCoverageStorageManager
|
16
16
|
def initialize(filters)
|
17
|
-
Coverage.start
|
18
17
|
@filters = filters
|
19
18
|
@inner = {}
|
20
19
|
end
|
21
20
|
|
22
21
|
def start_coverage_for_span(span)
|
23
22
|
if !@filters[CoverageSpanFilter::REGEX_NAME].nil? && @filters[CoverageSpanFilter::REGEX_NAME].match(span.name)
|
23
|
+
puts 'returned false'
|
24
24
|
return false
|
25
25
|
end
|
26
26
|
|
27
|
-
Coverage.
|
27
|
+
Coverage.start unless Coverage.running?
|
28
28
|
true
|
29
29
|
end
|
30
30
|
|
31
31
|
def stop_coverage_for_span(span)
|
32
|
-
span_id = span.span_id
|
33
|
-
Coverage.suspend
|
32
|
+
span_id = span.context.span_id
|
34
33
|
@inner[span_id] = Coverage.result(stop: false, clear: true)
|
35
34
|
end
|
36
35
|
|
@@ -48,10 +47,10 @@ class CodecovCoverageGenerator < OpenTelemetry::SDK::Trace::SpanProcessor
|
|
48
47
|
end
|
49
48
|
|
50
49
|
def on_start(span, _parent_context = nil)
|
51
|
-
@cov_storage.start_coverage_for_span(span) if rand < @sample_rate
|
50
|
+
@cov_storage.start_coverage_for_span(span) if rand() < @sample_rate
|
52
51
|
end
|
53
52
|
|
54
|
-
def
|
53
|
+
def on_finish(span)
|
55
54
|
@cov_storage.stop_coverage_for_span(span)
|
56
55
|
end
|
57
56
|
end
|
@@ -69,6 +68,7 @@ class CoverageExporter < OpenTelemetry::SDK::Trace::Export::SpanExporter
|
|
69
68
|
def export(spans, timeout)
|
70
69
|
tracked_spans = []
|
71
70
|
untracked_spans = []
|
71
|
+
|
72
72
|
spans.each do |span|
|
73
73
|
cov = @cov_storage.pop_coverage_for_span(span)
|
74
74
|
|
@@ -77,15 +77,18 @@ class CoverageExporter < OpenTelemetry::SDK::Trace::Export::SpanExporter
|
|
77
77
|
v = v.dup.force_encoding("ISO-8859-1").encode("UTF-8") if v.is_a? String
|
78
78
|
span_hash[k] = v
|
79
79
|
end
|
80
|
-
s = span_hash.to_json
|
81
80
|
|
82
81
|
if !cov.nil?
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
82
|
+
span_hash['codecov'] = {
|
83
|
+
'coverage': cov.to_json,
|
84
|
+
'type': 'json',
|
85
|
+
}
|
86
|
+
tracked_spans.append(span_hash.to_json)
|
87
|
+
elsif rand() < @untracked_export_rate
|
88
|
+
untracked_spans.append(span_hash.to_json)
|
87
89
|
end
|
88
90
|
end
|
91
|
+
|
89
92
|
return OpenTelemetry::SDK::Trace::Export::SUCCESS if !tracked_spans && !untracked_spans
|
90
93
|
|
91
94
|
body = { 'profiling' => @code }.to_json
|
@@ -110,7 +113,7 @@ class CoverageExporter < OpenTelemetry::SDK::Trace::Export::SpanExporter
|
|
110
113
|
req.body = {
|
111
114
|
'spans' => tracked_spans,
|
112
115
|
'untracked' => untracked_spans
|
113
|
-
}.to_json
|
116
|
+
}.to_json
|
114
117
|
https.request(req)
|
115
118
|
OpenTelemetry::SDK::Trace::Export::SUCCESS
|
116
119
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codecov_opentelem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ahmed-Elghrbawy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-06-
|
11
|
+
date: 2022-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|