epsagon 0.0.7 → 0.0.8
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7b3206724c319044ec03107de40ed46798b935d85e6aba2a5cadadfe777e86c
|
4
|
+
data.tar.gz: cd515cf0bcd75faba2d3153f456c44441fa9df5e511f7a8b4aea5dc95178a3c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa0bc9dcc5710f2498a9c39f3d86ebc43ed825b4fa23a8532457a6770ed9834de2ca2fab3e37c7324902ac38f0f426ea0de0ca2f1272a73c56ad35ff7afe1458
|
7
|
+
data.tar.gz: 00b78e433d7cfea98710f6f641123727a3b44edcfab51da0039363c1db135401166ea4d35f2d4e935f54d78de1434130ea33b092e83cd85d1ba56d3bead9e847
|
@@ -0,0 +1,74 @@
|
|
1
|
+
|
2
|
+
require_relative '../util'
|
3
|
+
require 'faraday'
|
4
|
+
|
5
|
+
# Faraday middleware for epsagon instrumentaton
|
6
|
+
class EpsagonFaradayMiddleware < ::Faraday::Middleware
|
7
|
+
def config
|
8
|
+
EpsagonFaradayInstrumentation.instance.config
|
9
|
+
end
|
10
|
+
|
11
|
+
HTTP_METHODS_SYMBOL_TO_STRING = {
|
12
|
+
connect: 'CONNECT',
|
13
|
+
delete: 'DELETE',
|
14
|
+
get: 'GET',
|
15
|
+
head: 'HEAD',
|
16
|
+
options: 'OPTIONS',
|
17
|
+
patch: 'PATCH',
|
18
|
+
post: 'POST',
|
19
|
+
put: 'PUT',
|
20
|
+
trace: 'TRACE'
|
21
|
+
}.freeze
|
22
|
+
|
23
|
+
def call(env)
|
24
|
+
http_method = HTTP_METHODS_SYMBOL_TO_STRING[env.method]
|
25
|
+
path, path_params = env.url.path.split(';')
|
26
|
+
|
27
|
+
attributes = {
|
28
|
+
'type' => 'http',
|
29
|
+
'operation' => http_method,
|
30
|
+
'http.scheme' => env.url.scheme,
|
31
|
+
'http.request.path' => path
|
32
|
+
}
|
33
|
+
|
34
|
+
unless config[:epsagon][:metadata_only]
|
35
|
+
attributes.merge!(Util.epsagon_query_attributes(env.url.query))
|
36
|
+
attributes.merge!({
|
37
|
+
'http.request.path_params' => path_params,
|
38
|
+
'http.request.headers' => env.request_headers.to_json,
|
39
|
+
'http.request.body' => env.body,
|
40
|
+
'http.request.headers.User-Agent' => env.request_headers['User-Agent']
|
41
|
+
})
|
42
|
+
end
|
43
|
+
|
44
|
+
tracer.in_span(
|
45
|
+
env.url.host,
|
46
|
+
attributes: attributes,
|
47
|
+
kind: :client
|
48
|
+
) do |span|
|
49
|
+
OpenTelemetry.propagation.http.inject(env.request_headers)
|
50
|
+
|
51
|
+
app.call(env).on_complete { |req| trace_response(span, req.response) }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
attr_reader :app
|
58
|
+
|
59
|
+
def tracer
|
60
|
+
EpsagonFaradayInstrumentation.instance.tracer
|
61
|
+
end
|
62
|
+
|
63
|
+
def trace_response(span, response)
|
64
|
+
span.set_attribute('http.status_code', response.status)
|
65
|
+
|
66
|
+
unless config[:epsagon][:metadata_only]
|
67
|
+
span.set_attribute('http.response.headers', response.headers.to_json)
|
68
|
+
span.set_attribute('http.response.body', response.body)
|
69
|
+
end
|
70
|
+
span.status = OpenTelemetry::Trace::Status.http_to_status(
|
71
|
+
response.status
|
72
|
+
)
|
73
|
+
end
|
74
|
+
end
|
@@ -1,79 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'faraday'
|
4
|
-
require_relative '../util'
|
5
|
-
|
6
|
-
# Faraday middleware for epsagon instrumentaton
|
7
|
-
class EpsagonFaradayMiddleware < ::Faraday::Middleware
|
8
|
-
def config
|
9
|
-
EpsagonFaradayInstrumentation.instance.config
|
10
|
-
end
|
11
|
-
|
12
|
-
HTTP_METHODS_SYMBOL_TO_STRING = {
|
13
|
-
connect: 'CONNECT',
|
14
|
-
delete: 'DELETE',
|
15
|
-
get: 'GET',
|
16
|
-
head: 'HEAD',
|
17
|
-
options: 'OPTIONS',
|
18
|
-
patch: 'PATCH',
|
19
|
-
post: 'POST',
|
20
|
-
put: 'PUT',
|
21
|
-
trace: 'TRACE'
|
22
|
-
}.freeze
|
23
|
-
|
24
|
-
def call(env)
|
25
|
-
http_method = HTTP_METHODS_SYMBOL_TO_STRING[env.method]
|
26
|
-
path, path_params = env.url.path.split(';')
|
27
|
-
|
28
|
-
attributes = {
|
29
|
-
'type' => 'http',
|
30
|
-
'operation' => http_method,
|
31
|
-
'http.scheme' => env.url.scheme,
|
32
|
-
'http.request.path' => path
|
33
|
-
}
|
34
|
-
|
35
|
-
unless config[:epsagon][:metadata_only]
|
36
|
-
attributes.merge!(Util.epsagon_query_attributes(env.url.query))
|
37
|
-
attributes.merge!({
|
38
|
-
'http.request.path_params' => path_params,
|
39
|
-
'http.request.headers' => env.request_headers.to_json,
|
40
|
-
'http.request.body' => env.body,
|
41
|
-
'http.request.headers.User-Agent' => env.request_headers['User-Agent']
|
42
|
-
})
|
43
|
-
end
|
44
|
-
|
45
|
-
tracer.in_span(
|
46
|
-
env.url.host,
|
47
|
-
attributes: attributes,
|
48
|
-
kind: :client
|
49
|
-
) do |span|
|
50
|
-
OpenTelemetry.propagation.http.inject(env.request_headers)
|
51
|
-
|
52
|
-
app.call(env).on_complete { |req| trace_response(span, req.response) }
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
private
|
57
|
-
|
58
|
-
attr_reader :app
|
59
|
-
|
60
|
-
def tracer
|
61
|
-
EpsagonFaradayInstrumentation.instance.tracer
|
62
|
-
end
|
63
|
-
|
64
|
-
def trace_response(span, response)
|
65
|
-
span.set_attribute('http.status_code', response.status)
|
66
|
-
|
67
|
-
unless config[:epsagon][:metadata_only]
|
68
|
-
span.set_attribute('http.response.headers', response.headers.to_json)
|
69
|
-
span.set_attribute('http.response.body', response.body)
|
70
|
-
end
|
71
|
-
span.status = OpenTelemetry::Trace::Status.http_to_status(
|
72
|
-
response.status
|
73
|
-
)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
2
|
# Patch faraday to include middleware
|
78
3
|
module EpsagonFaradayPatch
|
79
4
|
def adapter(*args)
|
@@ -90,6 +15,7 @@ class EpsagonFaradayInstrumentation < OpenTelemetry::Instrumentation::Base
|
|
90
15
|
VERSION = '0.0.0'
|
91
16
|
|
92
17
|
install do |_config|
|
18
|
+
require_relative 'epsagon_faraday_middleware'
|
93
19
|
::Faraday::Middleware.register_middleware(
|
94
20
|
epsagon_open_telemetry: EpsagonFaradayMiddleware
|
95
21
|
)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epsagon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Epsagon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04-
|
11
|
+
date: 2021-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -106,6 +106,7 @@ extra_rdoc_files: []
|
|
106
106
|
files:
|
107
107
|
- lib/epsagon.rb
|
108
108
|
- lib/instrumentation/aws_sdk.rb
|
109
|
+
- lib/instrumentation/epsagon_faraday_middleware.rb
|
109
110
|
- lib/instrumentation/faraday.rb
|
110
111
|
- lib/instrumentation/net_http.rb
|
111
112
|
- lib/instrumentation/sinatra.rb
|