datadog 2.46.0 → 2.48.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 +56 -2
- data/LICENSE-3rdparty.csv +1 -0
- data/ext/datadog_profiling_native_extension/collectors_stack.c +143 -86
- data/ext/datadog_profiling_native_extension/collectors_stack.h +9 -1
- data/ext/datadog_profiling_native_extension/collectors_thread_context.c +6 -1
- data/ext/datadog_profiling_native_extension/extconf.rb +7 -13
- data/ext/datadog_profiling_native_extension/native_extension_helpers.rb +3 -3
- data/ext/datadog_profiling_native_extension/private_vm_api_access.c +67 -14
- data/ext/datadog_profiling_native_extension/private_vm_api_access.h +8 -1
- data/ext/datadog_profiling_native_extension/profiling.c +1 -1
- data/ext/libdatadog_api/extconf.rb +9 -7
- data/ext/libdatadog_api/trace_exporter.c +34 -7
- data/ext/libdatadog_extconf_helpers.rb +2 -2
- data/lib/datadog/ai_guard/component.rb +1 -1
- data/lib/datadog/ai_guard/contrib/rack/request_middleware.rb +1 -9
- data/lib/datadog/ai_guard/contrib/rails/patcher.rb +1 -1
- data/lib/datadog/ai_guard/contrib/ruby_llm/message_adapter.rb +1 -1
- data/lib/datadog/ai_guard/contrib/ruby_llm/redaction_change_set.rb +3 -3
- data/lib/datadog/ai_guard/evaluation/client.rb +3 -3
- data/lib/datadog/ai_guard/evaluation.rb +2 -2
- data/lib/datadog/ai_guard/http_client.rb +3 -2
- data/lib/datadog/ai_guard/redaction.rb +1 -1
- data/lib/datadog/appsec/api_security/endpoint_collection/rails_collector.rb +1 -1
- data/lib/datadog/appsec/assets/waf_rules/README.md +3 -3
- data/lib/datadog/appsec/assets/waf_rules/recommended.json +5366 -1517
- data/lib/datadog/appsec/assets/waf_rules/strict.json +2 -2
- data/lib/datadog/appsec/autoload.rb +1 -1
- data/lib/datadog/appsec/component.rb +1 -1
- data/lib/datadog/appsec/compressed_json.rb +1 -1
- data/lib/datadog/appsec/configuration.rb +3 -3
- data/lib/datadog/appsec/context.rb +1 -1
- data/lib/datadog/appsec/contrib/active_record/instrumentation.rb +11 -1
- data/lib/datadog/appsec/contrib/active_record/patcher.rb +12 -4
- data/lib/datadog/appsec/contrib/aws_lambda/gateway/watcher.rb +2 -2
- data/lib/datadog/appsec/contrib/aws_lambda/waf_addresses.rb +1 -1
- data/lib/datadog/appsec/contrib/devise/configuration.rb +1 -1
- data/lib/datadog/appsec/contrib/devise/patches/signin_tracking_patch.rb +1 -1
- data/lib/datadog/appsec/contrib/devise/patches/signup_tracking_patch.rb +1 -1
- data/lib/datadog/appsec/contrib/devise/tracking_middleware.rb +1 -1
- data/lib/datadog/appsec/contrib/excon/ssrf_detection_middleware.rb +1 -1
- data/lib/datadog/appsec/contrib/faraday/ssrf_detection_middleware.rb +1 -1
- data/lib/datadog/appsec/contrib/graphql/gateway/multiplex.rb +7 -7
- data/lib/datadog/appsec/contrib/graphql/gateway/watcher.rb +1 -1
- data/lib/datadog/appsec/contrib/rack/gateway/watcher.rb +3 -3
- data/lib/datadog/appsec/contrib/rack/request_middleware.rb +5 -5
- data/lib/datadog/appsec/contrib/rails/gateway/watcher.rb +31 -4
- data/lib/datadog/appsec/contrib/rails/patcher.rb +2 -2
- data/lib/datadog/appsec/contrib/rails/patches/render_to_body_patch.rb +8 -7
- data/lib/datadog/appsec/contrib/rest_client/request_ssrf_detection_patch.rb +1 -1
- data/lib/datadog/appsec/contrib/sinatra/gateway/watcher.rb +17 -5
- data/lib/datadog/appsec/contrib/sinatra/patcher.rb +1 -1
- data/lib/datadog/appsec/contrib/sinatra/patches/json_patch.rb +8 -7
- data/lib/datadog/appsec/metrics/collector.rb +5 -5
- data/lib/datadog/appsec/metrics/telemetry_exporter.rb +3 -3
- data/lib/datadog/appsec/monitor/gateway/watcher.rb +2 -2
- data/lib/datadog/appsec/processor/rule_loader.rb +1 -1
- data/lib/datadog/appsec/response.rb +1 -1
- data/lib/datadog/appsec/security_engine/engine.rb +8 -7
- data/lib/datadog/appsec/security_engine/runner.rb +2 -2
- data/lib/datadog/appsec/trace_keeper.rb +1 -1
- data/lib/datadog/appsec.rb +1 -1
- data/lib/datadog/core/configuration/agent_settings_resolver.rb +14 -13
- data/lib/datadog/core/configuration/agentless_settings_resolver.rb +2 -2
- data/lib/datadog/core/configuration/components.rb +12 -11
- data/lib/datadog/core/configuration/components_state.rb +8 -1
- data/lib/datadog/core/configuration/settings.rb +5 -2
- data/lib/datadog/core/configuration/supported_configurations.rb +3 -0
- data/lib/datadog/core/configuration.rb +2 -2
- data/lib/datadog/core/crashtracking/component.rb +1 -1
- data/lib/datadog/core/diagnostics/environment_logger.rb +1 -1
- data/lib/datadog/core/environment/cgroup.rb +2 -2
- data/lib/datadog/core/environment/container.rb +3 -3
- data/lib/datadog/core/metrics/client.rb +6 -6
- data/lib/datadog/core/process_discovery.rb +1 -1
- data/lib/datadog/core/remote/client.rb +44 -3
- data/lib/datadog/core/remote/dispatcher.rb +34 -3
- data/lib/datadog/core/remote/tie/tracing.rb +4 -3
- data/lib/datadog/core/remote/transport/http.rb +2 -2
- data/lib/datadog/core/runtime/metrics.rb +14 -14
- data/lib/datadog/core/semaphore.rb +3 -1
- data/lib/datadog/core/telemetry/event/app_started.rb +9 -9
- data/lib/datadog/core/telemetry/logger.rb +1 -1
- data/lib/datadog/core/telemetry/logging.rb +1 -1
- data/lib/datadog/core/telemetry/request.rb +9 -3
- data/lib/datadog/core/telemetry/transport/http.rb +2 -2
- data/lib/datadog/core/telemetry/worker.rb +1 -1
- data/lib/datadog/core/transport/http/adapters/net.rb +1 -1
- data/lib/datadog/core/transport/http/adapters/unix_socket.rb +1 -1
- data/lib/datadog/core/transport/http/builder.rb +1 -1
- data/lib/datadog/core/transport/http.rb +3 -3
- data/lib/datadog/core/utils/at_fork_monkey_patch.rb +2 -2
- data/lib/datadog/core/workers/async.rb +1 -1
- data/lib/datadog/core/workers/runtime_metrics.rb +2 -2
- data/lib/datadog/data_streams/pathway_context.rb +1 -1
- data/lib/datadog/data_streams/processor.rb +48 -27
- data/lib/datadog/data_streams/transport/http.rb +1 -1
- data/lib/datadog/data_streams.rb +16 -0
- data/lib/datadog/di/capture_expression_evaluator.rb +48 -11
- data/lib/datadog/di/component.rb +73 -2
- data/lib/datadog/di/configuration.rb +19 -0
- data/lib/datadog/di/contrib/active_record.rb +1 -1
- data/lib/datadog/di/el/compiler.rb +4 -4
- data/lib/datadog/di/el/evaluator.rb +247 -43
- data/lib/datadog/di/el/expression.rb +36 -6
- data/lib/datadog/di/error.rb +16 -0
- data/lib/datadog/di/guardrails_telemetry/reason.rb +3 -2
- data/lib/datadog/di/instrumenter.rb +39 -10
- data/lib/datadog/di/probe_notification_builder.rb +58 -10
- data/lib/datadog/di/probe_notifier_worker.rb +1 -1
- data/lib/datadog/di/remote.rb +46 -2
- data/lib/datadog/di/serializer.rb +47 -13
- data/lib/datadog/di.rb +27 -0
- data/lib/datadog/error_tracking/component.rb +1 -1
- data/lib/datadog/error_tracking/configuration.rb +1 -1
- data/lib/datadog/kit/appsec/events/v2.rb +6 -6
- data/lib/datadog/kit/appsec/events.rb +1 -1
- data/lib/datadog/kit/enable_core_dumps.rb +1 -1
- data/lib/datadog/kit/identity.rb +1 -1
- data/lib/datadog/open_feature/activation.rb +26 -1
- data/lib/datadog/open_feature/agentless/configuration_source.rb +94 -15
- data/lib/datadog/open_feature/component.rb +22 -2
- data/lib/datadog/open_feature/configuration/agentless_endpoint.rb +6 -0
- data/lib/datadog/open_feature/configuration.rb +10 -4
- data/lib/datadog/open_feature/evaluation_engine.rb +62 -4
- data/lib/datadog/open_feature/exposures/buffer.rb +4 -0
- data/lib/datadog/open_feature/exposures/reporter.rb +17 -4
- data/lib/datadog/open_feature/exposures/worker.rb +37 -6
- data/lib/datadog/open_feature/flag_evaluation/aggregator.rb +5 -5
- data/lib/datadog/open_feature/flag_evaluation/writer.rb +1 -1
- data/lib/datadog/open_feature/hooks/debug_logging_hook.rb +56 -0
- data/lib/datadog/open_feature/hooks/evaluation_telemetry_opt_out_hook.rb +25 -0
- data/lib/datadog/open_feature/hooks/span_enrichment_hook.rb +2 -2
- data/lib/datadog/open_feature/metrics/flag_eval_metrics.rb +1 -1
- data/lib/datadog/open_feature/native_evaluator.rb +1 -1
- data/lib/datadog/open_feature/noop_evaluator.rb +1 -1
- data/lib/datadog/open_feature/provider.rb +69 -12
- data/lib/datadog/open_feature/remote.rb +8 -1
- data/lib/datadog/open_feature/resolution_details.rb +2 -2
- data/lib/datadog/open_feature/transport.rb +6 -6
- data/lib/datadog/opentelemetry/api/context.rb +3 -3
- data/lib/datadog/opentelemetry/logs.rb +5 -5
- data/lib/datadog/opentelemetry/metrics.rb +3 -3
- data/lib/datadog/opentelemetry/sdk/propagator.rb +3 -3
- data/lib/datadog/opentelemetry/sdk/span_processor.rb +2 -2
- data/lib/datadog/opentelemetry/sdk/trace/span.rb +1 -1
- data/lib/datadog/profiling/collectors/code_provenance.rb +3 -3
- data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +4 -4
- data/lib/datadog/profiling/collectors/idle_sampling_helper.rb +1 -1
- data/lib/datadog/profiling/collectors/info.rb +37 -6
- data/lib/datadog/profiling/collectors/thread_context.rb +1 -1
- data/lib/datadog/profiling/component.rb +41 -39
- data/lib/datadog/profiling/exporter.rb +4 -6
- data/lib/datadog/profiling/http_transport.rb +3 -3
- data/lib/datadog/profiling/profiler.rb +2 -2
- data/lib/datadog/profiling/scheduler.rb +2 -2
- data/lib/datadog/profiling/tag_builder.rb +1 -1
- data/lib/datadog/symbol_database/extractor.rb +8 -8
- data/lib/datadog/symbol_database/uploader.rb +1 -1
- data/lib/datadog/tracing/buffer.rb +3 -3
- data/lib/datadog/tracing/client_ip.rb +1 -1
- data/lib/datadog/tracing/component.rb +15 -10
- data/lib/datadog/tracing/configuration/dynamic/option.rb +2 -2
- data/lib/datadog/tracing/configuration/ext.rb +2 -0
- data/lib/datadog/tracing/configuration/settings.rb +14 -3
- data/lib/datadog/tracing/context.rb +1 -1
- data/lib/datadog/tracing/context_provider.rb +8 -0
- data/lib/datadog/tracing/contrib/action_cable/instrumentation.rb +2 -2
- data/lib/datadog/tracing/contrib/active_job/data_streams.rb +27 -2
- data/lib/datadog/tracing/contrib/active_record/configuration/resolver.rb +2 -2
- data/lib/datadog/tracing/contrib/active_record/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/active_record/utils.rb +1 -1
- data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +1 -1
- data/lib/datadog/tracing/contrib/active_support/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/active_support/notifications/subscriber.rb +2 -2
- data/lib/datadog/tracing/contrib/active_support/notifications/subscription.rb +2 -2
- data/lib/datadog/tracing/contrib/aws/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/aws/instrumentation.rb +1 -1
- data/lib/datadog/tracing/contrib/dalli/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/dalli/instrumentation.rb +1 -1
- data/lib/datadog/tracing/contrib/delayed_job/plugin.rb +2 -2
- data/lib/datadog/tracing/contrib/elasticsearch/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/elasticsearch/patcher.rb +3 -3
- data/lib/datadog/tracing/contrib/ethon/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/ethon/easy_patch.rb +17 -12
- data/lib/datadog/tracing/contrib/ethon/multi_patch.rb +1 -1
- data/lib/datadog/tracing/contrib/excon/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/excon/middleware.rb +16 -9
- data/lib/datadog/tracing/contrib/faraday/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/faraday/middleware.rb +14 -8
- data/lib/datadog/tracing/contrib/grape/endpoint.rb +4 -4
- data/lib/datadog/tracing/contrib/graphql/patcher.rb +1 -1
- data/lib/datadog/tracing/contrib/graphql/unified_trace.rb +3 -3
- data/lib/datadog/tracing/contrib/grpc/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/client.rb +2 -2
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/server.rb +1 -1
- data/lib/datadog/tracing/contrib/grpc.rb +1 -1
- data/lib/datadog/tracing/contrib/hanami/action_tracer.rb +1 -1
- data/lib/datadog/tracing/contrib/hanami/plugin.rb +1 -1
- data/lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb +1 -1
- data/lib/datadog/tracing/contrib/hanami/router_tracing.rb +1 -1
- data/lib/datadog/tracing/contrib/http/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/http/instrumentation.rb +21 -6
- data/lib/datadog/tracing/contrib/http.rb +1 -1
- data/lib/datadog/tracing/contrib/httpclient/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/httpclient/instrumentation.rb +14 -8
- data/lib/datadog/tracing/contrib/httprb/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/httprb/instrumentation.rb +14 -8
- data/lib/datadog/tracing/contrib/kafka/instrumentation/consumer.rb +2 -2
- data/lib/datadog/tracing/contrib/kafka/instrumentation/producer.rb +2 -2
- data/lib/datadog/tracing/contrib/karafka/monitor.rb +1 -1
- data/lib/datadog/tracing/contrib/karafka/patcher.rb +1 -1
- data/lib/datadog/tracing/contrib/karafka.rb +1 -1
- data/lib/datadog/tracing/contrib/lograge/patcher.rb +1 -1
- data/lib/datadog/tracing/contrib/mongodb/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/mongodb/parsers.rb +1 -1
- data/lib/datadog/tracing/contrib/mongodb/subscribers.rb +1 -1
- data/lib/datadog/tracing/contrib/mysql2/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +3 -3
- data/lib/datadog/tracing/contrib/opensearch/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/opensearch/patcher.rb +3 -3
- data/lib/datadog/tracing/contrib/pg/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/pg/instrumentation.rb +4 -4
- data/lib/datadog/tracing/contrib/presto/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/presto/instrumentation.rb +4 -4
- data/lib/datadog/tracing/contrib/propagation/sql_comment.rb +1 -1
- data/lib/datadog/tracing/contrib/que/tracer.rb +1 -1
- data/lib/datadog/tracing/contrib/racecar/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/racecar/events/batch.rb +1 -1
- data/lib/datadog/tracing/contrib/racecar/events/message.rb +1 -1
- data/lib/datadog/tracing/contrib/rack/middlewares.rb +3 -3
- data/lib/datadog/tracing/contrib/rack/patcher.rb +1 -1
- data/lib/datadog/tracing/contrib/rails/framework.rb +7 -7
- data/lib/datadog/tracing/contrib/rails/log_injection.rb +1 -1
- data/lib/datadog/tracing/contrib/rails/runner.rb +4 -4
- data/lib/datadog/tracing/contrib/redis/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/redis/quantize.rb +1 -1
- data/lib/datadog/tracing/contrib/redis/tags.rb +1 -1
- data/lib/datadog/tracing/contrib/rest_client/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +17 -10
- data/lib/datadog/tracing/contrib/sequel/database.rb +1 -1
- data/lib/datadog/tracing/contrib/sequel/dataset.rb +1 -1
- data/lib/datadog/tracing/contrib/shoryuken/tracer.rb +1 -1
- data/lib/datadog/tracing/contrib/sidekiq/client_tracer.rb +2 -2
- data/lib/datadog/tracing/contrib/sidekiq/server_tracer.rb +2 -2
- data/lib/datadog/tracing/contrib/sidekiq.rb +1 -1
- data/lib/datadog/tracing/contrib/sinatra/tracer_middleware.rb +1 -1
- data/lib/datadog/tracing/contrib/status_range_env_parser.rb +1 -1
- data/lib/datadog/tracing/contrib/sucker_punch/instrumentation.rb +1 -1
- data/lib/datadog/tracing/contrib/trilogy/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/trilogy/instrumentation.rb +3 -3
- data/lib/datadog/tracing/contrib/utils/quantization/http.rb +102 -0
- data/lib/datadog/tracing/contrib/waterdrop/middleware.rb +2 -2
- data/lib/datadog/tracing/contrib/waterdrop.rb +1 -1
- data/lib/datadog/tracing/diagnostics/environment_logger.rb +1 -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 +3 -3
- data/lib/datadog/tracing/distributed/datadog.rb +3 -3
- data/lib/datadog/tracing/distributed/propagation.rb +7 -7
- data/lib/datadog/tracing/distributed/trace_context.rb +1 -1
- data/lib/datadog/tracing/distributed/trace_state/open_telemetry.rb +1 -1
- data/lib/datadog/tracing/otel_thread_context.rb +3 -3
- data/lib/datadog/tracing/pipeline.rb +1 -1
- data/lib/datadog/tracing/remote.rb +50 -19
- data/lib/datadog/tracing/sampling/priority_sampler.rb +1 -1
- data/lib/datadog/tracing/sampling/rule.rb +1 -1
- data/lib/datadog/tracing/sampling/rule_sampler.rb +1 -1
- data/lib/datadog/tracing/sampling/span/rule_parser.rb +2 -2
- data/lib/datadog/tracing/span_operation.rb +1 -1
- data/lib/datadog/tracing/trace_digest.rb +1 -1
- data/lib/datadog/tracing/trace_operation.rb +6 -6
- data/lib/datadog/tracing/tracer.rb +6 -6
- data/lib/datadog/tracing/transport/http/telemetry.rb +1 -1
- data/lib/datadog/tracing/transport/http.rb +2 -2
- data/lib/datadog/tracing/transport/io.rb +1 -1
- data/lib/datadog/tracing/transport/native.rb +3 -3
- data/lib/datadog/tracing/transport/statistics.rb +2 -2
- data/lib/datadog/tracing/transport/telemetry.rb +3 -1
- data/lib/datadog/tracing/transport/trace_formatter.rb +12 -12
- data/lib/datadog/tracing/transport/traces.rb +1 -1
- data/lib/datadog/tracing/utils.rb +1 -1
- data/lib/datadog/tracing/workers.rb +1 -1
- data/lib/datadog/version.rb +1 -1
- metadata +9 -8
- data/lib/datadog/appsec/utils/hash_coercion.rb +0 -23
|
@@ -315,21 +315,65 @@ VALUE thread_name_for(VALUE thread) {
|
|
|
315
315
|
return thread_struct_from_object(thread)->name;
|
|
316
316
|
}
|
|
317
317
|
|
|
318
|
-
// This test
|
|
319
|
-
// the
|
|
318
|
+
// This test validates the layout of the rb_thread_t structure. Because the fields we check are near the end of
|
|
319
|
+
// the structure, if somehow we can't read the values we set, this probably means we're getting the structure wrong
|
|
320
320
|
// and we should stop immediately (this includes covering the use of `stat_insn_usage` on Ruby <= 3.2).
|
|
321
321
|
//
|
|
322
322
|
// One example where this happens is in patches such as
|
|
323
323
|
// https://github.com/gitlabhq/omnibus-gitlab/blob/master/config/patches/ruby/thread-memory-allocations-3.2.patch
|
|
324
|
-
// that add items to the structure and thus shift its
|
|
325
|
-
|
|
326
|
-
VALUE thread =
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
324
|
+
// that add items to the structure and thus shift its fields from where we expect.
|
|
325
|
+
static VALUE self_test_thread_struct_in_thread(DDTRACE_UNUSED void *unused) {
|
|
326
|
+
VALUE thread = rb_thread_current();
|
|
327
|
+
rb_thread_t *thread_struct = thread_struct_from_object(thread);
|
|
328
|
+
|
|
329
|
+
// Without a root fiber, Ruby includes the VM stack in the thread's reported size. Calling rb_fiber_current()
|
|
330
|
+
// creates the root fiber, so Ruby accounts for the stack under that fiber instead, leaving it out of thread size.
|
|
331
|
+
VALUE fiber = rb_fiber_current();
|
|
332
|
+
|
|
333
|
+
// Check size first, when possible, to avoid out-of-bounds field reads if Ruby's structure is smaller than we expect.
|
|
334
|
+
// For a new thread with a root fiber + no thread-local keys, we expect the reported size to be exactly the
|
|
335
|
+
// same as `rb_thread_t`
|
|
336
|
+
if (RARRAY_LEN(rb_funcall(thread, rb_intern("keys"), 0)) == 0) {
|
|
337
|
+
size_t actual_size = private_vm_api_global.thread_data_type->function.dsize(thread_struct);
|
|
338
|
+
if (actual_size != sizeof(rb_thread_t)) {
|
|
339
|
+
return rb_sprintf("size mismatch (Ruby reports %zu bytes, profiler expects %zu)", actual_size, sizeof(rb_thread_t));
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
if (thread_struct->root_fiber != DATA_PTR(fiber)) {
|
|
344
|
+
return rb_str_new_cstr("root_fiber does not match the current fiber");
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// Are we reading the name from the right place?
|
|
348
|
+
VALUE name = rb_obj_freeze(rb_str_new_cstr("dd-prof-test"));
|
|
349
|
+
rb_funcall(thread, rb_intern("name="), 1, name);
|
|
350
|
+
// We check for rb_method_basic_definition_p to avoid the issue in https://github.com/DataDog/dd-trace-rb/issues/6582:
|
|
351
|
+
// If `Thread#name` gets redefined, we fall back to the next steps, rather than failing the self-test.
|
|
352
|
+
// (This means we don't block users of the `semantic_logger` gem from profiling)
|
|
353
|
+
if (thread_struct->name != name && rb_method_basic_definition_p(rb_cThread, rb_intern("name"))) {
|
|
354
|
+
return rb_str_new_cstr("name does not match the assigned name");
|
|
332
355
|
}
|
|
356
|
+
|
|
357
|
+
#ifdef HAVE_RB_EXT_RACTOR_SAFE
|
|
358
|
+
bool original_ractor_safe = thread_struct->ext_config.ractor_safe;
|
|
359
|
+
rb_ext_ractor_safe(!original_ractor_safe);
|
|
360
|
+
if (thread_struct->ext_config.ractor_safe != !original_ractor_safe) {
|
|
361
|
+
return rb_str_new_cstr("ext_config.ractor_safe did not change after toggling it");
|
|
362
|
+
}
|
|
363
|
+
rb_ext_ractor_safe(original_ractor_safe);
|
|
364
|
+
if (thread_struct->ext_config.ractor_safe != original_ractor_safe) {
|
|
365
|
+
return rb_str_new_cstr("ext_config.ractor_safe did not match after restoring it");
|
|
366
|
+
}
|
|
367
|
+
#endif
|
|
368
|
+
|
|
369
|
+
return Qnil;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
void self_test_thread_struct(void) {
|
|
373
|
+
// We do this in a separate thread to isolate any of the changes we make
|
|
374
|
+
VALUE error = rb_funcall(rb_thread_create(self_test_thread_struct_in_thread, NULL), rb_intern("value"), 0);
|
|
375
|
+
|
|
376
|
+
if (!NIL_P(error)) rb_raise(rb_eRuntimeError, "rb_thread_t self-test failed: %"PRIsVALUE, error);
|
|
333
377
|
}
|
|
334
378
|
|
|
335
379
|
// -----------------------------------------------------------------------------
|
|
@@ -664,6 +708,7 @@ int ddtrace_rb_profile_frames(VALUE thread, int start, int limit, frame_info *st
|
|
|
664
708
|
stack_buffer[i].as.ruby_frame.iseq = iseq;
|
|
665
709
|
stack_buffer[i].as.ruby_frame.caching_pc = (void *) pc;
|
|
666
710
|
stack_buffer[i].cme = cme;
|
|
711
|
+
stack_buffer[i].cached_name_len = 0;
|
|
667
712
|
|
|
668
713
|
// The topmost frame may not have an updated PC because the JIT
|
|
669
714
|
// may not have set one. The JIT compiler will update the PC
|
|
@@ -699,6 +744,7 @@ int ddtrace_rb_profile_frames(VALUE thread, int start, int limit, frame_info *st
|
|
|
699
744
|
}
|
|
700
745
|
|
|
701
746
|
stack_buffer[i].cme = cme;
|
|
747
|
+
stack_buffer[i].cached_name_len = 0;
|
|
702
748
|
stack_buffer[i].is_ruby_frame = false;
|
|
703
749
|
i++;
|
|
704
750
|
}
|
|
@@ -1036,15 +1082,22 @@ static bool is_metaclass(VALUE mod, VALUE* attached) {
|
|
|
1036
1082
|
}
|
|
1037
1083
|
|
|
1038
1084
|
VALUE ddtrace_alloc_free_rb_mod_name(VALUE mod) {
|
|
1039
|
-
|
|
1085
|
+
// Reading the field is what rb_mod_name() does (MRI: classname()), minus the cross-library call, which shows up in
|
|
1086
|
+
// profiles as we do this for every frame. See has_permanent_classpath() below for why RCLASS_EXT_PRIME.
|
|
1087
|
+
#if defined(RCLASS_EXT_PRIME) // 4.0+
|
|
1088
|
+
VALUE name = RCLASS_EXT_PRIME(mod)->classpath;
|
|
1089
|
+
#elif defined(HAVE_PERMANENT_CLASSPATH) // 3.3 - 3.4
|
|
1090
|
+
VALUE name = RCLASS_EXT(mod)->classpath;
|
|
1091
|
+
#elif defined(NO_ALLOC_FREE_MOD_NAME) // 2.6 and older
|
|
1040
1092
|
VALUE name = rb_attr_get(mod, rb_intern("__classpath__"));
|
|
1041
|
-
#else
|
|
1093
|
+
#else // 2.7 - 3.2
|
|
1042
1094
|
VALUE name = rb_mod_name(mod);
|
|
1043
1095
|
#endif
|
|
1096
|
+
// `classpath` is Qfalse, not Qnil, for a module that has no name.
|
|
1044
1097
|
// While Module#const_set rejects empty strings,
|
|
1045
1098
|
// an empty String is possible if `rb_const_set(mod, "", val)` was used
|
|
1046
1099
|
// but that's not understandable so consider those anonymous too.
|
|
1047
|
-
if (name == Qnil || RSTRING_LEN(name) == 0) {
|
|
1100
|
+
if (name == Qfalse || name == Qnil || RSTRING_LEN(name) == 0) {
|
|
1048
1101
|
return Qnil;
|
|
1049
1102
|
} else {
|
|
1050
1103
|
return name;
|
|
@@ -1136,7 +1189,7 @@ static ssize_t calculate_iseq_label(VALUE owner, const rb_iseq_t *iseq, char *bu
|
|
|
1136
1189
|
// We use "Foo#bar (block)" because it's much faster and looks better in the UI.
|
|
1137
1190
|
const rb_iseq_t* method_iseq = ISEQ_BODY(iseq)->local_iseq;
|
|
1138
1191
|
|
|
1139
|
-
static const char suffix[] =
|
|
1192
|
+
static const char suffix[] = DDTRACE_BLOCK_SUFFIX;
|
|
1140
1193
|
size_t suffix_len = sizeof(suffix) - 1;
|
|
1141
1194
|
|
|
1142
1195
|
// Only use the result if there is enough space for both parts
|
|
@@ -34,6 +34,10 @@ typedef struct {
|
|
|
34
34
|
int line;
|
|
35
35
|
} ruby_frame;
|
|
36
36
|
} as;
|
|
37
|
+
// Length of the frame name cached for this slot in `sampling_buffer`, or 0 when there's none.
|
|
38
|
+
// ddtrace_rb_profile_frames() clears it when it replaces this frame, so a non-zero length always describes the
|
|
39
|
+
// cme and iseq currently here.
|
|
40
|
+
uint8_t cached_name_len;
|
|
37
41
|
bool is_ruby_frame : 1;
|
|
38
42
|
bool same_frame : 1;
|
|
39
43
|
} frame_info;
|
|
@@ -48,7 +52,7 @@ uint64_t native_thread_id_for(VALUE thread);
|
|
|
48
52
|
void ddtrace_thread_list(VALUE result_array);
|
|
49
53
|
bool is_thread_alive(VALUE thread);
|
|
50
54
|
VALUE thread_name_for(VALUE thread);
|
|
51
|
-
void
|
|
55
|
+
void self_test_thread_struct(void);
|
|
52
56
|
|
|
53
57
|
int ddtrace_rb_profile_frames(VALUE thread, int start, int limit, frame_info *stack_buffer);
|
|
54
58
|
|
|
@@ -102,6 +106,9 @@ VALUE ddtrace_alloc_free_rb_mod_name(VALUE mod);
|
|
|
102
106
|
// if the module does not have a permanent name (e.g. `#<Module:0x0123>::Foo`).
|
|
103
107
|
VALUE ddtrace_permanent_mod_name(VALUE mod);
|
|
104
108
|
|
|
109
|
+
// Suffix ddtrace_location_label() adds to blocks, e.g. "Foo#bar (block)"
|
|
110
|
+
#define DDTRACE_BLOCK_SUFFIX " (block)"
|
|
111
|
+
|
|
105
112
|
ssize_t ddtrace_location_label(const rb_callable_method_entry_t *cme, const rb_iseq_t *iseq, char *buf, size_t buf_size);
|
|
106
113
|
VALUE ddtrace_location_base_label(const rb_callable_method_entry_t *cme, const rb_iseq_t *iseq);
|
|
107
114
|
void* ddtrace_cme_cfunc_func(const rb_callable_method_entry_t *cme);
|
|
@@ -107,7 +107,7 @@ void DDTRACE_EXPORT Init_datadog_profiling_native_extension(void) {
|
|
|
107
107
|
|
|
108
108
|
static VALUE native_working_p(DDTRACE_UNUSED VALUE _self) {
|
|
109
109
|
private_vm_api_access_self_test();
|
|
110
|
-
|
|
110
|
+
self_test_thread_struct();
|
|
111
111
|
self_test_clock_id();
|
|
112
112
|
self_test_current_fiber_for();
|
|
113
113
|
self_test_mn_enabled();
|
|
@@ -6,7 +6,7 @@ require_relative "../libdatadog_extconf_helpers"
|
|
|
6
6
|
|
|
7
7
|
def skip_building_extension!(reason)
|
|
8
8
|
$stderr.puts(
|
|
9
|
-
"WARN: Skipping build of libdatadog_api (#{reason}). Some functionality will not be available."
|
|
9
|
+
"WARN: Skipping build of libdatadog_api (#{reason}). Some functionality will not be available.",
|
|
10
10
|
)
|
|
11
11
|
|
|
12
12
|
fail_install_if_missing_extension = ENV["DD_FAIL_INSTALL_IF_MISSING_EXTENSION"].to_s.strip.downcase == "true"
|
|
@@ -47,12 +47,14 @@ append_cflags "-Werror" if ENV["DATADOG_GEM_CI"] == "true"
|
|
|
47
47
|
# header lands upstream in libdatadog/libdatadog-rb. Remove this once that ships.
|
|
48
48
|
append_cflags "-Wno-error=typedef-redefinition" if ENV["DATADOG_GEM_CI"] == "true"
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
unless try_cflags("-std=gnu11")
|
|
51
|
+
skip_building_extension!(
|
|
52
|
+
"your C compiler does not support C11 (-std=gnu11). " \
|
|
53
|
+
"This issue can be fixed by upgrading to a later version of your " \
|
|
54
|
+
"operating system image or compiler.",
|
|
55
|
+
)
|
|
56
|
+
end
|
|
57
|
+
$CFLAGS += " -std=gnu11"
|
|
56
58
|
|
|
57
59
|
# Allow defining variables at any point in a function
|
|
58
60
|
append_cflags "-Wno-declaration-after-statement"
|
|
@@ -1692,6 +1692,9 @@ static int check_if_pending_exception(void) {
|
|
|
1692
1692
|
* On success returns [Response(ok: true, trace_count: N)].
|
|
1693
1693
|
* On error returns [Response(ok: false, ...)].
|
|
1694
1694
|
*
|
|
1695
|
+
* The optional block receives one observation Hash: the native report, or
|
|
1696
|
+
* cancelled drops when an interrupt prevented the native send from running.
|
|
1697
|
+
*
|
|
1695
1698
|
* The chunk-building loop calls into Ruby (ENFORCE_TYPE,
|
|
1696
1699
|
* convert_ruby_span_to_rust) which may raise. We use rb_ensure so
|
|
1697
1700
|
* that the Rust-allocated chunks are freed if an exception fires
|
|
@@ -1704,21 +1707,39 @@ typedef struct {
|
|
|
1704
1707
|
VALUE traces;
|
|
1705
1708
|
VALUE native_events_supported;
|
|
1706
1709
|
long trace_count;
|
|
1710
|
+
size_t span_count;
|
|
1707
1711
|
raw_span_owner span_owner;
|
|
1708
1712
|
ddog_TracerTraceChunks *chunks; /* NULL after send consumes it */
|
|
1709
1713
|
ddog_TraceExporterResponse *response;
|
|
1710
1714
|
} send_traces_ctx;
|
|
1711
1715
|
|
|
1712
1716
|
typedef struct {
|
|
1713
|
-
const ddog_TraceExporterObservations *report;
|
|
1717
|
+
const ddog_TraceExporterObservations *report; /* NULL when the send never ran */
|
|
1718
|
+
size_t cancelled_chunks;
|
|
1719
|
+
size_t cancelled_spans;
|
|
1720
|
+
} send_outcome;
|
|
1721
|
+
|
|
1722
|
+
typedef struct {
|
|
1723
|
+
const send_outcome *outcome;
|
|
1714
1724
|
VALUE block;
|
|
1715
1725
|
} observations_callback_args;
|
|
1716
1726
|
|
|
1727
|
+
/* Only for chunks never handed to an HTTP attempt: a cancelled in-flight
|
|
1728
|
+
* request may still have been received, so it must not be reported here. */
|
|
1729
|
+
static void add_cancelled_drop(VALUE values, size_t chunks, size_t spans) {
|
|
1730
|
+
if (chunks == 0) return;
|
|
1731
|
+
rb_hash_aset(values, ID2SYM(rb_intern_const("chunks_dropped_cancelled")), SIZET2NUM(chunks));
|
|
1732
|
+
if (spans == 0) return;
|
|
1733
|
+
rb_hash_aset(values, ID2SYM(rb_intern_const("spans_dropped_cancelled")), SIZET2NUM(spans));
|
|
1734
|
+
VALUE enqueued = ID2SYM(rb_intern_const("spans_enqueued_for_serialization"));
|
|
1735
|
+
rb_hash_aset(values, enqueued, ULL2NUM(NUM2ULL(rb_hash_lookup2(values, enqueued, INT2FIX(0))) + spans));
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1717
1738
|
static VALUE yield_observations(VALUE arg) {
|
|
1718
1739
|
observations_callback_args *callback = (observations_callback_args *)arg;
|
|
1719
|
-
const ddog_TraceExporterObservations *report = callback->report;
|
|
1740
|
+
const ddog_TraceExporterObservations *report = callback->outcome->report;
|
|
1720
1741
|
VALUE values = rb_hash_new();
|
|
1721
|
-
#define ADD_OBSERVATION(field) if (report->field > 0) rb_hash_aset(values, ID2SYM(rb_intern_const(#field)), ULL2NUM(report->field))
|
|
1742
|
+
#define ADD_OBSERVATION(field) if (report != NULL && report->field > 0) rb_hash_aset(values, ID2SYM(rb_intern_const(#field)), ULL2NUM(report->field))
|
|
1722
1743
|
ADD_OBSERVATION(requests_count);
|
|
1723
1744
|
ADD_OBSERVATION(errors_network);
|
|
1724
1745
|
ADD_OBSERVATION(errors_timeout);
|
|
@@ -1733,6 +1754,7 @@ static VALUE yield_observations(VALUE arg) {
|
|
|
1733
1754
|
ADD_OBSERVATION(responses_count);
|
|
1734
1755
|
ADD_OBSERVATION(status_code);
|
|
1735
1756
|
#undef ADD_OBSERVATION
|
|
1757
|
+
add_cancelled_drop(values, callback->outcome->cancelled_chunks, callback->outcome->cancelled_spans);
|
|
1736
1758
|
return rb_proc_call_with_block(callback->block, 1, &values, Qnil);
|
|
1737
1759
|
}
|
|
1738
1760
|
|
|
@@ -1751,7 +1773,7 @@ static VALUE protected_observations(RB_BLOCK_CALL_FUNC_ARGLIST(yielded, arg)) {
|
|
|
1751
1773
|
|
|
1752
1774
|
static VALUE forward_observations(VALUE arg) {
|
|
1753
1775
|
observations_callback_args callback = {
|
|
1754
|
-
.
|
|
1776
|
+
.outcome = (const send_outcome *)arg,
|
|
1755
1777
|
.block = rb_block_proc(),
|
|
1756
1778
|
};
|
|
1757
1779
|
/* Deliver fresh interrupts after the callback's StandardError rescue has ended. */
|
|
@@ -1785,6 +1807,7 @@ static VALUE build_and_send_traces(VALUE arg) {
|
|
|
1785
1807
|
ENFORCE_TYPE(chunk_spans, T_ARRAY);
|
|
1786
1808
|
|
|
1787
1809
|
long span_count = RARRAY_LEN(chunk_spans);
|
|
1810
|
+
ctx->span_count += (size_t)span_count;
|
|
1788
1811
|
/* Propagate a begin_chunk failure instead of swallowing it: continuing
|
|
1789
1812
|
* would build an incomplete payload and still report success. rb_ensure
|
|
1790
1813
|
* frees chunks on the raise. Today this only fails for an absurd
|
|
@@ -1856,13 +1879,17 @@ static VALUE build_and_send_traces(VALUE arg) {
|
|
|
1856
1879
|
if (!pending_exception) {
|
|
1857
1880
|
pending_exception = check_if_pending_exception();
|
|
1858
1881
|
}
|
|
1859
|
-
if (
|
|
1882
|
+
if (rb_block_given_p()) {
|
|
1883
|
+
/* A send that never ran left only an interrupt, and the chunks are freed unsent. */
|
|
1884
|
+
send_outcome outcome = args.send_ran
|
|
1885
|
+
? (send_outcome){.report = &args.observations}
|
|
1886
|
+
: (send_outcome){.cancelled_chunks = (size_t)ctx->trace_count, .cancelled_spans = ctx->span_count};
|
|
1860
1887
|
if (pending_exception) {
|
|
1861
1888
|
/* rb_ensure preserves Thread#kill's fatal sentinel, which rb_set_errinfo cannot restore. */
|
|
1862
1889
|
rb_ensure(rethrow_interrupt, INT2FIX(pending_exception),
|
|
1863
|
-
ensure_observations, (VALUE)&
|
|
1890
|
+
ensure_observations, (VALUE)&outcome);
|
|
1864
1891
|
} else {
|
|
1865
|
-
forward_observations((VALUE)&
|
|
1892
|
+
forward_observations((VALUE)&outcome);
|
|
1866
1893
|
}
|
|
1867
1894
|
}
|
|
1868
1895
|
if (pending_exception) {
|
|
@@ -11,7 +11,7 @@ module Datadog
|
|
|
11
11
|
module LibdatadogExtconfHelpers
|
|
12
12
|
# Used to make sure the correct gem version gets loaded, as extconf.rb does not get run with "bundle exec" and thus
|
|
13
13
|
# may see multiple libdatadog versions. See https://github.com/DataDog/dd-trace-rb/pull/2531 for the horror story.
|
|
14
|
-
LIBDATADOG_VERSION = "~> 46.
|
|
14
|
+
LIBDATADOG_VERSION = "~> 46.1.0.1.1"
|
|
15
15
|
|
|
16
16
|
# Used as an workaround for a limitation with how dynamic linking works in environments where the datadog gem and
|
|
17
17
|
# libdatadog are moved after the extension gets compiled.
|
|
@@ -203,7 +203,7 @@ module Datadog
|
|
|
203
203
|
"#{last_entry.chomp}" \
|
|
204
204
|
"+------------------------------------------------------------------------------+\n" \
|
|
205
205
|
"| Full failure log is at #{log_path}\n" \
|
|
206
|
-
"+------------------------------------------------------------------------------+\n"
|
|
206
|
+
"+------------------------------------------------------------------------------+\n",
|
|
207
207
|
)
|
|
208
208
|
end
|
|
209
209
|
end
|
|
@@ -33,7 +33,7 @@ module Datadog
|
|
|
33
33
|
endpoint: settings.ai_guard.endpoint,
|
|
34
34
|
api_key: settings.api_key,
|
|
35
35
|
application_key: settings.ai_guard.app_key,
|
|
36
|
-
timeout: settings.ai_guard.timeout_ms / 1_000
|
|
36
|
+
timeout: settings.ai_guard.timeout_ms / 1_000,
|
|
37
37
|
)
|
|
38
38
|
|
|
39
39
|
new(http_client, logger: logger, telemetry: telemetry)
|
|
@@ -29,7 +29,7 @@ module Datadog
|
|
|
29
29
|
|
|
30
30
|
@app.call(env)
|
|
31
31
|
ensure
|
|
32
|
-
# @type var trace: Datadog::Tracing::
|
|
32
|
+
# @type var trace: Datadog::Tracing::TraceOperation?
|
|
33
33
|
# Steep: https://github.com/soutaro/steep/issues/919
|
|
34
34
|
if trace
|
|
35
35
|
tag_client_ip_on_request_span!(trace) if ai_guard_executed?(trace)
|
|
@@ -40,7 +40,6 @@ module Datadog
|
|
|
40
40
|
|
|
41
41
|
private
|
|
42
42
|
|
|
43
|
-
# steep:ignore:start
|
|
44
43
|
def store_anomaly_detection_tags!(trace, env)
|
|
45
44
|
remote_ip = env["REMOTE_ADDR"]
|
|
46
45
|
trace.set_tag(Datadog::AIGuard::Ext::TRACE_NETWORK_CLIENT_IP_TAG, remote_ip) if remote_ip
|
|
@@ -54,9 +53,7 @@ module Datadog
|
|
|
54
53
|
rescue => e
|
|
55
54
|
Datadog::AIGuard.telemetry&.report(e, description: "AI Guard: failed to get request attributes")
|
|
56
55
|
end
|
|
57
|
-
# steep:ignore:end
|
|
58
56
|
|
|
59
|
-
# steep:ignore:start
|
|
60
57
|
def clean_up_ai_guard_temp_tags!(trace)
|
|
61
58
|
Ext::TRACE_ANOMALY_DETECTION_TAGS.each do |tag|
|
|
62
59
|
trace.clear_tag(tag)
|
|
@@ -64,17 +61,13 @@ module Datadog
|
|
|
64
61
|
|
|
65
62
|
trace.clear_tag(Datadog::AIGuard::Ext::TRACE_EXECUTED_TAG)
|
|
66
63
|
end
|
|
67
|
-
# steep:ignore:end
|
|
68
64
|
|
|
69
65
|
# AI Guard's evaluation flow sets `_dd.ai_guard.executed` on the
|
|
70
66
|
# trace whenever an AI Guard span is created during the request.
|
|
71
|
-
# steep:ignore:start
|
|
72
67
|
def ai_guard_executed?(trace)
|
|
73
68
|
trace.get_tag(Datadog::AIGuard::Ext::TRACE_EXECUTED_TAG) == "1"
|
|
74
69
|
end
|
|
75
|
-
# steep:ignore:end
|
|
76
70
|
|
|
77
|
-
# steep:ignore:start
|
|
78
71
|
def tag_client_ip_on_request_span!(trace)
|
|
79
72
|
span = Datadog::Tracing.active_span
|
|
80
73
|
return unless span
|
|
@@ -89,7 +82,6 @@ module Datadog
|
|
|
89
82
|
rescue => e
|
|
90
83
|
Datadog::AIGuard.telemetry&.report(e, description: "AI Guard: failed to tag client IP on root span")
|
|
91
84
|
end
|
|
92
|
-
# steep:ignore:end
|
|
93
85
|
end
|
|
94
86
|
end
|
|
95
87
|
end
|
|
@@ -48,7 +48,7 @@ module Datadog
|
|
|
48
48
|
if include_middleware?(Datadog::Tracing::Contrib::Rack::TraceMiddleware, app)
|
|
49
49
|
app.middleware.insert_after(
|
|
50
50
|
Datadog::Tracing::Contrib::Rack::TraceMiddleware,
|
|
51
|
-
Datadog::AIGuard::Contrib::Rack::RequestMiddleware
|
|
51
|
+
Datadog::AIGuard::Contrib::Rack::RequestMiddleware,
|
|
52
52
|
)
|
|
53
53
|
else
|
|
54
54
|
app.middleware.insert_before(0, Datadog::AIGuard::Contrib::Rack::RequestMiddleware)
|
|
@@ -66,7 +66,7 @@ module Datadog
|
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
Evaluation::Message.new(
|
|
69
|
-
role: message.role, content: content, tool_calls: builder.tool_calls, tool_call_id: message.tool_call_id
|
|
69
|
+
role: message.role, content: content, tool_calls: builder.tool_calls, tool_call_id: message.tool_call_id,
|
|
70
70
|
)
|
|
71
71
|
end
|
|
72
72
|
end
|
|
@@ -35,7 +35,7 @@ module Datadog
|
|
|
35
35
|
role: message.role, model: message.model, tool_call_id: message.tool_call_id,
|
|
36
36
|
raw: message.raw, thinking: message.thinking, citations: message.citations,
|
|
37
37
|
finish_reason: message.finish_reason, server_tool_calls: message.server_tool_calls,
|
|
38
|
-
raw_reasoning: message.raw_reasoning, cache_until_here: message.cache_until_here
|
|
38
|
+
raw_reasoning: message.raw_reasoning, cache_until_here: message.cache_until_here?,
|
|
39
39
|
)
|
|
40
40
|
changed_message.conversation = message.conversation
|
|
41
41
|
changed_message
|
|
@@ -105,7 +105,7 @@ module Datadog
|
|
|
105
105
|
|
|
106
106
|
attachments ||= message.attachments.dup
|
|
107
107
|
attachments[attachment_index] = ::RubyLLM::Attachment.new( # steep:ignore NoMethod
|
|
108
|
-
StringIO.new(replacement.text), filename: attachment.filename, config: attachment.config
|
|
108
|
+
StringIO.new(replacement.text), filename: attachment.filename, config: attachment.config,
|
|
109
109
|
)
|
|
110
110
|
end
|
|
111
111
|
|
|
@@ -122,7 +122,7 @@ module Datadog
|
|
|
122
122
|
tool_calls[id] = ::RubyLLM::ToolCall.new(
|
|
123
123
|
id: tool_call.id, name: tool_call.name, remote: tool_call.remote?,
|
|
124
124
|
thought_signature: tool_call.thought_signature,
|
|
125
|
-
arguments: JSON.parse(replacement.arguments)
|
|
125
|
+
arguments: JSON.parse(replacement.arguments),
|
|
126
126
|
)
|
|
127
127
|
end
|
|
128
128
|
|
|
@@ -18,7 +18,7 @@ module Datadog
|
|
|
18
18
|
raise "AI Guard HTTP client not initialized" unless http_client
|
|
19
19
|
|
|
20
20
|
response = Response.new(
|
|
21
|
-
http_client.post(Request::REQUEST_PATH, body: request.body)
|
|
21
|
+
http_client.post(Request::REQUEST_PATH, body: request.body),
|
|
22
22
|
)
|
|
23
23
|
|
|
24
24
|
redaction =
|
|
@@ -35,13 +35,13 @@ module Datadog
|
|
|
35
35
|
tags: response.tags,
|
|
36
36
|
sds_findings: response.sds_findings,
|
|
37
37
|
tag_probabilities: response.tag_probabilities,
|
|
38
|
-
redaction_replacements: response.redaction_replacements
|
|
38
|
+
redaction_replacements: response.redaction_replacements,
|
|
39
39
|
)
|
|
40
40
|
|
|
41
41
|
Outcome.new(
|
|
42
42
|
result: result,
|
|
43
43
|
redaction: redaction,
|
|
44
|
-
blocking_enabled: response.blocking_enabled
|
|
44
|
+
blocking_enabled: response.blocking_enabled?,
|
|
45
45
|
)
|
|
46
46
|
end
|
|
47
47
|
end
|
|
@@ -13,7 +13,7 @@ module Datadog
|
|
|
13
13
|
trace.keep!
|
|
14
14
|
trace.set_tag(
|
|
15
15
|
Tracing::Metadata::Ext::Distributed::TAG_DECISION_MAKER,
|
|
16
|
-
Tracing::Sampling::Ext::Decision::AI_GUARD
|
|
16
|
+
Tracing::Sampling::Ext::Decision::AI_GUARD,
|
|
17
17
|
)
|
|
18
18
|
trace.set_distributed_source(Ext::PRODUCT_BIT)
|
|
19
19
|
trace.set_tag(Ext::EVENT_TAG, true)
|
|
@@ -63,7 +63,7 @@ module Datadog
|
|
|
63
63
|
attack_categories: result.tags,
|
|
64
64
|
sds: result.sds_findings,
|
|
65
65
|
tag_probs: result.tag_probabilities,
|
|
66
|
-
}
|
|
66
|
+
},
|
|
67
67
|
)
|
|
68
68
|
|
|
69
69
|
blocked = allow_raise && outcome.block?
|
|
@@ -17,10 +17,11 @@ module Datadog
|
|
|
17
17
|
def initialize(endpoint:, api_key:, application_key:, timeout:)
|
|
18
18
|
@timeout = timeout
|
|
19
19
|
|
|
20
|
+
site = Datadog.configuration.site
|
|
20
21
|
@endpoint_uri = if endpoint
|
|
21
22
|
URI(endpoint) #: URI::HTTP
|
|
22
|
-
elsif
|
|
23
|
-
host =
|
|
23
|
+
elsif site
|
|
24
|
+
host = site.dup
|
|
24
25
|
host.prepend("app.") if host.count(".") == 1
|
|
25
26
|
|
|
26
27
|
URI::HTTPS.build(host: host, path: DEFAULT_PATH)
|
|
@@ -37,7 +37,7 @@ module Datadog
|
|
|
37
37
|
|
|
38
38
|
sinatra_routes.each do |sinatra_route, _, _|
|
|
39
39
|
yielder.yield SinatraRouteSerializer.serialize(
|
|
40
|
-
sinatra_route, method: method, path_prefix: route.path.spec.to_s
|
|
40
|
+
sinatra_route, method: method, path_prefix: route.path.spec.to_s,
|
|
41
41
|
)
|
|
42
42
|
end
|
|
43
43
|
end
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
AppSec WAF rules based on [appsec-event-rules](https://github.com/
|
|
1
|
+
AppSec WAF rules based on [appsec-event-rules](https://github.com/ddoghq/appsec-event-rules) builds
|
|
2
2
|
|
|
3
3
|
## How to update
|
|
4
4
|
|
|
5
|
-
In order to update rules, download `recommended.json` and `strict.json` of the desired version from [appsec-event-rules](https://github.com/
|
|
5
|
+
In order to update rules, download `recommended.json` and `strict.json` of the desired version from [appsec-event-rules](https://github.com/ddoghq/appsec-event-rules) (example: [v1.13.3](https://github.com/ddoghq/appsec-event-rules/tree/1.13.3/build))
|
|
6
6
|
|
|
7
7
|
You can store the following code as a `Rakefile` under `lib/datadog/appsec/assets/waf_rules`
|
|
8
8
|
|
|
9
9
|
```ruby
|
|
10
10
|
def download(filename)
|
|
11
|
-
build_path = 'repos/
|
|
11
|
+
build_path = 'repos/ddoghq/appsec-event-rules/contents/build'
|
|
12
12
|
|
|
13
13
|
system("gh api #{build_path}/#{filename} --jq '.content' | base64 -d > #{filename}")
|
|
14
14
|
end
|