ddtrace 1.6.1 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +40 -2
  3. data/ext/ddtrace_profiling_loader/extconf.rb +1 -1
  4. data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time.c +66 -6
  5. data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +51 -54
  6. data/ext/ddtrace_profiling_native_extension/collectors_stack.c +11 -13
  7. data/ext/ddtrace_profiling_native_extension/extconf.rb +1 -1
  8. data/ext/ddtrace_profiling_native_extension/private_vm_api_access.c +3 -2
  9. data/ext/ddtrace_profiling_native_extension/setup_signal_handler.c +96 -0
  10. data/ext/ddtrace_profiling_native_extension/setup_signal_handler.h +7 -0
  11. data/ext/ddtrace_profiling_native_extension/stack_recorder.c +70 -18
  12. data/ext/ddtrace_profiling_native_extension/stack_recorder.h +1 -0
  13. data/lib/datadog/appsec/assets/blocked.html +98 -3
  14. data/lib/datadog/appsec/assets/blocked.json +1 -0
  15. data/lib/datadog/appsec/assets/blocked.text +5 -0
  16. data/lib/datadog/appsec/assets/waf_rules/recommended.json +35 -46
  17. data/lib/datadog/appsec/assets/waf_rules/risky.json +1 -1
  18. data/lib/datadog/appsec/assets/waf_rules/strict.json +46 -1
  19. data/lib/datadog/appsec/assets.rb +2 -2
  20. data/lib/datadog/appsec/configuration/settings.rb +6 -0
  21. data/lib/datadog/appsec/configuration.rb +4 -0
  22. data/lib/datadog/appsec/contrib/rack/reactive/request.rb +4 -8
  23. data/lib/datadog/appsec/contrib/rack/request.rb +17 -0
  24. data/lib/datadog/appsec/contrib/rack/request_body_middleware.rb +2 -2
  25. data/lib/datadog/appsec/contrib/rack/request_middleware.rb +2 -2
  26. data/lib/datadog/appsec/contrib/rails/patcher.rb +3 -6
  27. data/lib/datadog/appsec/contrib/sinatra/ext.rb +1 -0
  28. data/lib/datadog/appsec/contrib/sinatra/gateway/watcher.rb +1 -1
  29. data/lib/datadog/appsec/contrib/sinatra/patcher.rb +11 -8
  30. data/lib/datadog/appsec/extensions.rb +10 -0
  31. data/lib/datadog/appsec/processor.rb +18 -0
  32. data/lib/datadog/appsec/response.rb +54 -0
  33. data/lib/datadog/core/runtime/ext.rb +1 -1
  34. data/lib/datadog/opentracer/distributed_headers.rb +5 -7
  35. data/lib/datadog/opentracer/rack_propagator.rb +0 -3
  36. data/lib/datadog/opentracer/text_map_propagator.rb +5 -7
  37. data/lib/datadog/profiling/collectors/cpu_and_wall_time.rb +10 -4
  38. data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +4 -0
  39. data/lib/datadog/profiling/collectors/old_stack.rb +7 -0
  40. data/lib/datadog/profiling/exporter.rb +5 -0
  41. data/lib/datadog/profiling/old_recorder.rb +8 -0
  42. data/lib/datadog/profiling/profiler.rb +7 -0
  43. data/lib/datadog/profiling/scheduler.rb +4 -7
  44. data/lib/datadog/profiling/stack_recorder.rb +22 -0
  45. data/lib/datadog/profiling/tasks/setup.rb +0 -7
  46. data/lib/datadog/tracing/contrib/delayed_job/plugin.rb +4 -0
  47. data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/client.rb +2 -1
  48. data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/server.rb +6 -12
  49. data/lib/datadog/tracing/contrib/grpc/distributed/fetcher.rb +27 -0
  50. data/lib/datadog/tracing/contrib/grpc/distributed/propagation.rb +38 -0
  51. data/lib/datadog/tracing/contrib/grpc/patcher.rb +0 -2
  52. data/lib/datadog/tracing/contrib/http/distributed/fetcher.rb +32 -0
  53. data/lib/datadog/tracing/contrib/http/distributed/propagation.rb +33 -0
  54. data/lib/datadog/tracing/contrib/kafka/consumer_event.rb +1 -0
  55. data/lib/datadog/tracing/contrib/kafka/events/produce_operation/send_messages.rb +1 -0
  56. data/lib/datadog/tracing/contrib/kafka/events/producer/deliver_messages.rb +1 -0
  57. data/lib/datadog/tracing/contrib/mongodb/subscribers.rb +2 -0
  58. data/lib/datadog/tracing/contrib/que/tracer.rb +2 -0
  59. data/lib/datadog/tracing/contrib/racecar/events/batch.rb +4 -1
  60. data/lib/datadog/tracing/contrib/racecar/events/message.rb +4 -1
  61. data/lib/datadog/tracing/contrib/rack/middlewares.rb +2 -0
  62. data/lib/datadog/tracing/contrib/redis/instrumentation.rb +2 -0
  63. data/lib/datadog/tracing/contrib/resque/resque_job.rb +2 -0
  64. data/lib/datadog/tracing/contrib/shoryuken/tracer.rb +2 -0
  65. data/lib/datadog/tracing/contrib/sidekiq/client_tracer.rb +5 -0
  66. data/lib/datadog/tracing/contrib/sidekiq/server_tracer.rb +5 -0
  67. data/lib/datadog/tracing/contrib/sneakers/tracer.rb +2 -0
  68. data/lib/datadog/tracing/distributed/b3.rb +66 -0
  69. data/lib/datadog/tracing/distributed/b3_single.rb +66 -0
  70. data/lib/datadog/tracing/distributed/datadog.rb +153 -0
  71. data/lib/datadog/tracing/distributed/datadog_tags_codec.rb +1 -0
  72. data/lib/datadog/tracing/distributed/fetcher.rb +30 -0
  73. data/lib/datadog/tracing/distributed/headers/ext.rb +18 -16
  74. data/lib/datadog/tracing/distributed/helpers.rb +7 -6
  75. data/lib/datadog/tracing/distributed/propagation.rb +127 -0
  76. data/lib/datadog/tracing/propagation/http.rb +3 -106
  77. data/lib/datadog/tracing/trace_segment.rb +1 -1
  78. data/lib/ddtrace/transport/trace_formatter.rb +2 -5
  79. data/lib/ddtrace/version.rb +2 -2
  80. metadata +19 -14
  81. data/lib/datadog/tracing/distributed/headers/b3.rb +0 -55
  82. data/lib/datadog/tracing/distributed/headers/b3_single.rb +0 -67
  83. data/lib/datadog/tracing/distributed/headers/datadog.rb +0 -144
  84. data/lib/datadog/tracing/distributed/headers/parser.rb +0 -37
  85. data/lib/datadog/tracing/distributed/metadata/b3.rb +0 -55
  86. data/lib/datadog/tracing/distributed/metadata/b3_single.rb +0 -66
  87. data/lib/datadog/tracing/distributed/metadata/datadog.rb +0 -73
  88. data/lib/datadog/tracing/distributed/metadata/parser.rb +0 -34
  89. data/lib/datadog/tracing/propagation/grpc.rb +0 -98
