boost-jaeger-client 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +47 -0
  5. data/.travis.yml +5 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +57 -0
  9. data/Rakefile +9 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/boost-jaeger-client.gemspec +31 -0
  13. data/lib/jaeger/client/carrier.rb +26 -0
  14. data/lib/jaeger/client/collector.rb +91 -0
  15. data/lib/jaeger/client/samplers/const.rb +29 -0
  16. data/lib/jaeger/client/samplers/probabilistic.rb +30 -0
  17. data/lib/jaeger/client/samplers.rb +4 -0
  18. data/lib/jaeger/client/scope.rb +40 -0
  19. data/lib/jaeger/client/scope_manager/scope_identifier.rb +15 -0
  20. data/lib/jaeger/client/scope_manager/scope_stack.rb +35 -0
  21. data/lib/jaeger/client/scope_manager.rb +49 -0
  22. data/lib/jaeger/client/span/thrift_log_builder.rb +20 -0
  23. data/lib/jaeger/client/span/thrift_tag_builder.rb +45 -0
  24. data/lib/jaeger/client/span.rb +83 -0
  25. data/lib/jaeger/client/span_context.rb +78 -0
  26. data/lib/jaeger/client/trace_id.rb +13 -0
  27. data/lib/jaeger/client/tracer.rb +220 -0
  28. data/lib/jaeger/client/udp_sender/transport.rb +42 -0
  29. data/lib/jaeger/client/udp_sender.rb +82 -0
  30. data/lib/jaeger/client/version.rb +7 -0
  31. data/lib/jaeger/client.rb +44 -0
  32. data/script/create_follows_from_trace +52 -0
  33. data/script/create_trace +53 -0
  34. data/thrift/agent.thrift +32 -0
  35. data/thrift/gen-rb/jaeger/thrift/agent/agent.rb +118 -0
  36. data/thrift/gen-rb/jaeger/thrift/agent/agent_constants.rb +15 -0
  37. data/thrift/gen-rb/jaeger/thrift/agent/agent_types.rb +17 -0
  38. data/thrift/gen-rb/jaeger/thrift/agent.rb +116 -0
  39. data/thrift/gen-rb/jaeger/thrift/agent_constants.rb +13 -0
  40. data/thrift/gen-rb/jaeger/thrift/agent_types.rb +15 -0
  41. data/thrift/gen-rb/jaeger/thrift/collector.rb +82 -0
  42. data/thrift/gen-rb/jaeger/thrift/jaeger_constants.rb +13 -0
  43. data/thrift/gen-rb/jaeger/thrift/jaeger_types.rb +211 -0
  44. data/thrift/gen-rb/jaeger/thrift/zipkin/zipkin_collector.rb +84 -0
  45. data/thrift/gen-rb/jaeger/thrift/zipkin/zipkincore_constants.rb +41 -0
  46. data/thrift/gen-rb/jaeger/thrift/zipkin/zipkincore_types.rb +220 -0
  47. data/thrift/jaeger.thrift +88 -0
  48. data/thrift/zipkincore.thrift +300 -0
  49. metadata +190 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8c3902062745f1d65ab3400e82306b4ccfab44b93cdfa8a63251153b91691bc2
