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
@@ -5,6 +5,7 @@ require_relative 'ext'
|
|
5
5
|
require_relative '../environment/ext'
|
6
6
|
require_relative '../runtime/ext'
|
7
7
|
require_relative '../telemetry/ext'
|
8
|
+
require_relative '../remote/ext'
|
8
9
|
require_relative '../../profiling/ext'
|
9
10
|
|
10
11
|
require_relative '../../tracing/configuration/settings'
|
@@ -202,9 +203,10 @@ module Datadog
|
|
202
203
|
# @public_api
|
203
204
|
settings :advanced do
|
204
205
|
# This should never be reduced, as it can cause the resulting profiles to become biased.
|
205
|
-
# The
|
206
|
+
# The default should be enough for most services, allowing 16 threads to be sampled around 30 times
|
206
207
|
# per second for a 60 second period.
|
207
|
-
#
|
208
|
+
#
|
209
|
+
# @deprecated This setting is ignored when CPU Profiling 2.0 is in use.
|
208
210
|
option :max_events, default: 32768
|
209
211
|
|
210
212
|
# Controls the maximum number of frames for each thread sampled. Can be tuned to avoid omitted frames in the
|
@@ -235,7 +237,7 @@ module Datadog
|
|
235
237
|
# grouping and categorization of stack traces.
|
236
238
|
option :code_provenance_enabled, default: true
|
237
239
|
|
238
|
-
# No longer does anything, and will be removed on dd-trace-rb 2.0.
|
240
|
+
# @deprecated No longer does anything, and will be removed on dd-trace-rb 2.0.
|
239
241
|
#
|
240
242
|
# This was added as a temporary support option in case of issues with the new `Profiling::HttpTransport` class
|
241
243
|
# but we're now confident it's working nicely so we've removed the old code path.
|
@@ -251,29 +253,44 @@ module Datadog
|
|
251
253
|
# Forces enabling the new CPU Profiling 2.0 profiler (see ddtrace release notes for more details).
|
252
254
|
#
|
253
255
|
# Note that setting this to "false" (or not setting it) will not prevent the new profiler from
|
254
|
-
# being automatically used
|
255
|
-
# This option will be deprecated for removal once the
|
256
|
+
# being automatically used.
|
257
|
+
# This option will be deprecated for removal once the legacy profiler is removed.
|
258
|
+
#
|
259
|
+
# @default `DD_PROFILING_FORCE_ENABLE_NEW` environment variable, otherwise `false`
|
256
260
|
option :force_enable_new_profiler do |o|
|
257
261
|
o.default { env_to_bool('DD_PROFILING_FORCE_ENABLE_NEW', false) }
|
258
262
|
o.lazy
|
259
263
|
end
|
260
264
|
|
265
|
+
# Forces enabling the *legacy* (non-CPU Profiling 2.0 profiler) even when it would otherwise NOT be enabled.
|
266
|
+
#
|
267
|
+
# Temporarily added to ease migration to the new CPU Profiling 2.0 profiler, and will be removed soon.
|
268
|
+
# Do not use unless instructed to by support.
|
269
|
+
# This option will be deprecated for removal once the legacy profiler is removed.
|
270
|
+
#
|
271
|
+
# @default `DD_PROFILING_FORCE_ENABLE_LEGACY` environment variable, otherwise `false`
|
272
|
+
option :force_enable_legacy_profiler do |o|
|
273
|
+
o.default { env_to_bool('DD_PROFILING_FORCE_ENABLE_LEGACY', false) }
|
274
|
+
o.lazy
|
275
|
+
end
|
276
|
+
|
261
277
|
# Forces enabling of profiling of time/resources spent in Garbage Collection.
|
262
278
|
#
|
263
279
|
# Note that setting this to "false" (or not setting it) will not prevent the feature from being
|
264
280
|
# being automatically enabled in the future.
|
265
281
|
#
|
266
|
-
# This
|
267
|
-
#
|
268
|
-
#
|
269
|
-
#
|
270
|
-
#
|
271
|
-
#
|
272
|
-
#
|
273
|
-
# Furthermore, currently this feature can add a lot of overhead for GC-heavy workloads.
|
282
|
+
# This feature defaults to off for two reasons:
|
283
|
+
# 1. Currently this feature can add a lot of overhead for GC-heavy workloads.
|
284
|
+
# 2. Although this feature is safe on Ruby 2.x, on Ruby 3.x it can break in applications that make use of
|
285
|
+
# Ractors due to two Ruby VM bugs:
|
286
|
+
# https://bugs.ruby-lang.org/issues/19112 AND https://bugs.ruby-lang.org/issues/18464.
|
287
|
+
# If you use Ruby 3.x and your application does not use Ractors (or if your Ruby has been patched), the
|
288
|
+
# feature is fully safe to enable and this toggle can be used to do so.
|
274
289
|
#
|
275
290
|
# We expect the once the above issues are overcome, we'll automatically enable the feature on fixed Ruby
|
276
291
|
# versions.
|
292
|
+
#
|
293
|
+
# @default `DD_PROFILING_FORCE_ENABLE_GC` environment variable, otherwise `false`
|
277
294
|
option :force_enable_gc_profiling do |o|
|
278
295
|
o.default { env_to_bool('DD_PROFILING_FORCE_ENABLE_GC', false) }
|
279
296
|
o.lazy
|
@@ -287,11 +304,26 @@ module Datadog
|
|
287
304
|
#
|
288
305
|
# If you use Ruby 3.x and your application does not use Ractors (or if your Ruby has been patched), the
|
289
306
|
# feature is fully safe to enable and this toggle can be used to do so.
|
307
|
+
#
|
308
|
+
# @default `true` on Ruby 2.x, `false` on Ruby 3.x
|
290
309
|
option :allocation_counting_enabled, default: RUBY_VERSION.start_with?('2.')
|
310
|
+
|
311
|
+
# Can be used to disable checking which version of `libmysqlclient` is being used by the `mysql2` gem.
|
312
|
+
#
|
313
|
+
# This setting is only used when the `mysql2` gem is installed.
|
314
|
+
#
|
315
|
+
# @default `DD_PROFILING_SKIP_MYSQL2_CHECK` environment variable, otherwise `false`
|
316
|
+
option :skip_mysql2_check do |o|
|
317
|
+
o.default { env_to_bool('DD_PROFILING_SKIP_MYSQL2_CHECK', false) }
|
318
|
+
o.lazy
|
319
|
+
end
|
291
320
|
end
|
292
321
|
|
293
322
|
# @public_api
|
294
323
|
settings :upload do
|
324
|
+
# Network timeout for reporting profiling data to Datadog.
|
325
|
+
#
|
326
|
+
# @default `DD_PROFILING_UPLOAD_TIMEOUT` environment variable, otherwise `30.0`
|
295
327
|
option :timeout_seconds do |o|
|
296
328
|
o.setter { |value| value.nil? ? 30.0 : value.to_f }
|
297
329
|
o.default { env_to_float(Profiling::Ext::ENV_UPLOAD_TIMEOUT, 30.0) }
|
@@ -436,11 +468,33 @@ module Datadog
|
|
436
468
|
settings :telemetry do
|
437
469
|
# Enable telemetry collection. This allows telemetry events to be emitted to the telemetry API.
|
438
470
|
#
|
439
|
-
# @default `DD_INSTRUMENTATION_TELEMETRY_ENABLED` environment variable, otherwise `
|
440
|
-
#
|
471
|
+
# @default `DD_INSTRUMENTATION_TELEMETRY_ENABLED` environment variable, otherwise `true`.
|
472
|
+
# Can be disabled as documented [here](https://docs.datadoghq.com/tracing/configure_data_security/#telemetry-collection).
|
473
|
+
# @return [Boolean]
|
474
|
+
option :enabled do |o|
|
475
|
+
o.default { env_to_bool(Core::Telemetry::Ext::ENV_ENABLED, true) }
|
476
|
+
o.lazy
|
477
|
+
end
|
478
|
+
end
|
479
|
+
|
480
|
+
# Remote configuration
|
481
|
+
# @public_api
|
482
|
+
settings :remote do
|
483
|
+
# Enable remote configuration. This allows fetching of remote configuration for live updates.
|
484
|
+
#
|
485
|
+
# @default `DD_REMOTE_CONFIGURATION_ENABLED` environment variable, otherwise `true`.
|
441
486
|
# @return [Boolean]
|
442
487
|
option :enabled do |o|
|
443
|
-
o.default { env_to_bool(Core::
|
488
|
+
o.default { env_to_bool(Core::Remote::Ext::ENV_ENABLED, true) }
|
489
|
+
o.lazy
|
490
|
+
end
|
491
|
+
|
492
|
+
# Tune remote configuration polling interval.
|
493
|
+
#
|
494
|
+
# @default `DD_REMOTE_CONFIGURATION_POLL_INTERVAL_SECONDS` environment variable, otherwise `5.0` seconds.
|
495
|
+
# @return [Float]
|
496
|
+
option :poll_interval_seconds do |o|
|
497
|
+
o.default { env_to_float(Core::Remote::Ext::ENV_POLL_INTERVAL_SECONDS, 5.0) }
|
444
498
|
o.lazy
|
445
499
|
end
|
446
500
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'securerandom'
|
2
4
|
|
3
5
|
require_relative 'ext'
|
@@ -47,9 +49,65 @@ module Datadog
|
|
47
49
|
Core::Environment::Ext::LANG_VERSION
|
48
50
|
end
|
49
51
|
|
52
|
+
# Returns tracer version, rubygems-style
|
50
53
|
def tracer_version
|
51
54
|
Core::Environment::Ext::TRACER_VERSION
|
52
55
|
end
|
56
|
+
|
57
|
+
# Returns tracer version, comforming to https://semver.org/spec/v2.0.0.html
|
58
|
+
def tracer_version_semver2
|
59
|
+
# from ddtrace/version.rb, we have MAJOR.MINOR.PATCH plus optional .PRE and .BUILD
|
60
|
+
# - transform .PRE to -PRE if present
|
61
|
+
# - transform .BUILD to +BUILD if present
|
62
|
+
# - keep triplet segments before that
|
63
|
+
|
64
|
+
m = SEMVER2_RE.match(tracer_version)
|
65
|
+
|
66
|
+
pre = "-#{m[:pre]}" if m[:pre]
|
67
|
+
build = "+gha#{m[:gha_run_id]}.g#{m[:git_sha]}.#{m[:branch].tr('.', '-')}" if m[:build]
|
68
|
+
|
69
|
+
"#{m[:major]}.#{m[:minor]}.#{m[:patch]}#{pre}#{build}"
|
70
|
+
end
|
71
|
+
|
72
|
+
SEMVER2_RE = /
|
73
|
+
^
|
74
|
+
# mandatory segments
|
75
|
+
(?<major>\d+)
|
76
|
+
\.
|
77
|
+
(?<minor>\d+)
|
78
|
+
\.
|
79
|
+
(?<patch>\d+)
|
80
|
+
|
81
|
+
# pre segments start with a value
|
82
|
+
# - containing at least one alpha
|
83
|
+
# - that is not part of our build segments expected values
|
84
|
+
# and stop with a value that is not part of our build segments expected values
|
85
|
+
(?:
|
86
|
+
\.
|
87
|
+
(?<pre>
|
88
|
+
(?!gha)
|
89
|
+
[a-zA-Z0-9]*[a-zA-Z][a-zA-Z0-9]*
|
90
|
+
(?:
|
91
|
+
\.
|
92
|
+
(?!gha)
|
93
|
+
[a-zA-Z0-9]+
|
94
|
+
)*
|
95
|
+
)
|
96
|
+
)?
|
97
|
+
|
98
|
+
# build segments: ours include CI info (`gha`), then git (`g`), then branch name
|
99
|
+
(?:
|
100
|
+
\.
|
101
|
+
(?<build>
|
102
|
+
gha(?<gha_run_id>\d+)
|
103
|
+
\.
|
104
|
+
g(?<git_sha>[a-f0-9]+)
|
105
|
+
\.
|
106
|
+
(?<branch>(?:[a-zA-Z0-9.])+)
|
107
|
+
)
|
108
|
+
)?
|
109
|
+
$
|
110
|
+
/xm.freeze
|
53
111
|
end
|
54
112
|
end
|
55
113
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Datadog
|
2
4
|
module Core
|
3
5
|
# Namespace for handling application environment
|
@@ -14,11 +16,17 @@ module Datadog
|
|
14
16
|
# @param [Boolean] default the default value if the keys in `var` are not present in the environment
|
15
17
|
# @param [Boolean] deprecation_warning when `var` is a list, record a deprecation log when
|
16
18
|
# the first key in `var` is not used.
|
17
|
-
# @return [Boolean] if the environment value is the string `true`
|
19
|
+
# @return [Boolean] if the environment value is the string `true` or `1`
|
18
20
|
# @return [default] if the environment value is not found
|
19
21
|
def env_to_bool(var, default = nil, deprecation_warning: true)
|
20
22
|
var = decode_array(var, deprecation_warning)
|
21
|
-
var && ENV.key?(var)
|
23
|
+
if var && ENV.key?(var)
|
24
|
+
value = ENV[var].to_s.strip
|
25
|
+
value.downcase!
|
26
|
+
value == 'true' || value == '1' # rubocop:disable Style/MultipleComparison
|
27
|
+
else
|
28
|
+
default
|
29
|
+
end
|
22
30
|
end
|
23
31
|
|
24
32
|
# Reads an environment variable as an Integer.
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../appsec/remote'
|
4
|
+
|
5
|
+
module Datadog
|
6
|
+
module Core
|
7
|
+
module Remote
|
8
|
+
class Client
|
9
|
+
# Capbailities
|
10
|
+
class Capabilities
|
11
|
+
attr_reader :products, :capabilities, :receivers, :base64_capabilities
|
12
|
+
|
13
|
+
def initialize(settings)
|
14
|
+
@capabilities = []
|
15
|
+
@products = []
|
16
|
+
@receivers = []
|
17
|
+
|
18
|
+
register(settings)
|
19
|
+
|
20
|
+
@base64_capabilities = capabilities_to_base64
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def register(settings)
|
26
|
+
if settings.appsec.enabled
|
27
|
+
register_capabilities(Datadog::AppSec::Remote.capabilities)
|
28
|
+
register_products(Datadog::AppSec::Remote.products)
|
29
|
+
register_receivers(Datadog::AppSec::Remote.receivers)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def register_capabilities(capabilities)
|
34
|
+
@capabilities.concat(capabilities)
|
35
|
+
end
|
36
|
+
|
37
|
+
def register_receivers(receivers)
|
38
|
+
@receivers.concat(receivers)
|
39
|
+
end
|
40
|
+
|
41
|
+
def register_products(products)
|
42
|
+
@products.concat(products)
|
43
|
+
end
|
44
|
+
|
45
|
+
def capabilities_to_base64
|
46
|
+
return '' if capabilities.empty?
|
47
|
+
|
48
|
+
cap_to_hexs = capabilities.reduce(:|).to_s(16).tap { |s| s.size.odd? && s.prepend('0') }.scan(/\h\h/)
|
49
|
+
binary = cap_to_hexs.each_with_object([]) { |hex, acc| acc << hex }.map { |e| e.to_i(16) }.pack('C*')
|
50
|
+
|
51
|
+
Base64.encode64(binary).chomp
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,225 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'securerandom'
|
4
|
+
|
5
|
+
require_relative 'configuration'
|
6
|
+
require_relative 'dispatcher'
|
7
|
+
|
8
|
+
module Datadog
|
9
|
+
module Core
|
10
|
+
module Remote
|
11
|
+
# Client communicates with the agent and sync remote configuration
|
12
|
+
class Client
|
13
|
+
class SyncError < StandardError; end
|
14
|
+
|
15
|
+
attr_reader :transport, :repository, :id, :dispatcher
|
16
|
+
|
17
|
+
def initialize(transport, capabilities, repository: Configuration::Repository.new)
|
18
|
+
@transport = transport
|
19
|
+
|
20
|
+
@repository = repository
|
21
|
+
@id = SecureRandom.uuid
|
22
|
+
@dispatcher = Dispatcher.new
|
23
|
+
@capabilities = capabilities
|
24
|
+
|
25
|
+
@capabilities.receivers.each do |receiver|
|
26
|
+
dispatcher.receivers << receiver
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# rubocop:disable Metrics/AbcSize,Metrics/PerceivedComplexity,Metrics/MethodLength,Metrics/CyclomaticComplexity
|
31
|
+
def sync
|
32
|
+
# TODO: Skip sync if no capabilities are registered
|
33
|
+
response = transport.send_config(payload)
|
34
|
+
|
35
|
+
if response.ok?
|
36
|
+
# when response is completely empty, do nothing as in: leave as is
|
37
|
+
if response.empty?
|
38
|
+
Datadog.logger.debug { 'remote: empty response => NOOP' }
|
39
|
+
|
40
|
+
return
|
41
|
+
end
|
42
|
+
|
43
|
+
begin
|
44
|
+
paths = response.client_configs.map do |path|
|
45
|
+
Configuration::Path.parse(path)
|
46
|
+
end
|
47
|
+
|
48
|
+
targets = Configuration::TargetMap.parse(response.targets)
|
49
|
+
|
50
|
+
contents = Configuration::ContentList.parse(response.target_files)
|
51
|
+
rescue Remote::Configuration::Path::ParseError => e
|
52
|
+
raise SyncError, e.message
|
53
|
+
end
|
54
|
+
|
55
|
+
# To make sure steep does not complain
|
56
|
+
return unless paths && targets && contents
|
57
|
+
|
58
|
+
# TODO: sometimes it can strangely be so that paths.empty?
|
59
|
+
# TODO: sometimes it can strangely be so that targets.empty?
|
60
|
+
|
61
|
+
changes = repository.transaction do |current, transaction|
|
62
|
+
# paths to be removed: previously applied paths minus ingress paths
|
63
|
+
(current.paths - paths).each { |p| transaction.delete(p) }
|
64
|
+
|
65
|
+
# go through each ingress path
|
66
|
+
paths.each do |path|
|
67
|
+
# match target with path
|
68
|
+
target = targets[path]
|
69
|
+
|
70
|
+
# abort entirely if matching target not found
|
71
|
+
raise SyncError, "no target for path '#{path}'" if target.nil?
|
72
|
+
|
73
|
+
# new paths are not in previously applied paths
|
74
|
+
new = !current.paths.include?(path)
|
75
|
+
|
76
|
+
# updated paths are in previously applied paths
|
77
|
+
# but the content hash changed
|
78
|
+
changed = current.paths.include?(path) && !current.contents.find_content(path, target)
|
79
|
+
|
80
|
+
# skip if unchanged
|
81
|
+
same = !new && !changed
|
82
|
+
|
83
|
+
next if same
|
84
|
+
|
85
|
+
# match content with path and target
|
86
|
+
content = contents.find_content(path, target)
|
87
|
+
|
88
|
+
# abort entirely if matching content not found
|
89
|
+
raise SyncError, "no valid content for target at path '#{path}'" if content.nil?
|
90
|
+
|
91
|
+
# to be added or updated << config
|
92
|
+
# TODO: metadata (hash, version, etc...)
|
93
|
+
transaction.insert(path, target, content) if new
|
94
|
+
transaction.update(path, target, content) if changed
|
95
|
+
end
|
96
|
+
|
97
|
+
# save backend opaque backend state
|
98
|
+
transaction.set(opaque_backend_state: targets.opaque_backend_state)
|
99
|
+
transaction.set(targets_version: targets.version)
|
100
|
+
|
101
|
+
# upon transaction end, new list of applied config + metadata (add, change, remove) will be saved
|
102
|
+
# TODO: also remove stale config (matching removed) from cache (client configs is exhaustive list of paths)
|
103
|
+
end
|
104
|
+
|
105
|
+
if changes.empty?
|
106
|
+
Datadog.logger.debug { 'remote: no changes' }
|
107
|
+
else
|
108
|
+
dispatcher.dispatch(changes, repository)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
# rubocop:enable Metrics/AbcSize,Metrics/PerceivedComplexity,Metrics/MethodLength,Metrics/CyclomaticComplexity
|
113
|
+
|
114
|
+
private
|
115
|
+
|
116
|
+
def payload # rubocop:disable Metrics/MethodLength
|
117
|
+
state = repository.state
|
118
|
+
|
119
|
+
client_tracer_tags = [
|
120
|
+
"platform:#{native_platform}", # native platform
|
121
|
+
# "asm.config.rules:#{}", # TODO: defined|undefined
|
122
|
+
# "asm.config.enabled:#{}", # TODO: true|false|undefined
|
123
|
+
"ruby.tracer.version:#{Core::Environment::Identity.tracer_version}",
|
124
|
+
"ruby.runtime.platform:#{RUBY_PLATFORM}",
|
125
|
+
"ruby.runtime.version:#{RUBY_VERSION}",
|
126
|
+
"ruby.runtime.engine.name:#{RUBY_ENGINE}",
|
127
|
+
"ruby.runtime.engine.version:#{ruby_engine_version}",
|
128
|
+
"ruby.rubygems.platform.local:#{Gem::Platform.local}",
|
129
|
+
"ruby.gem.libddwaf.version:#{gem_spec('libddwaf').version}",
|
130
|
+
"ruby.gem.libddwaf.platform:#{gem_spec('libddwaf').platform}",
|
131
|
+
"ruby.gem.libdatadog.version:#{gem_spec('libdatadog').version}",
|
132
|
+
"ruby.gem.libdatadog.platform:#{gem_spec('libdatadog').platform}",
|
133
|
+
]
|
134
|
+
|
135
|
+
client_tracer = {
|
136
|
+
runtime_id: Core::Environment::Identity.id,
|
137
|
+
language: Core::Environment::Identity.lang,
|
138
|
+
tracer_version: tracer_version_semver2,
|
139
|
+
service: Datadog.configuration.service,
|
140
|
+
env: Datadog.configuration.env,
|
141
|
+
tags: client_tracer_tags,
|
142
|
+
}
|
143
|
+
|
144
|
+
app_version = Datadog.configuration.version
|
145
|
+
|
146
|
+
client_tracer[:app_version] = app_version if app_version
|
147
|
+
|
148
|
+
{
|
149
|
+
client: {
|
150
|
+
state: {
|
151
|
+
root_version: state.root_version,
|
152
|
+
targets_version: state.targets_version,
|
153
|
+
config_states: state.config_states,
|
154
|
+
has_error: state.has_error,
|
155
|
+
error: state.error,
|
156
|
+
backend_client_state: state.opaque_backend_state,
|
157
|
+
},
|
158
|
+
id: id,
|
159
|
+
products: @capabilities.products,
|
160
|
+
is_tracer: true,
|
161
|
+
is_agent: false,
|
162
|
+
client_tracer: client_tracer,
|
163
|
+
# base64 is needed otherwise the Go agent fails with an unmarshal error
|
164
|
+
capabilities: @capabilities.base64_capabilities
|
165
|
+
},
|
166
|
+
cached_target_files: state.cached_target_files,
|
167
|
+
}
|
168
|
+
end
|
169
|
+
|
170
|
+
def tracer_version_semver2
|
171
|
+
@tracer_version_semver2 ||= Core::Environment::Identity.tracer_version_semver2
|
172
|
+
end
|
173
|
+
|
174
|
+
def ruby_engine_version
|
175
|
+
@ruby_engine_version ||= defined?(RUBY_ENGINE_VERSION) ? RUBY_ENGINE_VERSION : RUBY_VERSION
|
176
|
+
end
|
177
|
+
|
178
|
+
def gem_spec(name)
|
179
|
+
(@gem_specs ||= {})[name] ||= ::Gem.loaded_specs[name] || GemSpecificationFallback.new(nil, nil)
|
180
|
+
end
|
181
|
+
|
182
|
+
def native_platform
|
183
|
+
return @native_platform unless @native_platform.nil?
|
184
|
+
|
185
|
+
os = if RUBY_ENGINE == 'jruby'
|
186
|
+
os_name = java.lang.System.get_property('os.name')
|
187
|
+
|
188
|
+
case os_name
|
189
|
+
when /linux/i then 'linux'
|
190
|
+
when /mac/i then 'darwin'
|
191
|
+
else os_name
|
192
|
+
end
|
193
|
+
else
|
194
|
+
Gem::Platform.local.os
|
195
|
+
end
|
196
|
+
|
197
|
+
version = if os != 'linux'
|
198
|
+
nil
|
199
|
+
elsif RUBY_PLATFORM =~ /linux-(.+)$/
|
200
|
+
# Old rubygems don't handle non-gnu linux correctly
|
201
|
+
Regexp.last_match(1)
|
202
|
+
else
|
203
|
+
'gnu'
|
204
|
+
end
|
205
|
+
|
206
|
+
cpu = if RUBY_ENGINE == 'jruby'
|
207
|
+
os_arch = java.lang.System.get_property('os.arch')
|
208
|
+
|
209
|
+
case os_arch
|
210
|
+
when 'amd64' then 'x86_64'
|
211
|
+
when 'aarch64' then os == 'darwin' ? 'arm64' : 'aarch64'
|
212
|
+
else os_arch
|
213
|
+
end
|
214
|
+
else
|
215
|
+
Gem::Platform.local.cpu
|
216
|
+
end
|
217
|
+
|
218
|
+
@native_platform = [cpu, os, version].compact.join('-')
|
219
|
+
end
|
220
|
+
|
221
|
+
GemSpecificationFallback = _ = Struct.new(:version, :platform) # rubocop:disable Naming/ConstantName
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|