opentelemetry-sdk 0.3.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +2 -2
  3. data/CHANGELOG.md +32 -0
  4. data/LICENSE +1 -1
  5. data/README.md +1 -1
  6. data/lib/opentelemetry/sdk.rb +4 -3
  7. data/lib/opentelemetry/sdk/baggage.rb +16 -0
  8. data/lib/opentelemetry/sdk/{correlation_context → baggage}/builder.rb +5 -5
  9. data/lib/opentelemetry/sdk/{correlation_context → baggage}/manager.rb +37 -27
  10. data/lib/opentelemetry/sdk/configurator.rb +73 -39
  11. data/lib/opentelemetry/sdk/instrumentation_library.rb +13 -0
  12. data/lib/opentelemetry/sdk/resources.rb +1 -0
  13. data/lib/opentelemetry/sdk/resources/constants.rb +124 -0
  14. data/lib/opentelemetry/sdk/resources/resource.rb +38 -19
  15. data/lib/opentelemetry/sdk/trace.rb +1 -0
  16. data/lib/opentelemetry/sdk/trace/config/trace_config.rb +3 -3
  17. data/lib/opentelemetry/sdk/trace/event.rb +48 -0
  18. data/lib/opentelemetry/sdk/trace/export.rb +9 -9
  19. data/lib/opentelemetry/sdk/trace/export/batch_span_processor.rb +49 -28
  20. data/lib/opentelemetry/sdk/trace/export/console_span_exporter.rb +3 -6
  21. data/lib/opentelemetry/sdk/trace/export/in_memory_span_exporter.rb +6 -2
  22. data/lib/opentelemetry/sdk/trace/export/multi_span_exporter.rb +10 -13
  23. data/lib/opentelemetry/sdk/trace/export/noop_span_exporter.rb +2 -1
  24. data/lib/opentelemetry/sdk/trace/export/simple_span_processor.rb +13 -3
  25. data/lib/opentelemetry/sdk/trace/multi_span_processor.rb +12 -4
  26. data/lib/opentelemetry/sdk/trace/noop_span_processor.rb +15 -3
  27. data/lib/opentelemetry/sdk/trace/samplers.rb +52 -51
  28. data/lib/opentelemetry/sdk/trace/samplers/constant_sampler.rb +33 -0
  29. data/lib/opentelemetry/sdk/trace/samplers/decision.rb +3 -3
  30. data/lib/opentelemetry/sdk/trace/samplers/parent_based.rb +53 -0
  31. data/lib/opentelemetry/sdk/trace/samplers/result.rb +3 -3
  32. data/lib/opentelemetry/sdk/trace/samplers/trace_id_ratio_based.rb +45 -0
  33. data/lib/opentelemetry/sdk/trace/span.rb +32 -35
  34. data/lib/opentelemetry/sdk/trace/span_data.rb +18 -3
  35. data/lib/opentelemetry/sdk/trace/tracer.rb +29 -16
  36. data/lib/opentelemetry/sdk/trace/tracer_provider.rb +4 -4
  37. data/lib/opentelemetry/sdk/version.rb +1 -1
  38. metadata +15 -10
  39. data/lib/opentelemetry/sdk/correlation_context.rb +0 -16
  40. data/lib/opentelemetry/sdk/trace/samplers/probability_sampler.rb +0 -61
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Copyright 2019 OpenTelemetry Authors
4
- #
5
- # SPDX-License-Identifier: Apache-2.0
6
-
7
- require 'opentelemetry/sdk/correlation_context/builder'
8
- require 'opentelemetry/sdk/correlation_context/manager'
9
-
10
- module OpenTelemetry
11
- module SDK
12
- # Contains operational implementataions of the CorrelationContext::Manager
13
- module CorrelationContext
14
- end
15
- end
16
- end
@@ -1,61 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Copyright 2019 OpenTelemetry Authors
4
- #
5
- # SPDX-License-Identifier: Apache-2.0
6
-
7
- module OpenTelemetry
8
- module SDK
9
- module Trace
10
- module Samplers
11
- # @api private
12
- #
13
- # Implements sampling based on a probability.
14
- class ProbabilitySampler
15
- def initialize(probability, ignore_parent:, apply_to_remote_parent:, apply_to_all_spans:)
16
- @probability = probability
17
- @id_upper_bound = format('%016x', (probability * (2**64 - 1)).ceil)
18
- @use_parent_sampled_flag = !ignore_parent
19
- @apply_to_remote_parent = apply_to_remote_parent
20
- @apply_to_all_spans = apply_to_all_spans
21
- end
22
-
23
- # @api private
24
- #
25
- # Callable interface for probability sampler. See {Samplers}.
26
- def call(trace_id:, span_id:, parent_context:, links:, name:, kind:, attributes:)
27
- # Ignored for sampling decision: links, name, kind, attributes.
28
-
29
- if sample?(trace_id, parent_context)
30
- RECORD_AND_SAMPLED
31
- else
32
- NOT_RECORD
33
- end
34
- end
35
-
36
- private
37
-
38
- def sample?(trace_id, parent_context)
39
- if parent_context.nil?
40
- sample_trace_id?(trace_id)
41
- else
42
- parent_sampled?(parent_context) || sample_trace_id_for_child?(parent_context, trace_id)
43
- end
44
- end
45
-
46
- def parent_sampled?(parent_context)
47
- @use_parent_sampled_flag && parent_context.trace_flags.sampled?
48
- end
49
-
50
- def sample_trace_id_for_child?(parent_context, trace_id)
51
- (@apply_to_all_spans || (@apply_to_remote_parent && parent_context.remote?)) && sample_trace_id?(trace_id)
52
- end
53
-
54
- def sample_trace_id?(trace_id)
55
- @probability == 1.0 || trace_id[16, 16] < @id_upper_bound
56
- end
57
- end
58
- end
59
- end
60
- end
61
- end