datadog 2.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +4236 -0
- data/LICENSE +6 -0
- data/LICENSE-3rdparty.csv +7 -0
- data/LICENSE.Apache +200 -0
- data/LICENSE.BSD3 +24 -0
- data/NOTICE +4 -0
- data/README.md +25 -0
- data/bin/ddprofrb +15 -0
- data/ext/datadog_profiling_loader/datadog_profiling_loader.c +134 -0
- data/ext/datadog_profiling_loader/extconf.rb +72 -0
- data/ext/datadog_profiling_native_extension/NativeExtensionDesign.md +156 -0
- data/ext/datadog_profiling_native_extension/clock_id.h +22 -0
- data/ext/datadog_profiling_native_extension/clock_id_from_pthread.c +56 -0
- data/ext/datadog_profiling_native_extension/clock_id_noop.c +22 -0
- data/ext/datadog_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +1153 -0
- data/ext/datadog_profiling_native_extension/collectors_discrete_dynamic_sampler.c +422 -0
- data/ext/datadog_profiling_native_extension/collectors_discrete_dynamic_sampler.h +101 -0
- data/ext/datadog_profiling_native_extension/collectors_dynamic_sampling_rate.c +150 -0
- data/ext/datadog_profiling_native_extension/collectors_dynamic_sampling_rate.h +18 -0
- data/ext/datadog_profiling_native_extension/collectors_gc_profiling_helper.c +156 -0
- data/ext/datadog_profiling_native_extension/collectors_gc_profiling_helper.h +5 -0
- data/ext/datadog_profiling_native_extension/collectors_idle_sampling_helper.c +244 -0
- data/ext/datadog_profiling_native_extension/collectors_idle_sampling_helper.h +3 -0
- data/ext/datadog_profiling_native_extension/collectors_stack.c +372 -0
- data/ext/datadog_profiling_native_extension/collectors_stack.h +27 -0
- data/ext/datadog_profiling_native_extension/collectors_thread_context.c +1391 -0
- data/ext/datadog_profiling_native_extension/collectors_thread_context.h +15 -0
- data/ext/datadog_profiling_native_extension/extconf.rb +302 -0
- data/ext/datadog_profiling_native_extension/heap_recorder.c +970 -0
- data/ext/datadog_profiling_native_extension/heap_recorder.h +155 -0
- data/ext/datadog_profiling_native_extension/helpers.h +23 -0
- data/ext/datadog_profiling_native_extension/http_transport.c +375 -0
- data/ext/datadog_profiling_native_extension/libdatadog_helpers.c +62 -0
- data/ext/datadog_profiling_native_extension/libdatadog_helpers.h +42 -0
- data/ext/datadog_profiling_native_extension/native_extension_helpers.rb +319 -0
- data/ext/datadog_profiling_native_extension/private_vm_api_access.c +892 -0
- data/ext/datadog_profiling_native_extension/private_vm_api_access.h +61 -0
- data/ext/datadog_profiling_native_extension/profiling.c +267 -0
- data/ext/datadog_profiling_native_extension/ruby_helpers.c +267 -0
- data/ext/datadog_profiling_native_extension/ruby_helpers.h +119 -0
- data/ext/datadog_profiling_native_extension/setup_signal_handler.c +115 -0
- data/ext/datadog_profiling_native_extension/setup_signal_handler.h +11 -0
- data/ext/datadog_profiling_native_extension/stack_recorder.c +941 -0
- data/ext/datadog_profiling_native_extension/stack_recorder.h +27 -0
- data/ext/datadog_profiling_native_extension/time_helpers.c +53 -0
- data/ext/datadog_profiling_native_extension/time_helpers.h +26 -0
- data/lib/datadog/appsec/assets/blocked.html +99 -0
- data/lib/datadog/appsec/assets/blocked.json +1 -0
- data/lib/datadog/appsec/assets/blocked.text +5 -0
- data/lib/datadog/appsec/assets/waf_rules/README.md +7 -0
- data/lib/datadog/appsec/assets/waf_rules/processors.json +92 -0
- data/lib/datadog/appsec/assets/waf_rules/recommended.json +7703 -0
- data/lib/datadog/appsec/assets/waf_rules/scanners.json +114 -0
- data/lib/datadog/appsec/assets/waf_rules/strict.json +1635 -0
- data/lib/datadog/appsec/assets.rb +46 -0
- data/lib/datadog/appsec/autoload.rb +13 -0
- data/lib/datadog/appsec/component.rb +94 -0
- data/lib/datadog/appsec/configuration/settings.rb +202 -0
- data/lib/datadog/appsec/configuration.rb +11 -0
- data/lib/datadog/appsec/contrib/auto_instrument.rb +25 -0
- data/lib/datadog/appsec/contrib/devise/event.rb +57 -0
- data/lib/datadog/appsec/contrib/devise/ext.rb +13 -0
- data/lib/datadog/appsec/contrib/devise/integration.rb +42 -0
- data/lib/datadog/appsec/contrib/devise/patcher/authenticatable_patch.rb +76 -0
- data/lib/datadog/appsec/contrib/devise/patcher/registration_controller_patch.rb +54 -0
- data/lib/datadog/appsec/contrib/devise/patcher.rb +45 -0
- data/lib/datadog/appsec/contrib/devise/resource.rb +35 -0
- data/lib/datadog/appsec/contrib/devise/tracking.rb +49 -0
- data/lib/datadog/appsec/contrib/integration.rb +37 -0
- data/lib/datadog/appsec/contrib/patcher.rb +12 -0
- data/lib/datadog/appsec/contrib/rack/ext.rb +13 -0
- data/lib/datadog/appsec/contrib/rack/gateway/request.rb +104 -0
- data/lib/datadog/appsec/contrib/rack/gateway/response.rb +30 -0
- data/lib/datadog/appsec/contrib/rack/gateway/watcher.rb +162 -0
- data/lib/datadog/appsec/contrib/rack/integration.rb +44 -0
- data/lib/datadog/appsec/contrib/rack/patcher.rb +34 -0
- data/lib/datadog/appsec/contrib/rack/reactive/request.rb +81 -0
- data/lib/datadog/appsec/contrib/rack/reactive/request_body.rb +60 -0
- data/lib/datadog/appsec/contrib/rack/reactive/response.rb +66 -0
- data/lib/datadog/appsec/contrib/rack/request_body_middleware.rb +44 -0
- data/lib/datadog/appsec/contrib/rack/request_middleware.rb +196 -0
- data/lib/datadog/appsec/contrib/rails/ext.rb +13 -0
- data/lib/datadog/appsec/contrib/rails/framework.rb +16 -0
- data/lib/datadog/appsec/contrib/rails/gateway/request.rb +67 -0
- data/lib/datadog/appsec/contrib/rails/gateway/watcher.rb +71 -0
- data/lib/datadog/appsec/contrib/rails/integration.rb +43 -0
- data/lib/datadog/appsec/contrib/rails/patcher.rb +166 -0
- data/lib/datadog/appsec/contrib/rails/reactive/action.rb +66 -0
- data/lib/datadog/appsec/contrib/rails/request.rb +36 -0
- data/lib/datadog/appsec/contrib/rails/request_middleware.rb +20 -0
- data/lib/datadog/appsec/contrib/sinatra/ext.rb +14 -0
- data/lib/datadog/appsec/contrib/sinatra/framework.rb +20 -0
- data/lib/datadog/appsec/contrib/sinatra/gateway/request.rb +17 -0
- data/lib/datadog/appsec/contrib/sinatra/gateway/route_params.rb +23 -0
- data/lib/datadog/appsec/contrib/sinatra/gateway/watcher.rb +117 -0
- data/lib/datadog/appsec/contrib/sinatra/integration.rb +43 -0
- data/lib/datadog/appsec/contrib/sinatra/patcher.rb +168 -0
- data/lib/datadog/appsec/contrib/sinatra/reactive/routed.rb +61 -0
- data/lib/datadog/appsec/contrib/sinatra/request_middleware.rb +20 -0
- data/lib/datadog/appsec/event.rb +171 -0
- data/lib/datadog/appsec/ext.rb +10 -0
- data/lib/datadog/appsec/extensions.rb +15 -0
- data/lib/datadog/appsec/instrumentation/gateway/argument.rb +22 -0
- data/lib/datadog/appsec/instrumentation/gateway.rb +64 -0
- data/lib/datadog/appsec/instrumentation.rb +9 -0
- data/lib/datadog/appsec/monitor/gateway/watcher.rb +67 -0
- data/lib/datadog/appsec/monitor/reactive/set_user.rb +58 -0
- data/lib/datadog/appsec/monitor.rb +11 -0
- data/lib/datadog/appsec/processor/actions.rb +49 -0
- data/lib/datadog/appsec/processor/rule_loader.rb +123 -0
- data/lib/datadog/appsec/processor/rule_merger.rb +152 -0
- data/lib/datadog/appsec/processor.rb +171 -0
- data/lib/datadog/appsec/rate_limiter.rb +60 -0
- data/lib/datadog/appsec/reactive/address_hash.rb +22 -0
- data/lib/datadog/appsec/reactive/engine.rb +47 -0
- data/lib/datadog/appsec/reactive/operation.rb +68 -0
- data/lib/datadog/appsec/reactive/subscriber.rb +19 -0
- data/lib/datadog/appsec/remote.rb +129 -0
- data/lib/datadog/appsec/response.rb +151 -0
- data/lib/datadog/appsec/sample_rate.rb +21 -0
- data/lib/datadog/appsec/scope.rb +61 -0
- data/lib/datadog/appsec/utils/http/media_range.rb +201 -0
- data/lib/datadog/appsec/utils/http/media_type.rb +87 -0
- data/lib/datadog/appsec/utils/http.rb +11 -0
- data/lib/datadog/appsec/utils.rb +9 -0
- data/lib/datadog/appsec.rb +60 -0
- data/lib/datadog/auto_instrument.rb +16 -0
- data/lib/datadog/auto_instrument_base.rb +8 -0
- data/lib/datadog/core/buffer/cruby.rb +55 -0
- data/lib/datadog/core/buffer/random.rb +134 -0
- data/lib/datadog/core/buffer/thread_safe.rb +58 -0
- data/lib/datadog/core/chunker.rb +35 -0
- data/lib/datadog/core/configuration/agent_settings_resolver.rb +352 -0
- data/lib/datadog/core/configuration/base.rb +91 -0
- data/lib/datadog/core/configuration/components.rb +177 -0
- data/lib/datadog/core/configuration/ext.rb +45 -0
- data/lib/datadog/core/configuration/option.rb +319 -0
- data/lib/datadog/core/configuration/option_definition.rb +165 -0
- data/lib/datadog/core/configuration/options.rb +128 -0
- data/lib/datadog/core/configuration/settings.rb +786 -0
- data/lib/datadog/core/configuration.rb +296 -0
- data/lib/datadog/core/diagnostics/environment_logger.rb +173 -0
- data/lib/datadog/core/diagnostics/health.rb +19 -0
- data/lib/datadog/core/encoding.rb +74 -0
- data/lib/datadog/core/environment/cgroup.rb +53 -0
- data/lib/datadog/core/environment/class_count.rb +21 -0
- data/lib/datadog/core/environment/container.rb +91 -0
- data/lib/datadog/core/environment/execution.rb +103 -0
- data/lib/datadog/core/environment/ext.rb +45 -0
- data/lib/datadog/core/environment/gc.rb +20 -0
- data/lib/datadog/core/environment/git.rb +25 -0
- data/lib/datadog/core/environment/identity.rb +84 -0
- data/lib/datadog/core/environment/platform.rb +40 -0
- data/lib/datadog/core/environment/socket.rb +24 -0
- data/lib/datadog/core/environment/thread_count.rb +20 -0
- data/lib/datadog/core/environment/variable_helpers.rb +53 -0
- data/lib/datadog/core/environment/vm_cache.rb +64 -0
- data/lib/datadog/core/environment/yjit.rb +58 -0
- data/lib/datadog/core/error.rb +100 -0
- data/lib/datadog/core/extensions.rb +16 -0
- data/lib/datadog/core/git/ext.rb +16 -0
- data/lib/datadog/core/header_collection.rb +43 -0
- data/lib/datadog/core/logger.rb +45 -0
- data/lib/datadog/core/logging/ext.rb +13 -0
- data/lib/datadog/core/metrics/client.rb +199 -0
- data/lib/datadog/core/metrics/ext.rb +18 -0
- data/lib/datadog/core/metrics/helpers.rb +25 -0
- data/lib/datadog/core/metrics/logging.rb +44 -0
- data/lib/datadog/core/metrics/metric.rb +14 -0
- data/lib/datadog/core/metrics/options.rb +52 -0
- data/lib/datadog/core/pin.rb +75 -0
- data/lib/datadog/core/remote/client/capabilities.rb +62 -0
- data/lib/datadog/core/remote/client.rb +234 -0
- data/lib/datadog/core/remote/component.rb +162 -0
- data/lib/datadog/core/remote/configuration/content.rb +111 -0
- data/lib/datadog/core/remote/configuration/digest.rb +62 -0
- data/lib/datadog/core/remote/configuration/path.rb +90 -0
- data/lib/datadog/core/remote/configuration/repository.rb +294 -0
- data/lib/datadog/core/remote/configuration/target.rb +74 -0
- data/lib/datadog/core/remote/configuration.rb +18 -0
- data/lib/datadog/core/remote/dispatcher.rb +59 -0
- data/lib/datadog/core/remote/ext.rb +13 -0
- data/lib/datadog/core/remote/negotiation.rb +70 -0
- data/lib/datadog/core/remote/tie/tracing.rb +39 -0
- data/lib/datadog/core/remote/tie.rb +27 -0
- data/lib/datadog/core/remote/transport/config.rb +60 -0
- data/lib/datadog/core/remote/transport/http/api/instance.rb +39 -0
- data/lib/datadog/core/remote/transport/http/api/spec.rb +21 -0
- data/lib/datadog/core/remote/transport/http/api.rb +58 -0
- data/lib/datadog/core/remote/transport/http/builder.rb +219 -0
- data/lib/datadog/core/remote/transport/http/client.rb +48 -0
- data/lib/datadog/core/remote/transport/http/config.rb +280 -0
- data/lib/datadog/core/remote/transport/http/negotiation.rb +146 -0
- data/lib/datadog/core/remote/transport/http.rb +147 -0
- data/lib/datadog/core/remote/transport/negotiation.rb +62 -0
- data/lib/datadog/core/remote/worker.rb +102 -0
- data/lib/datadog/core/remote.rb +24 -0
- data/lib/datadog/core/runtime/ext.rb +38 -0
- data/lib/datadog/core/runtime/metrics.rb +185 -0
- data/lib/datadog/core/telemetry/client.rb +87 -0
- data/lib/datadog/core/telemetry/collector.rb +248 -0
- data/lib/datadog/core/telemetry/emitter.rb +50 -0
- data/lib/datadog/core/telemetry/event.rb +83 -0
- data/lib/datadog/core/telemetry/ext.rb +15 -0
- data/lib/datadog/core/telemetry/heartbeat.rb +35 -0
- data/lib/datadog/core/telemetry/http/adapters/net.rb +113 -0
- data/lib/datadog/core/telemetry/http/env.rb +20 -0
- data/lib/datadog/core/telemetry/http/ext.rb +22 -0
- data/lib/datadog/core/telemetry/http/response.rb +66 -0
- data/lib/datadog/core/telemetry/http/transport.rb +56 -0
- data/lib/datadog/core/telemetry/v1/app_event.rb +59 -0
- data/lib/datadog/core/telemetry/v1/application.rb +94 -0
- data/lib/datadog/core/telemetry/v1/configuration.rb +27 -0
- data/lib/datadog/core/telemetry/v1/dependency.rb +45 -0
- data/lib/datadog/core/telemetry/v1/host.rb +59 -0
- data/lib/datadog/core/telemetry/v1/install_signature.rb +38 -0
- data/lib/datadog/core/telemetry/v1/integration.rb +66 -0
- data/lib/datadog/core/telemetry/v1/product.rb +36 -0
- data/lib/datadog/core/telemetry/v1/telemetry_request.rb +108 -0
- data/lib/datadog/core/telemetry/v2/app_client_configuration_change.rb +41 -0
- data/lib/datadog/core/telemetry/v2/request.rb +29 -0
- data/lib/datadog/core/transport/ext.rb +43 -0
- data/lib/datadog/core/transport/http/adapters/net.rb +159 -0
- data/lib/datadog/core/transport/http/adapters/registry.rb +29 -0
- data/lib/datadog/core/transport/http/adapters/test.rb +89 -0
- data/lib/datadog/core/transport/http/adapters/unix_socket.rb +83 -0
- data/lib/datadog/core/transport/http/api/endpoint.rb +31 -0
- data/lib/datadog/core/transport/http/api/fallbacks.rb +26 -0
- data/lib/datadog/core/transport/http/api/map.rb +18 -0
- data/lib/datadog/core/transport/http/env.rb +62 -0
- data/lib/datadog/core/transport/http/response.rb +60 -0
- data/lib/datadog/core/transport/parcel.rb +22 -0
- data/lib/datadog/core/transport/request.rb +17 -0
- data/lib/datadog/core/transport/response.rb +64 -0
- data/lib/datadog/core/utils/duration.rb +52 -0
- data/lib/datadog/core/utils/forking.rb +63 -0
- data/lib/datadog/core/utils/hash.rb +79 -0
- data/lib/datadog/core/utils/network.rb +121 -0
- data/lib/datadog/core/utils/only_once.rb +42 -0
- data/lib/datadog/core/utils/safe_dup.rb +40 -0
- data/lib/datadog/core/utils/sequence.rb +26 -0
- data/lib/datadog/core/utils/time.rb +52 -0
- data/lib/datadog/core/utils/url.rb +25 -0
- data/lib/datadog/core/utils.rb +94 -0
- data/lib/datadog/core/vendor/multipart-post/LICENSE +11 -0
- data/lib/datadog/core/vendor/multipart-post/multipart/post/composite_read_io.rb +118 -0
- data/lib/datadog/core/vendor/multipart-post/multipart/post/multipartable.rb +59 -0
- data/lib/datadog/core/vendor/multipart-post/multipart/post/parts.rb +137 -0
- data/lib/datadog/core/vendor/multipart-post/multipart/post/version.rb +11 -0
- data/lib/datadog/core/vendor/multipart-post/multipart/post.rb +10 -0
- data/lib/datadog/core/vendor/multipart-post/multipart.rb +14 -0
- data/lib/datadog/core/vendor/multipart-post/net/http/post/multipart.rb +34 -0
- data/lib/datadog/core/worker.rb +24 -0
- data/lib/datadog/core/workers/async.rb +185 -0
- data/lib/datadog/core/workers/interval_loop.rb +123 -0
- data/lib/datadog/core/workers/polling.rb +59 -0
- data/lib/datadog/core/workers/queue.rb +44 -0
- data/lib/datadog/core/workers/runtime_metrics.rb +62 -0
- data/lib/datadog/core.rb +45 -0
- data/lib/datadog/kit/appsec/events.rb +169 -0
- data/lib/datadog/kit/enable_core_dumps.rb +49 -0
- data/lib/datadog/kit/identity.rb +104 -0
- data/lib/datadog/kit.rb +11 -0
- data/lib/datadog/opentelemetry/api/context.rb +193 -0
- data/lib/datadog/opentelemetry/api/trace/span.rb +14 -0
- data/lib/datadog/opentelemetry/sdk/configurator.rb +37 -0
- data/lib/datadog/opentelemetry/sdk/id_generator.rb +26 -0
- data/lib/datadog/opentelemetry/sdk/propagator.rb +92 -0
- data/lib/datadog/opentelemetry/sdk/span_processor.rb +134 -0
- data/lib/datadog/opentelemetry/sdk/trace/span.rb +167 -0
- data/lib/datadog/opentelemetry/trace.rb +59 -0
- data/lib/datadog/opentelemetry.rb +51 -0
- data/lib/datadog/profiling/collectors/code_provenance.rb +113 -0
- data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +114 -0
- data/lib/datadog/profiling/collectors/dynamic_sampling_rate.rb +14 -0
- data/lib/datadog/profiling/collectors/idle_sampling_helper.rb +70 -0
- data/lib/datadog/profiling/collectors/info.rb +103 -0
- data/lib/datadog/profiling/collectors/stack.rb +13 -0
- data/lib/datadog/profiling/collectors/thread_context.rb +61 -0
- data/lib/datadog/profiling/component.rb +418 -0
- data/lib/datadog/profiling/exporter.rb +103 -0
- data/lib/datadog/profiling/ext/forking.rb +98 -0
- data/lib/datadog/profiling/ext.rb +35 -0
- data/lib/datadog/profiling/flush.rb +43 -0
- data/lib/datadog/profiling/http_transport.rb +143 -0
- data/lib/datadog/profiling/load_native_extension.rb +28 -0
- data/lib/datadog/profiling/native_extension.rb +20 -0
- data/lib/datadog/profiling/preload.rb +5 -0
- data/lib/datadog/profiling/profiler.rb +64 -0
- data/lib/datadog/profiling/scheduler.rb +137 -0
- data/lib/datadog/profiling/stack_recorder.rb +69 -0
- data/lib/datadog/profiling/tag_builder.rb +60 -0
- data/lib/datadog/profiling/tasks/exec.rb +50 -0
- data/lib/datadog/profiling/tasks/help.rb +18 -0
- data/lib/datadog/profiling/tasks/setup.rb +60 -0
- data/lib/datadog/profiling.rb +152 -0
- data/lib/datadog/tracing/analytics.rb +25 -0
- data/lib/datadog/tracing/buffer.rb +129 -0
- data/lib/datadog/tracing/client_ip.rb +61 -0
- data/lib/datadog/tracing/component.rb +206 -0
- data/lib/datadog/tracing/configuration/dynamic/option.rb +71 -0
- data/lib/datadog/tracing/configuration/dynamic.rb +64 -0
- data/lib/datadog/tracing/configuration/ext.rb +98 -0
- data/lib/datadog/tracing/configuration/http.rb +74 -0
- data/lib/datadog/tracing/configuration/settings.rb +421 -0
- data/lib/datadog/tracing/context.rb +68 -0
- data/lib/datadog/tracing/context_provider.rb +82 -0
- data/lib/datadog/tracing/contrib/action_cable/configuration/settings.rb +39 -0
- data/lib/datadog/tracing/contrib/action_cable/event.rb +71 -0
- data/lib/datadog/tracing/contrib/action_cable/events/broadcast.rb +58 -0
- data/lib/datadog/tracing/contrib/action_cable/events/perform_action.rb +63 -0
- data/lib/datadog/tracing/contrib/action_cable/events/transmit.rb +59 -0
- data/lib/datadog/tracing/contrib/action_cable/events.rb +37 -0
- data/lib/datadog/tracing/contrib/action_cable/ext.rb +33 -0
- data/lib/datadog/tracing/contrib/action_cable/instrumentation.rb +90 -0
- data/lib/datadog/tracing/contrib/action_cable/integration.rb +50 -0
- data/lib/datadog/tracing/contrib/action_cable/patcher.rb +31 -0
- data/lib/datadog/tracing/contrib/action_mailer/configuration/settings.rb +43 -0
- data/lib/datadog/tracing/contrib/action_mailer/event.rb +52 -0
- data/lib/datadog/tracing/contrib/action_mailer/events/deliver.rb +60 -0
- data/lib/datadog/tracing/contrib/action_mailer/events/process.rb +47 -0
- data/lib/datadog/tracing/contrib/action_mailer/events.rb +34 -0
- data/lib/datadog/tracing/contrib/action_mailer/ext.rb +34 -0
- data/lib/datadog/tracing/contrib/action_mailer/integration.rb +50 -0
- data/lib/datadog/tracing/contrib/action_mailer/patcher.rb +29 -0
- data/lib/datadog/tracing/contrib/action_pack/action_controller/instrumentation.rb +138 -0
- data/lib/datadog/tracing/contrib/action_pack/action_controller/patcher.rb +29 -0
- data/lib/datadog/tracing/contrib/action_pack/configuration/settings.rb +40 -0
- data/lib/datadog/tracing/contrib/action_pack/ext.rb +23 -0
- data/lib/datadog/tracing/contrib/action_pack/integration.rb +51 -0
- data/lib/datadog/tracing/contrib/action_pack/patcher.rb +27 -0
- data/lib/datadog/tracing/contrib/action_pack/utils.rb +40 -0
- data/lib/datadog/tracing/contrib/action_view/configuration/settings.rb +43 -0
- data/lib/datadog/tracing/contrib/action_view/event.rb +35 -0
- data/lib/datadog/tracing/contrib/action_view/events/render_partial.rb +54 -0
- data/lib/datadog/tracing/contrib/action_view/events/render_template.rb +57 -0
- data/lib/datadog/tracing/contrib/action_view/events.rb +34 -0
- data/lib/datadog/tracing/contrib/action_view/ext.rb +25 -0
- data/lib/datadog/tracing/contrib/action_view/integration.rb +58 -0
- data/lib/datadog/tracing/contrib/action_view/patcher.rb +34 -0
- data/lib/datadog/tracing/contrib/action_view/utils.rb +36 -0
- data/lib/datadog/tracing/contrib/active_job/configuration/settings.rb +39 -0
- data/lib/datadog/tracing/contrib/active_job/event.rb +58 -0
- data/lib/datadog/tracing/contrib/active_job/events/discard.rb +50 -0
- data/lib/datadog/tracing/contrib/active_job/events/enqueue.rb +49 -0
- data/lib/datadog/tracing/contrib/active_job/events/enqueue_at.rb +49 -0
- data/lib/datadog/tracing/contrib/active_job/events/enqueue_retry.rb +51 -0
- data/lib/datadog/tracing/contrib/active_job/events/perform.rb +49 -0
- data/lib/datadog/tracing/contrib/active_job/events/retry_stopped.rb +50 -0
- data/lib/datadog/tracing/contrib/active_job/events.rb +42 -0
- data/lib/datadog/tracing/contrib/active_job/ext.rb +40 -0
- data/lib/datadog/tracing/contrib/active_job/integration.rb +50 -0
- data/lib/datadog/tracing/contrib/active_job/log_injection.rb +24 -0
- data/lib/datadog/tracing/contrib/active_job/patcher.rb +36 -0
- data/lib/datadog/tracing/contrib/active_model_serializers/configuration/settings.rb +37 -0
- data/lib/datadog/tracing/contrib/active_model_serializers/event.rb +68 -0
- data/lib/datadog/tracing/contrib/active_model_serializers/events/render.rb +45 -0
- data/lib/datadog/tracing/contrib/active_model_serializers/events/serialize.rb +47 -0
- data/lib/datadog/tracing/contrib/active_model_serializers/events.rb +34 -0
- data/lib/datadog/tracing/contrib/active_model_serializers/ext.rb +25 -0
- data/lib/datadog/tracing/contrib/active_model_serializers/integration.rb +45 -0
- data/lib/datadog/tracing/contrib/active_model_serializers/patcher.rb +32 -0
- data/lib/datadog/tracing/contrib/active_record/configuration/makara_resolver.rb +36 -0
- data/lib/datadog/tracing/contrib/active_record/configuration/resolver.rb +147 -0
- data/lib/datadog/tracing/contrib/active_record/configuration/settings.rb +48 -0
- data/lib/datadog/tracing/contrib/active_record/event.rb +30 -0
- data/lib/datadog/tracing/contrib/active_record/events/instantiation.rb +58 -0
- data/lib/datadog/tracing/contrib/active_record/events/sql.rb +77 -0
- data/lib/datadog/tracing/contrib/active_record/events.rb +34 -0
- data/lib/datadog/tracing/contrib/active_record/ext.rb +30 -0
- data/lib/datadog/tracing/contrib/active_record/integration.rb +57 -0
- data/lib/datadog/tracing/contrib/active_record/patcher.rb +27 -0
- data/lib/datadog/tracing/contrib/active_record/utils.rb +128 -0
- data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +186 -0
- data/lib/datadog/tracing/contrib/active_support/cache/patcher.rb +76 -0
- data/lib/datadog/tracing/contrib/active_support/cache/redis.rb +47 -0
- data/lib/datadog/tracing/contrib/active_support/configuration/settings.rb +47 -0
- data/lib/datadog/tracing/contrib/active_support/ext.rb +32 -0
- data/lib/datadog/tracing/contrib/active_support/integration.rb +52 -0
- data/lib/datadog/tracing/contrib/active_support/notifications/event.rb +71 -0
- data/lib/datadog/tracing/contrib/active_support/notifications/subscriber.rb +71 -0
- data/lib/datadog/tracing/contrib/active_support/notifications/subscription.rb +164 -0
- data/lib/datadog/tracing/contrib/active_support/patcher.rb +27 -0
- data/lib/datadog/tracing/contrib/analytics.rb +28 -0
- data/lib/datadog/tracing/contrib/auto_instrument.rb +53 -0
- data/lib/datadog/tracing/contrib/aws/configuration/settings.rb +53 -0
- data/lib/datadog/tracing/contrib/aws/ext.rb +50 -0
- data/lib/datadog/tracing/contrib/aws/instrumentation.rb +119 -0
- data/lib/datadog/tracing/contrib/aws/integration.rb +47 -0
- data/lib/datadog/tracing/contrib/aws/parsed_context.rb +64 -0
- data/lib/datadog/tracing/contrib/aws/patcher.rb +57 -0
- data/lib/datadog/tracing/contrib/aws/service/base.rb +16 -0
- data/lib/datadog/tracing/contrib/aws/service/dynamodb.rb +22 -0
- data/lib/datadog/tracing/contrib/aws/service/eventbridge.rb +22 -0
- data/lib/datadog/tracing/contrib/aws/service/kinesis.rb +32 -0
- data/lib/datadog/tracing/contrib/aws/service/s3.rb +22 -0
- data/lib/datadog/tracing/contrib/aws/service/sns.rb +30 -0
- data/lib/datadog/tracing/contrib/aws/service/sqs.rb +27 -0
- data/lib/datadog/tracing/contrib/aws/service/states.rb +40 -0
- data/lib/datadog/tracing/contrib/aws/services.rb +139 -0
- data/lib/datadog/tracing/contrib/component.rb +41 -0
- data/lib/datadog/tracing/contrib/concurrent_ruby/async_patch.rb +20 -0
- data/lib/datadog/tracing/contrib/concurrent_ruby/configuration/settings.rb +24 -0
- data/lib/datadog/tracing/contrib/concurrent_ruby/context_composite_executor_service.rb +53 -0
- data/lib/datadog/tracing/contrib/concurrent_ruby/ext.rb +16 -0
- data/lib/datadog/tracing/contrib/concurrent_ruby/future_patch.rb +20 -0
- data/lib/datadog/tracing/contrib/concurrent_ruby/integration.rb +44 -0
- data/lib/datadog/tracing/contrib/concurrent_ruby/patcher.rb +49 -0
- data/lib/datadog/tracing/contrib/concurrent_ruby/promises_future_patch.rb +22 -0
- data/lib/datadog/tracing/contrib/configurable.rb +102 -0
- data/lib/datadog/tracing/contrib/configuration/resolver.rb +85 -0
- data/lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb +43 -0
- data/lib/datadog/tracing/contrib/configuration/settings.rb +43 -0
- data/lib/datadog/tracing/contrib/dalli/configuration/settings.rb +58 -0
- data/lib/datadog/tracing/contrib/dalli/ext.rb +40 -0
- data/lib/datadog/tracing/contrib/dalli/instrumentation.rb +75 -0
- data/lib/datadog/tracing/contrib/dalli/integration.rb +52 -0
- data/lib/datadog/tracing/contrib/dalli/patcher.rb +28 -0
- data/lib/datadog/tracing/contrib/dalli/quantize.rb +26 -0
- data/lib/datadog/tracing/contrib/delayed_job/configuration/settings.rb +49 -0
- data/lib/datadog/tracing/contrib/delayed_job/ext.rb +29 -0
- data/lib/datadog/tracing/contrib/delayed_job/integration.rb +43 -0
- data/lib/datadog/tracing/contrib/delayed_job/patcher.rb +37 -0
- data/lib/datadog/tracing/contrib/delayed_job/plugin.rb +108 -0
- data/lib/datadog/tracing/contrib/delayed_job/server_internal_tracer/worker.rb +34 -0
- data/lib/datadog/tracing/contrib/elasticsearch/configuration/settings.rb +57 -0
- data/lib/datadog/tracing/contrib/elasticsearch/ext.rb +34 -0
- data/lib/datadog/tracing/contrib/elasticsearch/integration.rb +50 -0
- data/lib/datadog/tracing/contrib/elasticsearch/patcher.rb +164 -0
- data/lib/datadog/tracing/contrib/elasticsearch/quantize.rb +87 -0
- data/lib/datadog/tracing/contrib/ethon/configuration/settings.rb +56 -0
- data/lib/datadog/tracing/contrib/ethon/easy_patch.rb +223 -0
- data/lib/datadog/tracing/contrib/ethon/ext.rb +32 -0
- data/lib/datadog/tracing/contrib/ethon/integration.rb +48 -0
- data/lib/datadog/tracing/contrib/ethon/multi_patch.rb +102 -0
- data/lib/datadog/tracing/contrib/ethon/patcher.rb +30 -0
- data/lib/datadog/tracing/contrib/excon/configuration/settings.rb +74 -0
- data/lib/datadog/tracing/contrib/excon/ext.rb +30 -0
- data/lib/datadog/tracing/contrib/excon/integration.rb +48 -0
- data/lib/datadog/tracing/contrib/excon/middleware.rb +196 -0
- data/lib/datadog/tracing/contrib/excon/patcher.rb +31 -0
- data/lib/datadog/tracing/contrib/ext.rb +55 -0
- data/lib/datadog/tracing/contrib/extensions.rb +228 -0
- data/lib/datadog/tracing/contrib/faraday/configuration/settings.rb +77 -0
- data/lib/datadog/tracing/contrib/faraday/connection.rb +22 -0
- data/lib/datadog/tracing/contrib/faraday/ext.rb +30 -0
- data/lib/datadog/tracing/contrib/faraday/integration.rb +48 -0
- data/lib/datadog/tracing/contrib/faraday/middleware.rb +112 -0
- data/lib/datadog/tracing/contrib/faraday/patcher.rb +56 -0
- data/lib/datadog/tracing/contrib/faraday/rack_builder.rb +22 -0
- data/lib/datadog/tracing/contrib/grape/configuration/settings.rb +55 -0
- data/lib/datadog/tracing/contrib/grape/endpoint.rb +256 -0
- data/lib/datadog/tracing/contrib/grape/ext.rb +30 -0
- data/lib/datadog/tracing/contrib/grape/instrumentation.rb +37 -0
- data/lib/datadog/tracing/contrib/grape/integration.rb +44 -0
- data/lib/datadog/tracing/contrib/grape/patcher.rb +33 -0
- data/lib/datadog/tracing/contrib/graphql/configuration/settings.rb +50 -0
- data/lib/datadog/tracing/contrib/graphql/ext.rb +20 -0
- data/lib/datadog/tracing/contrib/graphql/integration.rb +56 -0
- data/lib/datadog/tracing/contrib/graphql/patcher.rb +55 -0
- data/lib/datadog/tracing/contrib/graphql/trace_patcher.rb +24 -0
- data/lib/datadog/tracing/contrib/graphql/tracing_patcher.rb +28 -0
- data/lib/datadog/tracing/contrib/grpc/configuration/settings.rb +58 -0
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/client.rb +117 -0
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/server.rb +96 -0
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor.rb +107 -0
- data/lib/datadog/tracing/contrib/grpc/distributed/fetcher.rb +26 -0
- data/lib/datadog/tracing/contrib/grpc/distributed/propagation.rb +46 -0
- data/lib/datadog/tracing/contrib/grpc/ext.rb +29 -0
- data/lib/datadog/tracing/contrib/grpc/formatting.rb +127 -0
- data/lib/datadog/tracing/contrib/grpc/integration.rb +50 -0
- data/lib/datadog/tracing/contrib/grpc/intercept_with_datadog.rb +53 -0
- data/lib/datadog/tracing/contrib/grpc/patcher.rb +34 -0
- data/lib/datadog/tracing/contrib/grpc.rb +45 -0
- data/lib/datadog/tracing/contrib/hanami/action_tracer.rb +47 -0
- data/lib/datadog/tracing/contrib/hanami/configuration/settings.rb +23 -0
- data/lib/datadog/tracing/contrib/hanami/ext.rb +24 -0
- data/lib/datadog/tracing/contrib/hanami/integration.rb +44 -0
- data/lib/datadog/tracing/contrib/hanami/patcher.rb +33 -0
- data/lib/datadog/tracing/contrib/hanami/plugin.rb +23 -0
- data/lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb +41 -0
- data/lib/datadog/tracing/contrib/hanami/router_tracing.rb +44 -0
- data/lib/datadog/tracing/contrib/http/circuit_breaker.rb +40 -0
- data/lib/datadog/tracing/contrib/http/configuration/settings.rb +69 -0
- data/lib/datadog/tracing/contrib/http/distributed/fetcher.rb +38 -0
- data/lib/datadog/tracing/contrib/http/distributed/propagation.rb +45 -0
- data/lib/datadog/tracing/contrib/http/ext.rb +29 -0
- data/lib/datadog/tracing/contrib/http/instrumentation.rb +144 -0
- data/lib/datadog/tracing/contrib/http/integration.rb +49 -0
- data/lib/datadog/tracing/contrib/http/patcher.rb +30 -0
- data/lib/datadog/tracing/contrib/http.rb +45 -0
- data/lib/datadog/tracing/contrib/http_annotation_helper.rb +17 -0
- data/lib/datadog/tracing/contrib/httpclient/configuration/settings.rb +68 -0
- data/lib/datadog/tracing/contrib/httpclient/ext.rb +30 -0
- data/lib/datadog/tracing/contrib/httpclient/instrumentation.rb +137 -0
- data/lib/datadog/tracing/contrib/httpclient/integration.rb +48 -0
- data/lib/datadog/tracing/contrib/httpclient/patcher.rb +42 -0
- data/lib/datadog/tracing/contrib/httprb/configuration/settings.rb +68 -0
- data/lib/datadog/tracing/contrib/httprb/ext.rb +29 -0
- data/lib/datadog/tracing/contrib/httprb/instrumentation.rb +145 -0
- data/lib/datadog/tracing/contrib/httprb/integration.rb +48 -0
- data/lib/datadog/tracing/contrib/httprb/patcher.rb +42 -0
- data/lib/datadog/tracing/contrib/integration.rb +78 -0
- data/lib/datadog/tracing/contrib/kafka/configuration/settings.rb +39 -0
- data/lib/datadog/tracing/contrib/kafka/consumer_event.rb +19 -0
- data/lib/datadog/tracing/contrib/kafka/consumer_group_event.rb +18 -0
- data/lib/datadog/tracing/contrib/kafka/event.rb +53 -0
- data/lib/datadog/tracing/contrib/kafka/events/connection/request.rb +42 -0
- data/lib/datadog/tracing/contrib/kafka/events/consumer/process_batch.rb +49 -0
- data/lib/datadog/tracing/contrib/kafka/events/consumer/process_message.rb +47 -0
- data/lib/datadog/tracing/contrib/kafka/events/consumer_group/heartbeat.rb +47 -0
- data/lib/datadog/tracing/contrib/kafka/events/consumer_group/join_group.rb +37 -0
- data/lib/datadog/tracing/contrib/kafka/events/consumer_group/leave_group.rb +37 -0
- data/lib/datadog/tracing/contrib/kafka/events/consumer_group/sync_group.rb +37 -0
- data/lib/datadog/tracing/contrib/kafka/events/produce_operation/send_messages.rb +41 -0
- data/lib/datadog/tracing/contrib/kafka/events/producer/deliver_messages.rb +44 -0
- data/lib/datadog/tracing/contrib/kafka/events.rb +48 -0
- data/lib/datadog/tracing/contrib/kafka/ext.rb +55 -0
- data/lib/datadog/tracing/contrib/kafka/integration.rb +44 -0
- data/lib/datadog/tracing/contrib/kafka/patcher.rb +29 -0
- data/lib/datadog/tracing/contrib/lograge/configuration/settings.rb +24 -0
- data/lib/datadog/tracing/contrib/lograge/ext.rb +15 -0
- data/lib/datadog/tracing/contrib/lograge/instrumentation.rb +31 -0
- data/lib/datadog/tracing/contrib/lograge/integration.rb +50 -0
- data/lib/datadog/tracing/contrib/lograge/patcher.rb +29 -0
- data/lib/datadog/tracing/contrib/mongodb/configuration/settings.rb +56 -0
- data/lib/datadog/tracing/contrib/mongodb/ext.rb +38 -0
- data/lib/datadog/tracing/contrib/mongodb/instrumentation.rb +47 -0
- data/lib/datadog/tracing/contrib/mongodb/integration.rb +48 -0
- data/lib/datadog/tracing/contrib/mongodb/parsers.rb +49 -0
- data/lib/datadog/tracing/contrib/mongodb/patcher.rb +34 -0
- data/lib/datadog/tracing/contrib/mongodb/subscribers.rb +141 -0
- data/lib/datadog/tracing/contrib/mysql2/configuration/settings.rb +64 -0
- data/lib/datadog/tracing/contrib/mysql2/ext.rb +28 -0
- data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +95 -0
- data/lib/datadog/tracing/contrib/mysql2/integration.rb +43 -0
- data/lib/datadog/tracing/contrib/mysql2/patcher.rb +31 -0
- data/lib/datadog/tracing/contrib/opensearch/configuration/settings.rb +54 -0
- data/lib/datadog/tracing/contrib/opensearch/ext.rb +38 -0
- data/lib/datadog/tracing/contrib/opensearch/integration.rb +44 -0
- data/lib/datadog/tracing/contrib/opensearch/patcher.rb +135 -0
- data/lib/datadog/tracing/contrib/opensearch/quantize.rb +81 -0
- data/lib/datadog/tracing/contrib/patchable.rb +109 -0
- data/lib/datadog/tracing/contrib/patcher.rb +85 -0
- data/lib/datadog/tracing/contrib/pg/configuration/settings.rb +64 -0
- data/lib/datadog/tracing/contrib/pg/ext.rb +35 -0
- data/lib/datadog/tracing/contrib/pg/instrumentation.rb +211 -0
- data/lib/datadog/tracing/contrib/pg/integration.rb +43 -0
- data/lib/datadog/tracing/contrib/pg/patcher.rb +31 -0
- data/lib/datadog/tracing/contrib/presto/configuration/settings.rb +52 -0
- data/lib/datadog/tracing/contrib/presto/ext.rb +38 -0
- data/lib/datadog/tracing/contrib/presto/instrumentation.rb +138 -0
- data/lib/datadog/tracing/contrib/presto/integration.rb +43 -0
- data/lib/datadog/tracing/contrib/presto/patcher.rb +37 -0
- data/lib/datadog/tracing/contrib/propagation/sql_comment/comment.rb +41 -0
- data/lib/datadog/tracing/contrib/propagation/sql_comment/ext.rb +33 -0
- data/lib/datadog/tracing/contrib/propagation/sql_comment/mode.rb +28 -0
- data/lib/datadog/tracing/contrib/propagation/sql_comment.rb +55 -0
- data/lib/datadog/tracing/contrib/que/configuration/settings.rb +55 -0
- data/lib/datadog/tracing/contrib/que/ext.rb +33 -0
- data/lib/datadog/tracing/contrib/que/integration.rb +44 -0
- data/lib/datadog/tracing/contrib/que/patcher.rb +26 -0
- data/lib/datadog/tracing/contrib/que/tracer.rb +63 -0
- data/lib/datadog/tracing/contrib/racecar/configuration/settings.rb +47 -0
- data/lib/datadog/tracing/contrib/racecar/event.rb +81 -0
- data/lib/datadog/tracing/contrib/racecar/events/batch.rb +38 -0
- data/lib/datadog/tracing/contrib/racecar/events/consume.rb +35 -0
- data/lib/datadog/tracing/contrib/racecar/events/message.rb +38 -0
- data/lib/datadog/tracing/contrib/racecar/events.rb +36 -0
- data/lib/datadog/tracing/contrib/racecar/ext.rb +33 -0
- data/lib/datadog/tracing/contrib/racecar/integration.rb +44 -0
- data/lib/datadog/tracing/contrib/racecar/patcher.rb +29 -0
- data/lib/datadog/tracing/contrib/rack/configuration/settings.rb +59 -0
- data/lib/datadog/tracing/contrib/rack/ext.rb +30 -0
- data/lib/datadog/tracing/contrib/rack/header_collection.rb +40 -0
- data/lib/datadog/tracing/contrib/rack/header_tagging.rb +63 -0
- data/lib/datadog/tracing/contrib/rack/integration.rb +50 -0
- data/lib/datadog/tracing/contrib/rack/middlewares.rb +265 -0
- data/lib/datadog/tracing/contrib/rack/patcher.rb +119 -0
- data/lib/datadog/tracing/contrib/rack/request_queue.rb +48 -0
- data/lib/datadog/tracing/contrib/rack/trace_proxy_middleware.rb +52 -0
- data/lib/datadog/tracing/contrib/rails/auto_instrument_railtie.rb +10 -0
- data/lib/datadog/tracing/contrib/rails/configuration/settings.rb +76 -0
- data/lib/datadog/tracing/contrib/rails/ext.rb +23 -0
- data/lib/datadog/tracing/contrib/rails/framework.rb +148 -0
- data/lib/datadog/tracing/contrib/rails/integration.rb +52 -0
- data/lib/datadog/tracing/contrib/rails/log_injection.rb +29 -0
- data/lib/datadog/tracing/contrib/rails/middlewares.rb +46 -0
- data/lib/datadog/tracing/contrib/rails/patcher.rb +88 -0
- data/lib/datadog/tracing/contrib/rails/railtie.rb +19 -0
- data/lib/datadog/tracing/contrib/rails/utils.rb +26 -0
- data/lib/datadog/tracing/contrib/rake/configuration/settings.rb +55 -0
- data/lib/datadog/tracing/contrib/rake/ext.rb +27 -0
- data/lib/datadog/tracing/contrib/rake/instrumentation.rb +103 -0
- data/lib/datadog/tracing/contrib/rake/integration.rb +43 -0
- data/lib/datadog/tracing/contrib/rake/patcher.rb +33 -0
- data/lib/datadog/tracing/contrib/redis/configuration/resolver.rb +49 -0
- data/lib/datadog/tracing/contrib/redis/configuration/settings.rb +57 -0
- data/lib/datadog/tracing/contrib/redis/ext.rb +35 -0
- data/lib/datadog/tracing/contrib/redis/instrumentation.rb +53 -0
- data/lib/datadog/tracing/contrib/redis/integration.rb +80 -0
- data/lib/datadog/tracing/contrib/redis/patcher.rb +92 -0
- data/lib/datadog/tracing/contrib/redis/quantize.rb +80 -0
- data/lib/datadog/tracing/contrib/redis/tags.rb +68 -0
- data/lib/datadog/tracing/contrib/redis/trace_middleware.rb +85 -0
- data/lib/datadog/tracing/contrib/redis/vendor/LICENSE +20 -0
- data/lib/datadog/tracing/contrib/redis/vendor/resolver.rb +160 -0
- data/lib/datadog/tracing/contrib/registerable.rb +50 -0
- data/lib/datadog/tracing/contrib/registry.rb +52 -0
- data/lib/datadog/tracing/contrib/resque/configuration/settings.rb +42 -0
- data/lib/datadog/tracing/contrib/resque/ext.rb +22 -0
- data/lib/datadog/tracing/contrib/resque/integration.rb +48 -0
- data/lib/datadog/tracing/contrib/resque/patcher.rb +29 -0
- data/lib/datadog/tracing/contrib/resque/resque_job.rb +106 -0
- data/lib/datadog/tracing/contrib/rest_client/configuration/settings.rb +55 -0
- data/lib/datadog/tracing/contrib/rest_client/ext.rb +28 -0
- data/lib/datadog/tracing/contrib/rest_client/integration.rb +43 -0
- data/lib/datadog/tracing/contrib/rest_client/patcher.rb +28 -0
- data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +129 -0
- data/lib/datadog/tracing/contrib/roda/configuration/settings.rb +38 -0
- data/lib/datadog/tracing/contrib/roda/ext.rb +19 -0
- data/lib/datadog/tracing/contrib/roda/instrumentation.rb +76 -0
- data/lib/datadog/tracing/contrib/roda/integration.rb +45 -0
- data/lib/datadog/tracing/contrib/roda/patcher.rb +30 -0
- data/lib/datadog/tracing/contrib/semantic_logger/configuration/settings.rb +24 -0
- data/lib/datadog/tracing/contrib/semantic_logger/ext.rb +15 -0
- data/lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb +35 -0
- data/lib/datadog/tracing/contrib/semantic_logger/integration.rb +52 -0
- data/lib/datadog/tracing/contrib/semantic_logger/patcher.rb +29 -0
- data/lib/datadog/tracing/contrib/sequel/configuration/settings.rb +37 -0
- data/lib/datadog/tracing/contrib/sequel/database.rb +62 -0
- data/lib/datadog/tracing/contrib/sequel/dataset.rb +67 -0
- data/lib/datadog/tracing/contrib/sequel/ext.rb +23 -0
- data/lib/datadog/tracing/contrib/sequel/integration.rb +43 -0
- data/lib/datadog/tracing/contrib/sequel/patcher.rb +37 -0
- data/lib/datadog/tracing/contrib/sequel/utils.rb +90 -0
- data/lib/datadog/tracing/contrib/shoryuken/configuration/settings.rb +43 -0
- data/lib/datadog/tracing/contrib/shoryuken/ext.rb +27 -0
- data/lib/datadog/tracing/contrib/shoryuken/integration.rb +44 -0
- data/lib/datadog/tracing/contrib/shoryuken/patcher.rb +28 -0
- data/lib/datadog/tracing/contrib/shoryuken/tracer.rb +65 -0
- data/lib/datadog/tracing/contrib/sidekiq/client_tracer.rb +62 -0
- data/lib/datadog/tracing/contrib/sidekiq/configuration/settings.rb +47 -0
- data/lib/datadog/tracing/contrib/sidekiq/distributed/propagation.rb +46 -0
- data/lib/datadog/tracing/contrib/sidekiq/ext.rb +44 -0
- data/lib/datadog/tracing/contrib/sidekiq/integration.rb +61 -0
- data/lib/datadog/tracing/contrib/sidekiq/patcher.rb +90 -0
- data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/heartbeat.rb +61 -0
- data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/job_fetch.rb +36 -0
- data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/redis_info.rb +34 -0
- data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/scheduled_poller.rb +57 -0
- data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/stop.rb +34 -0
- data/lib/datadog/tracing/contrib/sidekiq/server_tracer.rb +88 -0
- data/lib/datadog/tracing/contrib/sidekiq/utils.rb +44 -0
- data/lib/datadog/tracing/contrib/sidekiq.rb +37 -0
- data/lib/datadog/tracing/contrib/sinatra/configuration/settings.rb +46 -0
- data/lib/datadog/tracing/contrib/sinatra/env.rb +38 -0
- data/lib/datadog/tracing/contrib/sinatra/ext.rb +31 -0
- data/lib/datadog/tracing/contrib/sinatra/framework.rb +116 -0
- data/lib/datadog/tracing/contrib/sinatra/integration.rb +43 -0
- data/lib/datadog/tracing/contrib/sinatra/patcher.rb +75 -0
- data/lib/datadog/tracing/contrib/sinatra/tracer.rb +86 -0
- data/lib/datadog/tracing/contrib/sinatra/tracer_middleware.rb +109 -0
- data/lib/datadog/tracing/contrib/sneakers/configuration/settings.rb +43 -0
- data/lib/datadog/tracing/contrib/sneakers/ext.rb +27 -0
- data/lib/datadog/tracing/contrib/sneakers/integration.rb +44 -0
- data/lib/datadog/tracing/contrib/sneakers/patcher.rb +27 -0
- data/lib/datadog/tracing/contrib/sneakers/tracer.rb +60 -0
- data/lib/datadog/tracing/contrib/span_attribute_schema.rb +92 -0
- data/lib/datadog/tracing/contrib/status_range_env_parser.rb +33 -0
- data/lib/datadog/tracing/contrib/status_range_matcher.rb +25 -0
- data/lib/datadog/tracing/contrib/stripe/configuration/settings.rb +37 -0
- data/lib/datadog/tracing/contrib/stripe/ext.rb +27 -0
- data/lib/datadog/tracing/contrib/stripe/integration.rb +43 -0
- data/lib/datadog/tracing/contrib/stripe/patcher.rb +28 -0
- data/lib/datadog/tracing/contrib/stripe/request.rb +67 -0
- data/lib/datadog/tracing/contrib/sucker_punch/configuration/settings.rb +39 -0
- data/lib/datadog/tracing/contrib/sucker_punch/exception_handler.rb +28 -0
- data/lib/datadog/tracing/contrib/sucker_punch/ext.rb +28 -0
- data/lib/datadog/tracing/contrib/sucker_punch/instrumentation.rb +104 -0
- data/lib/datadog/tracing/contrib/sucker_punch/integration.rb +43 -0
- data/lib/datadog/tracing/contrib/sucker_punch/patcher.rb +35 -0
- data/lib/datadog/tracing/contrib/trilogy/configuration/settings.rb +58 -0
- data/lib/datadog/tracing/contrib/trilogy/ext.rb +27 -0
- data/lib/datadog/tracing/contrib/trilogy/instrumentation.rb +94 -0
- data/lib/datadog/tracing/contrib/trilogy/integration.rb +43 -0
- data/lib/datadog/tracing/contrib/trilogy/patcher.rb +31 -0
- data/lib/datadog/tracing/contrib/utils/database.rb +31 -0
- data/lib/datadog/tracing/contrib/utils/quantization/hash.rb +111 -0
- data/lib/datadog/tracing/contrib/utils/quantization/http.rb +179 -0
- data/lib/datadog/tracing/contrib.rb +81 -0
- data/lib/datadog/tracing/correlation.rb +103 -0
- data/lib/datadog/tracing/diagnostics/environment_logger.rb +159 -0
- data/lib/datadog/tracing/diagnostics/ext.rb +36 -0
- data/lib/datadog/tracing/diagnostics/health.rb +40 -0
- data/lib/datadog/tracing/distributed/b3_multi.rb +73 -0
- data/lib/datadog/tracing/distributed/b3_single.rb +69 -0
- data/lib/datadog/tracing/distributed/datadog.rb +200 -0
- data/lib/datadog/tracing/distributed/datadog_tags_codec.rb +84 -0
- data/lib/datadog/tracing/distributed/fetcher.rb +21 -0
- data/lib/datadog/tracing/distributed/helpers.rb +65 -0
- data/lib/datadog/tracing/distributed/none.rb +18 -0
- data/lib/datadog/tracing/distributed/propagation.rb +121 -0
- data/lib/datadog/tracing/distributed/trace_context.rb +436 -0
- data/lib/datadog/tracing/event.rb +76 -0
- data/lib/datadog/tracing/flush.rb +96 -0
- data/lib/datadog/tracing/metadata/analytics.rb +26 -0
- data/lib/datadog/tracing/metadata/errors.rb +24 -0
- data/lib/datadog/tracing/metadata/ext.rb +193 -0
- data/lib/datadog/tracing/metadata/tagging.rb +131 -0
- data/lib/datadog/tracing/metadata.rb +20 -0
- data/lib/datadog/tracing/pipeline/span_filter.rb +46 -0
- data/lib/datadog/tracing/pipeline/span_processor.rb +39 -0
- data/lib/datadog/tracing/pipeline.rb +63 -0
- data/lib/datadog/tracing/remote.rb +78 -0
- data/lib/datadog/tracing/runtime/metrics.rb +17 -0
- data/lib/datadog/tracing/sampling/all_sampler.rb +24 -0
- data/lib/datadog/tracing/sampling/ext.rb +56 -0
- data/lib/datadog/tracing/sampling/matcher.rb +65 -0
- data/lib/datadog/tracing/sampling/priority_sampler.rb +160 -0
- data/lib/datadog/tracing/sampling/rate_by_key_sampler.rb +87 -0
- data/lib/datadog/tracing/sampling/rate_by_service_sampler.rb +63 -0
- data/lib/datadog/tracing/sampling/rate_limiter.rb +185 -0
- data/lib/datadog/tracing/sampling/rate_sampler.rb +58 -0
- data/lib/datadog/tracing/sampling/rule.rb +61 -0
- data/lib/datadog/tracing/sampling/rule_sampler.rb +148 -0
- data/lib/datadog/tracing/sampling/sampler.rb +32 -0
- data/lib/datadog/tracing/sampling/span/ext.rb +25 -0
- data/lib/datadog/tracing/sampling/span/matcher.rb +89 -0
- data/lib/datadog/tracing/sampling/span/rule.rb +78 -0
- data/lib/datadog/tracing/sampling/span/rule_parser.rb +104 -0
- data/lib/datadog/tracing/sampling/span/sampler.rb +77 -0
- data/lib/datadog/tracing/span.rb +207 -0
- data/lib/datadog/tracing/span_operation.rb +498 -0
- data/lib/datadog/tracing/sync_writer.rb +67 -0
- data/lib/datadog/tracing/trace_digest.rb +185 -0
- data/lib/datadog/tracing/trace_operation.rb +492 -0
- data/lib/datadog/tracing/trace_segment.rb +222 -0
- data/lib/datadog/tracing/tracer.rb +531 -0
- data/lib/datadog/tracing/transport/http/api/instance.rb +37 -0
- data/lib/datadog/tracing/transport/http/api/spec.rb +19 -0
- data/lib/datadog/tracing/transport/http/api.rb +43 -0
- data/lib/datadog/tracing/transport/http/builder.rb +162 -0
- data/lib/datadog/tracing/transport/http/client.rb +57 -0
- data/lib/datadog/tracing/transport/http/statistics.rb +47 -0
- data/lib/datadog/tracing/transport/http/traces.rb +152 -0
- data/lib/datadog/tracing/transport/http.rb +97 -0
- data/lib/datadog/tracing/transport/io/client.rb +89 -0
- data/lib/datadog/tracing/transport/io/response.rb +27 -0
- data/lib/datadog/tracing/transport/io/traces.rb +101 -0
- data/lib/datadog/tracing/transport/io.rb +30 -0
- data/lib/datadog/tracing/transport/serializable_trace.rb +126 -0
- data/lib/datadog/tracing/transport/statistics.rb +77 -0
- data/lib/datadog/tracing/transport/trace_formatter.rb +240 -0
- data/lib/datadog/tracing/transport/traces.rb +224 -0
- data/lib/datadog/tracing/utils.rb +83 -0
- data/lib/datadog/tracing/workers/trace_writer.rb +196 -0
- data/lib/datadog/tracing/workers.rb +125 -0
- data/lib/datadog/tracing/writer.rb +188 -0
- data/lib/datadog/tracing.rb +169 -0
- data/lib/datadog/version.rb +26 -0
- data/lib/datadog.rb +10 -0
- metadata +886 -0
@@ -0,0 +1,436 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Datadog
|
4
|
+
module Tracing
|
5
|
+
module Distributed
|
6
|
+
# W3C Trace Context propagator implementation, version 00.
|
7
|
+
# The trace is propagated through two fields: `traceparent` and `tracestate`.
|
8
|
+
# @see https://www.w3.org/TR/trace-context/
|
9
|
+
class TraceContext
|
10
|
+
TRACEPARENT_KEY = 'traceparent'
|
11
|
+
TRACESTATE_KEY = 'tracestate'
|
12
|
+
SPEC_VERSION = '00'
|
13
|
+
|
14
|
+
def initialize(
|
15
|
+
fetcher:,
|
16
|
+
traceparent_key: TRACEPARENT_KEY,
|
17
|
+
tracestate_key: TRACESTATE_KEY
|
18
|
+
)
|
19
|
+
@fetcher = fetcher
|
20
|
+
@traceparent_key = traceparent_key
|
21
|
+
@tracestate_key = tracestate_key
|
22
|
+
end
|
23
|
+
|
24
|
+
def inject!(digest, data)
|
25
|
+
return if digest.nil?
|
26
|
+
|
27
|
+
if (traceparent = build_traceparent(digest))
|
28
|
+
data[@traceparent_key] = traceparent
|
29
|
+
|
30
|
+
if (tracestate = build_tracestate(digest))
|
31
|
+
data[@tracestate_key] = tracestate
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
data
|
36
|
+
end
|
37
|
+
|
38
|
+
def extract(data)
|
39
|
+
fetcher = @fetcher.new(data)
|
40
|
+
|
41
|
+
trace_id, parent_id, sampled, trace_flags = extract_traceparent(fetcher[@traceparent_key])
|
42
|
+
|
43
|
+
return unless trace_id # Could not parse traceparent
|
44
|
+
|
45
|
+
tracestate, sampling_priority, origin, ts_parent_id, tags, unknown_fields = extract_tracestate(
|
46
|
+
fetcher[@tracestate_key]
|
47
|
+
)
|
48
|
+
|
49
|
+
sampling_priority = parse_priority_sampling(sampled, sampling_priority) do |decision|
|
50
|
+
case decision
|
51
|
+
when String
|
52
|
+
tags ||= {}
|
53
|
+
tags[Tracing::Metadata::Ext::Distributed::TAG_DECISION_MAKER] = decision
|
54
|
+
when :drop
|
55
|
+
tags.delete(Tracing::Metadata::Ext::Distributed::TAG_DECISION_MAKER) if tags
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
tags ||= {}
|
60
|
+
tags[Tracing::Metadata::Ext::Distributed::TAG_DD_PARENT_ID] = ts_parent_id || '0000000000000000'
|
61
|
+
|
62
|
+
TraceDigest.new(
|
63
|
+
span_id: parent_id,
|
64
|
+
trace_id: trace_id,
|
65
|
+
trace_origin: origin,
|
66
|
+
trace_sampling_priority: sampling_priority,
|
67
|
+
trace_distributed_tags: tags,
|
68
|
+
trace_flags: trace_flags,
|
69
|
+
trace_state: tracestate,
|
70
|
+
trace_state_unknown_fields: unknown_fields,
|
71
|
+
span_remote: true,
|
72
|
+
)
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
# Refinements to ensure newer rubies do not suffer performance impact
|
78
|
+
# by needing to use older APIs.
|
79
|
+
module Refine
|
80
|
+
# Backport `Regexp::match?` because it is measurably the most performant
|
81
|
+
# way to check if a string matches a regular expression.
|
82
|
+
unless Regexp.method_defined?(:match?)
|
83
|
+
refine ::Regexp do
|
84
|
+
def match?(*args)
|
85
|
+
!match(*args).nil?
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
unless String.method_defined?(:delete_prefix)
|
91
|
+
refine ::String do
|
92
|
+
def delete_prefix(prefix)
|
93
|
+
prefix = prefix.to_s
|
94
|
+
if rindex(prefix, 0)
|
95
|
+
self[prefix.length..-1]
|
96
|
+
else
|
97
|
+
dup
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
using Refine
|
104
|
+
|
105
|
+
# @see https://www.w3.org/TR/trace-context/#traceparent-header
|
106
|
+
def build_traceparent(digest)
|
107
|
+
build_traceparent_string(
|
108
|
+
digest.trace_id,
|
109
|
+
digest.span_id,
|
110
|
+
build_trace_flags(digest)
|
111
|
+
)
|
112
|
+
end
|
113
|
+
|
114
|
+
# For the current version (00), the traceparent has the following format:
|
115
|
+
#
|
116
|
+
# `"#{version}-#{trace_id}-#{parent_id}-#{trace_flags}"`
|
117
|
+
#
|
118
|
+
# Where:
|
119
|
+
# * `version`: 2 hex-encoded digits, zero padded.
|
120
|
+
# * `trace_id`: 32 hex-encoded digits, zero padded.
|
121
|
+
# * `parent_id`: 16 hex-encoded digits, zero padded.
|
122
|
+
# * `trace_flags`: 2 hex-encoded digits, zero padded.
|
123
|
+
#
|
124
|
+
# All hex values should be lowercase.
|
125
|
+
#
|
126
|
+
# @param trace_id [Integer] 128-bit
|
127
|
+
# @param parent_id [Integer] 64-bit
|
128
|
+
# @param trace_flags [Integer] 8-bit
|
129
|
+
def build_traceparent_string(trace_id, parent_id, trace_flags)
|
130
|
+
"00-#{format('%032x', trace_id)}-#{format('%016x', parent_id)}-#{format('%02x', trace_flags)}"
|
131
|
+
end
|
132
|
+
|
133
|
+
# Sets the trace flag to an existing `trace_flags`.
|
134
|
+
def build_trace_flags(digest)
|
135
|
+
trace_flags = digest.trace_flags || DEFAULT_TRACE_FLAGS
|
136
|
+
|
137
|
+
if digest.trace_sampling_priority
|
138
|
+
if Tracing::Sampling::PrioritySampler.sampled?(digest.trace_sampling_priority)
|
139
|
+
trace_flags |= TRACE_FLAGS_SAMPLED
|
140
|
+
else
|
141
|
+
trace_flags &= ~TRACE_FLAGS_SAMPLED
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
trace_flags
|
146
|
+
end
|
147
|
+
|
148
|
+
# @see https://www.w3.org/TR/trace-context/#tracestate-header
|
149
|
+
def build_tracestate(digest)
|
150
|
+
tracestate = String.new('dd=')
|
151
|
+
tracestate << last_dd_parent_id(digest)
|
152
|
+
tracestate << "s:#{digest.trace_sampling_priority};" if digest.trace_sampling_priority
|
153
|
+
tracestate << "o:#{serialize_origin(digest.trace_origin)};" if digest.trace_origin
|
154
|
+
|
155
|
+
if digest.trace_distributed_tags
|
156
|
+
digest.trace_distributed_tags.each do |name, value|
|
157
|
+
tag = "t.#{serialize_tag_key(name)}:#{serialize_tag_value(value)};"
|
158
|
+
|
159
|
+
# If tracestate size limit is exceed, drop the remaining data.
|
160
|
+
# String#bytesize is used because only ASCII characters are allowed.
|
161
|
+
#
|
162
|
+
# We add 1 to the limit because of the trailing comma, which will be removed before returning.
|
163
|
+
break if tracestate.bytesize + tag.bytesize > (TRACESTATE_VALUE_SIZE_LIMIT + 1)
|
164
|
+
|
165
|
+
tracestate << tag
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
tracestate << digest.trace_state_unknown_fields if digest.trace_state_unknown_fields
|
170
|
+
|
171
|
+
# Is there any Datadog-specific information to propagate.
|
172
|
+
# Check for > 3 size because the empty prefix `dd=` has 3 characters.
|
173
|
+
if tracestate.size > 3
|
174
|
+
# Propagate upstream tracestate with `dd=...` appended to the list
|
175
|
+
tracestate.chop! # Removes trailing `;` from Datadog trace state string.
|
176
|
+
|
177
|
+
if digest.trace_state
|
178
|
+
trace_state = digest.trace_state.strip
|
179
|
+
|
180
|
+
# Delete existing `dd=` tracestate fields, if present.
|
181
|
+
vendors = split_tracestate(trace_state)
|
182
|
+
vendors.reject! { |v| v.start_with?('dd=') }
|
183
|
+
end
|
184
|
+
|
185
|
+
if vendors && !vendors.empty?
|
186
|
+
# Ensure the list has at most 31 elements, as we need to prepend Datadog's
|
187
|
+
# entry and the limit is 32 elements total.
|
188
|
+
vendors = vendors[0..30]
|
189
|
+
"#{tracestate},#{vendors.join(',')}"
|
190
|
+
else
|
191
|
+
tracestate.to_s
|
192
|
+
end
|
193
|
+
else
|
194
|
+
digest.trace_state # Propagate upstream tracestate with no Datadog changes
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
def last_dd_parent_id(digest)
|
199
|
+
if !digest.span_remote
|
200
|
+
"p:#{format('%016x', digest.span_id)};"
|
201
|
+
elsif digest.trace_distributed_tags&.key?(Tracing::Metadata::Ext::Distributed::TAG_DD_PARENT_ID)
|
202
|
+
"p:#{digest.trace_distributed_tags[Tracing::Metadata::Ext::Distributed::TAG_DD_PARENT_ID]};"
|
203
|
+
else
|
204
|
+
''
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
# If any characters in <origin_value> are invalid, replace each invalid character with 0x5F (underscore).
|
209
|
+
# Invalid characters are: characters outside the ASCII range 0x20 to 0x7E,
|
210
|
+
# 0x2C (comma), 0x3B (semi-colon), and 0x7E (tilde).
|
211
|
+
# Then, remap 0x3D (equals) to 0x7E (tilde)
|
212
|
+
def serialize_origin(value)
|
213
|
+
# DEV: It's unlikely that characters will be out of range, as they mostly
|
214
|
+
# DEV: come from Datadog-controlled sources.
|
215
|
+
# DEV: Trying to `match?` is measurably faster than a `gsub` that does not match.
|
216
|
+
value = if INVALID_ORIGIN_CHARS.match?(value)
|
217
|
+
value.gsub(INVALID_ORIGIN_CHARS, '_')
|
218
|
+
else
|
219
|
+
value
|
220
|
+
end
|
221
|
+
|
222
|
+
if REMAP_ORIGIN_CHARS.match?(value)
|
223
|
+
value.gsub(REMAP_ORIGIN_CHARS, '~')
|
224
|
+
else
|
225
|
+
value
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
# Serialize `_dd.p.{key}` by first removing the `_dd.p.` prefix.
|
230
|
+
# Then replacing invalid characters with `_`.
|
231
|
+
#
|
232
|
+
# The argument `name` is always frozen.
|
233
|
+
# Returns a new String object for the serialized key.
|
234
|
+
def serialize_tag_key(name)
|
235
|
+
key = name.delete_prefix(Tracing::Metadata::Ext::Distributed::TAGS_PREFIX)
|
236
|
+
|
237
|
+
# DEV: It's unlikely that characters will be out of range, as they mostly
|
238
|
+
# DEV: come from Datadog-controlled sources.
|
239
|
+
# DEV: Trying to `match?` is measurably faster than a `gsub!` that does not match.
|
240
|
+
key.gsub!(INVALID_TAG_KEY_CHARS, '_') if INVALID_TAG_KEY_CHARS.match?(key)
|
241
|
+
|
242
|
+
key
|
243
|
+
end
|
244
|
+
|
245
|
+
# Replaces invalid characters with `_`, then replaces `=` with `~`.
|
246
|
+
#
|
247
|
+
# The argument `value` belongs to {TraceDigest}, thus should not be directly modified.
|
248
|
+
# Returns a new String object for the serialized value.
|
249
|
+
def serialize_tag_value(value)
|
250
|
+
# DEV: It's unlikely that characters will be out of range, as they mostly
|
251
|
+
# DEV: come from Datadog-controlled sources.
|
252
|
+
# DEV: Trying to `match?` is measurably faster than a `gsub` that does not match.
|
253
|
+
ret = if INVALID_TAG_VALUE_CHARS.match?(value)
|
254
|
+
value.gsub(INVALID_TAG_VALUE_CHARS, '_')
|
255
|
+
else
|
256
|
+
value
|
257
|
+
end
|
258
|
+
|
259
|
+
# DEV: Checking for an unlikely '=' is faster than a no-op `tr`.
|
260
|
+
if ret.include?('=')
|
261
|
+
ret.tr('=', '~')
|
262
|
+
else
|
263
|
+
ret
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
def extract_traceparent(traceparent)
|
268
|
+
trace_id, parent_id, trace_flags = parse_traceparent_string(traceparent)
|
269
|
+
|
270
|
+
# Return unless all traceparent fields are valid.
|
271
|
+
return unless trace_id && !trace_id.zero? && parent_id && !parent_id.zero? && trace_flags
|
272
|
+
|
273
|
+
sampled = parse_sampled_flag(trace_flags)
|
274
|
+
|
275
|
+
[trace_id, parent_id, sampled, trace_flags]
|
276
|
+
end
|
277
|
+
|
278
|
+
def parse_traceparent_string(traceparent)
|
279
|
+
return unless traceparent
|
280
|
+
|
281
|
+
version, trace_id, parent_id, trace_flags, extra = traceparent.strip.split('-')
|
282
|
+
|
283
|
+
return if version.size != 2 || version[0] < '0' || version[0] > 'f' || version[1] < '0' || version[1] > 'f'
|
284
|
+
|
285
|
+
return if version == INVALID_VERSION
|
286
|
+
|
287
|
+
# Extra fields are not allowed in version 00, but we have to be lenient for future versions.
|
288
|
+
return if version == SPEC_VERSION && extra
|
289
|
+
|
290
|
+
# Invalid field sizes
|
291
|
+
return if trace_id.size != 32 || parent_id.size != 16 || trace_flags.size != 2
|
292
|
+
|
293
|
+
[Integer(trace_id, 16), Integer(parent_id, 16), Integer(trace_flags, 16)]
|
294
|
+
rescue ArgumentError # Conversion to integer failed
|
295
|
+
nil
|
296
|
+
end
|
297
|
+
|
298
|
+
def parse_sampled_flag(trace_flags)
|
299
|
+
trace_flags & TRACE_FLAGS_SAMPLED
|
300
|
+
end
|
301
|
+
|
302
|
+
# @return [Array<String,Integer,String,String,Hash>] returns 4 values:
|
303
|
+
# tracestate, sampling_priority, ts_parent_id, origin, tags.
|
304
|
+
def extract_tracestate(tracestate)
|
305
|
+
return unless tracestate
|
306
|
+
|
307
|
+
vendors = split_tracestate(tracestate)
|
308
|
+
|
309
|
+
# Find Datadog's `dd=` tracestate field.
|
310
|
+
idx = vendors.index { |v| v.start_with?('dd=') }
|
311
|
+
return tracestate unless idx
|
312
|
+
|
313
|
+
# Delete `dd=` prefix
|
314
|
+
dd_tracestate = vendors.delete_at(idx)
|
315
|
+
dd_tracestate.slice!(0..2)
|
316
|
+
|
317
|
+
origin, sampling_priority, ts_parent_id, tags, unknown_fields = extract_datadog_fields(dd_tracestate)
|
318
|
+
|
319
|
+
[vendors.join(','), sampling_priority, origin, ts_parent_id, tags, unknown_fields]
|
320
|
+
end
|
321
|
+
|
322
|
+
def extract_datadog_fields(dd_tracestate)
|
323
|
+
sampling_priority = nil
|
324
|
+
origin = nil
|
325
|
+
ts_parent_id = nil
|
326
|
+
tags = nil
|
327
|
+
unknown_fields = nil
|
328
|
+
|
329
|
+
# DEV: Since Ruby 2.6 `split` can receive a block, so `each` can be removed then.
|
330
|
+
dd_tracestate.split(';').each do |pair|
|
331
|
+
key, value = pair.split(':', 2)
|
332
|
+
case key
|
333
|
+
when 's'
|
334
|
+
sampling_priority = Integer(value) rescue nil
|
335
|
+
when 'o'
|
336
|
+
origin = value
|
337
|
+
when 'p'
|
338
|
+
ts_parent_id = value
|
339
|
+
when /^t\./
|
340
|
+
key.slice!(0..1) # Delete `t.` prefix
|
341
|
+
|
342
|
+
# Ignore the high order 64 bit trace id propagation tag to avoid confusion,
|
343
|
+
# the single source of truth is from traceparent
|
344
|
+
next if key == Tracing::Metadata::Ext::Distributed::TID
|
345
|
+
|
346
|
+
value = deserialize_tag_value(value)
|
347
|
+
|
348
|
+
tags ||= {}
|
349
|
+
tags["#{Tracing::Metadata::Ext::Distributed::TAGS_PREFIX}#{key}"] = value
|
350
|
+
else
|
351
|
+
unknown_fields ||= String.new
|
352
|
+
unknown_fields << pair
|
353
|
+
unknown_fields << ';'
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
357
|
+
[origin, sampling_priority, ts_parent_id, tags, unknown_fields]
|
358
|
+
end
|
359
|
+
|
360
|
+
# Restore `~` back to `=`.
|
361
|
+
def deserialize_tag_value(value)
|
362
|
+
value.tr!('~', '=')
|
363
|
+
value
|
364
|
+
end
|
365
|
+
|
366
|
+
# If `sampled` and `sampling_priority` disagree, `sampled` overrides the decision.
|
367
|
+
# @return [Integer] one of the {Datadog::Tracing::Sampling::Ext::Priority} values
|
368
|
+
# @yieldparam the new decision maker (either :drop or a new decision maker String value).
|
369
|
+
def parse_priority_sampling(sampled, sampling_priority)
|
370
|
+
if sampled == 1
|
371
|
+
if sampling_priority && Tracing::Sampling::PrioritySampler.sampled?(sampling_priority)
|
372
|
+
# Both sampling fields agree.
|
373
|
+
sampling_priority
|
374
|
+
else
|
375
|
+
# Sampling fields disagree.
|
376
|
+
# Let's force the trace to be kept, while also updating the decision maker to ourselves.
|
377
|
+
yield Tracing::Sampling::Ext::Decision::DEFAULT
|
378
|
+
sampled
|
379
|
+
end
|
380
|
+
elsif sampling_priority && !Tracing::Sampling::PrioritySampler.sampled?(sampling_priority)
|
381
|
+
sampling_priority
|
382
|
+
# Both sampling fields agree.
|
383
|
+
else
|
384
|
+
# Sampling fields disagree.
|
385
|
+
# Let's drop the trace and remove the sampling decision tag, as dropped spans don't carry sampling decision.
|
386
|
+
yield :drop
|
387
|
+
sampled
|
388
|
+
end
|
389
|
+
end
|
390
|
+
|
391
|
+
def split_tracestate(tracestate)
|
392
|
+
tracestate.split(/[ \t]*+,[ \t]*+/)[0..31]
|
393
|
+
end
|
394
|
+
|
395
|
+
# Version 0xFF is invalid as per spec
|
396
|
+
# @see https://www.w3.org/TR/trace-context/#version
|
397
|
+
INVALID_VERSION = 'ff'
|
398
|
+
private_constant :INVALID_VERSION
|
399
|
+
|
400
|
+
# Empty 8-bit `trace-flags`.
|
401
|
+
# @see https://www.w3.org/TR/trace-context/#trace-flags
|
402
|
+
DEFAULT_TRACE_FLAGS = 0b00000000
|
403
|
+
private_constant :DEFAULT_TRACE_FLAGS
|
404
|
+
|
405
|
+
# Bit-mask for `trace-flags` that represents a sampled span (sampled==true).
|
406
|
+
# @see https://www.w3.org/TR/trace-context/#trace-flags
|
407
|
+
TRACE_FLAGS_SAMPLED = 0b00000001
|
408
|
+
private_constant :TRACE_FLAGS_SAMPLED
|
409
|
+
|
410
|
+
# The limit is inclusive: sizes *greater* than 256 are disallowed.
|
411
|
+
# @see https://www.w3.org/TR/trace-context/#value
|
412
|
+
TRACESTATE_VALUE_SIZE_LIMIT = 256
|
413
|
+
private_constant :TRACESTATE_VALUE_SIZE_LIMIT
|
414
|
+
|
415
|
+
# Replace all characters with `_`, except ASCII characters 0x20-0x7E.
|
416
|
+
# Additionally, `,`, ';', and `~` must also be replaced by `_`.
|
417
|
+
INVALID_ORIGIN_CHARS = /[\u0000-\u0019,;~\u007F-\u{10FFFF}]/.freeze
|
418
|
+
private_constant :INVALID_ORIGIN_CHARS
|
419
|
+
|
420
|
+
# Additionally, remap `=` to `~`
|
421
|
+
REMAP_ORIGIN_CHARS = /=/.freeze
|
422
|
+
private_constant :REMAP_ORIGIN_CHARS
|
423
|
+
|
424
|
+
# Replace all characters with `_`, except ASCII characters 0x21-0x7E.
|
425
|
+
# Additionally, `,` and `=` must also be replaced by `_`.
|
426
|
+
INVALID_TAG_KEY_CHARS = /[\u0000-\u0020,=\u007F-\u{10FFFF}]/.freeze
|
427
|
+
private_constant :INVALID_TAG_KEY_CHARS
|
428
|
+
|
429
|
+
# Replace all characters with `_`, except ASCII characters 0x20-0x7D.
|
430
|
+
# Additionally, `,` and `;` must also be replaced by `_`.
|
431
|
+
INVALID_TAG_VALUE_CHARS = /[\u0000-\u001F,;\u007E-\u{10FFFF}]/.freeze
|
432
|
+
private_constant :INVALID_TAG_VALUE_CHARS
|
433
|
+
end
|
434
|
+
end
|
435
|
+
end
|
436
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Datadog
|
4
|
+
module Tracing
|
5
|
+
# Event behavior and DSL
|
6
|
+
module Events
|
7
|
+
def self.included(base)
|
8
|
+
base.extend(ClassMethods)
|
9
|
+
base.include(InstanceMethods)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Class methods
|
13
|
+
module ClassMethods
|
14
|
+
def build(**event_handlers)
|
15
|
+
events = new
|
16
|
+
events.subscribe(**event_handlers)
|
17
|
+
events
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Instance methods
|
22
|
+
module InstanceMethods
|
23
|
+
def subscribe(**event_handlers)
|
24
|
+
return unless event_handlers
|
25
|
+
|
26
|
+
event_handlers.each do |event_name, handlers|
|
27
|
+
handlers.each do |handler_name, handler|
|
28
|
+
events.send(event_name).subscribe(handler_name, &handler)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
event_handlers
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# A simple pub-sub event model for components to exchange messages through.
|
38
|
+
class Event
|
39
|
+
attr_reader \
|
40
|
+
:name,
|
41
|
+
:subscriptions
|
42
|
+
|
43
|
+
def initialize(name)
|
44
|
+
@name = name
|
45
|
+
@subscriptions = []
|
46
|
+
end
|
47
|
+
|
48
|
+
def subscribe(&block)
|
49
|
+
raise ArgumentError, 'Must give a block to subscribe!' unless block
|
50
|
+
|
51
|
+
subscriptions << block
|
52
|
+
end
|
53
|
+
|
54
|
+
def unsubscribe_all!
|
55
|
+
subscriptions.clear
|
56
|
+
|
57
|
+
true
|
58
|
+
end
|
59
|
+
|
60
|
+
def publish(*args)
|
61
|
+
subscriptions.each do |block|
|
62
|
+
begin
|
63
|
+
block.call(*args)
|
64
|
+
rescue StandardError => e
|
65
|
+
Datadog.logger.debug do
|
66
|
+
"Error while handling '#{name}' event with '#{block}': #{e.class.name} #{e.message} " \
|
67
|
+
"at #{Array(e.backtrace).first}"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
true
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Datadog
|
4
|
+
module Tracing
|
5
|
+
module Flush
|
6
|
+
# Consumes and returns a {TraceSegment} to be flushed, from
|
7
|
+
# the provided {TraceSegment}.
|
8
|
+
#
|
9
|
+
# Only finished spans are consumed. Any spans consumed are
|
10
|
+
# removed from +trace_op+ as a side effect. Unfinished spans are
|
11
|
+
# unaffected.
|
12
|
+
#
|
13
|
+
# @abstract
|
14
|
+
class Base
|
15
|
+
# Consumes and returns a {TraceSegment} to be flushed, from
|
16
|
+
# the provided {TraceSegment}.
|
17
|
+
#
|
18
|
+
# Only finished spans are consumed. Any spans consumed are
|
19
|
+
# removed from +trace_op+ as a side effect. Unfinished spans are
|
20
|
+
# unaffected.
|
21
|
+
#
|
22
|
+
# @param [TraceOperation] trace_op
|
23
|
+
# @return [TraceSegment] trace to be flushed, or +nil+ if the trace is not finished
|
24
|
+
def consume!(trace_op)
|
25
|
+
return unless flush?(trace_op)
|
26
|
+
|
27
|
+
get_trace(trace_op)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Should we consume spans from the +trace_op+?
|
31
|
+
# @abstract
|
32
|
+
def flush?(trace_op)
|
33
|
+
raise NotImplementedError
|
34
|
+
end
|
35
|
+
|
36
|
+
protected
|
37
|
+
|
38
|
+
# Consumes all finished spans from trace.
|
39
|
+
# @return [TraceSegment]
|
40
|
+
def get_trace(trace_op)
|
41
|
+
trace_op.flush! do |spans|
|
42
|
+
spans.select! { |span| single_sampled?(span) } unless trace_op.sampled?
|
43
|
+
|
44
|
+
spans
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Single Span Sampling has chosen to keep this span
|
49
|
+
# regardless of the trace-level sampling decision
|
50
|
+
def single_sampled?(span)
|
51
|
+
span.get_metric(Sampling::Span::Ext::TAG_MECHANISM) == Sampling::Ext::Mechanism::SPAN_SAMPLING_RATE
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Consumes and returns completed traces (where all spans have finished),
|
56
|
+
# if any, from the provided +trace_op+.
|
57
|
+
#
|
58
|
+
# Spans consumed are removed from +trace_op+ as a side effect.
|
59
|
+
class Finished < Base
|
60
|
+
# Are all spans finished?
|
61
|
+
def flush?(trace_op)
|
62
|
+
trace_op && trace_op.finished?
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Consumes and returns completed or partially completed
|
67
|
+
# traces from the provided +trace_op+, if any.
|
68
|
+
#
|
69
|
+
# Partial trace flushing avoids large traces residing in memory for too long.
|
70
|
+
#
|
71
|
+
# Partially completed traces, where not all spans have finished,
|
72
|
+
# will only be returned if there are at least
|
73
|
+
# +@min_spans_for_partial+ finished spans.
|
74
|
+
#
|
75
|
+
# Spans consumed are removed from +trace_op+ as a side effect.
|
76
|
+
class Partial < Base
|
77
|
+
# Start flushing partial trace after this many active spans in one trace
|
78
|
+
DEFAULT_MIN_SPANS_FOR_PARTIAL_FLUSH = 500
|
79
|
+
|
80
|
+
attr_reader :min_spans_for_partial
|
81
|
+
|
82
|
+
def initialize(options = {})
|
83
|
+
super()
|
84
|
+
@min_spans_for_partial = options.fetch(:min_spans_before_partial_flush, DEFAULT_MIN_SPANS_FOR_PARTIAL_FLUSH)
|
85
|
+
end
|
86
|
+
|
87
|
+
def flush?(trace_op)
|
88
|
+
return true if trace_op.finished?
|
89
|
+
return false if trace_op.finished_span_count < @min_spans_for_partial
|
90
|
+
|
91
|
+
true
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../analytics'
|
4
|
+
require_relative 'ext'
|
5
|
+
|
6
|
+
module Datadog
|
7
|
+
module Tracing
|
8
|
+
module Metadata
|
9
|
+
# Defines analytics tagging behavior
|
10
|
+
module Analytics
|
11
|
+
def set_tag(key, value)
|
12
|
+
case key
|
13
|
+
when Ext::Analytics::TAG_ENABLED
|
14
|
+
# If true, set rate to 1.0, otherwise set 0.0.
|
15
|
+
value = value == true ? Ext::Analytics::DEFAULT_SAMPLE_RATE : 0.0
|
16
|
+
Tracing::Analytics.set_sample_rate(self, value)
|
17
|
+
when Ext::Analytics::TAG_SAMPLE_RATE
|
18
|
+
Tracing::Analytics.set_sample_rate(self, value)
|
19
|
+
else
|
20
|
+
super if defined?(super)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../core/error'
|
4
|
+
|
5
|
+
require_relative 'ext'
|
6
|
+
|
7
|
+
module Datadog
|
8
|
+
module Tracing
|
9
|
+
module Metadata
|
10
|
+
# Adds error tagging behavior
|
11
|
+
# @public_api
|
12
|
+
module Errors
|
13
|
+
# Mark the span with the given error.
|
14
|
+
def set_error(e)
|
15
|
+
e = Core::Error.build_from(e)
|
16
|
+
|
17
|
+
set_tag(Ext::Errors::TAG_TYPE, e.type) unless e.type.empty?
|
18
|
+
set_tag(Ext::Errors::TAG_MSG, e.message) unless e.message.empty?
|
19
|
+
set_tag(Ext::Errors::TAG_STACK, e.backtrace) unless e.backtrace.empty?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|