4
+ data.tar.gz: 99c38c57a426b74763b47b845e10d6be1472041536543dea4f958d8923d30deb
5
+ SHA512:
6
+ metadata.gz: 7d1b85df28533d5e7893b44917ae1d11db06abda22c2f52e458eaab4e70499ce13f22464eb9bd3a2eed81fa4249f329c74c7f17aa2f67757fe9ff3046cecc314
7
+ data.tar.gz: 6822ba4b929df4333ceed3e00f7ec4372747b1a9dbefbab90406fb09f44d0ce318c534ac907a913d0a4887bea27e9720f7de4b2dd15fda91017656ad97aebfd2
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,47 @@
1
+ require: rubocop-rspec
2
+
3
+ AllCops:
4
+ Exclude:
5
+ - 'thrift/**/*'
6
+
7
+ Style/Documentation:
8
+ Enabled: no
9
+
10
+ Style/IfUnlessModifier:
11
+ Enabled: no
12
+
13
+ RSpec/NestedGroups:
14
+ Max: 4
15
+
16
+ RSpec/ExampleLength:
17
+ Enabled: no
18
+
19
+ RSpec/MultipleExpectations:
20
+ Enabled: no
21
+
22
+ Metrics/BlockLength:
23
+ Enabled: no
24
+
25
+ Metrics/MethodLength:
26
+ Enabled: no
27
+
28
+ Metrics/AbcSize:
29
+ Enabled: no
30
+
31
+ Metrics/ClassLength:
32
+ Enabled: no
33
+
34
+ Metrics/ParameterLists:
35
+ Enabled: no
36
+
37
+ Lint/UnusedMethodArgument:
38
+ Enabled: no
39
+
40
+ Style/FrozenStringLiteralComment:
41
+ Enabled: yes
42
+ EnforcedStyle: always
43
+ Include:
44
+ - 'lib/**/*'
45
+
46
+ Metrics/LineLength:
47
+ Max: 120
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ before_install: gem install bundler -v 1.14.4
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jaeger-client.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Indrek Juhkam
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ Jaeger::Client
2
+ ================
3
+ [![Gem Version](https://badge.fury.io/rb/jaeger-client.svg)](https://rubygems.org/gems/jaeger-client)
4
+ [![Build Status](https://travis-ci.org/salemove/jaeger-client-ruby.svg)](https://travis-ci.org/salemove/jaeger-client-ruby)
5
+
6
+ OpenTracing Tracer implementation for Jaeger in Ruby
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'jaeger-client'
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ ```ruby
19
+ require 'jaeger/client'
20
+ OpenTracing.global_tracer = Jaeger::Client.build(host: 'localhost', port: 6831, service_name: 'echo')
21
+
22
+ OpenTracing.start_active_span('span name') do
23
+ # do something
24
+
25
+ OpenTracing.start_active_span('inner span name') do
26
+ # do something else
27
+ end
28
+ end
29
+ ```
30
+
31
+ See [opentracing-ruby](https://github.com/opentracing/opentracing-ruby) for more examples.
32
+
33
+ ### Samplers
34
+
35
+ #### Const sampler
36
+
37
+ `Const` sampler always makes the same decision for new traces depending on the initialization value. Set `sampler` to: `Jaeger::Client::Samplers::Const.new(true)` to mark all new traces as sampled.
38
+
39
+ #### Probabilistic sampler
40
+
41
+ `Probabilistic` sampler samples traces with probability equal to `rate` (must be between 0.0 and 1.0). This can be enabled by setting `Jaeger::Client::Samplers::Probabilistic.new(rate: 0.1)`
42
+
43
+ ## Development
44
+
45
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
46
+
47
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
48
+
49
+ ## Contributing
50
+
51
+ Bug reports and pull requests are welcome on GitHub at https://github.com/salemove/jaeger-client-ruby
52
+
53
+
54
+ ## License
55
+
56
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
57
+
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ RuboCop::RakeTask.new(:rubocop)
8
+
9
+ task default: %i[rubocop spec]
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'jaeger/client'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,31 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ require 'jaeger/client/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'boost-jaeger-client'
8
+ spec.version = Jaeger::Client::VERSION
9
+ spec.authors = ['kruczjak', 'SaleMove TechMovers']
10
+ spec.email = ['kruczjak@gmail.com']
11
+
12
+ spec.summary = 'OpenTracing Tracer implementation for Jaeger in Ruby'
13
+ spec.description = ''
14
+ spec.homepage = ''
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.14'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'rspec', '~> 3.0'
26
+ spec.add_development_dependency 'rubocop', '~> 0.54.0'
27
+ spec.add_development_dependency 'rubocop-rspec', '~> 1.24.0'
28
+
29
+ spec.add_dependency 'opentracing', '~> 0.3'
30
+ spec.add_dependency 'thrift'
31
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jaeger
4
+ module Client
5
+ # Carriers are used for inject and extract operations. A carrier should be a
6
+ # Hash or hash-like object. At a minimum, it should implement `[]`, `[]=`, and
7
+ # `each` shown here.
8
+ class Carrier
9
+ # [] retrieves a value by the given key
10
+ # @param key [String] key to retrieve the value
11
+ # @return [String] the desired value
12
+ def [](key); end
13
+
14
+ # []= sets the value for the given key
15
+ # @param key [String] key to set
16
+ # @param value [String] value to set
17
+ def []=(key, value); end
18
+
19
+ # each iterates over every key-value pair in the carrier
20
+ # @yield [key, value]
21
+ # @yieldparam key [String] the key of the tuple
22
+ # @yieldparam value [String] the value of the tuple
23
+ def each(&block); end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,91 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'thread'
4
+
5
+ module Jaeger
6
+ module Client
7
+ class Collector
8
+ def initialize
9
+ @buffer = Buffer.new
10
+ end
11
+
12
+ def send_span(span, end_time)
13
+ context = span.context
14
+ start_ts, duration = build_timestamps(span, end_time)
15
+ return if !context.sampled? && !context.debug?
16
+
17
+ @buffer << Jaeger::Thrift::Span.new(
18
+ 'traceIdLow' => context.thrift_trace_id,
19
+ 'traceIdHigh' => 0,
20
+ 'spanId' => context.thrift_span_id,
21
+ 'parentSpanId' => context.thrift_parent_id,
22
+ 'operationName' => span.operation_name,
23
+ 'references' => build_references(span.references || []),
24
+ 'flags' => context.flags,
25
+ 'startTime' => start_ts,
26
+ 'duration' => duration,
27
+ 'tags' => span.tags,
28
+ 'logs' => span.logs
29
+ )
30
+ end
31
+
32
+ def retrieve
33
+ @buffer.retrieve
34
+ end
35
+
36
+ private
37
+
38
+ def build_references(references)
39
+ references.map do |ref|
40
+ Jaeger::Thrift::SpanRef.new(
41
+ 'refType' => span_ref_type(ref.type),
42
+ 'traceIdLow' => ref.context.thrift_trace_id,
43
+ 'traceIdHigh' => 0,
44
+ 'spanId' => ref.context.thrift_span_id
45
+ )
46
+ end
47
+ end
48
+
49
+ def build_timestamps(span, end_time)
50
+ start_ts = (span.start_time.to_f * 1_000_000).to_i
51
+ end_ts = (end_time.to_f * 1_000_000).to_i
52
+ duration = end_ts - start_ts
53
+ [start_ts, duration]
54
+ end
55
+
56
+ def span_ref_type(type)
57
+ case type
58
+ when OpenTracing::Reference::CHILD_OF
59
+ Jaeger::Thrift::SpanRefType::CHILD_OF
60
+ when OpenTracing::Reference::FOLLOWS_FROM
61
+ Jaeger::Thrift::SpanRefType::FOLLOWS_FROM
62
+ else
63
+ warn "Jaeger::Client with format #{type} is not supported yet"
64
+ nil
65
+ end
66
+ end
67
+
68
+ class Buffer
69
+ def initialize
70
+ @buffer = []
71
+ @mutex = Mutex.new
72
+ end
73
+
74
+ def <<(element)
75
+ @mutex.synchronize do
76
+ @buffer << element
77
+ true
78
+ end
79
+ end
80
+
81
+ def retrieve
82
+ @mutex.synchronize do
83
+ elements = @buffer.dup
84
+ @buffer.clear
85
+ elements
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jaeger
4
+ module Client
5
+ module Samplers
6
+ # Const sampler
7
+ #
8
+ # A sampler that always makes the same decision for new traces depending
9
+ # on the initialization value. Use `Jaeger::Client::Samplers::Const.new(true)`
10
+ # to mark all new traces as sampled.
11
+ class Const
12
+ def initialize(decision)
13
+ @decision = decision
14
+ @param = decision ? '1' : '0'
15
+ end
16
+
17
+ def sample?(*)
18
+ @decision
19
+ end
20
+
21
+ def type
22
+ 'const'
23
+ end
24
+
25
+ attr_reader :param
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jaeger
4
+ module Client
5
+ module Samplers
6
+ # Probabilistic sampler
7
+ #
8
+ # Sample a portion of traces using trace_id as the random decision
9
+ class Probabilistic
10
+ def initialize(rate: 0.001)
11
+ @param = rate.to_s
12
+ if rate < 0.0 || rate > 1.0
13
+ raise "Sampling rate must be between 0.0 and 1.0, got #{rate.inspect}"
14
+ end
15
+ @boundary = TraceId::TRACE_ID_UPPER_BOUND * rate
16
+ end
17
+
18
+ def sample?(trace_id)
19
+ @boundary >= trace_id
20
+ end
21
+
22
+ def type
23
+ 'probabilistic'
24
+ end
25
+
26
+ attr_reader :param
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'samplers/const'
4
+ require_relative 'samplers/probabilistic'
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jaeger
4
+ module Client
5
+ # Scope represents an OpenTracing Scope
6
+ #
7
+ # See http://www.opentracing.io for more information.
8
+ class Scope
9
+ def initialize(span, scope_stack, finish_on_close:)
10
+ @span = span
11
+ @scope_stack = scope_stack
12
+ @finish_on_close = finish_on_close
13
+ @closed = false
14
+ end
15
+
16
+ # Return the Span scoped by this Scope
17
+ #
18
+ # @return [Span]
19
+ attr_reader :span
20
+
21
+ # Close scope
22
+ #
23
+ # Mark the end of the active period for the current thread and Scope,
24
+ # updating the ScopeManager#active in the process.
25
+ def close
26
+ raise "Tried to close already closed span: #{inspect}" if @closed
27
+ @closed = true
28
+
29
+ @span.finish if @finish_on_close
30
+ removed_scope = @scope_stack.pop
31
+
32
+ if removed_scope != self # rubocop:disable Style/GuardClause
33
+ raise 'Removed non-active scope, ' \
34
+ "removed: #{removed_scope.inspect}, "\
35
+ "expected: #{inspect}"
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jaeger
4
+ module Client
5
+ class ScopeManager
6
+ # @api private
7
+ class ScopeIdentifier
8
+ def self.generate
9
+ # 65..90.chr are characters between A and Z
10
+ "opentracing_#{(0...8).map { rand(65..90).chr }.join}".to_sym
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jaeger
4
+ module Client
5
+ class ScopeManager
6
+ # @api private
7
+ class ScopeStack
8
+ def initialize
9
+ # Generate a random identifier to use as the Thread.current key. This is
10
+ # needed so that it would be possible to create multiple tracers in one
11
+ # thread (mostly useful for testing purposes)
12
+ @scope_identifier = ScopeIdentifier.generate
13
+ end
14
+
15
+ def push(scope)
16
+ store << scope
17
+ end
18
+
19
+ def pop
20
+ store.pop
21
+ end
22
+
23
+ def peek
24
+ store.last
25
+ end
26
+
27
+ private
28
+
29
+ def store
30
+ Thread.current[@scope_identifier] ||= []
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'scope_manager/scope_stack'
4
+ require_relative 'scope_manager/scope_identifier'
5
+
6
+ module Jaeger
7
+ module Client
8
+ # ScopeManager represents an OpenTracing ScopeManager
9
+ #
10
+ # See http://www.opentracing.io for more information.
11
+ #
12
+ # The ScopeManager interface abstracts both the activation of Span instances
13
+ # via ScopeManager#activate and access to an active Span/Scope via
14
+ # ScopeManager#active
15
+ #
16
+ class ScopeManager
17
+ def initialize
18
+ @scope_stack = ScopeStack.new
19
+ end
20
+
21
+ # Make a span instance active
22
+ #
23
+ # @param span [Span] the Span that should become active
24
+ # @param finish_on_close [Boolean] whether the Span should automatically be
25
+ # finished when Scope#close is called
26
+ # @return [Scope] instance to control the end of the active period for the
27
+ # Span. It is a programming error to neglect to call Scope#close on the
28
+ # returned instance.
29
+ def activate(span, finish_on_close: true)
30
+ return active if active && active.span == span
31
+ scope = Scope.new(span, @scope_stack, finish_on_close: finish_on_close)
32
+ @scope_stack.push(scope)
33
+ scope
34
+ end
35
+
36
+ # Return active scope
37
+ #
38
+ # If there is a non-null Scope, its wrapped Span becomes an implicit parent
39
+ # (as Reference#CHILD_OF) of any newly-created Span at
40
+ # Tracer#start_active_span or Tracer#start_span time.
41
+ #
42
+ # @return [Scope] the currently active Scope which can be used to access the
43
+ # currently active Span.
44
+ def active
45
+ @scope_stack.peek
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jaeger
4
+ module Client
5
+ class Span
6
+ class ThriftLogBuilder
7
+ FIELDS = Jaeger::Thrift::Log::FIELDS
8
+ TIMESTAMP = FIELDS[Jaeger::Thrift::Log::TIMESTAMP].fetch(:name)
9
+ LOG_FIELDS = FIELDS[Jaeger::Thrift::Log::LOG_FIELDS].fetch(:name)
10
+
11
+ def self.build(timestamp, fields)
12
+ Jaeger::Thrift::Log.new(
13
+ TIMESTAMP => (timestamp.to_f * 1_000_000).to_i,
14
+ LOG_FIELDS => fields.map { |key, value| ThriftTagBuilder.build(key, value) }
15
+ )
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jaeger
4
+ module Client
5
+ class Span
6
+ class ThriftTagBuilder
7
+ FIELDS = Jaeger::Thrift::Tag::FIELDS
8
+ KEY = FIELDS[Jaeger::Thrift::Tag::KEY].fetch(:name)
9
+ VTYPE = FIELDS[Jaeger::Thrift::Tag::VTYPE].fetch(:name)
10
+ VLONG = FIELDS[Jaeger::Thrift::Tag::VLONG].fetch(:name)
11
+ VDOUBLE = FIELDS[Jaeger::Thrift::Tag::VDOUBLE].fetch(:name)
12
+ VBOOL = FIELDS[Jaeger::Thrift::Tag::VBOOL].fetch(:name)
13
+ VSTR = FIELDS[Jaeger::Thrift::Tag::VSTR].fetch(:name)
14
+
15
+ def self.build(key, value)
16
+ if value.is_a?(Integer)
17
+ Jaeger::Thrift::Tag.new(
18
+ KEY => key.to_s,
19
+ VTYPE => Jaeger::Thrift::TagType::LONG,
20
+ VLONG => value
21
+ )
22
+ elsif value.is_a?(Float)
23
+ Jaeger::Thrift::Tag.new(
24
+ KEY => key.to_s,
25
+ VTYPE => Jaeger::Thrift::TagType::DOUBLE,
26
+ VDOUBLE => value
27
+ )
28
+ elsif value.is_a?(TrueClass) || value.is_a?(FalseClass)
29
+ Jaeger::Thrift::Tag.new(
30
+ KEY => key.to_s,
31
+ VTYPE => Jaeger::Thrift::TagType::BOOL,
32
+ VBOOL => value
33
+ )
34
+ else
35
+ Jaeger::Thrift::Tag.new(
36
+ KEY => key.to_s,
37
+ VTYPE => Jaeger::Thrift::TagType::STRING,
38
+ VSTR => value.to_s
39
+ )
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end