logasm-tracer 0.1.0 → 0.2.0

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
  SHA1:
3
- metadata.gz: 1b83a1b19cff46ec4102bdcad4135e3c9ea161a3
4
- data.tar.gz: b15354fc51d177e3472deec5ebce7bbc9c0d256a
3
+ metadata.gz: 3028cba0194bb363a3f2935667763cd907e183f4
4
+ data.tar.gz: 0633bc43e7df50179a6fb500c6a27e68c391a070
5
5
  SHA512:
6
- metadata.gz: 9300ace2170c9951c74c28d97e3ecd0ab5e9414621896c8c27fd09459ede42cb71584bd697826bbf4adff5b844f8d4dbcd7745251522f876a6c254c16212a2a0
7
- data.tar.gz: cec4b7f0baddd5aede0aa60bdfc9cd7802ddd41e82772693a0d68230fa66ed1d3ce7f8e3b4988b2a8fce52ce5f4796c011e7fd18ee228691d50692d2bea2cbeb
6
+ metadata.gz: '08ad18e49d2077a520beb2932edc47798a340145318b4856568fe2bcd369f01272d8da065b43dfacfdcd87a58c763f84503d06b9167b93531f164056dc21eb9e'
7
+ data.tar.gz: b27235706f5cb987c2f52c250addfb1125fde317a77b69f36aac20fd48c1545af0c2d3190cfcbd2df2b950f9abf08fadec0c9611667cd20c920add944e2850b7
@@ -20,22 +20,23 @@ class Logasm
20
20
  # Starts a new span.
21
21
  #
22
22
  # @param operation_name [String] The operation name for the Span
23
- # @param child_of [SpanContext] SpanContext that acts as a parent to
23
+ # @param child_of [SpanContext, Span] SpanContext that acts as a parent to
24
24
  # the newly-started Span. If a Span instance is provided, its
25
- # .span_context is automatically substituted.
25
+ # context is automatically substituted.
26
26
  # @param start_time [Time] When the Span started, if not now
27
27
  # @param tags [Hash] Tags to assign to the Span at start time
28
28
  #
29
29
  # @return [Span] The newly-started Span
30
- def start_span(operation_name, child_of: nil, start_time: Time.now, **)
30
+ def start_span(operation_name, child_of: nil, start_time: Time.now, tags: {}, **)
31
31
  context =
32
32
  if child_of
33
- SpanContext.create_from_parent_context(child_of)
33
+ parent_context = child_of.respond_to?(:context) ? child_of.context : child_of
34
+ SpanContext.create_from_parent_context(parent_context)
34
35
  else
35
36
  SpanContext.create_parent_context
36
37
  end
37
38
 
38
- Span.new(context, operation_name, @logger, start_time: start_time)
39
+ Span.new(context, operation_name, @logger, start_time: start_time, tags: tags)
39
40
  end
40
41
 
41
42
  # Inject a SpanContext into the given carrier
@@ -4,11 +4,12 @@ class Logasm
4
4
  class Span
5
5
  attr_reader :context
6
6
 
7
- def initialize(context, operation_name, logger, start_time: Time.now)
7
+ def initialize(context, operation_name, logger, start_time: Time.now, tags: {})
8
8
  @context = context
9
9
  @operation_name = operation_name
10
10
  @logger = logger
11
11
  @start_time = start_time
12
+ @tags = tags
12
13
  @logger.info "Span [#{@operation_name}] started", trace_information
13
14
  end
14
15
 
@@ -18,7 +19,7 @@ class Logasm
18
19
  # @param value [String, Numeric, Boolean] the value of the tag. If it's not
19
20
  # a String, Numeric, or Boolean it will be encoded with to_s
20
21
  def set_tag(key, value)
21
- self
22
+ @tags = @tags.merge(key => value)
22
23
  end
23
24
 
24
25
  # Set a baggage item on the span
@@ -70,7 +71,7 @@ class Logasm
70
71
  parent_id: @context.parent_id,
71
72
  span_id: @context.span_id,
72
73
  operation_name: @operation_name
73
- }.merge(additional_fields)
74
+ }.merge(additional_fields).merge(@tags)
74
75
  }
75
76
  end
76
77
  end
@@ -1,5 +1,5 @@
1
1
  class Logasm
2
2
  class Tracer
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logasm-tracer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SaleMove TechMovers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-29 00:00:00.000000000 Z
11
+ date: 2017-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler