datadog 2.12.1 → 2.19.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 +243 -2
- data/ext/datadog_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +63 -56
- data/ext/datadog_profiling_native_extension/collectors_stack.c +263 -76
- data/ext/datadog_profiling_native_extension/collectors_stack.h +20 -3
- data/ext/datadog_profiling_native_extension/collectors_thread_context.c +78 -26
- data/ext/datadog_profiling_native_extension/collectors_thread_context.h +1 -0
- 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 +10 -0
- data/ext/datadog_profiling_native_extension/heap_recorder.c +247 -364
- data/ext/datadog_profiling_native_extension/heap_recorder.h +4 -6
- data/ext/datadog_profiling_native_extension/http_transport.c +60 -94
- data/ext/datadog_profiling_native_extension/libdatadog_helpers.c +22 -0
- data/ext/datadog_profiling_native_extension/libdatadog_helpers.h +8 -5
- data/ext/datadog_profiling_native_extension/private_vm_api_access.c +41 -21
- data/ext/datadog_profiling_native_extension/private_vm_api_access.h +6 -4
- data/ext/datadog_profiling_native_extension/profiling.c +2 -0
- data/ext/datadog_profiling_native_extension/ruby_helpers.c +1 -13
- data/ext/datadog_profiling_native_extension/ruby_helpers.h +3 -11
- data/ext/datadog_profiling_native_extension/stack_recorder.c +173 -76
- data/ext/libdatadog_api/crashtracker.c +11 -12
- 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/extconf.rb +2 -2
- data/ext/libdatadog_api/init.c +15 -0
- data/ext/libdatadog_api/library_config.c +164 -0
- data/ext/libdatadog_api/library_config.h +25 -0
- data/ext/libdatadog_api/macos_development.md +3 -3
- data/ext/libdatadog_api/process_discovery.c +112 -0
- data/ext/libdatadog_api/process_discovery.h +5 -0
- data/ext/libdatadog_extconf_helpers.rb +2 -2
- data/lib/datadog/appsec/actions_handler/serializable_backtrace.rb +89 -0
- data/lib/datadog/appsec/actions_handler.rb +24 -2
- data/lib/datadog/appsec/anonymizer.rb +16 -0
- data/lib/datadog/appsec/api_security/lru_cache.rb +56 -0
- data/lib/datadog/appsec/api_security/route_extractor.rb +71 -0
- data/lib/datadog/appsec/api_security/sampler.rb +59 -0
- data/lib/datadog/appsec/api_security.rb +23 -0
- data/lib/datadog/appsec/assets/waf_rules/README.md +50 -5
- data/lib/datadog/appsec/assets/waf_rules/recommended.json +257 -85
- data/lib/datadog/appsec/assets/waf_rules/strict.json +10 -78
- data/lib/datadog/appsec/autoload.rb +1 -1
- data/lib/datadog/appsec/component.rb +46 -61
- data/lib/datadog/appsec/compressed_json.rb +40 -0
- data/lib/datadog/appsec/configuration/settings.rb +153 -30
- data/lib/datadog/appsec/context.rb +7 -7
- data/lib/datadog/appsec/contrib/active_record/instrumentation.rb +10 -12
- data/lib/datadog/appsec/contrib/active_record/integration.rb +2 -2
- data/lib/datadog/appsec/contrib/active_record/patcher.rb +22 -22
- data/lib/datadog/appsec/contrib/auto_instrument.rb +1 -1
- data/lib/datadog/appsec/contrib/devise/configuration.rb +7 -31
- 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 +34 -23
- 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} +2 -2
- data/lib/datadog/appsec/contrib/devise/tracking_middleware.rb +106 -0
- data/lib/datadog/appsec/contrib/excon/integration.rb +1 -1
- data/lib/datadog/appsec/contrib/excon/ssrf_detection_middleware.rb +9 -10
- data/lib/datadog/appsec/contrib/faraday/integration.rb +1 -1
- data/lib/datadog/appsec/contrib/faraday/ssrf_detection_middleware.rb +8 -9
- data/lib/datadog/appsec/contrib/graphql/gateway/watcher.rb +8 -9
- data/lib/datadog/appsec/contrib/graphql/integration.rb +1 -1
- data/lib/datadog/appsec/contrib/rack/ext.rb +34 -0
- data/lib/datadog/appsec/contrib/rack/gateway/watcher.rb +49 -32
- data/lib/datadog/appsec/contrib/rack/integration.rb +1 -1
- data/lib/datadog/appsec/contrib/rack/request_middleware.rb +42 -30
- data/lib/datadog/appsec/contrib/rails/gateway/watcher.rb +11 -13
- data/lib/datadog/appsec/contrib/rails/integration.rb +1 -1
- data/lib/datadog/appsec/contrib/rails/patcher.rb +21 -21
- data/lib/datadog/appsec/contrib/rest_client/integration.rb +1 -1
- data/lib/datadog/appsec/contrib/rest_client/request_ssrf_detection_patch.rb +10 -11
- data/lib/datadog/appsec/contrib/sinatra/gateway/watcher.rb +17 -23
- data/lib/datadog/appsec/contrib/sinatra/integration.rb +1 -1
- data/lib/datadog/appsec/event.rb +96 -135
- data/lib/datadog/appsec/ext.rb +4 -2
- 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/telemetry.rb +1 -1
- data/lib/datadog/appsec/monitor/gateway/watcher.rb +49 -14
- data/lib/datadog/appsec/processor/rule_loader.rb +30 -33
- data/lib/datadog/appsec/remote.rb +31 -59
- data/lib/datadog/appsec/response.rb +6 -6
- data/lib/datadog/appsec/security_engine/engine.rb +194 -0
- data/lib/datadog/appsec/security_engine/runner.rb +13 -14
- data/lib/datadog/appsec/security_event.rb +39 -0
- data/lib/datadog/appsec/utils.rb +0 -2
- data/lib/datadog/appsec.rb +5 -8
- data/lib/datadog/core/buffer/random.rb +18 -2
- data/lib/datadog/core/configuration/agent_settings.rb +52 -0
- data/lib/datadog/core/configuration/agent_settings_resolver.rb +4 -46
- data/lib/datadog/core/configuration/agentless_settings_resolver.rb +176 -0
- data/lib/datadog/core/configuration/components.rb +48 -31
- data/lib/datadog/core/configuration/components_state.rb +23 -0
- data/lib/datadog/core/configuration/ext.rb +4 -0
- data/lib/datadog/core/configuration/option.rb +81 -45
- data/lib/datadog/core/configuration/option_definition.rb +4 -4
- data/lib/datadog/core/configuration/options.rb +3 -3
- data/lib/datadog/core/configuration/settings.rb +109 -44
- data/lib/datadog/core/configuration/stable_config.rb +22 -0
- data/lib/datadog/core/configuration.rb +40 -16
- data/lib/datadog/core/crashtracking/component.rb +3 -10
- data/lib/datadog/core/crashtracking/tag_builder.rb +4 -22
- data/lib/datadog/core/diagnostics/environment_logger.rb +1 -1
- data/lib/datadog/core/encoding.rb +1 -1
- data/lib/datadog/core/environment/agent_info.rb +4 -3
- 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 +20 -21
- data/lib/datadog/core/metrics/logging.rb +5 -5
- data/lib/datadog/core/process_discovery/tracer_memfd.rb +15 -0
- data/lib/datadog/core/process_discovery.rb +36 -0
- data/lib/datadog/core/rate_limiter.rb +4 -2
- data/lib/datadog/core/remote/client.rb +40 -32
- data/lib/datadog/core/remote/component.rb +6 -9
- 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 +14 -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/client.rb +5 -4
- data/lib/datadog/core/remote/transport/http/config.rb +27 -37
- data/lib/datadog/core/remote/transport/http/negotiation.rb +7 -33
- data/lib/datadog/core/remote/transport/http.rb +22 -57
- data/lib/datadog/core/remote/transport/negotiation.rb +4 -3
- data/lib/datadog/core/runtime/metrics.rb +12 -5
- data/lib/datadog/core/tag_builder.rb +56 -0
- data/lib/datadog/core/telemetry/component.rb +81 -52
- data/lib/datadog/core/telemetry/emitter.rb +23 -11
- data/lib/datadog/core/telemetry/event/app_client_configuration_change.rb +66 -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 +287 -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 -472
- data/lib/datadog/core/telemetry/http/adapters/net.rb +12 -97
- data/lib/datadog/core/telemetry/logger.rb +5 -4
- data/lib/datadog/core/telemetry/logging.rb +11 -5
- data/lib/datadog/core/telemetry/metric.rb +8 -8
- 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 +90 -24
- data/lib/datadog/core/transport/http/adapters/net.rb +17 -2
- data/lib/datadog/core/transport/http/adapters/test.rb +2 -1
- data/lib/datadog/core/transport/http/api/instance.rb +17 -0
- data/lib/datadog/core/transport/http/api/spec.rb +17 -0
- data/lib/datadog/core/transport/http/builder.rb +19 -17
- data/lib/datadog/core/transport/http/env.rb +8 -0
- data/lib/datadog/core/transport/http.rb +39 -2
- 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/utils.rb +7 -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/boot.rb +34 -0
- data/lib/datadog/di/component.rb +0 -2
- data/lib/datadog/di/instrumenter.rb +48 -5
- data/lib/datadog/di/probe_notification_builder.rb +38 -43
- data/lib/datadog/di/probe_notifier_worker.rb +25 -17
- data/lib/datadog/di/remote.rb +2 -0
- data/lib/datadog/di/serializer.rb +10 -2
- data/lib/datadog/di/transport/diagnostics.rb +4 -3
- data/lib/datadog/di/transport/http/api.rb +2 -12
- data/lib/datadog/di/transport/http/client.rb +4 -3
- data/lib/datadog/di/transport/http/diagnostics.rb +7 -34
- data/lib/datadog/di/transport/http/input.rb +18 -35
- data/lib/datadog/di/transport/http.rb +14 -62
- data/lib/datadog/di/transport/input.rb +14 -5
- data/lib/datadog/di/utils.rb +5 -0
- data/lib/datadog/di.rb +0 -33
- 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/v2.rb +195 -0
- data/lib/datadog/kit/appsec/events.rb +12 -0
- data/lib/datadog/kit/identity.rb +5 -1
- 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 +18 -9
- data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +6 -0
- data/lib/datadog/profiling/collectors/idle_sampling_helper.rb +1 -0
- data/lib/datadog/profiling/collectors/info.rb +44 -0
- data/lib/datadog/profiling/collectors/thread_context.rb +17 -2
- data/lib/datadog/profiling/component.rb +8 -9
- data/lib/datadog/profiling/encoded_profile.rb +11 -0
- data/lib/datadog/profiling/exporter.rb +12 -7
- data/lib/datadog/profiling/ext.rb +0 -14
- data/lib/datadog/profiling/flush.rb +5 -8
- data/lib/datadog/profiling/http_transport.rb +7 -61
- data/lib/datadog/profiling/profiler.rb +2 -0
- data/lib/datadog/profiling/scheduler.rb +10 -2
- data/lib/datadog/profiling/sequence_tracker.rb +44 -0
- data/lib/datadog/profiling/stack_recorder.rb +9 -9
- data/lib/datadog/profiling/tag_builder.rb +7 -41
- data/lib/datadog/profiling/tasks/setup.rb +2 -0
- data/lib/datadog/profiling.rb +7 -2
- data/lib/datadog/single_step_instrument.rb +9 -0
- data/lib/datadog/tracing/analytics.rb +1 -1
- data/lib/datadog/tracing/component.rb +15 -12
- data/lib/datadog/tracing/configuration/ext.rb +7 -1
- data/lib/datadog/tracing/configuration/settings.rb +18 -2
- data/lib/datadog/tracing/context_provider.rb +1 -1
- data/lib/datadog/tracing/contrib/action_pack/action_controller/instrumentation.rb +15 -0
- data/lib/datadog/tracing/contrib/action_pack/action_dispatch/instrumentation.rb +19 -12
- data/lib/datadog/tracing/contrib/action_pack/ext.rb +2 -0
- data/lib/datadog/tracing/contrib/active_record/integration.rb +1 -1
- data/lib/datadog/tracing/contrib/active_support/cache/events/cache.rb +11 -2
- data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +33 -0
- data/lib/datadog/tracing/contrib/active_support/cache/patcher.rb +4 -0
- data/lib/datadog/tracing/contrib/active_support/cache/redis.rb +2 -4
- data/lib/datadog/tracing/contrib/active_support/configuration/settings.rb +13 -0
- data/lib/datadog/tracing/contrib/aws/instrumentation.rb +10 -0
- data/lib/datadog/tracing/contrib/aws/parsed_context.rb +5 -1
- data/lib/datadog/tracing/contrib/configuration/settings.rb +1 -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/faraday/middleware.rb +5 -3
- 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/httpclient/instrumentation.rb +6 -16
- data/lib/datadog/tracing/contrib/httprb/instrumentation.rb +7 -15
- 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/lograge/patcher.rb +4 -2
- 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/subscribers.rb +18 -1
- data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +16 -6
- 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/patcher.rb +5 -1
- data/lib/datadog/tracing/contrib/patcher.rb +5 -2
- data/lib/datadog/tracing/contrib/rack/request_queue.rb +1 -1
- data/lib/datadog/tracing/contrib/rails/patcher.rb +4 -1
- data/lib/datadog/tracing/contrib/rails/runner.rb +61 -40
- 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/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/sidekiq/server_tracer.rb +5 -2
- 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/diagnostics/environment_logger.rb +3 -1
- 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 +10 -1
- data/lib/datadog/tracing/span_event.rb +2 -2
- data/lib/datadog/tracing/span_operation.rb +68 -16
- data/lib/datadog/tracing/sync_writer.rb +2 -3
- data/lib/datadog/tracing/trace_digest.rb +9 -2
- data/lib/datadog/tracing/trace_operation.rb +55 -27
- data/lib/datadog/tracing/trace_segment.rb +6 -4
- data/lib/datadog/tracing/tracer.rb +51 -7
- data/lib/datadog/tracing/transport/http/api.rb +2 -10
- data/lib/datadog/tracing/transport/http/client.rb +5 -4
- data/lib/datadog/tracing/transport/http/traces.rb +13 -41
- data/lib/datadog/tracing/transport/http.rb +11 -44
- data/lib/datadog/tracing/transport/serializable_trace.rb +3 -1
- data/lib/datadog/tracing/transport/trace_formatter.rb +7 -0
- data/lib/datadog/tracing/transport/traces.rb +26 -9
- data/lib/datadog/tracing/utils.rb +1 -1
- data/lib/datadog/tracing/workers/trace_writer.rb +2 -6
- data/lib/datadog/tracing/writer.rb +2 -6
- data/lib/datadog/tracing.rb +16 -3
- data/lib/datadog/version.rb +2 -2
- data/lib/datadog.rb +8 -2
- metadata +88 -23
- data/lib/datadog/appsec/assets/waf_rules/processors.json +0 -92
- data/lib/datadog/appsec/assets/waf_rules/scanners.json +0 -114
- data/lib/datadog/appsec/contrib/devise/event.rb +0 -54
- data/lib/datadog/appsec/contrib/devise/patcher/authenticatable_patch.rb +0 -72
- data/lib/datadog/appsec/contrib/devise/patcher/registration_controller_patch.rb +0 -47
- data/lib/datadog/appsec/contrib/devise/resource.rb +0 -35
- data/lib/datadog/appsec/contrib/devise/tracking.rb +0 -57
- data/lib/datadog/appsec/processor/rule_merger.rb +0 -170
- data/lib/datadog/appsec/processor.rb +0 -107
- data/lib/datadog/appsec/utils/trace_operation.rb +0 -15
- 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
@@ -21,7 +21,8 @@ module Datadog
|
|
21
21
|
endpoint_collection_enabled:,
|
22
22
|
timeline_enabled:,
|
23
23
|
waiting_for_gvl_threshold_ns:,
|
24
|
-
otel_context_enabled
|
24
|
+
otel_context_enabled:,
|
25
|
+
native_filenames_enabled:
|
25
26
|
)
|
26
27
|
tracer_context_key = safely_extract_context_key_from(tracer)
|
27
28
|
self.class._native_initialize(
|
@@ -33,6 +34,7 @@ module Datadog
|
|
33
34
|
timeline_enabled: timeline_enabled,
|
34
35
|
waiting_for_gvl_threshold_ns: waiting_for_gvl_threshold_ns,
|
35
36
|
otel_context_enabled: otel_context_enabled,
|
37
|
+
native_filenames_enabled: validate_native_filenames(native_filenames_enabled),
|
36
38
|
)
|
37
39
|
end
|
38
40
|
|
@@ -44,6 +46,7 @@ module Datadog
|
|
44
46
|
timeline_enabled: false,
|
45
47
|
waiting_for_gvl_threshold_ns: 10_000_000,
|
46
48
|
otel_context_enabled: false,
|
49
|
+
native_filenames_enabled: true,
|
47
50
|
**options
|
48
51
|
)
|
49
52
|
new(
|
@@ -54,13 +57,14 @@ module Datadog
|
|
54
57
|
timeline_enabled: timeline_enabled,
|
55
58
|
waiting_for_gvl_threshold_ns: waiting_for_gvl_threshold_ns,
|
56
59
|
otel_context_enabled: otel_context_enabled,
|
60
|
+
native_filenames_enabled: native_filenames_enabled,
|
57
61
|
**options,
|
58
62
|
)
|
59
63
|
end
|
60
64
|
|
61
65
|
def inspect
|
62
66
|
# Compose Ruby's default inspect with our custom inspect for the native parts
|
63
|
-
result = super
|
67
|
+
result = super
|
64
68
|
result[-1] = "#{self.class._native_inspect(self)}>"
|
65
69
|
result
|
66
70
|
end
|
@@ -81,6 +85,17 @@ module Datadog
|
|
81
85
|
context = provider.instance_variable_get(:@context)
|
82
86
|
context&.instance_variable_get(:@key)
|
83
87
|
end
|
88
|
+
|
89
|
+
def validate_native_filenames(native_filenames_enabled)
|
90
|
+
if native_filenames_enabled && !Datadog::Profiling::Collectors::Stack._native_filenames_available?
|
91
|
+
Datadog.logger.debug(
|
92
|
+
"Native filenames are enabled, but the required dladdr API was not available. Disabling native filenames."
|
93
|
+
)
|
94
|
+
false
|
95
|
+
else
|
96
|
+
native_filenames_enabled
|
97
|
+
end
|
98
|
+
end
|
84
99
|
end
|
85
100
|
end
|
86
101
|
end
|
@@ -67,6 +67,7 @@ module Datadog
|
|
67
67
|
allocation_profiling_enabled: allocation_profiling_enabled,
|
68
68
|
allocation_counting_enabled: settings.profiling.advanced.allocation_counting_enabled,
|
69
69
|
gvl_profiling_enabled: enable_gvl_profiling?(settings, logger),
|
70
|
+
sighandler_sampling_enabled: settings.profiling.advanced.sighandler_sampling_enabled,
|
70
71
|
)
|
71
72
|
|
72
73
|
internal_metadata = {
|
@@ -96,6 +97,7 @@ module Datadog
|
|
96
97
|
timeline_enabled: timeline_enabled,
|
97
98
|
waiting_for_gvl_threshold_ns: settings.profiling.advanced.waiting_for_gvl_threshold_ns,
|
98
99
|
otel_context_enabled: settings.profiling.advanced.preview_otel_context_enabled,
|
100
|
+
native_filenames_enabled: settings.profiling.advanced.native_filenames_enabled,
|
99
101
|
)
|
100
102
|
end
|
101
103
|
|
@@ -221,13 +223,14 @@ module Datadog
|
|
221
223
|
end
|
222
224
|
|
223
225
|
unless allocation_profiling_enabled
|
224
|
-
|
226
|
+
logger.warn(
|
227
|
+
"Heap profiling was requested but allocation profiling is not enabled. " \
|
228
|
+
"Heap profiling has been disabled."
|
229
|
+
)
|
230
|
+
return false
|
225
231
|
end
|
226
232
|
|
227
|
-
logger.
|
228
|
-
"Enabled experimental heap profiling: heap_sample_rate=#{heap_sample_rate}. This is experimental, not " \
|
229
|
-
"recommended, and will increase overhead!"
|
230
|
-
)
|
233
|
+
logger.debug("Enabled heap profiling: heap_sample_rate=#{heap_sample_rate}")
|
231
234
|
|
232
235
|
true
|
233
236
|
end
|
@@ -237,10 +240,6 @@ module Datadog
|
|
237
240
|
|
238
241
|
return false unless heap_profiling_enabled && heap_size_profiling_enabled
|
239
242
|
|
240
|
-
logger.warn(
|
241
|
-
"Enabled experimental heap size profiling. This is experimental, not recommended, and will increase overhead!"
|
242
|
-
)
|
243
|
-
|
244
243
|
true
|
245
244
|
end
|
246
245
|
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Datadog
|
4
|
+
module Profiling
|
5
|
+
# This class exists to wrap a ddog_prof_EncodedProfile into a Ruby object
|
6
|
+
#
|
7
|
+
# This class is not empty; all of this class is implemented as native code.
|
8
|
+
class EncodedProfile # rubocop:disable Lint/EmptyClass
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -26,7 +26,8 @@ module Datadog
|
|
26
26
|
:last_flush_finish_at,
|
27
27
|
:created_at,
|
28
28
|
:internal_metadata,
|
29
|
-
:info_json
|
29
|
+
:info_json,
|
30
|
+
:sequence_tracker
|
30
31
|
|
31
32
|
public
|
32
33
|
|
@@ -37,7 +38,8 @@ module Datadog
|
|
37
38
|
code_provenance_collector:,
|
38
39
|
internal_metadata:,
|
39
40
|
minimum_duration_seconds: PROFILE_DURATION_THRESHOLD_SECONDS,
|
40
|
-
time_provider: Time
|
41
|
+
time_provider: Time,
|
42
|
+
sequence_tracker: Datadog::Profiling::SequenceTracker
|
41
43
|
)
|
42
44
|
@pprof_recorder = pprof_recorder
|
43
45
|
@worker = worker
|
@@ -49,7 +51,8 @@ module Datadog
|
|
49
51
|
@internal_metadata = internal_metadata
|
50
52
|
# NOTE: At the time of this comment collected info does not change over time so we'll hardcode
|
51
53
|
# it on startup to prevent serializing the same info on every flush.
|
52
|
-
@info_json = JSON.
|
54
|
+
@info_json = JSON.generate(info_collector.info).freeze
|
55
|
+
@sequence_tracker = sequence_tracker
|
53
56
|
end
|
54
57
|
|
55
58
|
def flush
|
@@ -57,7 +60,7 @@ module Datadog
|
|
57
60
|
serialization_result = pprof_recorder.serialize
|
58
61
|
return if serialization_result.nil?
|
59
62
|
|
60
|
-
start, finish,
|
63
|
+
start, finish, encoded_profile, profile_stats = serialization_result
|
61
64
|
@last_flush_finish_at = finish
|
62
65
|
|
63
66
|
if duration_below_threshold?(start, finish)
|
@@ -70,11 +73,13 @@ module Datadog
|
|
70
73
|
Flush.new(
|
71
74
|
start: start,
|
72
75
|
finish: finish,
|
73
|
-
|
74
|
-
pprof_data: compressed_pprof.to_s,
|
76
|
+
encoded_profile: encoded_profile,
|
75
77
|
code_provenance_file_name: Datadog::Profiling::Ext::Transport::HTTP::CODE_PROVENANCE_FILENAME,
|
76
78
|
code_provenance_data: uncompressed_code_provenance,
|
77
|
-
tags_as_array: Datadog::Profiling::TagBuilder.call(
|
79
|
+
tags_as_array: Datadog::Profiling::TagBuilder.call(
|
80
|
+
settings: Datadog.configuration,
|
81
|
+
profile_seq: sequence_tracker.get_next,
|
82
|
+
).to_a,
|
78
83
|
internal_metadata: internal_metadata.merge(
|
79
84
|
{
|
80
85
|
worker_stats: worker_stats,
|
@@ -11,22 +11,8 @@ module Datadog
|
|
11
11
|
|
12
12
|
module Transport
|
13
13
|
module HTTP
|
14
|
-
FORM_FIELD_TAG_ENV = "env"
|
15
|
-
FORM_FIELD_TAG_HOST = "host"
|
16
|
-
FORM_FIELD_TAG_LANGUAGE = "language"
|
17
|
-
FORM_FIELD_TAG_PID = "process_id"
|
18
14
|
FORM_FIELD_TAG_PROFILER_VERSION = "profiler_version"
|
19
|
-
FORM_FIELD_TAG_RUNTIME = "runtime"
|
20
|
-
FORM_FIELD_TAG_RUNTIME_ENGINE = "runtime_engine"
|
21
|
-
FORM_FIELD_TAG_RUNTIME_ID = "runtime-id"
|
22
|
-
FORM_FIELD_TAG_RUNTIME_PLATFORM = "runtime_platform"
|
23
|
-
FORM_FIELD_TAG_RUNTIME_VERSION = "runtime_version"
|
24
|
-
FORM_FIELD_TAG_SERVICE = "service"
|
25
|
-
FORM_FIELD_TAG_VERSION = "version"
|
26
|
-
TAG_GIT_REPOSITORY_URL = "git.repository_url"
|
27
|
-
TAG_GIT_COMMIT_SHA = "git.commit.sha"
|
28
15
|
|
29
|
-
PPROF_DEFAULT_FILENAME = "rubyprofile.pprof"
|
30
16
|
CODE_PROVENANCE_FILENAME = "code-provenance.json"
|
31
17
|
end
|
32
18
|
end
|
@@ -9,10 +9,9 @@ module Datadog
|
|
9
9
|
attr_reader \
|
10
10
|
:start,
|
11
11
|
:finish,
|
12
|
-
:
|
13
|
-
:pprof_data, # gzipped pprof bytes
|
12
|
+
:encoded_profile,
|
14
13
|
:code_provenance_file_name,
|
15
|
-
:code_provenance_data,
|
14
|
+
:code_provenance_data,
|
16
15
|
:tags_as_array,
|
17
16
|
:internal_metadata_json,
|
18
17
|
:info_json
|
@@ -20,8 +19,7 @@ module Datadog
|
|
20
19
|
def initialize(
|
21
20
|
start:,
|
22
21
|
finish:,
|
23
|
-
|
24
|
-
pprof_data:,
|
22
|
+
encoded_profile:,
|
25
23
|
code_provenance_file_name:,
|
26
24
|
code_provenance_data:,
|
27
25
|
tags_as_array:,
|
@@ -30,12 +28,11 @@ module Datadog
|
|
30
28
|
)
|
31
29
|
@start = start
|
32
30
|
@finish = finish
|
33
|
-
@
|
34
|
-
@pprof_data = pprof_data
|
31
|
+
@encoded_profile = encoded_profile
|
35
32
|
@code_provenance_file_name = code_provenance_file_name
|
36
33
|
@code_provenance_data = code_provenance_data
|
37
34
|
@tags_as_array = tags_as_array
|
38
|
-
@internal_metadata_json = JSON.
|
35
|
+
@internal_metadata_json = JSON.generate(internal_metadata)
|
39
36
|
@info_json = info_json
|
40
37
|
end
|
41
38
|
end
|
@@ -20,34 +20,16 @@ module Datadog
|
|
20
20
|
[:agent, agent_settings.url].freeze
|
21
21
|
end
|
22
22
|
|
23
|
-
status, result =
|
23
|
+
status, result = self.class._native_validate_exporter(exporter_configuration)
|
24
24
|
|
25
25
|
raise(ArgumentError, "Failed to initialize transport: #{result}") if status == :error
|
26
26
|
end
|
27
27
|
|
28
28
|
def export(flush)
|
29
|
-
status, result =
|
30
|
-
exporter_configuration
|
31
|
-
|
32
|
-
|
33
|
-
# why "timespec"?
|
34
|
-
# libdatadog represents time using POSIX's struct timespec, see
|
35
|
-
# https://www.gnu.org/software/libc/manual/html_node/Time-Types.html
|
36
|
-
# aka it represents the seconds part separate from the nanoseconds part
|
37
|
-
start_timespec_seconds: flush.start.tv_sec,
|
38
|
-
start_timespec_nanoseconds: flush.start.tv_nsec,
|
39
|
-
finish_timespec_seconds: flush.finish.tv_sec,
|
40
|
-
finish_timespec_nanoseconds: flush.finish.tv_nsec,
|
41
|
-
|
42
|
-
pprof_file_name: flush.pprof_file_name,
|
43
|
-
pprof_data: flush.pprof_data,
|
44
|
-
code_provenance_file_name: flush.code_provenance_file_name,
|
45
|
-
code_provenance_data: flush.code_provenance_data,
|
46
|
-
|
47
|
-
tags_as_array: flush.tags_as_array,
|
48
|
-
internal_metadata_json: flush.internal_metadata_json,
|
49
|
-
|
50
|
-
info_json: flush.info_json
|
29
|
+
status, result = self.class._native_do_export(
|
30
|
+
exporter_configuration,
|
31
|
+
@upload_timeout_milliseconds,
|
32
|
+
flush
|
51
33
|
)
|
52
34
|
|
53
35
|
if status == :ok
|
@@ -55,7 +37,7 @@ module Datadog
|
|
55
37
|
Datadog.logger.debug("Successfully reported profiling data")
|
56
38
|
true
|
57
39
|
else
|
58
|
-
Datadog.logger.
|
40
|
+
Datadog.logger.warn(
|
59
41
|
"Failed to report profiling data (#{config_without_api_key}): " \
|
60
42
|
"server returned unexpected HTTP #{result} status code"
|
61
43
|
)
|
@@ -65,7 +47,7 @@ module Datadog
|
|
65
47
|
false
|
66
48
|
end
|
67
49
|
else
|
68
|
-
Datadog.logger.
|
50
|
+
Datadog.logger.warn("Failed to report profiling data (#{config_without_api_key}): #{result}")
|
69
51
|
Datadog::Core::Telemetry::Logger.error("Failed to report profiling data")
|
70
52
|
false
|
71
53
|
end
|
@@ -77,42 +59,6 @@ module Datadog
|
|
77
59
|
site && api_key && Core::Environment::VariableHelpers.env_to_bool(Profiling::Ext::ENV_AGENTLESS, false)
|
78
60
|
end
|
79
61
|
|
80
|
-
def validate_exporter(exporter_configuration)
|
81
|
-
self.class._native_validate_exporter(exporter_configuration)
|
82
|
-
end
|
83
|
-
|
84
|
-
def do_export(
|
85
|
-
exporter_configuration:,
|
86
|
-
upload_timeout_milliseconds:,
|
87
|
-
start_timespec_seconds:,
|
88
|
-
start_timespec_nanoseconds:,
|
89
|
-
finish_timespec_seconds:,
|
90
|
-
finish_timespec_nanoseconds:,
|
91
|
-
pprof_file_name:,
|
92
|
-
pprof_data:,
|
93
|
-
code_provenance_file_name:,
|
94
|
-
code_provenance_data:,
|
95
|
-
tags_as_array:,
|
96
|
-
internal_metadata_json:,
|
97
|
-
info_json:
|
98
|
-
)
|
99
|
-
self.class._native_do_export(
|
100
|
-
exporter_configuration,
|
101
|
-
upload_timeout_milliseconds,
|
102
|
-
start_timespec_seconds,
|
103
|
-
start_timespec_nanoseconds,
|
104
|
-
finish_timespec_seconds,
|
105
|
-
finish_timespec_nanoseconds,
|
106
|
-
pprof_file_name,
|
107
|
-
pprof_data,
|
108
|
-
code_provenance_file_name,
|
109
|
-
code_provenance_data,
|
110
|
-
tags_as_array,
|
111
|
-
internal_metadata_json,
|
112
|
-
info_json,
|
113
|
-
)
|
114
|
-
end
|
115
|
-
|
116
62
|
def config_without_api_key
|
117
63
|
"#{exporter_configuration[0]}: #{exporter_configuration[1]}"
|
118
64
|
end
|
@@ -50,6 +50,8 @@ module Datadog
|
|
50
50
|
"Detected issue with profiler (#{failed_component} component), stopping profiling. " \
|
51
51
|
"See previous log messages for details."
|
52
52
|
)
|
53
|
+
Datadog::Core::Telemetry::Logger
|
54
|
+
.error("Detected issue with profiler (#{failed_component} component), stopping profiling")
|
53
55
|
|
54
56
|
# We explicitly not stop the crash tracker in this situation, under the assumption that, if a component failed,
|
55
57
|
# we're operating in a degraded state and crash tracking may still be helpful.
|
@@ -37,6 +37,7 @@ module Datadog
|
|
37
37
|
@exporter = exporter
|
38
38
|
@transport = transport
|
39
39
|
@profiler_failed = false
|
40
|
+
@stop_requested = false
|
40
41
|
|
41
42
|
# Workers::Async::Thread settings
|
42
43
|
self.fork_policy = fork_policy
|
@@ -67,6 +68,7 @@ module Datadog
|
|
67
68
|
"Cause: #{e.class.name} #{e.message} Location: #{Array(e.backtrace).first}"
|
68
69
|
)
|
69
70
|
on_failure_proc&.call
|
71
|
+
Datadog::Core::Telemetry::Logger.report(e, description: "Profiling::Scheduler thread error")
|
70
72
|
raise
|
71
73
|
ensure
|
72
74
|
Datadog.logger.debug("#flush was interrupted or failed before it could complete") if interrupted
|
@@ -88,7 +90,7 @@ module Datadog
|
|
88
90
|
end
|
89
91
|
|
90
92
|
def work_pending?
|
91
|
-
!profiler_failed && exporter.can_flush?
|
93
|
+
!profiler_failed && exporter.can_flush? && (run_loop? || !stop_requested?)
|
92
94
|
end
|
93
95
|
|
94
96
|
def reset_after_fork
|
@@ -132,14 +134,20 @@ module Datadog
|
|
132
134
|
begin
|
133
135
|
transport.export(flush)
|
134
136
|
rescue => e
|
135
|
-
Datadog.logger.
|
137
|
+
Datadog.logger.warn(
|
136
138
|
"Unable to report profile. Cause: #{e.class.name} #{e.message} Location: #{Array(e.backtrace).first}"
|
137
139
|
)
|
138
140
|
Datadog::Core::Telemetry::Logger.report(e, description: "Unable to report profile")
|
139
141
|
end
|
140
142
|
|
143
|
+
@stop_requested = !run_loop?
|
144
|
+
|
141
145
|
true
|
142
146
|
end
|
147
|
+
|
148
|
+
def stop_requested?
|
149
|
+
@stop_requested
|
150
|
+
end
|
143
151
|
end
|
144
152
|
end
|
145
153
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../core/utils/forking'
|
4
|
+
|
5
|
+
module Datadog
|
6
|
+
module Profiling
|
7
|
+
# Used to generate the `profile_seq` tag, which effectively counts how many profiles we've attempted to report
|
8
|
+
# from a given runtime-id.
|
9
|
+
#
|
10
|
+
# Note that the above implies a few things:
|
11
|
+
# 1. The sequence number only gets incremented when we decide to report a profile and create a `Flush` for it
|
12
|
+
# 2. The `SequenceTracker` must live across profiler reconfigurations and resets, since no matter how many
|
13
|
+
# profiler instances get created due to reconfiguration, the runtime-id is still the same, so the sequence number
|
14
|
+
# should be kept and not restarted from 0
|
15
|
+
# 3. The `SequenceTracker` must be reset after a fork, since the runtime-id will change, and we want to start
|
16
|
+
# counting from 0 again
|
17
|
+
#
|
18
|
+
# This is why this module is implemented as a singleton that we reuse, not as an instance that we recreate.
|
19
|
+
#
|
20
|
+
# Note that this module is not thread-safe, so it's up to the callers to make sure
|
21
|
+
# it's only used by a single thread at a time (which is what the `Profiling::Exporter`)
|
22
|
+
# is doing.
|
23
|
+
module SequenceTracker
|
24
|
+
class << self
|
25
|
+
include Core::Utils::Forking
|
26
|
+
|
27
|
+
def get_next
|
28
|
+
reset! unless defined?(@sequence_number)
|
29
|
+
after_fork! { reset! }
|
30
|
+
|
31
|
+
next_seq = @sequence_number
|
32
|
+
@sequence_number += 1
|
33
|
+
next_seq
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def reset!
|
39
|
+
@sequence_number = 0
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -23,7 +23,7 @@ module Datadog
|
|
23
23
|
# This isn't something we expect to happen normally, but because it would break the assumptions of the
|
24
24
|
# C-level mutexes (that there is a single serializer thread), we add it here as an extra safeguard against it
|
25
25
|
# accidentally happening.
|
26
|
-
@
|
26
|
+
@no_concurrent_serialize_mutex = Mutex.new
|
27
27
|
|
28
28
|
self.class._native_initialize(
|
29
29
|
self_instance: self,
|
@@ -60,31 +60,31 @@ module Datadog
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def serialize
|
63
|
-
status, result = @
|
63
|
+
status, result = @no_concurrent_serialize_mutex.synchronize { self.class._native_serialize(self) }
|
64
64
|
|
65
65
|
if status == :ok
|
66
|
-
start, finish,
|
66
|
+
start, finish, encoded_profile, profile_stats = result
|
67
67
|
|
68
68
|
Datadog.logger.debug { "Encoded profile covering #{start.iso8601} to #{finish.iso8601}" }
|
69
69
|
|
70
|
-
[start, finish,
|
70
|
+
[start, finish, encoded_profile, profile_stats]
|
71
71
|
else
|
72
72
|
error_message = result
|
73
73
|
|
74
|
-
Datadog.logger.
|
75
|
-
Datadog::Core::Telemetry::Logger.error("Failed to serialize profiling data")
|
74
|
+
Datadog.logger.warn("Failed to serialize profiling data: #{error_message}")
|
75
|
+
Datadog::Core::Telemetry::Logger.error("Failed to serialize profiling data (#{error_message})")
|
76
76
|
|
77
77
|
nil
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
81
|
def serialize!
|
82
|
-
status, result = @
|
82
|
+
status, result = @no_concurrent_serialize_mutex.synchronize { self.class._native_serialize(self) }
|
83
83
|
|
84
84
|
if status == :ok
|
85
|
-
_start, _finish,
|
85
|
+
_start, _finish, encoded_profile = result
|
86
86
|
|
87
|
-
|
87
|
+
encoded_profile
|
88
88
|
else
|
89
89
|
error_message = result
|
90
90
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative "../core/tag_builder"
|
3
4
|
require_relative "../core/utils"
|
4
|
-
require_relative "../core/environment/git"
|
5
5
|
|
6
6
|
module Datadog
|
7
7
|
module Profiling
|
@@ -11,49 +11,15 @@ module Datadog
|
|
11
11
|
|
12
12
|
def self.call(
|
13
13
|
settings:,
|
14
|
-
# Unified service tagging
|
15
|
-
env: settings.env,
|
16
|
-
service: settings.service,
|
17
|
-
version: settings.version,
|
18
14
|
# Other metadata
|
19
|
-
|
20
|
-
|
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
|
-
profiler_version: Core::Environment::Identity.gem_datadog_version,
|
25
|
-
runtime_engine: Core::Environment::Identity.lang_engine,
|
26
|
-
runtime_id: Core::Environment::Identity.id,
|
27
|
-
runtime_platform: Core::Environment::Identity.lang_platform,
|
28
|
-
runtime_version: Core::Environment::Identity.lang_version,
|
29
|
-
git_repository_url: Core::Environment::Git.git_repository_url,
|
30
|
-
git_commit_sha: Core::Environment::Git.git_commit_sha,
|
31
|
-
# User-provided tags
|
32
|
-
user_tags: settings.tags
|
15
|
+
profile_seq:,
|
16
|
+
profiler_version: Core::Environment::Identity.gem_datadog_version
|
33
17
|
)
|
34
|
-
|
35
|
-
# When changing or adding these, make sure they are kept in sync with
|
36
|
-
# https://docs.google.com/spreadsheets/d/1LOGMf4c4Avbtn36uZ2SWvhIGKRPLM1BoWkUP4JYj7hA/ (Datadog internal link)
|
37
|
-
FORM_FIELD_TAG_HOST => host,
|
38
|
-
FORM_FIELD_TAG_LANGUAGE => language,
|
39
|
-
FORM_FIELD_TAG_PID => pid,
|
18
|
+
hash = Core::TagBuilder.tags(settings).merge(
|
40
19
|
FORM_FIELD_TAG_PROFILER_VERSION => profiler_version,
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
FORM_FIELD_TAG_RUNTIME_PLATFORM => runtime_platform,
|
45
|
-
FORM_FIELD_TAG_RUNTIME_VERSION => runtime_version,
|
46
|
-
}
|
47
|
-
tags[FORM_FIELD_TAG_ENV] = env if env
|
48
|
-
tags[FORM_FIELD_TAG_SERVICE] = service if service
|
49
|
-
tags[FORM_FIELD_TAG_VERSION] = version if version
|
50
|
-
tags[TAG_GIT_REPOSITORY_URL] = git_repository_url if git_repository_url
|
51
|
-
tags[TAG_GIT_COMMIT_SHA] = git_commit_sha if git_commit_sha
|
52
|
-
|
53
|
-
# Make sure everything is an utf-8 string, to avoid encoding issues in native code/libddprof/further downstream
|
54
|
-
user_tags.merge(tags).map do |key, value|
|
55
|
-
[Datadog::Core::Utils.utf8_encode(key), Datadog::Core::Utils.utf8_encode(value)]
|
56
|
-
end.to_h
|
20
|
+
'profile_seq' => profile_seq.to_s,
|
21
|
+
)
|
22
|
+
Core::Utils.encode_tags(hash)
|
57
23
|
end
|
58
24
|
end
|
59
25
|
end
|
@@ -19,6 +19,7 @@ module Datadog
|
|
19
19
|
"Profiler extensions unavailable. Cause: #{e.class.name} #{e.message} " \
|
20
20
|
"Location: #{Array(e.backtrace).first}"
|
21
21
|
end
|
22
|
+
Datadog::Core::Telemetry::Logger.report(e, description: "Profiler extensions unavailable")
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
@@ -33,6 +34,7 @@ module Datadog
|
|
33
34
|
"Error during post-fork hooks. Cause: #{e.class.name} #{e.message} " \
|
34
35
|
"Location: #{Array(e.backtrace).first}"
|
35
36
|
end
|
37
|
+
Datadog::Core::Telemetry::Logger.report(e, description: "Error during post-fork hooks")
|
36
38
|
end
|
37
39
|
end
|
38
40
|
end
|
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'
|
@@ -153,6 +157,7 @@ module Datadog
|
|
153
157
|
require_relative 'profiling/native_extension'
|
154
158
|
require_relative 'profiling/tag_builder'
|
155
159
|
require_relative 'profiling/http_transport'
|
160
|
+
require_relative 'profiling/sequence_tracker'
|
156
161
|
|
157
162
|
replace_noop_allocation_count
|
158
163
|
|
@@ -5,8 +5,17 @@
|
|
5
5
|
#
|
6
6
|
# This file's path is private. Do not reference this file.
|
7
7
|
#
|
8
|
+
|
9
|
+
module Datadog
|
10
|
+
# This module handles conditional loading of single step auto-instrumentation,
|
11
|
+
# which enables Datadog tracing and profiling features when available.
|
12
|
+
module SingleStepInstrument
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
8
16
|
begin
|
9
17
|
require_relative 'auto_instrument'
|
18
|
+
Datadog::SingleStepInstrument::LOADED = true
|
10
19
|
rescue StandardError, LoadError => e
|
11
20
|
warn "Single step instrumentation failed: #{e.class}:#{e.message}\n\tSource:\n\t#{Array(e.backtrace).join("\n\t")}"
|
12
21
|
end
|
@@ -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
|