@@ -1,98 +0,0 @@
1
- # typed: false
2
-
3
- require_relative '../distributed/metadata/datadog'
4
- require_relative '../distributed/metadata/b3'
5
- require_relative '../distributed/metadata/b3_single'
6
-
7
- require_relative '../span'
8
- require_relative '../trace_digest'
9
- require_relative '../trace_operation'
10
-
11
- module Datadog
12
- module Tracing
13
- module Propagation
14
- # opentracing.io compliant methods for distributing trace headers
15
- # between two or more distributed services. Note this is very close
16
- # to the Propagation::HTTP; the key difference is the way gRPC handles
17
- # header information (called "metadata") as it operates over HTTP2
18
- module GRPC
19
- PROPAGATION_STYLES = {
20
- Configuration::Ext::Distributed::PROPAGATION_STYLE_B3 => Distributed::Metadata::B3,
21
- Configuration::Ext::Distributed::PROPAGATION_STYLE_B3_SINGLE_HEADER => Distributed::Metadata::B3Single,
22
- Configuration::Ext::Distributed::PROPAGATION_STYLE_DATADOG => Distributed::Metadata::Datadog
23
- }.freeze
24
-
25
- def self.inject!(digest, metadata)
26
- return if digest.nil?
27
-
28
- digest = digest.to_digest if digest.is_a?(TraceOperation)
29
-
30
- Datadog.configuration.tracing.distributed_tracing.propagation_inject_style.each do |style|
31
- propagator = PROPAGATION_STYLES[style]
32
- begin
33
- propagator.inject!(digest, metadata) unless propagator.nil?
34
- rescue => e
35
- Datadog.logger.error(
36
- 'Error injecting propagated trace headers into the environment. ' \
37
- "Cause: #{e} Location: #{Array(e.backtrace).first}"
38
- )
39
- end
40
- end
41
- end
42
-
43
- def self.extract(metadata)
44
- trace_digest = nil
45
- dd_trace_digest = nil
46
-
47
- Datadog.configuration.tracing.distributed_tracing.propagation_extract_style.each do |style|
48
- propagator = PROPAGATION_STYLES[style]
49
-
50
- next if propagator.nil?
51
-
52
- # Extract trace headers
53
- begin
54
- extracted_trace_digest = propagator.extract(metadata)
55
- rescue => e
56
- Datadog.logger.error(
57
- 'Error extracting propagated trace headers from the environment. ' \
58
- "Cause: #{e} Location: #{Array(e.backtrace).first}"
59
- )
60
- end
61
-
62
- # Skip this style if no valid headers were found
63
- next if extracted_trace_digest.nil?
64
-
65
- # Keep track of the Datadog extract trace headers, we want to return
66
- # this one if we have one
67
- if extracted_trace_digest && style == Configuration::Ext::Distributed::PROPAGATION_STYLE_DATADOG
68
- dd_trace_digest = extracted_trace_digest
69
- end
70
-
71
- # No previously extracted trace headers, use the one we just extracted
72
- if trace_digest.nil?
73
- trace_digest = extracted_trace_digest
74
- else
75
- unless trace_digest.trace_id == extracted_trace_digest.trace_id \
76
- && trace_digest.span_id == extracted_trace_digest.span_id
77
- # Return an empty/new trace headers if we have a mismatch in values extracted
78
- msg = "#{trace_digest.trace_id} != #{extracted_trace_digest.trace_id} && " \
79
- "#{trace_digest.span_id} != #{extracted_trace_digest.span_id}"
80
- Datadog.logger.debug(
81
- "Cannot extract trace headers from HTTP: extracted trace headers differ, #{msg}"
82
- )
83
- # DEV: This will return from `self.extract` not this `each` block
84
- return TraceDigest.new
85
- end
86
- end
87
- end
88
-
89
- # Return the extracted trace headers if we found one or else a new empty trace headers
90
- # Always return the Datadog trace headers if one exists since it has more
91
- # information than the B3 headers e.g. origin, expanded priority
92
- # sampling values, etc
93
- dd_trace_digest || trace_digest || nil
94
- end
95
- end
96
- end
97
- end
98
- end