ddtrace 1.10.1 → 1.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +125 -1
- data/README.md +8 -10
- data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +110 -18
- data/ext/ddtrace_profiling_native_extension/collectors_thread_context.c +26 -3
- data/ext/ddtrace_profiling_native_extension/private_vm_api_access.c +3 -0
- data/lib/datadog/appsec/component.rb +40 -6
- data/lib/datadog/appsec/configuration/settings.rb +20 -4
- data/lib/datadog/appsec/configuration.rb +8 -0
- data/lib/datadog/appsec/contrib/auto_instrument.rb +2 -0
- data/lib/datadog/appsec/contrib/configuration/settings.rb +2 -0
- data/lib/datadog/appsec/contrib/integration.rb +2 -0
- data/lib/datadog/appsec/contrib/patcher.rb +2 -0
- data/lib/datadog/appsec/contrib/rack/configuration/settings.rb +2 -0
- data/lib/datadog/appsec/contrib/rack/gateway/request.rb +4 -15
- data/lib/datadog/appsec/contrib/rack/gateway/response.rb +1 -1
- data/lib/datadog/appsec/contrib/rack/patcher.rb +2 -0
- data/lib/datadog/appsec/contrib/rack/reactive/response.rb +6 -0
- data/lib/datadog/appsec/contrib/rack/request_middleware.rb +17 -4
- data/lib/datadog/appsec/contrib/rails/configuration/settings.rb +2 -0
- data/lib/datadog/appsec/contrib/rails/framework.rb +2 -0
- data/lib/datadog/appsec/contrib/rails/gateway/request.rb +1 -1
- data/lib/datadog/appsec/contrib/rails/request.rb +2 -0
- data/lib/datadog/appsec/contrib/rails/request_middleware.rb +2 -0
- data/lib/datadog/appsec/contrib/sinatra/configuration/settings.rb +2 -0
- data/lib/datadog/appsec/contrib/sinatra/framework.rb +2 -0
- data/lib/datadog/appsec/contrib/sinatra/gateway/route_params.rb +1 -1
- data/lib/datadog/appsec/contrib/sinatra/request_middleware.rb +2 -0
- data/lib/datadog/appsec/extensions.rb +2 -0
- data/lib/datadog/appsec/instrumentation/gateway/argument.rb +2 -4
- data/lib/datadog/appsec/processor/rule_loader.rb +63 -0
- data/lib/datadog/appsec/processor/rule_merger.rb +146 -0
- data/lib/datadog/appsec/processor.rb +15 -70
- data/lib/datadog/appsec/remote.rb +121 -0
- data/lib/datadog/appsec/utils/http.rb +2 -0
- data/lib/datadog/appsec/utils.rb +2 -0
- data/lib/datadog/appsec.rb +18 -4
- data/lib/datadog/ci/configuration/components.rb +2 -0
- data/lib/datadog/ci/configuration/settings.rb +2 -0
- data/lib/datadog/ci/contrib/cucumber/configuration/settings.rb +2 -0
- data/lib/datadog/ci/contrib/cucumber/formatter.rb +2 -0
- data/lib/datadog/ci/contrib/cucumber/instrumentation.rb +2 -0
- data/lib/datadog/ci/contrib/cucumber/patcher.rb +2 -0
- data/lib/datadog/ci/contrib/rspec/configuration/settings.rb +2 -0
- data/lib/datadog/ci/contrib/rspec/patcher.rb +2 -0
- data/lib/datadog/ci/extensions.rb +2 -0
- data/lib/datadog/ci/flush.rb +2 -0
- data/lib/datadog/ci.rb +2 -0
- data/lib/datadog/core/buffer/cruby.rb +2 -0
- data/lib/datadog/core/buffer/random.rb +2 -0
- data/lib/datadog/core/buffer/thread_safe.rb +2 -0
- data/lib/datadog/core/chunker.rb +2 -0
- data/lib/datadog/core/configuration/agent_settings_resolver.rb +68 -17
- data/lib/datadog/core/configuration/components.rb +11 -14
- data/lib/datadog/core/configuration/dependency_resolver.rb +2 -0
- data/lib/datadog/core/configuration/option.rb +2 -0
- data/lib/datadog/core/configuration/option_definition.rb +2 -0
- data/lib/datadog/core/configuration/option_definition_set.rb +2 -0
- data/lib/datadog/core/configuration/option_set.rb +2 -0
- data/lib/datadog/core/configuration/settings.rb +70 -16
- data/lib/datadog/core/diagnostics/health.rb +2 -0
- data/lib/datadog/core/environment/class_count.rb +2 -0
- data/lib/datadog/core/environment/gc.rb +2 -0
- data/lib/datadog/core/environment/identity.rb +58 -0
- data/lib/datadog/core/environment/socket.rb +2 -0
- data/lib/datadog/core/environment/thread_count.rb +2 -0
- data/lib/datadog/core/environment/variable_helpers.rb +10 -2
- data/lib/datadog/core/environment/vm_cache.rb +2 -0
- data/lib/datadog/core/extensions.rb +2 -0
- data/lib/datadog/core/header_collection.rb +2 -0
- data/lib/datadog/core/metrics/helpers.rb +2 -0
- data/lib/datadog/core/metrics/metric.rb +2 -0
- data/lib/datadog/core/remote/client/capabilities.rb +57 -0
- data/lib/datadog/core/remote/client.rb +225 -0
- data/lib/datadog/core/remote/component.rb +158 -0
- data/lib/datadog/core/remote/configuration/content.rb +84 -0
- data/lib/datadog/core/remote/configuration/digest.rb +62 -0
- data/lib/datadog/core/remote/configuration/path.rb +90 -0
- data/lib/datadog/core/remote/configuration/repository.rb +292 -0
- data/lib/datadog/core/remote/configuration/target.rb +74 -0
- data/lib/datadog/core/remote/configuration.rb +18 -0
- data/lib/datadog/core/remote/dispatcher.rb +59 -0
- data/lib/datadog/core/remote/ext.rb +12 -0
- data/lib/datadog/core/remote/negotiation.rb +57 -0
- data/lib/datadog/core/remote/worker.rb +96 -0
- data/lib/datadog/core/remote.rb +24 -0
- data/lib/datadog/core/telemetry/collector.rb +8 -9
- data/lib/datadog/core/telemetry/heartbeat.rb +2 -0
- data/lib/datadog/core/telemetry/http/env.rb +2 -0
- data/lib/datadog/core/telemetry/http/transport.rb +2 -0
- data/lib/datadog/core/telemetry/v1/app_event.rb +2 -0
- data/lib/datadog/core/telemetry/v1/application.rb +7 -1
- data/lib/datadog/core/telemetry/v1/dependency.rb +7 -1
- data/lib/datadog/core/telemetry/v1/host.rb +9 -1
- data/lib/datadog/core/telemetry/v1/integration.rb +7 -1
- data/lib/datadog/core/telemetry/v1/product.rb +9 -1
- data/lib/datadog/core/telemetry/v1/telemetry_request.rb +7 -1
- data/lib/datadog/core/transport/config.rb +58 -0
- data/lib/datadog/core/transport/http/api/instance.rb +37 -0
- data/lib/datadog/core/transport/http/api/spec.rb +19 -0
- data/lib/datadog/core/transport/http/api.rb +57 -0
- data/lib/datadog/core/transport/http/builder.rb +217 -0
- data/lib/datadog/core/transport/http/client.rb +45 -0
- data/lib/datadog/core/transport/http/config.rb +268 -0
- data/lib/datadog/core/transport/http/negotiation.rb +144 -0
- data/lib/datadog/core/transport/http.rb +169 -0
- data/lib/datadog/core/transport/negotiation.rb +60 -0
- data/lib/datadog/core/utils/compression.rb +2 -0
- data/lib/datadog/core/utils/hash.rb +32 -0
- data/lib/datadog/core/utils/object_set.rb +2 -0
- data/lib/datadog/core/utils/safe_dup.rb +20 -2
- data/lib/datadog/core/utils/sequence.rb +2 -0
- data/lib/datadog/core/utils/time.rb +2 -0
- data/lib/datadog/core/worker.rb +2 -0
- data/lib/datadog/core/workers/async.rb +6 -2
- data/lib/datadog/core/workers/interval_loop.rb +7 -1
- data/lib/datadog/core/workers/queue.rb +2 -0
- data/lib/datadog/core/workers/runtime_metrics.rb +2 -0
- data/lib/datadog/kit.rb +2 -0
- data/lib/datadog/opentracer/binary_propagator.rb +2 -0
- data/lib/datadog/opentracer/carrier.rb +2 -0
- data/lib/datadog/opentracer/global_tracer.rb +2 -0
- data/lib/datadog/opentracer/propagator.rb +2 -0
- data/lib/datadog/opentracer/scope.rb +2 -0
- data/lib/datadog/opentracer/scope_manager.rb +2 -0
- data/lib/datadog/opentracer/span_context.rb +2 -0
- data/lib/datadog/opentracer/span_context_factory.rb +2 -0
- data/lib/datadog/opentracer/thread_local_scope.rb +2 -0
- data/lib/datadog/opentracer.rb +2 -0
- data/lib/datadog/profiling/backtrace_location.rb +2 -0
- data/lib/datadog/profiling/buffer.rb +2 -0
- data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +19 -3
- data/lib/datadog/profiling/collectors/dynamic_sampling_rate.rb +2 -0
- data/lib/datadog/profiling/collectors/idle_sampling_helper.rb +1 -1
- data/lib/datadog/profiling/collectors/stack.rb +2 -0
- data/lib/datadog/profiling/collectors/thread_context.rb +2 -2
- data/lib/datadog/profiling/component.rb +103 -29
- data/lib/datadog/profiling/event.rb +2 -0
- data/lib/datadog/profiling/events/stack.rb +2 -0
- data/lib/datadog/profiling/ext.rb +28 -26
- data/lib/datadog/profiling/flush.rb +2 -0
- data/lib/datadog/profiling/native_extension.rb +2 -0
- data/lib/datadog/profiling/pprof/message_set.rb +2 -0
- data/lib/datadog/profiling/pprof/payload.rb +2 -0
- data/lib/datadog/profiling/pprof/string_table.rb +2 -0
- data/lib/datadog/profiling/preload.rb +2 -0
- data/lib/datadog/profiling/scheduler.rb +3 -1
- data/lib/datadog/profiling/stack_recorder.rb +0 -18
- data/lib/datadog/profiling/tag_builder.rb +2 -0
- data/lib/datadog/profiling/tasks/setup.rb +0 -26
- data/lib/datadog/profiling.rb +2 -1
- data/lib/datadog/tracing/analytics.rb +2 -0
- data/lib/datadog/tracing/configuration/ext.rb +7 -0
- data/lib/datadog/tracing/configuration/settings.rb +14 -0
- data/lib/datadog/tracing/context.rb +2 -0
- data/lib/datadog/tracing/contrib/action_cable/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/action_cable/event.rb +2 -0
- data/lib/datadog/tracing/contrib/action_cable/events.rb +2 -0
- data/lib/datadog/tracing/contrib/action_cable/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/action_mailer/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/action_mailer/event.rb +2 -0
- data/lib/datadog/tracing/contrib/action_mailer/events.rb +2 -0
- data/lib/datadog/tracing/contrib/action_mailer/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/action_pack/action_controller/instrumentation.rb +2 -24
- data/lib/datadog/tracing/contrib/action_pack/action_controller/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/action_pack/configuration/settings.rb +14 -1
- data/lib/datadog/tracing/contrib/action_pack/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/action_view/event.rb +2 -0
- data/lib/datadog/tracing/contrib/action_view/events.rb +2 -0
- data/lib/datadog/tracing/contrib/active_job/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/active_job/event.rb +2 -0
- data/lib/datadog/tracing/contrib/active_job/events.rb +2 -0
- data/lib/datadog/tracing/contrib/active_job/log_injection.rb +2 -0
- data/lib/datadog/tracing/contrib/active_job/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/active_model_serializers/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/active_model_serializers/event.rb +2 -0
- data/lib/datadog/tracing/contrib/active_model_serializers/events.rb +2 -0
- data/lib/datadog/tracing/contrib/active_model_serializers/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/active_record/configuration/settings.rb +8 -1
- data/lib/datadog/tracing/contrib/active_record/event.rb +2 -0
- data/lib/datadog/tracing/contrib/active_record/events/sql.rb +4 -1
- data/lib/datadog/tracing/contrib/active_record/events.rb +2 -0
- data/lib/datadog/tracing/contrib/active_record/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +6 -2
- data/lib/datadog/tracing/contrib/active_support/cache/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/active_support/cache/redis.rb +2 -0
- data/lib/datadog/tracing/contrib/active_support/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/active_support/notifications/event.rb +2 -0
- data/lib/datadog/tracing/contrib/active_support/notifications/subscriber.rb +2 -0
- data/lib/datadog/tracing/contrib/active_support/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/analytics.rb +2 -0
- data/lib/datadog/tracing/contrib/auto_instrument.rb +2 -0
- data/lib/datadog/tracing/contrib/aws/configuration/settings.rb +9 -1
- data/lib/datadog/tracing/contrib/aws/instrumentation.rb +8 -1
- data/lib/datadog/tracing/contrib/aws/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/concurrent_ruby/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/concurrent_ruby/context_composite_executor_service.rb +2 -0
- data/lib/datadog/tracing/contrib/concurrent_ruby/future_patch.rb +2 -0
- data/lib/datadog/tracing/contrib/concurrent_ruby/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/configurable.rb +2 -0
- data/lib/datadog/tracing/contrib/configuration/resolver.rb +2 -0
- data/lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb +2 -0
- data/lib/datadog/tracing/contrib/dalli/configuration/settings.rb +8 -1
- data/lib/datadog/tracing/contrib/dalli/instrumentation.rb +4 -1
- data/lib/datadog/tracing/contrib/dalli/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/delayed_job/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/delayed_job/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/delayed_job/plugin.rb +2 -0
- data/lib/datadog/tracing/contrib/delayed_job/server_internal_tracer/worker.rb +2 -0
- data/lib/datadog/tracing/contrib/elasticsearch/configuration/settings.rb +8 -1
- data/lib/datadog/tracing/contrib/elasticsearch/patcher.rb +4 -1
- data/lib/datadog/tracing/contrib/ethon/configuration/settings.rb +8 -1
- data/lib/datadog/tracing/contrib/ethon/easy_patch.rb +5 -3
- data/lib/datadog/tracing/contrib/ethon/multi_patch.rb +6 -2
- data/lib/datadog/tracing/contrib/ethon/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/excon/configuration/settings.rb +8 -1
- data/lib/datadog/tracing/contrib/excon/middleware.rb +5 -2
- data/lib/datadog/tracing/contrib/excon/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/faraday/configuration/settings.rb +8 -1
- data/lib/datadog/tracing/contrib/faraday/connection.rb +2 -0
- data/lib/datadog/tracing/contrib/faraday/middleware.rb +5 -2
- data/lib/datadog/tracing/contrib/faraday/rack_builder.rb +2 -0
- data/lib/datadog/tracing/contrib/grape/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/grape/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/graphql/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/grpc/configuration/settings.rb +8 -1
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/client.rb +5 -2
- data/lib/datadog/tracing/contrib/grpc/intercept_with_datadog.rb +2 -0
- data/lib/datadog/tracing/contrib/grpc/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/hanami/action_tracer.rb +2 -0
- data/lib/datadog/tracing/contrib/hanami/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/hanami/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/hanami/plugin.rb +2 -0
- data/lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb +2 -0
- data/lib/datadog/tracing/contrib/hanami/router_tracing.rb +2 -0
- data/lib/datadog/tracing/contrib/http/circuit_breaker.rb +2 -0
- data/lib/datadog/tracing/contrib/http/configuration/settings.rb +8 -1
- data/lib/datadog/tracing/contrib/http/instrumentation.rb +5 -2
- data/lib/datadog/tracing/contrib/http/integration.rb +2 -0
- data/lib/datadog/tracing/contrib/http/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/http_annotation_helper.rb +2 -0
- data/lib/datadog/tracing/contrib/httpclient/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/httprb/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/integration.rb +2 -0
- data/lib/datadog/tracing/contrib/kafka/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/kafka/consumer_event.rb +2 -0
- data/lib/datadog/tracing/contrib/kafka/consumer_group_event.rb +2 -0
- data/lib/datadog/tracing/contrib/kafka/event.rb +2 -0
- data/lib/datadog/tracing/contrib/kafka/events.rb +2 -0
- data/lib/datadog/tracing/contrib/kafka/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/lograge/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/lograge/instrumentation.rb +2 -0
- data/lib/datadog/tracing/contrib/lograge/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/mongodb/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/mongodb/instrumentation.rb +2 -0
- data/lib/datadog/tracing/contrib/mongodb/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/mysql2/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +2 -0
- data/lib/datadog/tracing/contrib/mysql2/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/patchable.rb +2 -0
- data/lib/datadog/tracing/contrib/pg/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/pg/instrumentation.rb +2 -0
- data/lib/datadog/tracing/contrib/pg/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/presto/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/propagation/sql_comment/mode.rb +2 -0
- data/lib/datadog/tracing/contrib/qless/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/qless/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/qless/tracer_cleaner.rb +2 -0
- data/lib/datadog/tracing/contrib/racecar/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/racecar/event.rb +2 -0
- data/lib/datadog/tracing/contrib/racecar/events.rb +2 -0
- data/lib/datadog/tracing/contrib/racecar/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/rails/configuration/settings.rb +9 -2
- data/lib/datadog/tracing/contrib/rails/framework.rb +2 -0
- data/lib/datadog/tracing/contrib/rails/middlewares.rb +2 -0
- data/lib/datadog/tracing/contrib/rails/utils.rb +3 -1
- data/lib/datadog/tracing/contrib/rake/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/rake/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/redis/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/redis/tags.rb +2 -0
- data/lib/datadog/tracing/contrib/registerable.rb +2 -0
- data/lib/datadog/tracing/contrib/registry.rb +2 -0
- data/lib/datadog/tracing/contrib/resque/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/resque/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/resque/resque_job.rb +2 -0
- data/lib/datadog/tracing/contrib/rest_client/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/rest_client/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +2 -0
- data/lib/datadog/tracing/contrib/roda/configuration/settings.rb +34 -0
- data/lib/datadog/tracing/contrib/roda/ext.rb +18 -0
- data/lib/datadog/tracing/contrib/roda/instrumentation.rb +76 -0
- data/lib/datadog/tracing/contrib/roda/integration.rb +45 -0
- data/lib/datadog/tracing/contrib/roda/patcher.rb +30 -0
- data/lib/datadog/tracing/contrib/semantic_logger/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb +3 -0
- data/lib/datadog/tracing/contrib/semantic_logger/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/sequel/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/sequel/dataset.rb +2 -0
- data/lib/datadog/tracing/contrib/sequel/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/shoryuken/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/shoryuken/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/shoryuken/tracer.rb +2 -0
- data/lib/datadog/tracing/contrib/sidekiq/client_tracer.rb +12 -3
- data/lib/datadog/tracing/contrib/sidekiq/configuration/settings.rb +3 -0
- data/lib/datadog/tracing/contrib/sidekiq/distributed/propagation.rb +38 -0
- data/lib/datadog/tracing/contrib/sidekiq/integration.rb +8 -0
- data/lib/datadog/tracing/contrib/sidekiq/patcher.rb +16 -2
- data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/heartbeat.rb +11 -4
- data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/job_fetch.rb +2 -0
- data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/redis_info.rb +2 -0
- data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/scheduled_poller.rb +2 -0
- data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/stop.rb +34 -0
- data/lib/datadog/tracing/contrib/sidekiq/server_tracer.rb +18 -2
- data/lib/datadog/tracing/contrib/sidekiq/{tracing.rb → utils.rb} +3 -1
- data/lib/datadog/tracing/contrib/sinatra/headers.rb +2 -0
- data/lib/datadog/tracing/contrib/sinatra/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/sinatra/tracer_middleware.rb +2 -0
- data/lib/datadog/tracing/contrib/span_attribute_schema.rb +28 -0
- data/lib/datadog/tracing/contrib/sucker_punch/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/sucker_punch/exception_handler.rb +2 -0
- data/lib/datadog/tracing/contrib/sucker_punch/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/utils/quantization/http.rb +2 -2
- data/lib/datadog/tracing/contrib.rb +3 -0
- data/lib/datadog/tracing/correlation.rb +10 -10
- data/lib/datadog/tracing/diagnostics/health.rb +2 -0
- data/lib/datadog/tracing/distributed/trace_context.rb +22 -15
- data/lib/datadog/tracing/flush.rb +2 -0
- data/lib/datadog/tracing/metadata/analytics.rb +2 -0
- data/lib/datadog/tracing/metadata/errors.rb +2 -0
- data/lib/datadog/tracing/metadata/ext.rb +6 -0
- data/lib/datadog/tracing/metadata.rb +2 -0
- data/lib/datadog/tracing/pipeline/span_filter.rb +2 -0
- data/lib/datadog/tracing/pipeline/span_processor.rb +2 -0
- data/lib/datadog/tracing/propagation/http.rb +2 -0
- data/lib/datadog/tracing/runtime/metrics.rb +2 -0
- data/lib/datadog/tracing/sampling/all_sampler.rb +2 -0
- data/lib/datadog/tracing/sampling/matcher.rb +2 -0
- data/lib/datadog/tracing/sampling/priority_sampler.rb +2 -0
- data/lib/datadog/tracing/sampling/span/sampler.rb +2 -0
- data/lib/datadog/tracing/sync_writer.rb +2 -0
- data/lib/datadog/tracing/trace_digest.rb +2 -0
- data/lib/datadog/tracing/utils.rb +2 -0
- data/lib/datadog/tracing.rb +2 -0
- data/lib/ddtrace/auto_instrument.rb +2 -0
- data/lib/ddtrace/auto_instrument_base.rb +2 -0
- data/lib/ddtrace/transport/http/adapters/net.rb +12 -0
- data/lib/ddtrace/transport/http/adapters/registry.rb +2 -0
- data/lib/ddtrace/transport/http/api/endpoint.rb +2 -0
- data/lib/ddtrace/transport/http/api/fallbacks.rb +2 -0
- data/lib/ddtrace/transport/http/api/instance.rb +2 -0
- data/lib/ddtrace/transport/http/api/map.rb +2 -0
- data/lib/ddtrace/transport/http/api/spec.rb +2 -0
- data/lib/ddtrace/transport/http/env.rb +2 -0
- data/lib/ddtrace/transport/http/response.rb +2 -0
- data/lib/ddtrace/transport/io/response.rb +2 -0
- data/lib/ddtrace/transport/io/traces.rb +2 -0
- data/lib/ddtrace/transport/io.rb +2 -0
- data/lib/ddtrace/transport/parcel.rb +2 -0
- data/lib/ddtrace/transport/request.rb +3 -1
- data/lib/ddtrace/transport/statistics.rb +2 -0
- data/lib/ddtrace/transport/trace_formatter.rb +2 -0
- data/lib/ddtrace/version.rb +9 -5
- data/lib/ddtrace.rb +2 -0
- metadata +43 -6
@@ -0,0 +1,144 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
require_relative '../negotiation'
|
6
|
+
require_relative 'client'
|
7
|
+
require_relative '../../../../ddtrace/transport/http/response'
|
8
|
+
require_relative '../../../../ddtrace/transport/http/api/endpoint'
|
9
|
+
|
10
|
+
# TODO: Decouple standard transport/http/api/instance
|
11
|
+
#
|
12
|
+
# Separate classes are needed because transport/http/trace includes
|
13
|
+
# Trace::API::Instance which closes over and uses a single spec, which is
|
14
|
+
# negotiated as either /v3 or /v4 for the whole API at the spec level, but we
|
15
|
+
# need an independent toplevel path at the endpoint level.
|
16
|
+
#
|
17
|
+
# Separate classes are needed because of `include Trace::API::Instance`.
|
18
|
+
#
|
19
|
+
# Below should be:
|
20
|
+
# require_relative '../../../../ddtrace/transport/http/api/instance'
|
21
|
+
require_relative 'api/instance'
|
22
|
+
# Below should be:
|
23
|
+
# require_relative '../../../../ddtrace/transport/http/api/spec'
|
24
|
+
require_relative 'api/spec'
|
25
|
+
|
26
|
+
module Datadog
|
27
|
+
module Core
|
28
|
+
module Transport
|
29
|
+
module HTTP
|
30
|
+
# HTTP transport behavior for agent feature negotiation
|
31
|
+
module Negotiation
|
32
|
+
# Response from HTTP transport for agent feature negotiation
|
33
|
+
class Response
|
34
|
+
include Datadog::Transport::HTTP::Response
|
35
|
+
include Core::Transport::Negotiation::Response
|
36
|
+
|
37
|
+
def initialize(http_response, options = {})
|
38
|
+
super(http_response)
|
39
|
+
|
40
|
+
# TODO: transform endpoint hash in a better object for negotiation
|
41
|
+
# TODO: transform config in a better object, notably config has max_request_bytes
|
42
|
+
@version = options[:version]
|
43
|
+
@endpoints = options[:endpoints]
|
44
|
+
@config = options[:config]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Extensions for HTTP client
|
49
|
+
module Client
|
50
|
+
def send_info_payload(request)
|
51
|
+
send_request(request) do |api, env|
|
52
|
+
api.send_info(env)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
module API
|
58
|
+
# Extensions for HTTP API Spec
|
59
|
+
module Spec
|
60
|
+
attr_reader :info
|
61
|
+
|
62
|
+
def info=(endpoint)
|
63
|
+
@info = endpoint
|
64
|
+
end
|
65
|
+
|
66
|
+
def send_info(env, &block)
|
67
|
+
raise NoNegotiationEndpointDefinedError, self if info.nil?
|
68
|
+
|
69
|
+
info.call(env, &block)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Raised when traces sent but no traces endpoint is defined
|
73
|
+
class NoNegotiationEndpointDefinedError < StandardError
|
74
|
+
attr_reader :spec
|
75
|
+
|
76
|
+
def initialize(spec)
|
77
|
+
super()
|
78
|
+
|
79
|
+
@spec = spec
|
80
|
+
end
|
81
|
+
|
82
|
+
def message
|
83
|
+
'No info endpoint is defined for API specification!'
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# Extensions for HTTP API Instance
|
89
|
+
module Instance
|
90
|
+
def send_info(env)
|
91
|
+
raise NegotiationNotSupportedError, spec unless spec.is_a?(Negotiation::API::Spec)
|
92
|
+
|
93
|
+
spec.send_info(env) do |request_env|
|
94
|
+
call(request_env)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# Raised when traces sent to API that does not support traces
|
99
|
+
class NegotiationNotSupportedError < StandardError
|
100
|
+
attr_reader :spec
|
101
|
+
|
102
|
+
def initialize(spec)
|
103
|
+
super()
|
104
|
+
|
105
|
+
@spec = spec
|
106
|
+
end
|
107
|
+
|
108
|
+
def message
|
109
|
+
'Info not supported for this API!'
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# Endpoint for negotiation
|
115
|
+
class Endpoint < Datadog::Transport::HTTP::API::Endpoint
|
116
|
+
def initialize(path)
|
117
|
+
super(:get, path)
|
118
|
+
end
|
119
|
+
|
120
|
+
def call(env, &block)
|
121
|
+
# Query for response
|
122
|
+
http_response = super(env, &block)
|
123
|
+
|
124
|
+
# Process the response
|
125
|
+
body = JSON.parse(http_response.payload, symbolize_names: true) if http_response.ok?
|
126
|
+
|
127
|
+
# TODO: there should be more processing here to ensure a proper response_options
|
128
|
+
response_options = body.is_a?(Hash) ? body : {}
|
129
|
+
|
130
|
+
# Build and return a trace response
|
131
|
+
Negotiation::Response.new(http_response, response_options)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
# Add negotiation behavior to transport components
|
137
|
+
HTTP::Client.include(Negotiation::Client)
|
138
|
+
HTTP::API::Spec.include(Negotiation::API::Spec)
|
139
|
+
HTTP::API::Instance.include(Negotiation::API::Instance)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,169 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
require_relative '../environment/container'
|
6
|
+
require_relative '../environment/ext'
|
7
|
+
require_relative '../../../ddtrace/transport/ext'
|
8
|
+
require_relative '../../../ddtrace/transport/http/adapters/net'
|
9
|
+
require_relative '../../../ddtrace/transport/http/adapters/test'
|
10
|
+
require_relative '../../../ddtrace/transport/http/adapters/unix_socket'
|
11
|
+
|
12
|
+
# TODO: Improve negotiation to allow per endpoint selection
|
13
|
+
#
|
14
|
+
# Since endpoint negotiation happens at the `API::Spec` level there can not be
|
15
|
+
# a mix of enpoints at various versions or versionless without describing all
|
16
|
+
# the possible combinations as specs. See http/api.
|
17
|
+
#
|
18
|
+
# Below should be:
|
19
|
+
# require_relative '../../../ddtrace/transport/http/api'
|
20
|
+
require_relative 'http/api'
|
21
|
+
|
22
|
+
# TODO: Decouple transport/http/builder
|
23
|
+
#
|
24
|
+
# See http/builder
|
25
|
+
#
|
26
|
+
# Below should be:
|
27
|
+
# require_relative '../../../ddtrace/transport/http/builder'
|
28
|
+
require_relative 'http/builder'
|
29
|
+
|
30
|
+
# TODO: Decouple transport/http
|
31
|
+
#
|
32
|
+
# Because a new transport is required for every (API, Client, Transport)
|
33
|
+
# triplet and endpoints cannot be negotiated independently, there can not be a
|
34
|
+
# single `default` transport, but only endpoint-specific ones.
|
35
|
+
|
36
|
+
module Datadog
|
37
|
+
module Core
|
38
|
+
module Transport
|
39
|
+
# Namespace for HTTP transport components
|
40
|
+
module HTTP
|
41
|
+
# NOTE: Due to... legacy reasons... This class likes having a default `AgentSettings` instance to fall back to.
|
42
|
+
# Because we generate this instance with an empty instance of `Settings`, the resulting `AgentSettings` below
|
43
|
+
# represents only settings specified via environment variables + the usual defaults.
|
44
|
+
#
|
45
|
+
# DO NOT USE THIS IN NEW CODE, as it ignores any settings specified by users via `Datadog.configure`.
|
46
|
+
DO_NOT_USE_ENVIRONMENT_AGENT_SETTINGS = Datadog::Core::Configuration::AgentSettingsResolver.call(
|
47
|
+
Datadog::Core::Configuration::Settings.new,
|
48
|
+
logger: nil,
|
49
|
+
)
|
50
|
+
|
51
|
+
module_function
|
52
|
+
|
53
|
+
# Builds a new Transport::HTTP::Client
|
54
|
+
def new(klass, &block)
|
55
|
+
Builder.new(&block).to_transport(klass)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Builds a new Transport::HTTP::Client with default settings
|
59
|
+
# Pass a block to override any settings.
|
60
|
+
def root(
|
61
|
+
agent_settings: DO_NOT_USE_ENVIRONMENT_AGENT_SETTINGS,
|
62
|
+
**options
|
63
|
+
)
|
64
|
+
new(Transport::Negotiation::Transport) do |transport|
|
65
|
+
transport.adapter(agent_settings)
|
66
|
+
transport.headers(default_headers)
|
67
|
+
|
68
|
+
apis = API.defaults
|
69
|
+
|
70
|
+
transport.api API::ROOT, apis[API::ROOT]
|
71
|
+
|
72
|
+
# Apply any settings given by options
|
73
|
+
unless options.empty?
|
74
|
+
transport.default_api = options[:api_version] if options.key?(:api_version)
|
75
|
+
transport.headers options[:headers] if options.key?(:headers)
|
76
|
+
end
|
77
|
+
|
78
|
+
if agent_settings.deprecated_for_removal_transport_configuration_proc
|
79
|
+
agent_settings.deprecated_for_removal_transport_configuration_proc.call(transport)
|
80
|
+
end
|
81
|
+
|
82
|
+
# Call block to apply any customization, if provided
|
83
|
+
yield(transport) if block_given?
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# Builds a new Transport::HTTP::Client with default settings
|
88
|
+
# Pass a block to override any settings.
|
89
|
+
def v7(
|
90
|
+
agent_settings: DO_NOT_USE_ENVIRONMENT_AGENT_SETTINGS,
|
91
|
+
**options
|
92
|
+
)
|
93
|
+
new(Transport::Config::Transport) do |transport|
|
94
|
+
transport.adapter(agent_settings)
|
95
|
+
transport.headers default_headers
|
96
|
+
|
97
|
+
apis = API.defaults
|
98
|
+
|
99
|
+
transport.api API::V7, apis[API::V7]
|
100
|
+
|
101
|
+
# Apply any settings given by options
|
102
|
+
unless options.empty?
|
103
|
+
transport.default_api = options[:api_version] if options.key?(:api_version)
|
104
|
+
transport.headers options[:headers] if options.key?(:headers)
|
105
|
+
end
|
106
|
+
|
107
|
+
if agent_settings.deprecated_for_removal_transport_configuration_proc
|
108
|
+
agent_settings.deprecated_for_removal_transport_configuration_proc.call(transport)
|
109
|
+
end
|
110
|
+
|
111
|
+
# Call block to apply any customization, if provided
|
112
|
+
yield(transport) if block_given?
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def default_headers
|
117
|
+
{
|
118
|
+
Datadog::Transport::Ext::HTTP::HEADER_CLIENT_COMPUTED_TOP_LEVEL => '1',
|
119
|
+
Datadog::Transport::Ext::HTTP::HEADER_META_LANG => Datadog::Core::Environment::Ext::LANG,
|
120
|
+
Datadog::Transport::Ext::HTTP::HEADER_META_LANG_VERSION => Datadog::Core::Environment::Ext::LANG_VERSION,
|
121
|
+
Datadog::Transport::Ext::HTTP::HEADER_META_LANG_INTERPRETER =>
|
122
|
+
Datadog::Core::Environment::Ext::LANG_INTERPRETER,
|
123
|
+
Datadog::Transport::Ext::HTTP::HEADER_META_TRACER_VERSION => Datadog::Core::Environment::Ext::TRACER_VERSION
|
124
|
+
}.tap do |headers|
|
125
|
+
# Add container ID, if present.
|
126
|
+
container_id = Datadog::Core::Environment::Container.container_id
|
127
|
+
headers[Datadog::Transport::Ext::HTTP::HEADER_CONTAINER_ID] = container_id unless container_id.nil?
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def default_adapter
|
132
|
+
Datadog::Transport::Ext::HTTP::ADAPTER
|
133
|
+
end
|
134
|
+
|
135
|
+
def default_hostname(logger: Datadog.logger)
|
136
|
+
logger.warn(
|
137
|
+
'Deprecated for removal: Using #default_hostname for configuration is deprecated and will ' \
|
138
|
+
'be removed on a future ddtrace release.'
|
139
|
+
)
|
140
|
+
|
141
|
+
DO_NOT_USE_ENVIRONMENT_AGENT_SETTINGS.hostname
|
142
|
+
end
|
143
|
+
|
144
|
+
def default_port(logger: Datadog.logger)
|
145
|
+
logger.warn(
|
146
|
+
'Deprecated for removal: Using #default_hostname for configuration is deprecated and will ' \
|
147
|
+
'be removed on a future ddtrace release.'
|
148
|
+
)
|
149
|
+
|
150
|
+
DO_NOT_USE_ENVIRONMENT_AGENT_SETTINGS.port
|
151
|
+
end
|
152
|
+
|
153
|
+
def default_url(logger: Datadog.logger)
|
154
|
+
logger.warn(
|
155
|
+
'Deprecated for removal: Using #default_url for configuration is deprecated and will ' \
|
156
|
+
'be removed on a future ddtrace release.'
|
157
|
+
)
|
158
|
+
|
159
|
+
nil
|
160
|
+
end
|
161
|
+
|
162
|
+
# Add adapters to registry
|
163
|
+
Builder::REGISTRY.set(Datadog::Transport::HTTP::Adapters::Net, Datadog::Transport::Ext::HTTP::ADAPTER)
|
164
|
+
Builder::REGISTRY.set(Datadog::Transport::HTTP::Adapters::Test, Datadog::Transport::Ext::Test::ADAPTER)
|
165
|
+
Builder::REGISTRY.set(Datadog::Transport::HTTP::Adapters::UnixSocket, Datadog::Transport::Ext::UnixSocket::ADAPTER)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../ddtrace/transport/request'
|
4
|
+
|
5
|
+
# TODO: Resolve conceptual conundrum
|
6
|
+
#
|
7
|
+
# It seems that through naming of `Transport::Traces::Transport` the transport
|
8
|
+
# is specific to traces, which kind of matches the almost-generic-but-not-quite
|
9
|
+
# implementation.
|
10
|
+
#
|
11
|
+
# This may be why `Transport::Traces::Transport` negotiates only considering
|
12
|
+
# the `/vX/traces` path, but here we don't negotiate since we are at the root.
|
13
|
+
#
|
14
|
+
# In turn this means that API::Spec cannot describe multiple roots, or even
|
15
|
+
# endpoints that happen to differ in version.
|
16
|
+
#
|
17
|
+
# Concepts such as Spec, API, Endpoint, and Transport should be clarified
|
18
|
+
# before attempting further refactoring here, to attempt to resolve whether a
|
19
|
+
# Transport - via its negotiated Spec - describes a function (implemented as
|
20
|
+
# one or more endpoints) or whether the Spec describes the API towards the
|
21
|
+
# agent as a whole, morphing through negotiation into the best available
|
22
|
+
# version for each endpoint.
|
23
|
+
|
24
|
+
module Datadog
|
25
|
+
module Core
|
26
|
+
module Transport
|
27
|
+
module Negotiation
|
28
|
+
# Negotiation request
|
29
|
+
class Request < Datadog::Transport::Request
|
30
|
+
end
|
31
|
+
|
32
|
+
# Negotiation response
|
33
|
+
module Response
|
34
|
+
attr_reader :version, :endpoints, :config
|
35
|
+
end
|
36
|
+
|
37
|
+
# Negotiation transport
|
38
|
+
class Transport
|
39
|
+
attr_reader :client, :apis, :default_api, :current_api_id
|
40
|
+
|
41
|
+
def initialize(apis, default_api)
|
42
|
+
@apis = apis
|
43
|
+
|
44
|
+
@client = HTTP::Client.new(current_api)
|
45
|
+
end
|
46
|
+
|
47
|
+
def send_info
|
48
|
+
request = Request.new
|
49
|
+
|
50
|
+
@client.send_info_payload(request)
|
51
|
+
end
|
52
|
+
|
53
|
+
def current_api
|
54
|
+
@apis[HTTP::API::ROOT]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Datadog
|
4
|
+
module Core
|
5
|
+
module Utils
|
6
|
+
# Refinements for {Hash}.
|
7
|
+
module Hash
|
8
|
+
# This refinement ensures modern rubies are allowed to use newer,
|
9
|
+
# simpler, and more performant APIs.
|
10
|
+
module Refinement
|
11
|
+
# Introduced in Ruby 2.4
|
12
|
+
unless ::Hash.method_defined?(:compact)
|
13
|
+
refine ::Hash do
|
14
|
+
def compact
|
15
|
+
reject { |_k, v| v.nil? }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# Introduced in Ruby 2.4
|
21
|
+
unless ::Hash.method_defined?(:compact!)
|
22
|
+
refine ::Hash do
|
23
|
+
def compact!
|
24
|
+
reject! { |_k, v| v.nil? }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -16,8 +16,26 @@ module Datadog
|
|
16
16
|
using RefineNil
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
# String#+@ was introduced in Ruby 2.3
|
20
|
+
if String.method_defined?(:+@) && String.method_defined?(:-@)
|
21
|
+
def self.frozen_or_dup(v)
|
22
|
+
# If the string is not frozen, the +(-v) will:
|
23
|
+
# - first create a frozen deduplicated copy with -v
|
24
|
+
# - then it will dup it more efficiently with +v
|
25
|
+
v.frozen? ? v : +(-v)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.frozen_dup(v)
|
29
|
+
-v if v
|
30
|
+
end
|
31
|
+
else
|
32
|
+
def self.frozen_or_dup(v)
|
33
|
+
v.frozen? ? v : v.dup
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.frozen_dup(v)
|
37
|
+
v.frozen? ? v : v.dup.freeze
|
38
|
+
end
|
21
39
|
end
|
22
40
|
end
|
23
41
|
end
|
data/lib/datadog/core/worker.rb
CHANGED
@@ -11,6 +11,10 @@ module Datadog
|
|
11
11
|
FORK_POLICY_RESTART = :restart
|
12
12
|
SHUTDOWN_TIMEOUT = 1
|
13
13
|
|
14
|
+
# This single shared mutex is used to avoid concurrency issues during the
|
15
|
+
# initialization of per-instance lazy-initialized mutexes.
|
16
|
+
MUTEX_INIT = Mutex.new
|
17
|
+
|
14
18
|
def self.included(base)
|
15
19
|
base.prepend(PrependedMethods)
|
16
20
|
end
|
@@ -86,7 +90,7 @@ module Datadog
|
|
86
90
|
:result
|
87
91
|
|
88
92
|
def mutex
|
89
|
-
@mutex ||= Mutex.new
|
93
|
+
@mutex || MUTEX_INIT.synchronize { @mutex ||= Mutex.new }
|
90
94
|
end
|
91
95
|
|
92
96
|
def after_fork
|
@@ -99,7 +103,7 @@ module Datadog
|
|
99
103
|
:pid
|
100
104
|
|
101
105
|
def mutex_after_fork
|
102
|
-
@mutex_after_fork ||= Mutex.new
|
106
|
+
@mutex_after_fork || MUTEX_INIT.synchronize { @mutex_after_fork ||= Mutex.new }
|
103
107
|
end
|
104
108
|
|
105
109
|
def worker
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Datadog
|
2
4
|
module Core
|
3
5
|
module Workers
|
@@ -8,6 +10,10 @@ module Datadog
|
|
8
10
|
BACK_OFF_MAX = 5
|
9
11
|
BASE_INTERVAL = 1
|
10
12
|
|
13
|
+
# This single shared mutex is used to avoid concurrency issues during the
|
14
|
+
# initialization of per-instance lazy-initialized mutexes.
|
15
|
+
MUTEX_INIT = Mutex.new
|
16
|
+
|
11
17
|
def self.included(base)
|
12
18
|
base.prepend(PrependedMethods)
|
13
19
|
end
|
@@ -80,7 +86,7 @@ module Datadog
|
|
80
86
|
:loop_base_interval
|
81
87
|
|
82
88
|
def mutex
|
83
|
-
@mutex ||= Mutex.new
|
89
|
+
@mutex || MUTEX_INIT.synchronize { @mutex ||= Mutex.new }
|
84
90
|
end
|
85
91
|
|
86
92
|
private
|
data/lib/datadog/kit.rb
CHANGED
data/lib/datadog/opentracer.rb
CHANGED
@@ -17,17 +17,33 @@ module Datadog
|
|
17
17
|
recorder:,
|
18
18
|
max_frames:,
|
19
19
|
tracer:,
|
20
|
+
endpoint_collection_enabled:,
|
20
21
|
gc_profiling_enabled:,
|
21
22
|
allocation_counting_enabled:,
|
22
|
-
thread_context_collector: ThreadContext.new(
|
23
|
-
|
23
|
+
thread_context_collector: ThreadContext.new(
|
24
|
+
recorder: recorder,
|
25
|
+
max_frames: max_frames,
|
26
|
+
tracer: tracer,
|
27
|
+
endpoint_collection_enabled: endpoint_collection_enabled,
|
28
|
+
),
|
29
|
+
idle_sampling_helper: IdleSamplingHelper.new,
|
30
|
+
# **NOTE**: This should only be used for testing; disabling the dynamic sampling rate will increase the
|
31
|
+
# profiler overhead!
|
32
|
+
dynamic_sampling_rate_enabled: true
|
24
33
|
)
|
34
|
+
unless dynamic_sampling_rate_enabled
|
35
|
+
Datadog.logger.warn(
|
36
|
+
'Profiling dynamic sampling rate disabled. This should only be used for testing, and will increase overhead!'
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
25
40
|
self.class._native_initialize(
|
26
41
|
self,
|
27
42
|
thread_context_collector,
|
28
43
|
gc_profiling_enabled,
|
29
44
|
idle_sampling_helper,
|
30
|
-
allocation_counting_enabled
|
45
|
+
allocation_counting_enabled,
|
46
|
+
dynamic_sampling_rate_enabled,
|
31
47
|
)
|
32
48
|
@worker_thread = nil
|
33
49
|
@failure_exception = nil
|