datadog 2.7.1 → 2.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +310 -1
- data/ext/datadog_profiling_native_extension/clock_id.h +2 -2
- data/ext/datadog_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +66 -56
- data/ext/datadog_profiling_native_extension/collectors_discrete_dynamic_sampler.c +1 -1
- data/ext/datadog_profiling_native_extension/collectors_discrete_dynamic_sampler.h +1 -1
- data/ext/datadog_profiling_native_extension/collectors_idle_sampling_helper.c +16 -16
- data/ext/datadog_profiling_native_extension/collectors_stack.c +10 -10
- data/ext/datadog_profiling_native_extension/collectors_stack.h +2 -2
- data/ext/datadog_profiling_native_extension/collectors_thread_context.c +314 -145
- data/ext/datadog_profiling_native_extension/datadog_ruby_common.c +1 -4
- data/ext/datadog_profiling_native_extension/datadog_ruby_common.h +10 -0
- data/ext/datadog_profiling_native_extension/encoded_profile.c +79 -0
- data/ext/datadog_profiling_native_extension/encoded_profile.h +8 -0
- data/ext/datadog_profiling_native_extension/extconf.rb +7 -8
- data/ext/datadog_profiling_native_extension/gvl_profiling_helper.c +2 -0
- data/ext/datadog_profiling_native_extension/gvl_profiling_helper.h +0 -8
- data/ext/datadog_profiling_native_extension/heap_recorder.c +61 -174
- data/ext/datadog_profiling_native_extension/heap_recorder.h +2 -2
- data/ext/datadog_profiling_native_extension/http_transport.c +64 -98
- data/ext/datadog_profiling_native_extension/private_vm_api_access.c +68 -1
- data/ext/datadog_profiling_native_extension/private_vm_api_access.h +10 -1
- data/ext/datadog_profiling_native_extension/profiling.c +19 -8
- data/ext/datadog_profiling_native_extension/ruby_helpers.c +8 -8
- data/ext/datadog_profiling_native_extension/stack_recorder.c +84 -131
- data/ext/datadog_profiling_native_extension/stack_recorder.h +2 -2
- data/ext/datadog_profiling_native_extension/time_helpers.h +1 -1
- data/ext/datadog_profiling_native_extension/unsafe_api_calls_check.c +47 -0
- data/ext/datadog_profiling_native_extension/unsafe_api_calls_check.h +31 -0
- data/ext/libdatadog_api/crashtracker.c +17 -15
- data/ext/libdatadog_api/crashtracker.h +5 -0
- data/ext/libdatadog_api/datadog_ruby_common.c +1 -4
- data/ext/libdatadog_api/datadog_ruby_common.h +10 -0
- data/ext/libdatadog_api/init.c +15 -0
- data/ext/libdatadog_api/library_config.c +122 -0
- data/ext/libdatadog_api/library_config.h +19 -0
- data/ext/libdatadog_api/macos_development.md +3 -3
- data/ext/libdatadog_api/process_discovery.c +117 -0
- data/ext/libdatadog_api/process_discovery.h +5 -0
- data/ext/libdatadog_extconf_helpers.rb +1 -1
- data/lib/datadog/appsec/actions_handler/serializable_backtrace.rb +89 -0
- data/lib/datadog/appsec/actions_handler.rb +49 -0
- data/lib/datadog/appsec/anonymizer.rb +16 -0
- data/lib/datadog/appsec/api_security/lru_cache.rb +49 -0
- data/lib/datadog/appsec/api_security.rb +9 -0
- data/lib/datadog/appsec/assets/waf_rules/README.md +50 -5
- data/lib/datadog/appsec/assets/waf_rules/processors.json +239 -10
- data/lib/datadog/appsec/assets/waf_rules/recommended.json +355 -157
- data/lib/datadog/appsec/assets/waf_rules/scanners.json +926 -17
- data/lib/datadog/appsec/assets/waf_rules/strict.json +62 -32
- data/lib/datadog/appsec/autoload.rb +1 -1
- data/lib/datadog/appsec/component.rb +41 -33
- data/lib/datadog/appsec/compressed_json.rb +40 -0
- data/lib/datadog/appsec/configuration/settings.rb +152 -25
- data/lib/datadog/appsec/context.rb +74 -0
- data/lib/datadog/appsec/contrib/active_record/instrumentation.rb +92 -0
- data/lib/datadog/appsec/contrib/active_record/integration.rb +41 -0
- data/lib/datadog/appsec/contrib/active_record/patcher.rb +101 -0
- data/lib/datadog/appsec/contrib/auto_instrument.rb +1 -1
- data/lib/datadog/appsec/contrib/devise/configuration.rb +52 -0
- data/lib/datadog/appsec/contrib/devise/data_extractor.rb +78 -0
- data/lib/datadog/appsec/contrib/devise/ext.rb +22 -0
- data/lib/datadog/appsec/contrib/devise/integration.rb +1 -2
- data/lib/datadog/appsec/contrib/devise/patcher.rb +33 -25
- data/lib/datadog/appsec/contrib/devise/patches/signin_tracking_patch.rb +102 -0
- data/lib/datadog/appsec/contrib/devise/patches/signup_tracking_patch.rb +69 -0
- data/lib/datadog/appsec/contrib/devise/{patcher/rememberable_patch.rb → patches/skip_signin_tracking_patch.rb} +3 -3
- data/lib/datadog/appsec/contrib/devise/tracking_middleware.rb +106 -0
- data/lib/datadog/appsec/contrib/excon/integration.rb +41 -0
- data/lib/datadog/appsec/contrib/excon/patcher.rb +28 -0
- data/lib/datadog/appsec/contrib/excon/ssrf_detection_middleware.rb +42 -0
- data/lib/datadog/appsec/contrib/faraday/connection_patch.rb +22 -0
- data/lib/datadog/appsec/contrib/faraday/integration.rb +42 -0
- data/lib/datadog/appsec/contrib/faraday/patcher.rb +53 -0
- data/lib/datadog/appsec/contrib/faraday/rack_builder_patch.rb +22 -0
- data/lib/datadog/appsec/contrib/faraday/ssrf_detection_middleware.rb +41 -0
- data/lib/datadog/appsec/contrib/graphql/appsec_trace.rb +1 -7
- data/lib/datadog/appsec/contrib/graphql/gateway/watcher.rb +17 -30
- data/lib/datadog/appsec/contrib/graphql/integration.rb +1 -1
- data/lib/datadog/appsec/contrib/graphql/patcher.rb +0 -3
- data/lib/datadog/appsec/contrib/rack/ext.rb +34 -0
- data/lib/datadog/appsec/contrib/rack/gateway/response.rb +3 -3
- data/lib/datadog/appsec/contrib/rack/gateway/watcher.rb +78 -98
- data/lib/datadog/appsec/contrib/rack/integration.rb +1 -1
- data/lib/datadog/appsec/contrib/rack/patcher.rb +0 -3
- data/lib/datadog/appsec/contrib/rack/request_body_middleware.rb +10 -11
- data/lib/datadog/appsec/contrib/rack/request_middleware.rb +52 -68
- data/lib/datadog/appsec/contrib/rails/gateway/watcher.rb +16 -33
- data/lib/datadog/appsec/contrib/rails/integration.rb +1 -1
- data/lib/datadog/appsec/contrib/rails/patcher.rb +25 -38
- data/lib/datadog/appsec/contrib/rest_client/integration.rb +45 -0
- data/lib/datadog/appsec/contrib/rest_client/patcher.rb +28 -0
- data/lib/datadog/appsec/contrib/rest_client/request_ssrf_detection_patch.rb +38 -0
- data/lib/datadog/appsec/contrib/sinatra/gateway/watcher.rb +31 -68
- data/lib/datadog/appsec/contrib/sinatra/integration.rb +1 -1
- data/lib/datadog/appsec/contrib/sinatra/patcher.rb +5 -31
- data/lib/datadog/appsec/event.rb +96 -135
- data/lib/datadog/appsec/ext.rb +12 -3
- data/lib/datadog/appsec/instrumentation/gateway/argument.rb +7 -2
- data/lib/datadog/appsec/instrumentation/gateway/middleware.rb +24 -0
- data/lib/datadog/appsec/instrumentation/gateway.rb +17 -22
- data/lib/datadog/appsec/metrics/collector.rb +38 -0
- data/lib/datadog/appsec/metrics/exporter.rb +35 -0
- data/lib/datadog/appsec/metrics/telemetry.rb +23 -0
- data/lib/datadog/appsec/metrics.rb +13 -0
- data/lib/datadog/appsec/monitor/gateway/watcher.rb +52 -32
- data/lib/datadog/appsec/processor/rule_loader.rb +26 -31
- data/lib/datadog/appsec/processor/rule_merger.rb +7 -6
- data/lib/datadog/appsec/processor.rb +5 -4
- data/lib/datadog/appsec/remote.rb +26 -12
- data/lib/datadog/appsec/response.rb +19 -85
- data/lib/datadog/appsec/security_engine/result.rb +67 -0
- data/lib/datadog/appsec/security_engine/runner.rb +88 -0
- data/lib/datadog/appsec/security_engine.rb +9 -0
- data/lib/datadog/appsec/security_event.rb +39 -0
- data/lib/datadog/appsec/utils.rb +0 -2
- data/lib/datadog/appsec.rb +23 -10
- data/lib/datadog/auto_instrument.rb +3 -0
- data/lib/datadog/core/buffer/random.rb +18 -2
- data/lib/datadog/core/configuration/agent_settings_resolver.rb +42 -14
- data/lib/datadog/core/configuration/agentless_settings_resolver.rb +176 -0
- data/lib/datadog/core/configuration/components.rb +76 -32
- data/lib/datadog/core/configuration/components_state.rb +23 -0
- data/lib/datadog/core/configuration/ext.rb +5 -1
- data/lib/datadog/core/configuration/option.rb +79 -43
- data/lib/datadog/core/configuration/option_definition.rb +6 -4
- data/lib/datadog/core/configuration/options.rb +3 -3
- data/lib/datadog/core/configuration/settings.rb +100 -41
- data/lib/datadog/core/configuration/stable_config.rb +23 -0
- data/lib/datadog/core/configuration.rb +43 -11
- data/lib/datadog/{tracing → core}/contrib/rails/utils.rb +1 -3
- data/lib/datadog/core/crashtracking/component.rb +4 -13
- data/lib/datadog/core/diagnostics/environment_logger.rb +1 -1
- data/lib/datadog/core/encoding.rb +17 -1
- data/lib/datadog/core/environment/agent_info.rb +78 -0
- data/lib/datadog/core/environment/cgroup.rb +10 -12
- data/lib/datadog/core/environment/container.rb +38 -40
- data/lib/datadog/core/environment/ext.rb +6 -6
- data/lib/datadog/core/environment/git.rb +1 -0
- data/lib/datadog/core/environment/identity.rb +3 -3
- data/lib/datadog/core/environment/platform.rb +3 -3
- data/lib/datadog/core/environment/variable_helpers.rb +1 -1
- data/lib/datadog/core/error.rb +11 -9
- data/lib/datadog/core/logger.rb +2 -2
- data/lib/datadog/core/metrics/client.rb +27 -27
- data/lib/datadog/core/metrics/logging.rb +5 -5
- data/lib/datadog/core/process_discovery.rb +32 -0
- data/lib/datadog/core/rate_limiter.rb +4 -2
- data/lib/datadog/core/remote/client/capabilities.rb +6 -0
- data/lib/datadog/core/remote/client.rb +107 -92
- data/lib/datadog/core/remote/component.rb +18 -19
- data/lib/datadog/core/remote/configuration/digest.rb +7 -7
- data/lib/datadog/core/remote/configuration/path.rb +1 -1
- data/lib/datadog/core/remote/configuration/repository.rb +2 -1
- data/lib/datadog/core/remote/negotiation.rb +9 -9
- data/lib/datadog/core/remote/transport/config.rb +4 -3
- data/lib/datadog/core/remote/transport/http/api.rb +13 -18
- data/lib/datadog/core/remote/transport/http/client.rb +5 -4
- data/lib/datadog/core/remote/transport/http/config.rb +27 -55
- data/lib/datadog/core/remote/transport/http/negotiation.rb +8 -51
- data/lib/datadog/core/remote/transport/http.rb +25 -94
- data/lib/datadog/core/remote/transport/negotiation.rb +17 -4
- data/lib/datadog/core/remote/worker.rb +10 -7
- data/lib/datadog/core/runtime/metrics.rb +12 -5
- data/lib/datadog/core/telemetry/component.rb +84 -49
- data/lib/datadog/core/telemetry/emitter.rb +23 -11
- data/lib/datadog/core/telemetry/event/app_client_configuration_change.rb +65 -0
- data/lib/datadog/core/telemetry/event/app_closing.rb +18 -0
- data/lib/datadog/core/telemetry/event/app_dependencies_loaded.rb +33 -0
- data/lib/datadog/core/telemetry/event/app_heartbeat.rb +18 -0
- data/lib/datadog/core/telemetry/event/app_integrations_change.rb +58 -0
- data/lib/datadog/core/telemetry/event/app_started.rb +179 -0
- data/lib/datadog/core/telemetry/event/base.rb +40 -0
- data/lib/datadog/core/telemetry/event/distributions.rb +18 -0
- data/lib/datadog/core/telemetry/event/generate_metrics.rb +43 -0
- data/lib/datadog/core/telemetry/event/log.rb +76 -0
- data/lib/datadog/core/telemetry/event/message_batch.rb +42 -0
- data/lib/datadog/core/telemetry/event/synth_app_client_configuration_change.rb +43 -0
- data/lib/datadog/core/telemetry/event.rb +17 -383
- data/lib/datadog/core/telemetry/ext.rb +1 -0
- data/lib/datadog/core/telemetry/http/adapters/net.rb +12 -97
- data/lib/datadog/core/telemetry/logger.rb +1 -1
- data/lib/datadog/core/telemetry/logging.rb +2 -2
- data/lib/datadog/core/telemetry/metric.rb +28 -6
- data/lib/datadog/core/telemetry/request.rb +4 -4
- data/lib/datadog/core/telemetry/transport/http/api.rb +43 -0
- data/lib/datadog/core/telemetry/transport/http/client.rb +49 -0
- data/lib/datadog/core/telemetry/transport/http/telemetry.rb +92 -0
- data/lib/datadog/core/telemetry/transport/http.rb +63 -0
- data/lib/datadog/core/telemetry/transport/telemetry.rb +51 -0
- data/lib/datadog/core/telemetry/worker.rb +128 -25
- data/lib/datadog/core/transport/http/adapters/test.rb +2 -1
- data/lib/datadog/core/transport/http/adapters/unix_socket.rb +1 -1
- data/lib/datadog/{tracing → core}/transport/http/api/instance.rb +18 -1
- data/lib/datadog/core/transport/http/api/spec.rb +36 -0
- data/lib/datadog/{tracing → core}/transport/http/builder.rb +53 -31
- data/lib/datadog/core/transport/http.rb +75 -0
- data/lib/datadog/core/transport/response.rb +4 -0
- data/lib/datadog/core/utils/at_fork_monkey_patch.rb +6 -6
- data/lib/datadog/core/utils/duration.rb +32 -32
- data/lib/datadog/core/utils/forking.rb +2 -2
- data/lib/datadog/core/utils/network.rb +6 -6
- data/lib/datadog/core/utils/only_once_successful.rb +16 -5
- data/lib/datadog/core/utils/time.rb +20 -0
- data/lib/datadog/core/utils/truncation.rb +21 -0
- data/lib/datadog/core/vendor/multipart-post/multipart/post/composite_read_io.rb +1 -1
- data/lib/datadog/core/vendor/multipart-post/multipart/post/multipartable.rb +8 -8
- data/lib/datadog/core/vendor/multipart-post/multipart/post/parts.rb +7 -7
- data/lib/datadog/core/worker.rb +1 -1
- data/lib/datadog/core/workers/async.rb +29 -12
- data/lib/datadog/core/workers/interval_loop.rb +12 -1
- data/lib/datadog/core/workers/runtime_metrics.rb +2 -2
- data/lib/datadog/core.rb +8 -0
- data/lib/datadog/di/base.rb +115 -0
- data/lib/datadog/di/boot.rb +34 -0
- data/lib/datadog/di/code_tracker.rb +26 -15
- data/lib/datadog/di/component.rb +23 -14
- data/lib/datadog/di/configuration/settings.rb +25 -1
- data/lib/datadog/di/contrib/active_record.rb +1 -0
- data/lib/datadog/di/contrib/railtie.rb +15 -0
- data/lib/datadog/di/contrib.rb +28 -0
- data/lib/datadog/di/error.rb +5 -0
- data/lib/datadog/di/instrumenter.rb +111 -20
- data/lib/datadog/di/logger.rb +30 -0
- data/lib/datadog/di/preload.rb +18 -0
- data/lib/datadog/di/probe.rb +14 -7
- data/lib/datadog/di/probe_builder.rb +1 -0
- data/lib/datadog/di/probe_manager.rb +11 -5
- data/lib/datadog/di/probe_notification_builder.rb +34 -8
- data/lib/datadog/di/probe_notifier_worker.rb +52 -26
- data/lib/datadog/di/redactor.rb +0 -1
- data/lib/datadog/di/remote.rb +147 -0
- data/lib/datadog/di/serializer.rb +14 -7
- data/lib/datadog/di/transport/diagnostics.rb +62 -0
- data/lib/datadog/di/transport/http/api.rb +42 -0
- data/lib/datadog/di/transport/http/client.rb +47 -0
- data/lib/datadog/di/transport/http/diagnostics.rb +65 -0
- data/lib/datadog/di/transport/http/input.rb +67 -0
- data/lib/datadog/di/transport/http.rb +57 -0
- data/lib/datadog/di/transport/input.rb +62 -0
- data/lib/datadog/di/utils.rb +103 -0
- data/lib/datadog/di.rb +14 -76
- data/lib/datadog/error_tracking/collector.rb +87 -0
- data/lib/datadog/error_tracking/component.rb +167 -0
- data/lib/datadog/error_tracking/configuration/settings.rb +63 -0
- data/lib/datadog/error_tracking/configuration.rb +11 -0
- data/lib/datadog/error_tracking/ext.rb +18 -0
- data/lib/datadog/error_tracking/extensions.rb +16 -0
- data/lib/datadog/error_tracking/filters.rb +77 -0
- data/lib/datadog/error_tracking.rb +18 -0
- data/lib/datadog/kit/appsec/events.rb +15 -3
- data/lib/datadog/kit/identity.rb +9 -5
- data/lib/datadog/opentelemetry/api/baggage.rb +90 -0
- data/lib/datadog/opentelemetry/api/baggage.rbs +26 -0
- data/lib/datadog/opentelemetry/api/context.rb +16 -2
- data/lib/datadog/opentelemetry/sdk/trace/span.rb +1 -1
- data/lib/datadog/opentelemetry.rb +2 -1
- data/lib/datadog/profiling/collectors/code_provenance.rb +1 -1
- data/lib/datadog/profiling/collectors/info.rb +3 -0
- data/lib/datadog/profiling/collectors/thread_context.rb +1 -1
- data/lib/datadog/profiling/component.rb +60 -76
- data/lib/datadog/profiling/encoded_profile.rb +11 -0
- data/lib/datadog/profiling/exporter.rb +3 -4
- data/lib/datadog/profiling/ext.rb +0 -2
- data/lib/datadog/profiling/flush.rb +5 -8
- data/lib/datadog/profiling/http_transport.rb +6 -85
- data/lib/datadog/profiling/load_native_extension.rb +1 -33
- data/lib/datadog/profiling/scheduler.rb +8 -1
- data/lib/datadog/profiling/stack_recorder.rb +4 -4
- data/lib/datadog/profiling/tag_builder.rb +1 -5
- data/lib/datadog/profiling.rb +6 -2
- data/lib/datadog/tracing/analytics.rb +1 -1
- data/lib/datadog/tracing/component.rb +16 -12
- data/lib/datadog/tracing/configuration/ext.rb +8 -1
- data/lib/datadog/tracing/configuration/settings.rb +22 -10
- data/lib/datadog/tracing/context_provider.rb +1 -1
- data/lib/datadog/tracing/contrib/action_cable/integration.rb +5 -2
- data/lib/datadog/tracing/contrib/action_mailer/integration.rb +6 -2
- data/lib/datadog/tracing/contrib/action_pack/integration.rb +5 -2
- data/lib/datadog/tracing/contrib/action_view/integration.rb +5 -2
- data/lib/datadog/tracing/contrib/active_job/integration.rb +5 -2
- data/lib/datadog/tracing/contrib/active_record/integration.rb +7 -3
- data/lib/datadog/tracing/contrib/active_support/cache/events/cache.rb +7 -2
- data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +36 -1
- data/lib/datadog/tracing/contrib/active_support/cache/patcher.rb +4 -0
- data/lib/datadog/tracing/contrib/active_support/cache/redis.rb +14 -4
- data/lib/datadog/tracing/contrib/active_support/configuration/settings.rb +10 -0
- data/lib/datadog/tracing/contrib/active_support/integration.rb +5 -2
- data/lib/datadog/tracing/contrib/auto_instrument.rb +2 -2
- data/lib/datadog/tracing/contrib/aws/instrumentation.rb +10 -0
- data/lib/datadog/tracing/contrib/aws/integration.rb +3 -0
- data/lib/datadog/tracing/contrib/aws/parsed_context.rb +5 -1
- data/lib/datadog/tracing/contrib/concurrent_ruby/integration.rb +3 -0
- data/lib/datadog/tracing/contrib/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/elasticsearch/configuration/settings.rb +4 -0
- data/lib/datadog/tracing/contrib/elasticsearch/patcher.rb +6 -1
- data/lib/datadog/tracing/contrib/ethon/easy_patch.rb +4 -5
- data/lib/datadog/tracing/contrib/excon/middleware.rb +5 -3
- data/lib/datadog/tracing/contrib/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/extensions.rb +29 -3
- data/lib/datadog/tracing/contrib/faraday/middleware.rb +5 -3
- data/lib/datadog/tracing/contrib/graphql/configuration/error_extension_env_parser.rb +21 -0
- data/lib/datadog/tracing/contrib/graphql/configuration/settings.rb +11 -0
- data/lib/datadog/tracing/contrib/graphql/ext.rb +5 -0
- data/lib/datadog/tracing/contrib/graphql/unified_trace.rb +102 -11
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/client.rb +7 -1
- data/lib/datadog/tracing/contrib/grpc/distributed/propagation.rb +3 -0
- data/lib/datadog/tracing/contrib/http/circuit_breaker.rb +0 -15
- data/lib/datadog/tracing/contrib/http/distributed/propagation.rb +4 -1
- data/lib/datadog/tracing/contrib/http/instrumentation.rb +6 -10
- data/lib/datadog/tracing/contrib/http/integration.rb +3 -0
- data/lib/datadog/tracing/contrib/httpclient/instrumentation.rb +6 -16
- data/lib/datadog/tracing/contrib/httprb/instrumentation.rb +7 -15
- data/lib/datadog/tracing/contrib/httprb/integration.rb +3 -0
- data/lib/datadog/tracing/contrib/kafka/integration.rb +3 -0
- data/lib/datadog/tracing/contrib/karafka/configuration/settings.rb +27 -0
- data/lib/datadog/tracing/contrib/karafka/distributed/propagation.rb +48 -0
- data/lib/datadog/tracing/contrib/karafka/ext.rb +27 -0
- data/lib/datadog/tracing/contrib/karafka/integration.rb +45 -0
- data/lib/datadog/tracing/contrib/karafka/monitor.rb +66 -0
- data/lib/datadog/tracing/contrib/karafka/patcher.rb +71 -0
- data/lib/datadog/tracing/contrib/karafka.rb +37 -0
- data/lib/datadog/tracing/contrib/mongodb/configuration/settings.rb +8 -0
- data/lib/datadog/tracing/contrib/mongodb/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/mongodb/integration.rb +3 -0
- data/lib/datadog/tracing/contrib/mongodb/subscribers.rb +18 -1
- data/lib/datadog/tracing/contrib/opensearch/configuration/settings.rb +17 -0
- data/lib/datadog/tracing/contrib/opensearch/ext.rb +9 -0
- data/lib/datadog/tracing/contrib/opensearch/integration.rb +3 -0
- data/lib/datadog/tracing/contrib/opensearch/patcher.rb +5 -1
- data/lib/datadog/tracing/contrib/patcher.rb +5 -2
- data/lib/datadog/tracing/contrib/presto/integration.rb +3 -0
- data/lib/datadog/tracing/contrib/rack/header_collection.rb +11 -1
- data/lib/datadog/tracing/contrib/rack/integration.rb +2 -2
- data/lib/datadog/tracing/contrib/rack/middlewares.rb +1 -1
- data/lib/datadog/tracing/contrib/rack/request_queue.rb +1 -1
- data/lib/datadog/tracing/contrib/rails/framework.rb +2 -2
- data/lib/datadog/tracing/contrib/rails/patcher.rb +1 -1
- data/lib/datadog/tracing/contrib/rest_client/integration.rb +3 -0
- data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +5 -3
- data/lib/datadog/tracing/contrib/sidekiq/client_tracer.rb +6 -1
- data/lib/datadog/tracing/contrib/sidekiq/distributed/propagation.rb +3 -0
- data/lib/datadog/tracing/contrib/sidekiq/server_tracer.rb +1 -1
- data/lib/datadog/tracing/contrib/span_attribute_schema.rb +6 -1
- data/lib/datadog/tracing/contrib/support.rb +28 -0
- data/lib/datadog/tracing/contrib.rb +1 -0
- data/lib/datadog/tracing/correlation.rb +9 -2
- data/lib/datadog/tracing/distributed/b3_multi.rb +1 -1
- data/lib/datadog/tracing/distributed/b3_single.rb +1 -1
- data/lib/datadog/tracing/distributed/baggage.rb +131 -0
- data/lib/datadog/tracing/distributed/datadog.rb +4 -2
- data/lib/datadog/tracing/distributed/propagation.rb +25 -4
- data/lib/datadog/tracing/distributed/propagation_policy.rb +42 -0
- data/lib/datadog/tracing/metadata/errors.rb +4 -4
- data/lib/datadog/tracing/metadata/ext.rb +5 -0
- data/lib/datadog/tracing/metadata/metastruct.rb +36 -0
- data/lib/datadog/tracing/metadata/metastruct_tagging.rb +42 -0
- data/lib/datadog/tracing/metadata.rb +2 -0
- data/lib/datadog/tracing/sampling/rate_sampler.rb +2 -1
- data/lib/datadog/tracing/sampling/span/rule.rb +0 -1
- data/lib/datadog/tracing/span.rb +22 -5
- data/lib/datadog/tracing/span_event.rb +124 -4
- data/lib/datadog/tracing/span_operation.rb +52 -16
- data/lib/datadog/tracing/sync_writer.rb +9 -5
- data/lib/datadog/tracing/trace_digest.rb +9 -2
- data/lib/datadog/tracing/trace_operation.rb +44 -24
- data/lib/datadog/tracing/trace_segment.rb +6 -4
- data/lib/datadog/tracing/tracer.rb +60 -12
- data/lib/datadog/tracing/transport/http/api.rb +5 -4
- data/lib/datadog/tracing/transport/http/client.rb +5 -4
- data/lib/datadog/tracing/transport/http/traces.rb +13 -44
- data/lib/datadog/tracing/transport/http.rb +13 -70
- data/lib/datadog/tracing/transport/serializable_trace.rb +31 -7
- data/lib/datadog/tracing/transport/trace_formatter.rb +7 -0
- data/lib/datadog/tracing/transport/traces.rb +47 -13
- data/lib/datadog/tracing/utils.rb +1 -1
- data/lib/datadog/tracing/workers/trace_writer.rb +8 -5
- data/lib/datadog/tracing/workers.rb +5 -4
- data/lib/datadog/tracing/writer.rb +10 -6
- data/lib/datadog/tracing.rb +16 -3
- data/lib/datadog/version.rb +2 -2
- data/lib/datadog.rb +2 -0
- metadata +143 -50
- data/ext/datadog_profiling_loader/datadog_profiling_loader.c +0 -142
- data/ext/datadog_profiling_loader/extconf.rb +0 -60
- data/lib/datadog/appsec/contrib/devise/event.rb +0 -57
- data/lib/datadog/appsec/contrib/devise/patcher/authenticatable_patch.rb +0 -77
- data/lib/datadog/appsec/contrib/devise/patcher/registration_controller_patch.rb +0 -54
- data/lib/datadog/appsec/contrib/devise/resource.rb +0 -35
- data/lib/datadog/appsec/contrib/devise/tracking.rb +0 -57
- data/lib/datadog/appsec/contrib/graphql/reactive/multiplex.rb +0 -46
- data/lib/datadog/appsec/contrib/patcher.rb +0 -12
- data/lib/datadog/appsec/contrib/rack/reactive/request.rb +0 -69
- data/lib/datadog/appsec/contrib/rack/reactive/request_body.rb +0 -47
- data/lib/datadog/appsec/contrib/rack/reactive/response.rb +0 -53
- data/lib/datadog/appsec/contrib/rails/reactive/action.rb +0 -53
- data/lib/datadog/appsec/contrib/sinatra/ext.rb +0 -14
- data/lib/datadog/appsec/contrib/sinatra/reactive/routed.rb +0 -48
- data/lib/datadog/appsec/monitor/reactive/set_user.rb +0 -45
- data/lib/datadog/appsec/processor/actions.rb +0 -49
- data/lib/datadog/appsec/processor/context.rb +0 -107
- data/lib/datadog/appsec/reactive/address_hash.rb +0 -22
- data/lib/datadog/appsec/reactive/engine.rb +0 -47
- data/lib/datadog/appsec/reactive/operation.rb +0 -68
- data/lib/datadog/appsec/reactive/subscriber.rb +0 -19
- data/lib/datadog/appsec/scope.rb +0 -58
- data/lib/datadog/appsec/utils/trace_operation.rb +0 -15
- data/lib/datadog/core/crashtracking/agent_base_url.rb +0 -21
- data/lib/datadog/core/remote/transport/http/api/instance.rb +0 -39
- data/lib/datadog/core/remote/transport/http/api/spec.rb +0 -21
- data/lib/datadog/core/remote/transport/http/builder.rb +0 -219
- data/lib/datadog/core/telemetry/http/env.rb +0 -20
- data/lib/datadog/core/telemetry/http/ext.rb +0 -28
- data/lib/datadog/core/telemetry/http/response.rb +0 -70
- data/lib/datadog/core/telemetry/http/transport.rb +0 -90
- data/lib/datadog/di/transport.rb +0 -81
- data/lib/datadog/tracing/transport/http/api/spec.rb +0 -19
@@ -19,12 +19,9 @@ module Datadog
|
|
19
19
|
host: Core::Environment::Socket.hostname,
|
20
20
|
language: Core::Environment::Identity.lang,
|
21
21
|
pid: Process.pid.to_s,
|
22
|
-
# TODO: If profiling is extracted and its version diverges from the datadog gem, this is inaccurate.
|
23
|
-
# Update if this ever occurs.
|
24
22
|
profiler_version: Core::Environment::Identity.gem_datadog_version,
|
25
23
|
runtime_engine: Core::Environment::Identity.lang_engine,
|
26
24
|
runtime_id: Core::Environment::Identity.id,
|
27
|
-
runtime_platform: Core::Environment::Identity.lang_platform,
|
28
25
|
runtime_version: Core::Environment::Identity.lang_version,
|
29
26
|
git_repository_url: Core::Environment::Git.git_repository_url,
|
30
27
|
git_commit_sha: Core::Environment::Git.git_commit_sha,
|
@@ -41,7 +38,6 @@ module Datadog
|
|
41
38
|
FORM_FIELD_TAG_RUNTIME => language, # This is known to be repeated from language, above
|
42
39
|
FORM_FIELD_TAG_RUNTIME_ENGINE => runtime_engine,
|
43
40
|
FORM_FIELD_TAG_RUNTIME_ID => runtime_id,
|
44
|
-
FORM_FIELD_TAG_RUNTIME_PLATFORM => runtime_platform,
|
45
41
|
FORM_FIELD_TAG_RUNTIME_VERSION => runtime_version,
|
46
42
|
}
|
47
43
|
tags[FORM_FIELD_TAG_ENV] = env if env
|
@@ -50,7 +46,7 @@ module Datadog
|
|
50
46
|
tags[TAG_GIT_REPOSITORY_URL] = git_repository_url if git_repository_url
|
51
47
|
tags[TAG_GIT_COMMIT_SHA] = git_commit_sha if git_commit_sha
|
52
48
|
|
53
|
-
# Make sure everything is an utf-8 string, to avoid encoding issues in native code/
|
49
|
+
# Make sure everything is an utf-8 string, to avoid encoding issues in native code/further downstream
|
54
50
|
user_tags.merge(tags).map do |key, value|
|
55
51
|
[Datadog::Core::Utils.utf8_encode(key), Datadog::Core::Utils.utf8_encode(value)]
|
56
52
|
end.to_h
|
data/lib/datadog/profiling.rb
CHANGED
@@ -78,8 +78,11 @@ module Datadog
|
|
78
78
|
end
|
79
79
|
|
80
80
|
private_class_method def self.replace_noop_allocation_count
|
81
|
-
|
82
|
-
|
81
|
+
class << self
|
82
|
+
remove_method :allocation_count
|
83
|
+
def allocation_count
|
84
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_allocation_count
|
85
|
+
end
|
83
86
|
end
|
84
87
|
end
|
85
88
|
|
@@ -146,6 +149,7 @@ module Datadog
|
|
146
149
|
require_relative 'profiling/collectors/thread_context'
|
147
150
|
require_relative 'profiling/stack_recorder'
|
148
151
|
require_relative 'profiling/exporter'
|
152
|
+
require_relative 'profiling/encoded_profile'
|
149
153
|
require_relative 'profiling/flush'
|
150
154
|
require_relative 'profiling/scheduler'
|
151
155
|
require_relative 'profiling/tasks/setup'
|
@@ -16,7 +16,7 @@ module Datadog
|
|
16
16
|
def set_measured(span_op, value = true)
|
17
17
|
return if span_op.nil?
|
18
18
|
|
19
|
-
value = value == true || value == 1 ? 1 : 0
|
19
|
+
value = value == true || value == 1 ? 1 : 0
|
20
20
|
span_op.set_metric(Metadata::Ext::Analytics::TAG_MEASURED, value)
|
21
21
|
end
|
22
22
|
end
|
@@ -6,6 +6,7 @@ require_relative 'sync_writer'
|
|
6
6
|
require_relative 'sampling/span/rule_parser'
|
7
7
|
require_relative 'sampling/span/sampler'
|
8
8
|
require_relative 'diagnostics/environment_logger'
|
9
|
+
require_relative 'contrib/component'
|
9
10
|
|
10
11
|
module Datadog
|
11
12
|
module Tracing
|
@@ -49,6 +50,7 @@ module Datadog
|
|
49
50
|
Tracing::Tracer.new(
|
50
51
|
default_service: settings.service,
|
51
52
|
enabled: settings.tracing.enabled,
|
53
|
+
logger: logger,
|
52
54
|
trace_flush: trace_flush,
|
53
55
|
sampler: sampler_delegator,
|
54
56
|
span_sampler: build_span_sampler(settings),
|
@@ -73,18 +75,11 @@ module Datadog
|
|
73
75
|
return sampler
|
74
76
|
end
|
75
77
|
|
76
|
-
#
|
77
|
-
#
|
78
|
-
#
|
79
|
-
#
|
80
|
-
|
81
|
-
if settings.appsec.standalone.enabled
|
82
|
-
post_sampler = Tracing::Sampling::RuleSampler.new(
|
83
|
-
[Tracing::Sampling::SimpleRule.new(sample_rate: 1.0)],
|
84
|
-
rate_limiter: Datadog::Core::TokenBucket.new(1.0 / 60, 1.0),
|
85
|
-
default_sample_rate: 1.0 / 60
|
86
|
-
)
|
87
|
-
end
|
78
|
+
# APM Disablement means that we don't want to send traces that only contains APM data.
|
79
|
+
# Other products can then put the sampling priority to MANUAL_KEEP if they want to keep traces.
|
80
|
+
# (e.g.: AppSec will MANUAL_KEEP traces with AppSec events) and clients will be billed only for those traces.
|
81
|
+
# But to keep the service alive on the backend side, we need to send one trace per minute.
|
82
|
+
post_sampler = build_rate_limit_post_sampler(seconds: 60) unless settings.apm.tracing.enabled
|
88
83
|
|
89
84
|
# Sampling rules are provided
|
90
85
|
if (rules = settings.tracing.sampling.rules)
|
@@ -196,6 +191,15 @@ module Datadog
|
|
196
191
|
end
|
197
192
|
end
|
198
193
|
|
194
|
+
# Build a post-sampler that limits the rate of traces to one per `seconds`.
|
195
|
+
# E.g.: `build_rate_limit_post_sampler(seconds: 60)` will limit the rate to one trace per minute.
|
196
|
+
def build_rate_limit_post_sampler(seconds:)
|
197
|
+
Tracing::Sampling::RuleSampler.new(
|
198
|
+
rate_limiter: Datadog::Core::TokenBucket.new(1.0 / seconds, 1.0),
|
199
|
+
default_sample_rate: 1.0
|
200
|
+
)
|
201
|
+
end
|
202
|
+
|
199
203
|
def build_test_mode_trace_flush(settings)
|
200
204
|
# If context flush behavior is provided, use it instead.
|
201
205
|
settings.tracing.test_mode.trace_flush || build_trace_flush(settings)
|
@@ -12,10 +12,12 @@ module Datadog
|
|
12
12
|
ENV_OTEL_TRACES_EXPORTER = 'OTEL_TRACES_EXPORTER'
|
13
13
|
ENV_HEADER_TAGS = 'DD_TRACE_HEADER_TAGS'
|
14
14
|
ENV_TRACE_ID_128_BIT_GENERATION_ENABLED = 'DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED'
|
15
|
+
ENV_NATIVE_SPAN_EVENTS = 'DD_TRACE_NATIVE_SPAN_EVENTS'
|
15
16
|
|
16
17
|
# @public_api
|
17
18
|
module SpanAttributeSchema
|
18
19
|
ENV_GLOBAL_DEFAULT_SERVICE_NAME_ENABLED = 'DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED'
|
20
|
+
ENV_PEER_SERVICE_DEFAULTS_ENABLED = 'DD_TRACE_PEER_SERVICE_DEFAULTS_ENABLED'
|
19
21
|
ENV_PEER_SERVICE_MAPPING = 'DD_TRACE_PEER_SERVICE_MAPPING'
|
20
22
|
end
|
21
23
|
|
@@ -40,8 +42,13 @@ module Datadog
|
|
40
42
|
# W3C Trace Context
|
41
43
|
PROPAGATION_STYLE_TRACE_CONTEXT = 'tracecontext'
|
42
44
|
|
45
|
+
# W3C Baggage
|
46
|
+
# @see https://www.w3.org/TR/baggage/
|
47
|
+
PROPAGATION_STYLE_BAGGAGE = 'baggage'
|
48
|
+
|
43
49
|
PROPAGATION_STYLE_SUPPORTED = [PROPAGATION_STYLE_DATADOG, PROPAGATION_STYLE_B3_MULTI_HEADER,
|
44
|
-
PROPAGATION_STYLE_B3_SINGLE_HEADER, PROPAGATION_STYLE_TRACE_CONTEXT
|
50
|
+
PROPAGATION_STYLE_B3_SINGLE_HEADER, PROPAGATION_STYLE_TRACE_CONTEXT,
|
51
|
+
PROPAGATION_STYLE_BAGGAGE].freeze
|
45
52
|
|
46
53
|
# Sets both extract and inject propagation style tho the provided value.
|
47
54
|
# Has lower precedence than `DD_TRACE_PROPAGATION_STYLE_INJECT` or
|
@@ -42,7 +42,7 @@ module Datadog
|
|
42
42
|
#
|
43
43
|
# The tracer will try to find distributed headers in the order they are present in the list provided to this option.
|
44
44
|
# The first format to have valid data present will be used.
|
45
|
-
#
|
45
|
+
# Baggage style is a special case, as it will always be extracted in addition if present.
|
46
46
|
# @default `DD_TRACE_PROPAGATION_STYLE_EXTRACT` environment variable (comma-separated list),
|
47
47
|
# otherwise `['datadog','b3multi','b3']`.
|
48
48
|
# @return [Array<String>]
|
@@ -53,6 +53,7 @@ module Datadog
|
|
53
53
|
[
|
54
54
|
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_DATADOG,
|
55
55
|
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_TRACE_CONTEXT,
|
56
|
+
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_BAGGAGE,
|
56
57
|
]
|
57
58
|
)
|
58
59
|
o.after_set do |styles|
|
@@ -74,6 +75,7 @@ module Datadog
|
|
74
75
|
o.default [
|
75
76
|
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_DATADOG,
|
76
77
|
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_TRACE_CONTEXT,
|
78
|
+
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_BAGGAGE,
|
77
79
|
]
|
78
80
|
o.after_set do |styles|
|
79
81
|
# Make values case-insensitive
|
@@ -186,7 +188,7 @@ module Datadog
|
|
186
188
|
# It is not supported by our backend yet. Do not enable it.
|
187
189
|
option :trace_id_128_bit_logging_enabled do |o|
|
188
190
|
o.env Tracing::Configuration::Ext::Correlation::ENV_TRACE_ID_128_BIT_LOGGING_ENABLED
|
189
|
-
o.default
|
191
|
+
o.default true
|
190
192
|
o.type :bool
|
191
193
|
end
|
192
194
|
|
@@ -249,6 +251,20 @@ module Datadog
|
|
249
251
|
o.type :bool
|
250
252
|
end
|
251
253
|
|
254
|
+
# Forces the tracer to always send span events with the native span events format
|
255
|
+
# regardless of the agent support. This is useful in agent-less setups.
|
256
|
+
#
|
257
|
+
# When set to `nil`, the default, the agent will be queried for
|
258
|
+
# native span events support.
|
259
|
+
#
|
260
|
+
# @default `DD_TRACE_NATIVE_SPAN_EVENTS` environment variable, otherwise `false`
|
261
|
+
# @return [Boolean,nil]
|
262
|
+
option :native_span_events do |o|
|
263
|
+
o.env Tracing::Configuration::Ext::ENV_NATIVE_SPAN_EVENTS
|
264
|
+
o.default nil
|
265
|
+
o.type :bool, nilable: true
|
266
|
+
end
|
267
|
+
|
252
268
|
# A custom sampler instance.
|
253
269
|
# The object must respect the {Datadog::Tracing::Sampling::Sampler} interface.
|
254
270
|
# @default `nil`
|
@@ -368,22 +384,18 @@ module Datadog
|
|
368
384
|
end
|
369
385
|
end
|
370
386
|
|
371
|
-
#
|
387
|
+
# This is only for internal Datadog use via https://github.com/DataDog/datadog-ci-rb . It should not be
|
388
|
+
# used directly.
|
389
|
+
#
|
390
|
+
# DEV-3.0: Make this a non-public API in the next release.
|
372
391
|
# @public_api
|
373
392
|
settings :test_mode do
|
374
|
-
# Enable test mode. This allows the tracer to collect spans from test runs.
|
375
|
-
#
|
376
|
-
# It also prevents the tracer from collecting spans in a production environment. Only use in a test environment.
|
377
|
-
#
|
378
|
-
# @default `DD_TRACE_TEST_MODE_ENABLED` environment variable, otherwise `false`
|
379
|
-
# @return [Boolean]
|
380
393
|
option :enabled do |o|
|
381
394
|
o.type :bool
|
382
395
|
o.default false
|
383
396
|
o.env Tracing::Configuration::Ext::Test::ENV_MODE_ENABLED
|
384
397
|
end
|
385
398
|
|
386
|
-
# Use async writer in test mode
|
387
399
|
option :async do |o|
|
388
400
|
o.type :bool
|
389
401
|
o.default false
|
@@ -49,7 +49,7 @@ module Datadog
|
|
49
49
|
# To support multiple tracers simultaneously, each {Datadog::Tracing::FiberLocalContext}
|
50
50
|
# instance has its own fiber-local variable.
|
51
51
|
def initialize
|
52
|
-
@key = "datadog_context_#{FiberLocalContext.next_instance_id}"
|
52
|
+
@key = :"datadog_context_#{FiberLocalContext.next_instance_id}"
|
53
53
|
|
54
54
|
self.local = Context.new
|
55
55
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative '../integration'
|
4
4
|
require_relative 'configuration/settings'
|
5
5
|
require_relative 'patcher'
|
6
|
-
require_relative '
|
6
|
+
require_relative '../../../core/contrib/rails/utils'
|
7
7
|
|
8
8
|
module Datadog
|
9
9
|
module Tracing
|
@@ -17,6 +17,9 @@ module Datadog
|
|
17
17
|
|
18
18
|
# @public_api Changing the integration name or integration options can cause breaking changes
|
19
19
|
register_as :action_cable, auto_patch: false
|
20
|
+
def self.gem_name
|
21
|
+
'actioncable'
|
22
|
+
end
|
20
23
|
|
21
24
|
def self.version
|
22
25
|
Gem.loaded_specs['actioncable'] && Gem.loaded_specs['actioncable'].version
|
@@ -33,7 +36,7 @@ module Datadog
|
|
33
36
|
# enabled by rails integration so should only auto instrument
|
34
37
|
# if detected that it is being used without rails
|
35
38
|
def auto_instrument?
|
36
|
-
!Contrib::Rails::Utils.railtie_supported?
|
39
|
+
!Core::Contrib::Rails::Utils.railtie_supported?
|
37
40
|
end
|
38
41
|
|
39
42
|
def new_configuration
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative 'configuration/settings'
|
4
4
|
require_relative 'patcher'
|
5
5
|
require_relative '../integration'
|
6
|
-
require_relative '
|
6
|
+
require_relative '../../../core/contrib/rails/utils'
|
7
7
|
|
8
8
|
module Datadog
|
9
9
|
module Tracing
|
@@ -18,6 +18,10 @@ module Datadog
|
|
18
18
|
# @public_api Changing the integration name or integration options can cause breaking changes
|
19
19
|
register_as :action_mailer, auto_patch: false
|
20
20
|
|
21
|
+
def self.gem_name
|
22
|
+
'actionmailer'
|
23
|
+
end
|
24
|
+
|
21
25
|
def self.version
|
22
26
|
Gem.loaded_specs['actionmailer'] && Gem.loaded_specs['actionmailer'].version
|
23
27
|
end
|
@@ -33,7 +37,7 @@ module Datadog
|
|
33
37
|
# enabled by rails integration so should only auto instrument
|
34
38
|
# if detected that it is being used without rails
|
35
39
|
def auto_instrument?
|
36
|
-
!Contrib::Rails::Utils.railtie_supported?
|
40
|
+
!Core::Contrib::Rails::Utils.railtie_supported?
|
37
41
|
end
|
38
42
|
|
39
43
|
def new_configuration
|
@@ -4,7 +4,7 @@ require_relative 'configuration/settings'
|
|
4
4
|
require_relative 'patcher'
|
5
5
|
require_relative '../integration'
|
6
6
|
require_relative '../rails/ext'
|
7
|
-
require_relative '
|
7
|
+
require_relative '../../../core/contrib/rails/utils'
|
8
8
|
|
9
9
|
module Datadog
|
10
10
|
module Tracing
|
@@ -18,6 +18,9 @@ module Datadog
|
|
18
18
|
|
19
19
|
# @public_api Changing the integration name or integration options can cause breaking changes
|
20
20
|
register_as :action_pack, auto_patch: false
|
21
|
+
def self.gem_name
|
22
|
+
'actionpack'
|
23
|
+
end
|
21
24
|
|
22
25
|
def self.version
|
23
26
|
Gem.loaded_specs['actionpack'] && Gem.loaded_specs['actionpack'].version
|
@@ -34,7 +37,7 @@ module Datadog
|
|
34
37
|
# enabled by rails integration so should only auto instrument
|
35
38
|
# if detected that it is being used without rails
|
36
39
|
def auto_instrument?
|
37
|
-
!Contrib::Rails::Utils.railtie_supported?
|
40
|
+
!Core::Contrib::Rails::Utils.railtie_supported?
|
38
41
|
end
|
39
42
|
|
40
43
|
def new_configuration
|
@@ -4,7 +4,7 @@ require_relative 'configuration/settings'
|
|
4
4
|
require_relative 'patcher'
|
5
5
|
require_relative '../integration'
|
6
6
|
require_relative '../rails/ext'
|
7
|
-
require_relative '
|
7
|
+
require_relative '../../../core/contrib/rails/utils'
|
8
8
|
|
9
9
|
module Datadog
|
10
10
|
module Tracing
|
@@ -18,6 +18,9 @@ module Datadog
|
|
18
18
|
|
19
19
|
# @public_api Changing the integration name or integration options can cause breaking changes
|
20
20
|
register_as :action_view, auto_patch: false
|
21
|
+
def self.gem_name
|
22
|
+
'actionview'
|
23
|
+
end
|
21
24
|
|
22
25
|
def self.version
|
23
26
|
# ActionView is its own gem in Rails 4.1+
|
@@ -41,7 +44,7 @@ module Datadog
|
|
41
44
|
# enabled by rails integration so should only auto instrument
|
42
45
|
# if detected that it is being used without rails
|
43
46
|
def auto_instrument?
|
44
|
-
!Contrib::Rails::Utils.railtie_supported?
|
47
|
+
!Core::Contrib::Rails::Utils.railtie_supported?
|
45
48
|
end
|
46
49
|
|
47
50
|
def new_configuration
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative 'configuration/settings'
|
4
4
|
require_relative 'patcher'
|
5
5
|
require_relative '../integration'
|
6
|
-
require_relative '
|
6
|
+
require_relative '../../../core/contrib/rails/utils'
|
7
7
|
|
8
8
|
module Datadog
|
9
9
|
module Tracing
|
@@ -17,6 +17,9 @@ module Datadog
|
|
17
17
|
|
18
18
|
# @public_api Changing the integration name or integration options can cause breaking changes
|
19
19
|
register_as :active_job, auto_patch: false
|
20
|
+
def self.gem_name
|
21
|
+
'activejob'
|
22
|
+
end
|
20
23
|
|
21
24
|
def self.version
|
22
25
|
Gem.loaded_specs['activejob'] && Gem.loaded_specs['activejob'].version
|
@@ -33,7 +36,7 @@ module Datadog
|
|
33
36
|
# enabled by rails integration so should only auto instrument
|
34
37
|
# if detected that it is being used without rails
|
35
38
|
def auto_instrument?
|
36
|
-
!Contrib::Rails::Utils.railtie_supported?
|
39
|
+
!Core::Contrib::Rails::Utils.railtie_supported?
|
37
40
|
end
|
38
41
|
|
39
42
|
def new_configuration
|
@@ -7,7 +7,7 @@ require_relative 'patcher'
|
|
7
7
|
require_relative '../component'
|
8
8
|
require_relative '../integration'
|
9
9
|
require_relative '../rails/ext'
|
10
|
-
require_relative '
|
10
|
+
require_relative '../../../core/contrib/rails/utils'
|
11
11
|
|
12
12
|
module Datadog
|
13
13
|
module Tracing
|
@@ -22,6 +22,10 @@ module Datadog
|
|
22
22
|
# @public_api Changing the integration name or integration options can cause breaking changes
|
23
23
|
register_as :active_record, auto_patch: false
|
24
24
|
|
25
|
+
def self.gem_name
|
26
|
+
'activerecord'
|
27
|
+
end
|
28
|
+
|
25
29
|
def self.version
|
26
30
|
Gem.loaded_specs['activerecord'] && Gem.loaded_specs['activerecord'].version
|
27
31
|
end
|
@@ -37,7 +41,7 @@ module Datadog
|
|
37
41
|
# enabled by rails integration so should only auto instrument
|
38
42
|
# if detected that it is being used without rails
|
39
43
|
def auto_instrument?
|
40
|
-
!Contrib::Rails::Utils.railtie_supported?
|
44
|
+
!Core::Contrib::Rails::Utils.railtie_supported?
|
41
45
|
end
|
42
46
|
|
43
47
|
def new_configuration
|
@@ -53,7 +57,7 @@ module Datadog
|
|
53
57
|
end
|
54
58
|
|
55
59
|
def reset_resolver_cache
|
56
|
-
@resolver&.reset_cache
|
60
|
+
@resolver&.reset_cache if defined?(@resolver)
|
57
61
|
end
|
58
62
|
|
59
63
|
Contrib::Component.register('activerecord') do |_config|
|
@@ -62,7 +62,10 @@ module Datadog
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def on_start(span, event, _id, payload)
|
65
|
-
key
|
65
|
+
# Since Rails 8, `dd_original_keys` contains the denormalized key provided by the user.
|
66
|
+
# In previous versions, the denormalized key is stored in the official `key` attribute.
|
67
|
+
# We fall back to `key`, even in Rails 8, as a defensive measure.
|
68
|
+
key = payload[:dd_original_keys] || payload[:key]
|
66
69
|
store = payload[:store]
|
67
70
|
|
68
71
|
mapping = MAPPING.fetch(event)
|
@@ -81,7 +84,9 @@ module Datadog
|
|
81
84
|
|
82
85
|
span.set_tag('EVENT', event)
|
83
86
|
|
84
|
-
|
87
|
+
if Datadog.configuration.tracing[:active_support][:cache_key].enabled
|
88
|
+
set_cache_key(span, key, mapping[:multi_key])
|
89
|
+
end
|
85
90
|
rescue StandardError => e
|
86
91
|
Datadog.logger.error(e.message)
|
87
92
|
Datadog::Core::Telemetry::Logger.report(e)
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require_relative '../../../../core/utils'
|
4
4
|
require_relative '../../../metadata/ext'
|
5
5
|
require_relative '../ext'
|
6
|
+
require_relative 'event'
|
6
7
|
|
7
8
|
module Datadog
|
8
9
|
module Tracing
|
@@ -58,7 +59,8 @@ module Datadog
|
|
58
59
|
end
|
59
60
|
|
60
61
|
span.set_tag(Ext::TAG_CACHE_BACKEND, store) if store
|
61
|
-
|
62
|
+
|
63
|
+
set_cache_key(span, key, multi_key) if Datadog.configuration.tracing[:active_support][:cache_key].enabled
|
62
64
|
|
63
65
|
yield
|
64
66
|
end
|
@@ -182,6 +184,39 @@ module Datadog
|
|
182
184
|
super(operation, key, polyfill_options)
|
183
185
|
end
|
184
186
|
end
|
187
|
+
|
188
|
+
# Save the original, user-supplied cache key, before it gets normalized.
|
189
|
+
#
|
190
|
+
# Normalized keys can include internal implementation detail,
|
191
|
+
# for example FileStore keys include temp directory names, which
|
192
|
+
# changes on every run, making it impossible to group by the cache key afterward.
|
193
|
+
# Also, the user is never exposed to the normalized key, and only sets/gets using the
|
194
|
+
# original key.
|
195
|
+
module PreserveOriginalKey
|
196
|
+
# Stores the original keys in the options hash, as an array of keys.
|
197
|
+
# It's important to keep all the keys for multi-key operations.
|
198
|
+
# For single-key operations, the key is stored as an array of a single element.
|
199
|
+
def normalize_key(key, options)
|
200
|
+
orig_keys = options[:dd_original_keys] || []
|
201
|
+
orig_keys << key
|
202
|
+
options[:dd_original_keys] = orig_keys
|
203
|
+
|
204
|
+
super
|
205
|
+
end
|
206
|
+
|
207
|
+
# Ensure we don't pollute the default Store instance `options` in {PreserveOriginalKey#normalize_key}.
|
208
|
+
# In most cases, `merged_options` returns a new hash,
|
209
|
+
# but we check for cases where it reuses the instance hash.
|
210
|
+
def merged_options(call_options)
|
211
|
+
ret = super
|
212
|
+
|
213
|
+
if ret.equal?(options)
|
214
|
+
ret.dup
|
215
|
+
else
|
216
|
+
ret
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
185
220
|
end
|
186
221
|
end
|
187
222
|
end
|
@@ -22,6 +22,10 @@ module Datadog
|
|
22
22
|
def patch
|
23
23
|
Events.subscribe!
|
24
24
|
|
25
|
+
if Integration.version >= Gem::Version.new('8.0.0')
|
26
|
+
::ActiveSupport::Cache::Store.prepend(Cache::Instrumentation::PreserveOriginalKey)
|
27
|
+
end
|
28
|
+
|
25
29
|
# Backfill the `:store` key in the ActiveSupport event payload for older Rails.
|
26
30
|
if Integration.version < Gem::Version.new('6.1.0')
|
27
31
|
::ActiveSupport::Cache::Store.prepend(Cache::Instrumentation::Store)
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative '../../support'
|
3
4
|
require_relative 'patcher'
|
4
5
|
|
5
6
|
module Datadog
|
@@ -22,17 +23,26 @@ module Datadog
|
|
22
23
|
# For Rails >= 5.2 w/o redis-activesupport...
|
23
24
|
# ActiveSupport includes a Redis cache store internally, and does not require these overrides.
|
24
25
|
# https://github.com/rails/rails/blob/master/activesupport/lib/active_support/cache/redis_cache_store.rb
|
25
|
-
def
|
26
|
+
def patch_redis_store?(meth)
|
26
27
|
!Gem.loaded_specs['redis-activesupport'].nil? \
|
27
28
|
&& defined?(::ActiveSupport::Cache::RedisStore) \
|
28
29
|
&& ::ActiveSupport::Cache::RedisStore.instance_methods(false).include?(meth)
|
29
30
|
end
|
30
31
|
|
32
|
+
# Patches the Rails built-in Redis cache backend `redis_cache_store`, added in Rails 5.2.
|
33
|
+
# We avoid loading the RedisCacheStore class, as it invokes the statement `gem "redis", ">= 4.0.1"` which
|
34
|
+
# fails if the application is using an old version of Redis, or not using Redis at all.
|
35
|
+
# @see https://github.com/rails/rails/blob/d0dcb8fa6073a0c4d42600c15e82e3bb386b27d3/activesupport/lib/active_support/cache/redis_cache_store.rb#L4
|
36
|
+
def patch_redis_cache_store?(meth)
|
37
|
+
Gem.loaded_specs['redis'] &&
|
38
|
+
Support.fully_loaded?(::ActiveSupport::Cache, :RedisCacheStore) &&
|
39
|
+
::ActiveSupport::Cache::RedisCacheStore.instance_methods(false).include?(meth)
|
40
|
+
end
|
41
|
+
|
31
42
|
def cache_store_class(meth)
|
32
|
-
if
|
43
|
+
if patch_redis_store?(meth)
|
33
44
|
[::ActiveSupport::Cache::RedisStore, ::ActiveSupport::Cache::Store]
|
34
|
-
elsif
|
35
|
-
&& ::ActiveSupport::Cache::RedisCacheStore.instance_methods(false).include?(meth)
|
45
|
+
elsif patch_redis_cache_store?(meth)
|
36
46
|
[::ActiveSupport::Cache::RedisCacheStore, ::ActiveSupport::Cache::Store]
|
37
47
|
else
|
38
48
|
super
|
@@ -39,6 +39,16 @@ module Datadog
|
|
39
39
|
)
|
40
40
|
end
|
41
41
|
end
|
42
|
+
|
43
|
+
# grouped "cache_key.*" settings
|
44
|
+
settings :cache_key do
|
45
|
+
# enable or disabling the inclusion of the cache_key in the span
|
46
|
+
option :enabled do |o|
|
47
|
+
# cache_key.enabled
|
48
|
+
o.type :bool
|
49
|
+
o.default true
|
50
|
+
end
|
51
|
+
end
|
42
52
|
end
|
43
53
|
end
|
44
54
|
end
|
@@ -5,7 +5,7 @@ require_relative 'configuration/settings'
|
|
5
5
|
require_relative 'patcher'
|
6
6
|
require_relative 'cache/redis'
|
7
7
|
require_relative '../rails/ext'
|
8
|
-
require_relative '
|
8
|
+
require_relative '../../../core/contrib/rails/utils'
|
9
9
|
|
10
10
|
module Datadog
|
11
11
|
module Tracing
|
@@ -19,6 +19,9 @@ module Datadog
|
|
19
19
|
|
20
20
|
# @public_api Changing the integration name or integration options can cause breaking changes
|
21
21
|
register_as :active_support, auto_patch: false
|
22
|
+
def self.gem_name
|
23
|
+
'activesupport'
|
24
|
+
end
|
22
25
|
|
23
26
|
def self.version
|
24
27
|
Gem.loaded_specs['activesupport'] && Gem.loaded_specs['activesupport'].version
|
@@ -35,7 +38,7 @@ module Datadog
|
|
35
38
|
# enabled by rails integration so should only auto instrument
|
36
39
|
# if detected that it is being used without rails
|
37
40
|
def auto_instrument?
|
38
|
-
!Contrib::Rails::Utils.railtie_supported?
|
41
|
+
!Core::Contrib::Rails::Utils.railtie_supported?
|
39
42
|
end
|
40
43
|
|
41
44
|
def new_configuration
|
@@ -9,10 +9,10 @@ module Datadog
|
|
9
9
|
module Contrib
|
10
10
|
# Auto-activate instrumentation
|
11
11
|
def self.auto_instrument!
|
12
|
-
require_relative 'rails/utils'
|
12
|
+
require_relative '../../core/contrib/rails/utils'
|
13
13
|
|
14
14
|
# Defer to Rails if this is a Rails application
|
15
|
-
if Datadog::
|
15
|
+
if Datadog::Core::Contrib::Rails::Utils.railtie_supported?
|
16
16
|
require_relative 'rails/auto_instrument_railtie'
|
17
17
|
else
|
18
18
|
AutoInstrument.patch_all!
|
@@ -35,6 +35,16 @@ module Datadog
|
|
35
35
|
span.type = Tracing::Metadata::Ext::HTTP::TYPE_OUTBOUND
|
36
36
|
span.name = Ext::SPAN_COMMAND
|
37
37
|
span.resource = context.safely(:resource)
|
38
|
+
|
39
|
+
# Set error on the span if the Response Status Code is in error range
|
40
|
+
if Tracing::Metadata::Ext::HTTP::ERROR_RANGE.cover?(context.safely(:status_code))
|
41
|
+
# At this point we do not have any additional diagnostics
|
42
|
+
# besides the HTTP status code which is recorded in the span tags
|
43
|
+
# later in this method.
|
44
|
+
# Just set the span as errored.
|
45
|
+
span.set_error(nil)
|
46
|
+
end
|
47
|
+
|
38
48
|
aws_service = span.resource.split('.')[0]
|
39
49
|
span.set_tag(Ext::TAG_AWS_SERVICE, aws_service)
|
40
50
|
params = context.safely(:params)
|