microscope_tracer 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0513168a35953e75573826931f13ea725e1bb031
|
4
|
+
data.tar.gz: 199ff8b305362fb00214dad9456e42f771f2d0c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 316b085faa1c8794713baad2e80fd746f7309c4b0eccfe4862398cdbc8d980818cae1b85c05026c0c438c4dac6c69c484010cc46ca5d39c1cef1e24fefbd6f39
|
7
|
+
data.tar.gz: 21e25b771482e95a9b87eafea23d6ff088df6df93a905a29c305cb3747decd30eb0ffdc20ffe96256df00422fdb0e9eb7f448cf23b959ffe74ded1df7fa093ce
|
@@ -4,8 +4,8 @@ require 'microscope_tracer/trace_logger'
|
|
4
4
|
|
5
5
|
module MicroscopeTracer
|
6
6
|
class FaradayMiddleware < Faraday::Middleware
|
7
|
-
def initialize(app,
|
8
|
-
@trace_logger = TraceLogger.new(
|
7
|
+
def initialize(app,service_name)
|
8
|
+
@trace_logger = TraceLogger.new(service_name)
|
9
9
|
super(app)
|
10
10
|
end
|
11
11
|
|
@@ -7,9 +7,9 @@ require 'microscope_tracer/trace_logger'
|
|
7
7
|
module MicroscopeTracer
|
8
8
|
|
9
9
|
class RackMiddleware
|
10
|
-
def initialize(app,
|
10
|
+
def initialize(app,service_name)
|
11
11
|
@app = app
|
12
|
-
@trace_logger = TraceLogger.new(
|
12
|
+
@trace_logger = TraceLogger.new(service_name)
|
13
13
|
end
|
14
14
|
|
15
15
|
def call(env)
|
@@ -1,7 +1,11 @@
|
|
1
1
|
module MicroscopeTracer
|
2
2
|
class TraceLogger
|
3
|
-
def initialize(
|
4
|
-
@
|
3
|
+
def initialize(service_name)
|
4
|
+
@service_name = service_name
|
5
|
+
|
6
|
+
# hardcoded for now
|
7
|
+
@log_prefix = "MICROSCOPE: "
|
8
|
+
@io = $stdout
|
5
9
|
end
|
6
10
|
|
7
11
|
def log_server_start(span)
|
@@ -23,10 +27,10 @@ class TraceLogger
|
|
23
27
|
end
|
24
28
|
|
25
29
|
def log(type,span,extras={})
|
26
|
-
fields = {type:type,traceId:span.trace_id,spanId:span.span_id,pspanId:span.parent_span_id}.merge(extras)
|
30
|
+
fields = {service:@service_name,type:type,traceId:span.trace_id,spanId:span.span_id,pspanId:span.parent_span_id}.merge(extras)
|
27
31
|
line = fields.map{ |k,v| if v then "#{k}=\"#{v}\"" else nil end }.compact.join(" ")
|
28
32
|
|
29
|
-
@io.puts(line)
|
33
|
+
@io.puts(@log_prefix + line)
|
30
34
|
end
|
31
35
|
end
|
32
36
|
end
|