ddtrace 1.2.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +70 -0
- data/LICENSE-3rdparty.csv +2 -0
- data/README.md +1 -1
- data/ext/ddtrace_profiling_loader/ddtrace_profiling_loader.c +1 -1
- data/ext/ddtrace_profiling_native_extension/NativeExtensionDesign.md +9 -2
- data/ext/ddtrace_profiling_native_extension/clock_id.h +20 -0
- data/ext/ddtrace_profiling_native_extension/clock_id_from_pthread.c +30 -1
- data/ext/ddtrace_profiling_native_extension/clock_id_noop.c +10 -1
- data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time.c +152 -31
- data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time.h +6 -0
- data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +391 -0
- data/ext/ddtrace_profiling_native_extension/collectors_stack.c +11 -7
- data/ext/ddtrace_profiling_native_extension/extconf.rb +26 -19
- data/ext/ddtrace_profiling_native_extension/helpers.h +12 -0
- data/ext/ddtrace_profiling_native_extension/http_transport.c +40 -47
- data/ext/ddtrace_profiling_native_extension/{libddprof_helpers.h → libdatadog_helpers.h} +2 -1
- data/ext/ddtrace_profiling_native_extension/native_extension_helpers.rb +36 -20
- data/ext/ddtrace_profiling_native_extension/private_vm_api_access.c +39 -29
- data/ext/ddtrace_profiling_native_extension/private_vm_api_access.h +2 -5
- data/ext/ddtrace_profiling_native_extension/profiling.c +4 -3
- data/ext/ddtrace_profiling_native_extension/ruby_helpers.c +25 -0
- data/ext/ddtrace_profiling_native_extension/ruby_helpers.h +33 -1
- data/ext/ddtrace_profiling_native_extension/stack_recorder.c +294 -19
- data/ext/ddtrace_profiling_native_extension/stack_recorder.h +9 -8
- data/lib/datadog/appsec/autoload.rb +4 -2
- data/lib/datadog/appsec/configuration.rb +1 -1
- data/lib/datadog/appsec/contrib/auto_instrument.rb +0 -2
- data/lib/datadog/appsec/contrib/configuration/settings.rb +1 -1
- data/lib/datadog/appsec/contrib/rack/configuration/settings.rb +2 -2
- data/lib/datadog/appsec/contrib/rack/gateway/watcher.rb +6 -6
- data/lib/datadog/appsec/contrib/rack/integration.rb +5 -5
- data/lib/datadog/appsec/contrib/rack/patcher.rb +2 -2
- data/lib/datadog/appsec/contrib/rack/reactive/request.rb +1 -1
- data/lib/datadog/appsec/contrib/rack/reactive/request_body.rb +1 -1
- data/lib/datadog/appsec/contrib/rack/reactive/response.rb +1 -1
- data/lib/datadog/appsec/contrib/rack/request_body_middleware.rb +2 -2
- data/lib/datadog/appsec/contrib/rack/request_middleware.rb +3 -3
- data/lib/datadog/appsec/contrib/rails/configuration/settings.rb +2 -2
- data/lib/datadog/appsec/contrib/rails/gateway/watcher.rb +4 -4
- data/lib/datadog/appsec/contrib/rails/integration.rb +4 -4
- data/lib/datadog/appsec/contrib/rails/patcher.rb +16 -12
- data/lib/datadog/appsec/contrib/rails/reactive/action.rb +1 -1
- data/lib/datadog/appsec/contrib/sinatra/configuration/settings.rb +2 -2
- data/lib/datadog/appsec/contrib/sinatra/gateway/watcher.rb +5 -5
- data/lib/datadog/appsec/contrib/sinatra/integration.rb +4 -4
- data/lib/datadog/appsec/contrib/sinatra/patcher.rb +16 -12
- data/lib/datadog/appsec/event.rb +3 -3
- data/lib/datadog/appsec/extensions.rb +1 -1
- data/lib/datadog/appsec/processor.rb +1 -1
- data/lib/datadog/appsec/reactive/engine.rb +2 -2
- data/lib/datadog/appsec/reactive/operation.rb +3 -3
- data/lib/datadog/appsec.rb +5 -5
- data/lib/datadog/ci/configuration/components.rb +1 -1
- data/lib/datadog/ci/configuration/settings.rb +1 -1
- data/lib/datadog/ci/contrib/cucumber/configuration/settings.rb +2 -2
- data/lib/datadog/ci/contrib/cucumber/formatter.rb +5 -5
- data/lib/datadog/ci/contrib/cucumber/instrumentation.rb +1 -1
- data/lib/datadog/ci/contrib/cucumber/integration.rb +4 -4
- data/lib/datadog/ci/contrib/cucumber/patcher.rb +2 -2
- data/lib/datadog/ci/contrib/rspec/configuration/settings.rb +2 -2
- data/lib/datadog/ci/contrib/rspec/example.rb +5 -5
- data/lib/datadog/ci/contrib/rspec/integration.rb +4 -4
- data/lib/datadog/ci/contrib/rspec/patcher.rb +2 -2
- data/lib/datadog/ci/ext/environment.rb +8 -6
- data/lib/datadog/ci/extensions.rb +4 -4
- data/lib/datadog/ci/flush.rb +2 -2
- data/lib/datadog/ci/test.rb +3 -3
- data/lib/datadog/ci.rb +6 -6
- data/lib/datadog/core/buffer/cruby.rb +1 -1
- data/lib/datadog/core/buffer/thread_safe.rb +1 -1
- data/lib/datadog/core/configuration/agent_settings_resolver.rb +6 -6
- data/lib/datadog/core/configuration/base.rb +11 -2
- data/lib/datadog/core/configuration/components.rb +51 -48
- data/lib/datadog/core/configuration/option_definition.rb +1 -1
- data/lib/datadog/core/configuration/option_definition_set.rb +1 -1
- data/lib/datadog/core/configuration/options.rb +3 -3
- data/lib/datadog/core/configuration/settings.rb +34 -7
- data/lib/datadog/core/configuration.rb +8 -5
- data/lib/datadog/core/diagnostics/environment_logger.rb +1 -1
- data/lib/datadog/core/diagnostics/health.rb +2 -2
- data/lib/datadog/core/environment/cgroup.rb +1 -1
- data/lib/datadog/core/environment/container.rb +1 -1
- data/lib/datadog/core/environment/ext.rb +1 -1
- data/lib/datadog/core/environment/identity.rb +2 -2
- data/lib/datadog/core/environment/platform.rb +1 -1
- data/lib/datadog/core/environment/socket.rb +1 -1
- data/lib/datadog/core/error.rb +1 -1
- data/lib/datadog/core/extensions.rb +1 -1
- data/lib/datadog/core/metrics/client.rb +8 -8
- data/lib/datadog/core/metrics/options.rb +3 -3
- data/lib/datadog/core/runtime/metrics.rb +6 -6
- data/lib/datadog/core/telemetry/client.rb +79 -0
- data/lib/datadog/core/telemetry/collector.rb +234 -0
- data/lib/datadog/core/telemetry/emitter.rb +48 -0
- data/lib/datadog/core/telemetry/event.rb +71 -0
- data/lib/datadog/core/telemetry/ext.rb +11 -0
- data/lib/datadog/core/telemetry/heartbeat.rb +37 -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 +20 -0
- data/lib/datadog/core/telemetry/http/response.rb +68 -0
- data/lib/datadog/core/telemetry/http/transport.rb +53 -0
- data/lib/datadog/core/telemetry/v1/app_event.rb +52 -0
- data/lib/datadog/core/telemetry/v1/application.rb +86 -0
- data/lib/datadog/core/telemetry/v1/configuration.rb +25 -0
- data/lib/datadog/core/telemetry/v1/dependency.rb +36 -0
- data/lib/datadog/core/telemetry/v1/host.rb +51 -0
- data/lib/datadog/core/telemetry/v1/integration.rb +58 -0
- data/lib/datadog/core/telemetry/v1/product.rb +28 -0
- data/lib/datadog/core/telemetry/v1/telemetry_request.rb +100 -0
- data/lib/datadog/core/utils/object_set.rb +1 -1
- data/lib/datadog/core/utils/sequence.rb +5 -0
- data/lib/datadog/core/utils/string_table.rb +1 -1
- data/lib/datadog/core/utils/time.rb +3 -3
- data/lib/datadog/core/utils.rb +2 -2
- data/lib/datadog/core/vendor/multipart-post/multipart/post/multipartable.rb +2 -2
- data/lib/datadog/core/vendor/multipart-post/net/http/post/multipart.rb +3 -3
- data/lib/datadog/core/workers/async.rb +1 -1
- data/lib/datadog/core/workers/polling.rb +2 -2
- data/lib/datadog/core/workers/runtime_metrics.rb +4 -4
- data/lib/datadog/core.rb +50 -50
- data/lib/datadog/kit.rb +1 -1
- data/lib/datadog/opentracer/distributed_headers.rb +2 -2
- data/lib/datadog/opentracer/rack_propagator.rb +11 -7
- data/lib/datadog/opentracer/span.rb +1 -1
- data/lib/datadog/opentracer/text_map_propagator.rb +9 -6
- data/lib/datadog/opentracer/thread_local_scope_manager.rb +1 -1
- data/lib/datadog/opentracer/tracer.rb +19 -15
- data/lib/datadog/opentracer.rb +16 -16
- data/lib/datadog/profiling/buffer.rb +3 -3
- data/lib/datadog/profiling/collectors/cpu_and_wall_time.rb +4 -19
- data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +74 -0
- data/lib/datadog/profiling/collectors/old_stack.rb +7 -7
- data/lib/datadog/profiling/collectors/stack.rb +3 -8
- data/lib/datadog/profiling/encoding/profile.rb +1 -1
- data/lib/datadog/profiling/events/stack.rb +1 -1
- data/lib/datadog/profiling/exporter.rb +17 -9
- data/lib/datadog/profiling/ext/forking.rb +36 -37
- data/lib/datadog/profiling/ext.rb +1 -0
- data/lib/datadog/profiling/flush.rb +0 -3
- data/lib/datadog/profiling/http_transport.rb +4 -3
- data/lib/datadog/profiling/old_recorder.rb +2 -7
- data/lib/datadog/profiling/pprof/builder.rb +4 -4
- data/lib/datadog/profiling/pprof/converter.rb +1 -1
- data/lib/datadog/profiling/pprof/message_set.rb +1 -1
- data/lib/datadog/profiling/pprof/stack_sample.rb +4 -4
- data/lib/datadog/profiling/pprof/string_table.rb +1 -1
- data/lib/datadog/profiling/pprof/template.rb +5 -5
- data/lib/datadog/profiling/preload.rb +1 -1
- data/lib/datadog/profiling/scheduler.rb +5 -4
- data/lib/datadog/profiling/stack_recorder.rb +14 -4
- data/lib/datadog/profiling/tag_builder.rb +6 -1
- data/lib/datadog/profiling/tasks/setup.rb +2 -2
- data/lib/datadog/profiling/trace_identifiers/ddtrace.rb +2 -2
- data/lib/datadog/profiling/trace_identifiers/helper.rb +1 -1
- data/lib/datadog/profiling/transport/http/api/endpoint.rb +5 -5
- data/lib/datadog/profiling/transport/http/api/instance.rb +2 -2
- data/lib/datadog/profiling/transport/http/api/spec.rb +1 -1
- data/lib/datadog/profiling/transport/http/api.rb +5 -5
- data/lib/datadog/profiling/transport/http/builder.rb +3 -3
- data/lib/datadog/profiling/transport/http/client.rb +2 -2
- data/lib/datadog/profiling/transport/http/response.rb +1 -1
- data/lib/datadog/profiling/transport/http.rb +21 -15
- data/lib/datadog/profiling.rb +21 -20
- data/lib/datadog/tracing/analytics.rb +1 -1
- data/lib/datadog/tracing/buffer.rb +5 -5
- data/lib/datadog/tracing/context.rb +1 -1
- data/lib/datadog/tracing/context_provider.rb +2 -2
- data/lib/datadog/tracing/contrib/action_cable/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/action_cable/event.rb +4 -5
- data/lib/datadog/tracing/contrib/action_cable/events/broadcast.rb +4 -4
- data/lib/datadog/tracing/contrib/action_cable/events/perform_action.rb +3 -3
- data/lib/datadog/tracing/contrib/action_cable/events/transmit.rb +4 -4
- data/lib/datadog/tracing/contrib/action_cable/events.rb +4 -4
- data/lib/datadog/tracing/contrib/action_cable/instrumentation.rb +3 -4
- data/lib/datadog/tracing/contrib/action_cable/integration.rb +4 -4
- data/lib/datadog/tracing/contrib/action_cable/patcher.rb +4 -4
- data/lib/datadog/tracing/contrib/action_mailer/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/action_mailer/event.rb +3 -3
- data/lib/datadog/tracing/contrib/action_mailer/events/deliver.rb +3 -3
- data/lib/datadog/tracing/contrib/action_mailer/events/process.rb +3 -3
- data/lib/datadog/tracing/contrib/action_mailer/events.rb +2 -2
- data/lib/datadog/tracing/contrib/action_mailer/integration.rb +4 -4
- data/lib/datadog/tracing/contrib/action_mailer/patcher.rb +3 -3
- data/lib/datadog/tracing/contrib/action_pack/action_controller/instrumentation.rb +6 -6
- data/lib/datadog/tracing/contrib/action_pack/action_controller/patcher.rb +2 -2
- data/lib/datadog/tracing/contrib/action_pack/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/action_pack/integration.rb +4 -4
- data/lib/datadog/tracing/contrib/action_pack/patcher.rb +2 -2
- data/lib/datadog/tracing/contrib/action_pack/utils.rb +1 -1
- data/lib/datadog/tracing/contrib/action_view/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/action_view/event.rb +1 -1
- data/lib/datadog/tracing/contrib/action_view/events/render_partial.rb +5 -5
- data/lib/datadog/tracing/contrib/action_view/events/render_template.rb +5 -5
- data/lib/datadog/tracing/contrib/action_view/events.rb +2 -2
- data/lib/datadog/tracing/contrib/action_view/instrumentation/partial_renderer.rb +2 -2
- data/lib/datadog/tracing/contrib/action_view/instrumentation/template_renderer.rb +2 -2
- data/lib/datadog/tracing/contrib/action_view/integration.rb +4 -4
- data/lib/datadog/tracing/contrib/action_view/patcher.rb +7 -7
- data/lib/datadog/tracing/contrib/action_view/utils.rb +1 -1
- data/lib/datadog/tracing/contrib/active_job/configuration/settings.rb +3 -3
- data/lib/datadog/tracing/contrib/active_job/event.rb +3 -3
- data/lib/datadog/tracing/contrib/active_job/events/discard.rb +4 -4
- data/lib/datadog/tracing/contrib/active_job/events/enqueue.rb +4 -4
- data/lib/datadog/tracing/contrib/active_job/events/enqueue_at.rb +4 -4
- data/lib/datadog/tracing/contrib/active_job/events/enqueue_retry.rb +4 -4
- data/lib/datadog/tracing/contrib/active_job/events/perform.rb +4 -4
- data/lib/datadog/tracing/contrib/active_job/events/retry_stopped.rb +4 -4
- data/lib/datadog/tracing/contrib/active_job/events.rb +6 -6
- data/lib/datadog/tracing/contrib/active_job/integration.rb +4 -4
- data/lib/datadog/tracing/contrib/active_job/log_injection.rb +0 -2
- data/lib/datadog/tracing/contrib/active_job/patcher.rb +4 -4
- data/lib/datadog/tracing/contrib/active_model_serializers/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/active_model_serializers/event.rb +4 -5
- data/lib/datadog/tracing/contrib/active_model_serializers/events/render.rb +3 -3
- data/lib/datadog/tracing/contrib/active_model_serializers/events/serialize.rb +2 -2
- data/lib/datadog/tracing/contrib/active_model_serializers/events.rb +2 -2
- data/lib/datadog/tracing/contrib/active_model_serializers/integration.rb +3 -3
- data/lib/datadog/tracing/contrib/active_model_serializers/patcher.rb +3 -4
- data/lib/datadog/tracing/contrib/active_record/configuration/resolver.rb +2 -2
- data/lib/datadog/tracing/contrib/active_record/configuration/settings.rb +3 -3
- data/lib/datadog/tracing/contrib/active_record/event.rb +1 -1
- data/lib/datadog/tracing/contrib/active_record/events/instantiation.rb +4 -4
- data/lib/datadog/tracing/contrib/active_record/events/sql.rb +6 -6
- data/lib/datadog/tracing/contrib/active_record/events.rb +2 -2
- data/lib/datadog/tracing/contrib/active_record/integration.rb +6 -6
- data/lib/datadog/tracing/contrib/active_record/patcher.rb +2 -2
- data/lib/datadog/tracing/contrib/active_record/utils.rb +2 -2
- data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +19 -9
- data/lib/datadog/tracing/contrib/active_support/cache/patcher.rb +2 -2
- data/lib/datadog/tracing/contrib/active_support/cache/redis.rb +1 -1
- data/lib/datadog/tracing/contrib/active_support/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/active_support/integration.rb +5 -5
- data/lib/datadog/tracing/contrib/active_support/notifications/event.rb +1 -1
- data/lib/datadog/tracing/contrib/active_support/notifications/subscriber.rb +1 -1
- data/lib/datadog/tracing/contrib/active_support/patcher.rb +2 -2
- data/lib/datadog/tracing/contrib/analytics.rb +1 -1
- data/lib/datadog/tracing/contrib/auto_instrument.rb +4 -4
- data/lib/datadog/tracing/contrib/aws/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/aws/instrumentation.rb +3 -4
- data/lib/datadog/tracing/contrib/aws/integration.rb +3 -3
- data/lib/datadog/tracing/contrib/aws/patcher.rb +5 -5
- data/lib/datadog/tracing/contrib/concurrent_ruby/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/concurrent_ruby/future_patch.rb +1 -1
- data/lib/datadog/tracing/contrib/concurrent_ruby/integration.rb +3 -3
- data/lib/datadog/tracing/contrib/concurrent_ruby/patcher.rb +2 -2
- data/lib/datadog/tracing/contrib/configurable.rb +2 -2
- data/lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb +1 -1
- data/lib/datadog/tracing/contrib/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/dalli/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/dalli/instrumentation.rb +4 -5
- data/lib/datadog/tracing/contrib/dalli/integration.rb +3 -3
- data/lib/datadog/tracing/contrib/dalli/patcher.rb +3 -3
- data/lib/datadog/tracing/contrib/dalli/quantize.rb +1 -1
- data/lib/datadog/tracing/contrib/delayed_job/configuration/settings.rb +3 -3
- data/lib/datadog/tracing/contrib/delayed_job/ext.rb +2 -0
- data/lib/datadog/tracing/contrib/delayed_job/integration.rb +3 -3
- data/lib/datadog/tracing/contrib/delayed_job/patcher.rb +8 -2
- data/lib/datadog/tracing/contrib/delayed_job/plugin.rb +3 -4
- data/lib/datadog/tracing/contrib/delayed_job/server_internal_tracer/worker.rb +32 -0
- data/lib/datadog/tracing/contrib/elasticsearch/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/elasticsearch/integration.rb +3 -3
- data/lib/datadog/tracing/contrib/elasticsearch/patcher.rb +6 -7
- data/lib/datadog/tracing/contrib/elasticsearch/quantize.rb +1 -1
- data/lib/datadog/tracing/contrib/ethon/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/ethon/easy_patch.rb +4 -5
- data/lib/datadog/tracing/contrib/ethon/integration.rb +4 -4
- data/lib/datadog/tracing/contrib/ethon/multi_patch.rb +3 -4
- data/lib/datadog/tracing/contrib/ethon/patcher.rb +3 -3
- data/lib/datadog/tracing/contrib/excon/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/excon/integration.rb +4 -4
- data/lib/datadog/tracing/contrib/excon/middleware.rb +6 -7
- data/lib/datadog/tracing/contrib/excon/patcher.rb +2 -2
- data/lib/datadog/tracing/contrib/extensions.rb +5 -3
- data/lib/datadog/tracing/contrib/faraday/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/faraday/integration.rb +4 -4
- data/lib/datadog/tracing/contrib/faraday/middleware.rb +5 -6
- data/lib/datadog/tracing/contrib/faraday/patcher.rb +5 -5
- data/lib/datadog/tracing/contrib/grape/configuration/settings.rb +3 -3
- data/lib/datadog/tracing/contrib/grape/endpoint.rb +4 -5
- data/lib/datadog/tracing/contrib/grape/integration.rb +3 -3
- data/lib/datadog/tracing/contrib/grape/patcher.rb +4 -4
- data/lib/datadog/tracing/contrib/graphql/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/graphql/integration.rb +3 -3
- data/lib/datadog/tracing/contrib/graphql/patcher.rb +2 -3
- data/lib/datadog/tracing/contrib/grpc/configuration/settings.rb +3 -3
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/client.rb +13 -4
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/server.rb +6 -6
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor.rb +3 -4
- data/lib/datadog/tracing/contrib/grpc/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/grpc/integration.rb +3 -3
- data/lib/datadog/tracing/contrib/grpc/patcher.rb +5 -5
- data/lib/datadog/tracing/contrib/http/circuit_breaker.rb +1 -2
- data/lib/datadog/tracing/contrib/http/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/http/instrumentation.rb +3 -4
- data/lib/datadog/tracing/contrib/http/integration.rb +6 -6
- data/lib/datadog/tracing/contrib/http/patcher.rb +3 -3
- data/lib/datadog/tracing/contrib/httpclient/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/httpclient/instrumentation.rb +4 -5
- data/lib/datadog/tracing/contrib/httpclient/integration.rb +4 -4
- data/lib/datadog/tracing/contrib/httpclient/patcher.rb +3 -3
- data/lib/datadog/tracing/contrib/httprb/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/httprb/instrumentation.rb +4 -5
- data/lib/datadog/tracing/contrib/httprb/integration.rb +4 -4
- data/lib/datadog/tracing/contrib/httprb/patcher.rb +3 -3
- data/lib/datadog/tracing/contrib/integration.rb +3 -3
- data/lib/datadog/tracing/contrib/kafka/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/kafka/event.rb +3 -3
- data/lib/datadog/tracing/contrib/kafka/events/connection/request.rb +2 -2
- data/lib/datadog/tracing/contrib/kafka/events/consumer/process_batch.rb +3 -3
- data/lib/datadog/tracing/contrib/kafka/events/consumer/process_message.rb +3 -3
- data/lib/datadog/tracing/contrib/kafka/events/consumer_group/heartbeat.rb +4 -4
- data/lib/datadog/tracing/contrib/kafka/events/consumer_group/join_group.rb +4 -4
- data/lib/datadog/tracing/contrib/kafka/events/consumer_group/leave_group.rb +4 -4
- data/lib/datadog/tracing/contrib/kafka/events/consumer_group/sync_group.rb +4 -4
- data/lib/datadog/tracing/contrib/kafka/events/produce_operation/send_messages.rb +2 -2
- data/lib/datadog/tracing/contrib/kafka/events/producer/deliver_messages.rb +2 -2
- data/lib/datadog/tracing/contrib/kafka/events.rb +9 -9
- data/lib/datadog/tracing/contrib/kafka/integration.rb +3 -3
- data/lib/datadog/tracing/contrib/kafka/patcher.rb +3 -3
- data/lib/datadog/tracing/contrib/lograge/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/lograge/instrumentation.rb +1 -2
- data/lib/datadog/tracing/contrib/lograge/integration.rb +3 -3
- data/lib/datadog/tracing/contrib/lograge/patcher.rb +2 -2
- data/lib/datadog/tracing/contrib/mongodb/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/mongodb/instrumentation.rb +3 -3
- data/lib/datadog/tracing/contrib/mongodb/integration.rb +4 -4
- data/lib/datadog/tracing/contrib/mongodb/parsers.rb +1 -1
- data/lib/datadog/tracing/contrib/mongodb/patcher.rb +3 -3
- data/lib/datadog/tracing/contrib/mongodb/subscribers.rb +4 -4
- data/lib/datadog/tracing/contrib/mysql2/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +3 -4
- data/lib/datadog/tracing/contrib/mysql2/integration.rb +3 -3
- data/lib/datadog/tracing/contrib/mysql2/patcher.rb +2 -2
- data/lib/datadog/tracing/contrib/patcher.rb +13 -2
- data/lib/datadog/tracing/contrib/pg/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/pg/instrumentation.rb +3 -4
- data/lib/datadog/tracing/contrib/pg/integration.rb +3 -3
- data/lib/datadog/tracing/contrib/pg/patcher.rb +2 -2
- data/lib/datadog/tracing/contrib/presto/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/presto/instrumentation.rb +2 -3
- data/lib/datadog/tracing/contrib/presto/integration.rb +3 -3
- data/lib/datadog/tracing/contrib/presto/patcher.rb +4 -4
- data/lib/datadog/tracing/contrib/qless/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/qless/integration.rb +3 -3
- data/lib/datadog/tracing/contrib/qless/patcher.rb +1 -2
- data/lib/datadog/tracing/contrib/qless/qless_job.rb +2 -3
- data/lib/datadog/tracing/contrib/qless/tracer_cleaner.rb +0 -2
- data/lib/datadog/tracing/contrib/que/configuration/settings.rb +3 -3
- data/lib/datadog/tracing/contrib/que/integration.rb +4 -4
- data/lib/datadog/tracing/contrib/que/patcher.rb +1 -1
- data/lib/datadog/tracing/contrib/que/tracer.rb +1 -1
- data/lib/datadog/tracing/contrib/racecar/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/racecar/event.rb +4 -5
- data/lib/datadog/tracing/contrib/racecar/events/batch.rb +2 -2
- data/lib/datadog/tracing/contrib/racecar/events/consume.rb +2 -2
- data/lib/datadog/tracing/contrib/racecar/events/message.rb +2 -2
- data/lib/datadog/tracing/contrib/racecar/events.rb +3 -3
- data/lib/datadog/tracing/contrib/racecar/integration.rb +3 -3
- data/lib/datadog/tracing/contrib/racecar/patcher.rb +3 -3
- data/lib/datadog/tracing/contrib/rack/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/rack/integration.rb +4 -4
- data/lib/datadog/tracing/contrib/rack/middlewares.rb +24 -20
- data/lib/datadog/tracing/contrib/rack/patcher.rb +12 -2
- data/lib/datadog/tracing/contrib/rails/auto_instrument_railtie.rb +1 -1
- data/lib/datadog/tracing/contrib/rails/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/rails/framework.rb +16 -21
- data/lib/datadog/tracing/contrib/rails/integration.rb +4 -4
- data/lib/datadog/tracing/contrib/rails/log_injection.rb +0 -2
- data/lib/datadog/tracing/contrib/rails/middlewares.rb +1 -2
- data/lib/datadog/tracing/contrib/rails/patcher.rb +7 -8
- data/lib/datadog/tracing/contrib/rails/railtie.rb +3 -3
- data/lib/datadog/tracing/contrib/rails/utils.rb +1 -1
- data/lib/datadog/tracing/contrib/rake/configuration/settings.rb +17 -2
- data/lib/datadog/tracing/contrib/rake/instrumentation.rb +12 -7
- data/lib/datadog/tracing/contrib/rake/integration.rb +3 -3
- data/lib/datadog/tracing/contrib/rake/patcher.rb +3 -4
- data/lib/datadog/tracing/contrib/redis/configuration/resolver.rb +1 -1
- data/lib/datadog/tracing/contrib/redis/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/redis/instrumentation.rb +6 -7
- data/lib/datadog/tracing/contrib/redis/integration.rb +3 -3
- data/lib/datadog/tracing/contrib/redis/patcher.rb +6 -6
- data/lib/datadog/tracing/contrib/redis/tags.rb +3 -4
- data/lib/datadog/tracing/contrib/resque/configuration/settings.rb +3 -3
- data/lib/datadog/tracing/contrib/resque/integration.rb +3 -3
- data/lib/datadog/tracing/contrib/resque/patcher.rb +2 -2
- data/lib/datadog/tracing/contrib/resque/resque_job.rb +3 -4
- data/lib/datadog/tracing/contrib/rest_client/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/rest_client/integration.rb +3 -3
- data/lib/datadog/tracing/contrib/rest_client/patcher.rb +2 -2
- data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +4 -5
- data/lib/datadog/tracing/contrib/semantic_logger/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb +1 -2
- data/lib/datadog/tracing/contrib/semantic_logger/integration.rb +3 -3
- data/lib/datadog/tracing/contrib/semantic_logger/patcher.rb +2 -2
- data/lib/datadog/tracing/contrib/sequel/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/sequel/database.rb +4 -5
- data/lib/datadog/tracing/contrib/sequel/dataset.rb +4 -5
- data/lib/datadog/tracing/contrib/sequel/integration.rb +3 -3
- data/lib/datadog/tracing/contrib/sequel/patcher.rb +3 -3
- data/lib/datadog/tracing/contrib/sequel/utils.rb +2 -2
- data/lib/datadog/tracing/contrib/shoryuken/configuration/settings.rb +3 -3
- data/lib/datadog/tracing/contrib/shoryuken/integration.rb +4 -4
- data/lib/datadog/tracing/contrib/shoryuken/patcher.rb +1 -1
- data/lib/datadog/tracing/contrib/shoryuken/tracer.rb +1 -1
- data/lib/datadog/tracing/contrib/sidekiq/client_tracer.rb +4 -5
- data/lib/datadog/tracing/contrib/sidekiq/configuration/settings.rb +3 -3
- data/lib/datadog/tracing/contrib/sidekiq/ext.rb +6 -0
- data/lib/datadog/tracing/contrib/sidekiq/integration.rb +3 -3
- data/lib/datadog/tracing/contrib/sidekiq/patcher.rb +14 -7
- data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/heartbeat.rb +19 -1
- data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/{scheduled_push.rb → redis_info.rb} +5 -6
- data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/scheduled_poller.rb +53 -0
- data/lib/datadog/tracing/contrib/sidekiq/server_tracer.rb +5 -6
- data/lib/datadog/tracing/contrib/sidekiq/tracing.rb +2 -2
- data/lib/datadog/tracing/contrib/sinatra/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/sinatra/env.rb +2 -2
- data/lib/datadog/tracing/contrib/sinatra/framework.rb +0 -2
- data/lib/datadog/tracing/contrib/sinatra/headers.rb +1 -1
- data/lib/datadog/tracing/contrib/sinatra/integration.rb +3 -3
- data/lib/datadog/tracing/contrib/sinatra/patcher.rb +5 -5
- data/lib/datadog/tracing/contrib/sinatra/tracer.rb +7 -8
- data/lib/datadog/tracing/contrib/sinatra/tracer_middleware.rb +6 -7
- data/lib/datadog/tracing/contrib/sneakers/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/sneakers/integration.rb +4 -4
- data/lib/datadog/tracing/contrib/sneakers/patcher.rb +2 -2
- data/lib/datadog/tracing/contrib/sneakers/tracer.rb +2 -3
- data/lib/datadog/tracing/contrib/status_code_matcher.rb +2 -2
- data/lib/datadog/tracing/contrib/sucker_punch/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/sucker_punch/instrumentation.rb +3 -4
- data/lib/datadog/tracing/contrib/sucker_punch/integration.rb +3 -3
- data/lib/datadog/tracing/contrib/sucker_punch/patcher.rb +4 -5
- data/lib/datadog/tracing/contrib.rb +48 -48
- data/lib/datadog/tracing/correlation.rb +1 -1
- data/lib/datadog/tracing/distributed/headers/b3.rb +4 -4
- data/lib/datadog/tracing/distributed/headers/b3_single.rb +4 -4
- data/lib/datadog/tracing/distributed/headers/datadog.rb +3 -3
- data/lib/datadog/tracing/distributed/headers/parser.rb +1 -1
- data/lib/datadog/tracing/distributed/helpers.rb +2 -2
- data/lib/datadog/tracing/distributed/metadata/b3.rb +4 -4
- data/lib/datadog/tracing/distributed/metadata/b3_single.rb +4 -4
- data/lib/datadog/tracing/distributed/metadata/datadog.rb +2 -2
- data/lib/datadog/tracing/distributed/metadata/parser.rb +1 -1
- data/lib/datadog/tracing/event.rb +1 -1
- data/lib/datadog/tracing/metadata/analytics.rb +2 -2
- data/lib/datadog/tracing/metadata/errors.rb +2 -2
- data/lib/datadog/tracing/metadata/tagging.rb +2 -2
- data/lib/datadog/tracing/metadata.rb +3 -3
- data/lib/datadog/tracing/pipeline/span_filter.rb +10 -6
- data/lib/datadog/tracing/pipeline.rb +3 -3
- data/lib/datadog/tracing/propagation/grpc.rb +6 -6
- data/lib/datadog/tracing/propagation/http.rb +8 -8
- data/lib/datadog/tracing/runtime/metrics.rb +1 -1
- data/lib/datadog/tracing/sampling/all_sampler.rb +1 -1
- data/lib/datadog/tracing/sampling/priority_sampler.rb +5 -5
- data/lib/datadog/tracing/sampling/rate_by_key_sampler.rb +2 -2
- data/lib/datadog/tracing/sampling/rate_by_service_sampler.rb +3 -3
- data/lib/datadog/tracing/sampling/rate_limiter.rb +1 -1
- data/lib/datadog/tracing/sampling/rate_sampler.rb +5 -5
- data/lib/datadog/tracing/sampling/rule.rb +3 -3
- data/lib/datadog/tracing/sampling/rule_sampler.rb +4 -4
- data/lib/datadog/tracing/span.rb +4 -4
- data/lib/datadog/tracing/span_operation.rb +9 -9
- data/lib/datadog/tracing/sync_writer.rb +5 -5
- data/lib/datadog/tracing/trace_operation.rb +16 -9
- data/lib/datadog/tracing/trace_segment.rb +5 -5
- data/lib/datadog/tracing/tracer.rb +15 -15
- data/lib/datadog/tracing/workers/trace_writer.rb +9 -9
- data/lib/datadog/tracing/workers.rb +3 -3
- data/lib/datadog/tracing/writer.rb +5 -5
- data/lib/datadog/tracing.rb +8 -8
- data/lib/ddtrace/auto_instrument.rb +9 -2
- data/lib/ddtrace/transport/ext.rb +7 -1
- data/lib/ddtrace/transport/http/adapters/net.rb +3 -2
- data/lib/ddtrace/transport/http/adapters/test.rb +1 -1
- data/lib/ddtrace/transport/http/adapters/unix_socket.rb +2 -2
- data/lib/ddtrace/transport/http/api/map.rb +1 -1
- data/lib/ddtrace/transport/http/api.rb +4 -4
- data/lib/ddtrace/transport/http/builder.rb +5 -5
- data/lib/ddtrace/transport/http/client.rb +2 -2
- data/lib/ddtrace/transport/http/response.rb +1 -1
- data/lib/ddtrace/transport/http/statistics.rb +1 -1
- data/lib/ddtrace/transport/http/traces.rb +5 -5
- data/lib/ddtrace/transport/http.rb +12 -9
- data/lib/ddtrace/transport/io/client.rb +2 -2
- data/lib/ddtrace/transport/io/response.rb +1 -1
- data/lib/ddtrace/transport/io/traces.rb +3 -3
- data/lib/ddtrace/transport/io.rb +3 -3
- data/lib/ddtrace/transport/statistics.rb +2 -2
- data/lib/ddtrace/transport/trace_formatter.rb +5 -5
- data/lib/ddtrace/transport/traces.rb +5 -5
- data/lib/ddtrace/version.rb +1 -1
- data/lib/ddtrace.rb +6 -6
- metadata +35 -22
- data/.editorconfig +0 -22
- data/.gitignore +0 -58
- data/CONTRIBUTING.md +0 -81
- data/ddtrace.gemspec +0 -71
- data/docs/0.x-trace.png +0 -0
- data/docs/1.0-trace.png +0 -0
- data/docs/AutoInstrumentation.md +0 -36
- data/docs/Deprecation.md +0 -8
- data/docs/DevelopmentGuide.md +0 -259
- data/docs/GettingStarted.md +0 -2712
- data/docs/ProfilingDevelopment.md +0 -109
- data/docs/PublicApi.md +0 -14
- data/docs/UpgradeGuide.md +0 -736
data/docs/GettingStarted.md
DELETED
@@ -1,2712 +0,0 @@
|
|
1
|
-
***Version 1.0.0 has been released. Check out our [upgrade guide](https://github.com/DataDog/dd-trace-rb/blob/master/docs/UpgradeGuide.md#from-0x-to-10) for more details.***
|
2
|
-
|
3
|
-
# Datadog Ruby Trace Client
|
4
|
-
|
5
|
-
`ddtrace` is Datadog’s tracing client for Ruby. It is used to trace requests as they flow across web servers,
|
6
|
-
databases and microservices so that developers have high visibility into bottlenecks and troublesome requests.
|
7
|
-
|
8
|
-
## Getting started
|
9
|
-
|
10
|
-
For the general APM documentation, see our [setup documentation][setup docs].
|
11
|
-
|
12
|
-
For more information about what APM looks like once your application is sending information to Datadog, take a look at [Visualizing your APM data][visualization docs].
|
13
|
-
|
14
|
-
For the library API documentation, see our [YARD documentation][yard docs].
|
15
|
-
|
16
|
-
To contribute, check out the [contribution guidelines][contribution docs] and [development guide][development docs].
|
17
|
-
|
18
|
-
[setup docs]: https://docs.datadoghq.com/tracing/
|
19
|
-
[development docs]: https://github.com/DataDog/dd-trace-rb/blob/master/README.md#development
|
20
|
-
[visualization docs]: https://docs.datadoghq.com/tracing/visualization/
|
21
|
-
[contribution docs]: https://github.com/DataDog/dd-trace-rb/blob/master/CONTRIBUTING.md
|
22
|
-
[development docs]: https://github.com/DataDog/dd-trace-rb/blob/master/docs/DevelopmentGuide.md
|
23
|
-
[yard docs]: https://www.rubydoc.info/gems/ddtrace/
|
24
|
-
|
25
|
-
## Table of Contents
|
26
|
-
|
27
|
-
- [Compatibility](#compatibility)
|
28
|
-
- [Installation](#installation)
|
29
|
-
- [Setup the Datadog Agent for tracing](#setup-the-datadog-agent-for-tracing)
|
30
|
-
- [Instrument your application](#instrument-your-application)
|
31
|
-
- [Rails applications](#rails-applications)
|
32
|
-
- [Ruby applications](#ruby-applications)
|
33
|
-
- [Configuring OpenTracing](#configuring-opentracing)
|
34
|
-
- [Configuring OpenTelemetry](#configuring-opentelemetry)
|
35
|
-
- [Connect your application to the Datadog Agent](#connect-your-application-to-the-datadog-agent)
|
36
|
-
- [Manual instrumentation](#manual-instrumentation)
|
37
|
-
- [Integration instrumentation](#integration-instrumentation)
|
38
|
-
- [Action Cable](#action-cable)
|
39
|
-
- [Action Mailer](#action-mailer)
|
40
|
-
- [Action Pack](#action-pack)
|
41
|
-
- [Action View](#action-view)
|
42
|
-
- [Active Job](#active-job)
|
43
|
-
- [Active Model Serializers](#active-model-serializers)
|
44
|
-
- [Active Record](#active-record)
|
45
|
-
- [Active Support](#active-support)
|
46
|
-
- [AWS](#aws)
|
47
|
-
- [Concurrent Ruby](#concurrent-ruby)
|
48
|
-
- [Cucumber](#cucumber)
|
49
|
-
- [Dalli](#dalli)
|
50
|
-
- [DelayedJob](#delayedjob)
|
51
|
-
- [Elasticsearch](#elasticsearch)
|
52
|
-
- [Ethon & Typhoeus](#ethon)
|
53
|
-
- [Excon](#excon)
|
54
|
-
- [Faraday](#faraday)
|
55
|
-
- [Grape](#grape)
|
56
|
-
- [GraphQL](#graphql)
|
57
|
-
- [gRPC](#grpc)
|
58
|
-
- [http.rb](#httprb)
|
59
|
-
- [httpclient](#httpclient)
|
60
|
-
- [httpx](#httpx)
|
61
|
-
- [Kafka](#kafka)
|
62
|
-
- [MongoDB](#mongodb)
|
63
|
-
- [MySQL2](#mysql2)
|
64
|
-
- [Net/HTTP](#nethttp)
|
65
|
-
- [Postgres](#postgres)
|
66
|
-
- [Presto](#presto)
|
67
|
-
- [Qless](#qless)
|
68
|
-
- [Que](#que)
|
69
|
-
- [Racecar](#racecar)
|
70
|
-
- [Rack](#rack)
|
71
|
-
- [Rails](#rails)
|
72
|
-
- [Rake](#rake)
|
73
|
-
- [Redis](#redis)
|
74
|
-
- [Resque](#resque)
|
75
|
-
- [Rest Client](#rest-client)
|
76
|
-
- [RSpec](#rspec)
|
77
|
-
- [Sequel](#sequel)
|
78
|
-
- [Shoryuken](#shoryuken)
|
79
|
-
- [Sidekiq](#sidekiq)
|
80
|
-
- [Sinatra](#sinatra)
|
81
|
-
- [Sneakers](#sneakers)
|
82
|
-
- [Sucker Punch](#sucker-punch)
|
83
|
-
- [Additional configuration](#additional-configuration)
|
84
|
-
- [Custom logging](#custom-logging)
|
85
|
-
- [Environment and tags](#environment-and-tags)
|
86
|
-
- [Debugging and diagnostics](#debugging-and-diagnostics)
|
87
|
-
- [Sampling](#sampling)
|
88
|
-
- [Application-side sampling](#application-side-sampling)
|
89
|
-
- [Priority sampling](#priority-sampling)
|
90
|
-
- [Distributed tracing](#distributed-tracing)
|
91
|
-
- [HTTP request queuing](#http-request-queuing)
|
92
|
-
- [Processing pipeline](#processing-pipeline)
|
93
|
-
- [Filtering](#filtering)
|
94
|
-
- [Processing](#processing)
|
95
|
-
- [Trace correlation](#trace-correlation)
|
96
|
-
- [Configuring the transport layer](#configuring-the-transport-layer)
|
97
|
-
- [Metrics](#metrics)
|
98
|
-
- [For application runtime](#for-application-runtime)
|
99
|
-
- [OpenTracing](#opentracing)
|
100
|
-
- [Profiling](#profiling)
|
101
|
-
- [Troubleshooting](#troubleshooting)
|
102
|
-
- [Profiling Resque jobs](#profiling-resque-jobs)
|
103
|
-
- [Known issues and suggested configurations](#known-issues-and-suggested-configurations)
|
104
|
-
- [Payload too large](#payload-too-large)
|
105
|
-
- [Stack level too deep](#stack-level-too-deep)
|
106
|
-
|
107
|
-
## Compatibility
|
108
|
-
|
109
|
-
<!--
|
110
|
-
Note: Please replicate any changes to this section also to
|
111
|
-
https://github.com/datadog/documentation/blob/master/content/en/tracing/setup_overview/compatibility_requirements/ruby.md
|
112
|
-
so that they remain in sync.
|
113
|
-
-->
|
114
|
-
|
115
|
-
**Supported Ruby interpreters**:
|
116
|
-
|
117
|
-
| Type | Documentation | Version | Support type | Gem version support |
|
118
|
-
| ----- | -------------------------- | ----- | ------------------------------------ | ------------------- |
|
119
|
-
| MRI | https://www.ruby-lang.org/ | 3.1 | Full | Latest |
|
120
|
-
| | | 3.0 | Full | Latest |
|
121
|
-
| | | 2.7 | Full | Latest |
|
122
|
-
| | | 2.6 | Full | Latest |
|
123
|
-
| | | 2.5 | Full | Latest |
|
124
|
-
| | | 2.4 | Full | Latest |
|
125
|
-
| | | 2.3 | Full | Latest |
|
126
|
-
| | | 2.2 | Full | Latest |
|
127
|
-
| | | 2.1 | Full | Latest |
|
128
|
-
| | | 2.0 | EOL since June 7th, 2021 | < 0.50.0 |
|
129
|
-
| | | 1.9.3 | EOL since August 6th, 2020 | < 0.27.0 |
|
130
|
-
| | | 1.9.1 | EOL since August 6th, 2020 | < 0.27.0 |
|
131
|
-
| JRuby | https://www.jruby.org | 9.3 | Full | Latest |
|
132
|
-
| | | 9.2 | Full | Latest |
|
133
|
-
|
134
|
-
**Supported web servers**:
|
135
|
-
|
136
|
-
| Type | Documentation | Version | Support type |
|
137
|
-
| --------- | --------------------------------- | ------------ | ------------ |
|
138
|
-
| Puma | http://puma.io/ | 2.16+ / 3.6+ | Full |
|
139
|
-
| Unicorn | https://bogomips.org/unicorn/ | 4.8+ / 5.1+ | Full |
|
140
|
-
| Passenger | https://www.phusionpassenger.com/ | 5.0+ | Full |
|
141
|
-
|
142
|
-
**Supported tracing frameworks**:
|
143
|
-
|
144
|
-
| Type | Documentation | Version | Gem version support |
|
145
|
-
| ----------- | ----------------------------------------------- | --------------------- | ------------------- |
|
146
|
-
| OpenTracing | https://github.com/opentracing/opentracing-ruby | 0.4.1+ (w/ Ruby 2.1+) | >= 0.16.0 |
|
147
|
-
|
148
|
-
*Full* support indicates all tracer features are available.
|
149
|
-
|
150
|
-
*Deprecated* indicates support will transition to *Maintenance* in a future release.
|
151
|
-
|
152
|
-
*Maintenance* indicates only critical bugfixes are backported until EOL.
|
153
|
-
|
154
|
-
*EOL* indicates support is no longer provided.
|
155
|
-
|
156
|
-
### Apple macOS support
|
157
|
-
|
158
|
-
Use of `ddtrace` on macOS is supported for development, but not for production deployments.
|
159
|
-
|
160
|
-
### Microsoft Windows support
|
161
|
-
|
162
|
-
Using `ddtrace` on Microsoft Windows is currently unsupported. We'll still accept community contributions and issues,
|
163
|
-
but will consider them as having low priority.
|
164
|
-
|
165
|
-
## Installation
|
166
|
-
|
167
|
-
Adding tracing to your Ruby application only takes a few quick steps:
|
168
|
-
|
169
|
-
1. Setup the Datadog Agent for tracing
|
170
|
-
2. Instrument your application
|
171
|
-
3. Connect your application to the Datadog Agent
|
172
|
-
|
173
|
-
### Setup the Datadog Agent for tracing
|
174
|
-
|
175
|
-
Before installing `ddtrace`, [install the Datadog Agent](https://docs.datadoghq.com/agent/), to which `ddtrace` will send trace data.
|
176
|
-
|
177
|
-
Then configure the Datadog Agent to accept traces. To do this, either:
|
178
|
-
|
179
|
-
- Set `DD_APM_ENABLED=true` in the agent's environment
|
180
|
-
|
181
|
-
OR
|
182
|
-
|
183
|
-
- Add `apm_enabled: true` to the [agent's configuration file](https://docs.datadoghq.com/agent/guide/agent-configuration-files/?tab=agentv6v7#agent-main-configuration-file)
|
184
|
-
|
185
|
-
*Additionally, in containerized environments...*
|
186
|
-
|
187
|
-
- Set `DD_APM_NON_LOCAL_TRAFFIC=true` in the agent's environment
|
188
|
-
|
189
|
-
OR
|
190
|
-
|
191
|
-
- Add `apm_non_local_traffic: true` to the [agent's configuration file](https://docs.datadoghq.com/agent/guide/agent-configuration-files/?tab=agentv6v7#agent-main-configuration-file).
|
192
|
-
|
193
|
-
See the specific setup instructions for [Docker](https://docs.datadoghq.com/agent/docker/apm/?tab=ruby), [Kubernetes](https://docs.datadoghq.com/agent/kubernetes/apm/?tab=helm), [Amazon ECS](https://docs.datadoghq.com/agent/amazon_ecs/apm/?tab=ruby) or [Fargate](https://docs.datadoghq.com/integrations/ecs_fargate/#trace-collection) to ensure that the Agent is configured to receive traces in a containerized environment.
|
194
|
-
|
195
|
-
#### Configuring trace data ingestion
|
196
|
-
|
197
|
-
The Datadog agent will listen for traces via HTTP on port `8126` by default.
|
198
|
-
|
199
|
-
You may change the protocol or port the agent listens for trace data using the following:
|
200
|
-
|
201
|
-
**For HTTP over TCP**:
|
202
|
-
|
203
|
-
- Set `DD_APM_RECEIVER_PORT=<port>` in the agent's environment
|
204
|
-
|
205
|
-
OR
|
206
|
-
|
207
|
-
- Add `apm_config: receiver_port: <port>` to the [agent's configuration file](https://docs.datadoghq.com/agent/guide/agent-configuration-files/?tab=agentv6v7#agent-main-configuration-file)
|
208
|
-
|
209
|
-
**For Unix Domain Socket (UDS)**:
|
210
|
-
|
211
|
-
- Set `DD_APM_RECEIVER_SOCKET=<path-to-socket-file>`
|
212
|
-
|
213
|
-
OR
|
214
|
-
|
215
|
-
- Add `apm_config: receiver_socket: <path-to-socket-file>` to the [agent's configuration file](https://docs.datadoghq.com/agent/guide/agent-configuration-files/?tab=agentv6v7#agent-main-configuration-file)
|
216
|
-
|
217
|
-
### Instrument your application
|
218
|
-
|
219
|
-
#### Rails applications
|
220
|
-
|
221
|
-
1. Add the `ddtrace` gem to your Gemfile:
|
222
|
-
|
223
|
-
```ruby
|
224
|
-
source 'https://rubygems.org'
|
225
|
-
gem 'ddtrace', require: 'ddtrace/auto_instrument'
|
226
|
-
```
|
227
|
-
|
228
|
-
2. Install the gem with `bundle install`
|
229
|
-
|
230
|
-
3. Create a `config/initializers/datadog.rb` file containing:
|
231
|
-
|
232
|
-
```ruby
|
233
|
-
Datadog.configure do |c|
|
234
|
-
# Add additional configuration here.
|
235
|
-
# Activate integrations, change tracer settings, etc...
|
236
|
-
end
|
237
|
-
```
|
238
|
-
|
239
|
-
Using this block you can:
|
240
|
-
|
241
|
-
- [Add additional configuration settings](#additional-configuration)
|
242
|
-
- [Activate or reconfigure instrumentation](#integration-instrumentation)
|
243
|
-
|
244
|
-
#### Ruby applications
|
245
|
-
|
246
|
-
1. Add the `ddtrace` gem to your Gemfile:
|
247
|
-
|
248
|
-
```ruby
|
249
|
-
source 'https://rubygems.org'
|
250
|
-
gem 'ddtrace'
|
251
|
-
```
|
252
|
-
|
253
|
-
2. Install the gem with `bundle install`
|
254
|
-
3. `require` any [supported libraries or frameworks](#integration-instrumentation) that should be instrumented.
|
255
|
-
4. Add `require 'ddtrace/auto_instrument'` to your application. _Note:_ This must be done _after_ requiring any supported libraries or frameworks.
|
256
|
-
|
257
|
-
```ruby
|
258
|
-
# Example frameworks and libraries
|
259
|
-
require 'sinatra'
|
260
|
-
require 'faraday'
|
261
|
-
require 'redis'
|
262
|
-
|
263
|
-
require 'ddtrace/auto_instrument'
|
264
|
-
```
|
265
|
-
|
266
|
-
5. Add a configuration block to your application:
|
267
|
-
|
268
|
-
```ruby
|
269
|
-
Datadog.configure do |c|
|
270
|
-
# Add additional configuration here.
|
271
|
-
# Activate integrations, change tracer settings, etc...
|
272
|
-
end
|
273
|
-
```
|
274
|
-
|
275
|
-
Using this block you can:
|
276
|
-
|
277
|
-
- [Add additional configuration settings](#additional-configuration)
|
278
|
-
- [Activate or reconfigure instrumentation](#integration-instrumentation)
|
279
|
-
|
280
|
-
#### Configuring OpenTracing
|
281
|
-
|
282
|
-
1. Add the `ddtrace` gem to your Gemfile:
|
283
|
-
|
284
|
-
```ruby
|
285
|
-
source 'https://rubygems.org'
|
286
|
-
gem 'ddtrace'
|
287
|
-
```
|
288
|
-
|
289
|
-
2. Install the gem with `bundle install`
|
290
|
-
3. To your OpenTracing configuration file, add the following:
|
291
|
-
|
292
|
-
```ruby
|
293
|
-
require 'opentracing'
|
294
|
-
require 'datadog/tracing'
|
295
|
-
require 'datadog/opentracer'
|
296
|
-
|
297
|
-
# Activate the Datadog tracer for OpenTracing
|
298
|
-
OpenTracing.global_tracer = Datadog::OpenTracer::Tracer.new
|
299
|
-
```
|
300
|
-
|
301
|
-
4. Add a configuration block to your application:
|
302
|
-
|
303
|
-
```ruby
|
304
|
-
Datadog.configure do |c|
|
305
|
-
# Configure the Datadog tracer here.
|
306
|
-
# Activate integrations, change tracer settings, etc...
|
307
|
-
# By default without additional configuration,
|
308
|
-
# no additional integrations will be traced, only
|
309
|
-
# what you have instrumented with OpenTracing.
|
310
|
-
end
|
311
|
-
```
|
312
|
-
|
313
|
-
Using this block you can:
|
314
|
-
|
315
|
-
- [Add additional Datadog configuration settings](#additional-configuration)
|
316
|
-
- [Activate or reconfigure Datadog instrumentation](#integration-instrumentation)
|
317
|
-
|
318
|
-
#### Configuring OpenTelemetry
|
319
|
-
|
320
|
-
You can send OpenTelemetry traces directly to the Datadog agent (without `ddtrace`) by using OTLP. Check out our documentation on [OTLP ingest in the Datadog Agent](https://docs.datadoghq.com/tracing/setup_overview/open_standards/#otlp-ingest-in-datadog-agent) for details.
|
321
|
-
|
322
|
-
### Connect your application to the Datadog Agent
|
323
|
-
|
324
|
-
By default, `ddtrace` will connect to the agent using the first available settings in the listed priority:
|
325
|
-
|
326
|
-
1. Via any explicitly provided configuration settings (hostname/port/transport)
|
327
|
-
2. Via Unix Domain Socket (UDS) located at `/var/run/datadog/apm.socket`
|
328
|
-
3. Via HTTP over TCP to `127.0.0.1:8126`
|
329
|
-
|
330
|
-
If your Datadog Agent is listening at any of these locations, no further configuration should be required.
|
331
|
-
|
332
|
-
If your agent runs on a different host or container than your application, or you would like to send traces via a different protocol, you will need to configure your application accordingly.
|
333
|
-
|
334
|
-
- [How to send trace data via HTTP over TCP to agent](#changing-default-agent-hostname-and-port)
|
335
|
-
- [How to send trace data via Unix Domain Socket (UDS) to agent](#using-the-unix-domain-socket-uds-adapter)
|
336
|
-
|
337
|
-
### Final steps for installation
|
338
|
-
|
339
|
-
After setting up, your services will appear on the [APM services page](https://app.datadoghq.com/apm/services) within a few minutes. Learn more about [using the APM UI][visualization docs].
|
340
|
-
|
341
|
-
## Manual Instrumentation
|
342
|
-
|
343
|
-
If you aren't using a supported framework instrumentation, you may want to manually instrument your code.
|
344
|
-
|
345
|
-
To trace any Ruby code, you can use the `Datadog::Tracing.trace` method:
|
346
|
-
|
347
|
-
```ruby
|
348
|
-
Datadog::Tracing.trace(name, options) do |span, trace|
|
349
|
-
# Wrap this block around the code you want to instrument
|
350
|
-
# Additionally, you can modify the span here.
|
351
|
-
# e.g. Change the resource name, set tags, etc...
|
352
|
-
end
|
353
|
-
```
|
354
|
-
|
355
|
-
Where `name` should be a `String` that describes the generic kind of operation being done (e.g. `'web.request'`, or `'request.parse'`)
|
356
|
-
|
357
|
-
And `options` is an optional `Hash` that accepts the following parameters:
|
358
|
-
|
359
|
-
| Key | Type | Description | Default |
|
360
|
-
| --------------- | ----------------------- | --- | --- |
|
361
|
-
| `autostart` | `Bool` | Whether the time measurement should be started automatically. If `false`, user must call `span.start`. | `true` |
|
362
|
-
| `continue_from` | `Datadog::TraceDigest` | Continues a trace that originated from another execution context. TraceDigest describes the continuation point. | `nil` |
|
363
|
-
| `on_error` | `Proc` | Overrides error handling behavior, when a span raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
|
364
|
-
| `resource` | `String` | Name of the resource or action being operated on. Traces with the same resource value will be grouped together for the purpose of metrics (but still independently viewable.) Usually domain specific, such as a URL, query, request, etc. (e.g. `'Article#submit'`, `http://example.com/articles/list`.) | `name` of Span. |
|
365
|
-
| `service` | `String` | The service name which this span belongs (e.g. `'my-web-service'`) | Tracer `default-service`, `$PROGRAM_NAME` or `'ruby'` |
|
366
|
-
| `start_time` | `Time` | When the span actually starts. Useful when tracing events that have already happened. | `Time.now` |
|
367
|
-
| `tags` | `Hash` | Extra tags which should be added to the span. | `{}` |
|
368
|
-
| `type` | `String` | The type of the span (such as `'http'`, `'db'`, etc.) | `nil` |
|
369
|
-
|
370
|
-
It's highly recommended you set both `service` and `resource` at a minimum. Spans without a `service` or `resource` as `nil` will be discarded by the Datadog agent.
|
371
|
-
|
372
|
-
Example of manual instrumentation in action:
|
373
|
-
|
374
|
-
```ruby
|
375
|
-
get '/posts' do
|
376
|
-
Datadog::Tracing.trace('web.request', service: 'my-blog', resource: 'GET /posts') do |span|
|
377
|
-
# Trace the activerecord call
|
378
|
-
Datadog::Tracing.trace('posts.fetch') do
|
379
|
-
@posts = Posts.order(created_at: :desc).limit(10)
|
380
|
-
end
|
381
|
-
|
382
|
-
# Add some APM tags
|
383
|
-
span.set_tag('http.method', request.request_method)
|
384
|
-
span.set_tag('posts.count', @posts.length)
|
385
|
-
|
386
|
-
# Trace the template rendering
|
387
|
-
Datadog::Tracing.trace('template.render') do
|
388
|
-
erb :index
|
389
|
-
end
|
390
|
-
end
|
391
|
-
end
|
392
|
-
```
|
393
|
-
|
394
|
-
### Asynchronous tracing
|
395
|
-
|
396
|
-
It might not always be possible to wrap `Datadog::Tracing.trace` around a block of code. Some event or notification based instrumentation might only notify you when an event begins or ends.
|
397
|
-
|
398
|
-
To trace these operations, you can trace code asynchronously by calling `Datadog::Tracing.trace` without a block:
|
399
|
-
|
400
|
-
```ruby
|
401
|
-
# Some instrumentation framework calls this after an event finishes...
|
402
|
-
def db_query(start, finish, query)
|
403
|
-
span = Datadog::Tracing.trace('database.query', start_time: start)
|
404
|
-
span.resource = query
|
405
|
-
span.finish(finish)
|
406
|
-
end
|
407
|
-
```
|
408
|
-
|
409
|
-
Calling `Datadog::Tracing.trace` without a block will cause the function to return a `Datadog::SpanOperation` that is started, but not finished. You can then modify this span however you wish, then close it `finish`.
|
410
|
-
|
411
|
-
*You must not leave any unfinished spans.* If any spans are left open when the trace completes, the trace will be discarded. You can [activate debug mode](#tracer-settings) to check for warnings if you suspect this might be happening.
|
412
|
-
|
413
|
-
To avoid this scenario when handling start/finish events, you can use `Datadog::Tracing.active_span` to get the current active span.
|
414
|
-
|
415
|
-
```ruby
|
416
|
-
# e.g. ActiveSupport::Notifications calls this when an event starts
|
417
|
-
def start(name, id, payload)
|
418
|
-
# Start a span
|
419
|
-
Datadog::Tracing.trace(name)
|
420
|
-
end
|
421
|
-
|
422
|
-
# e.g. ActiveSupport::Notifications calls this when an event finishes
|
423
|
-
def finish(name, id, payload)
|
424
|
-
# Retrieve current active span (thread-safe)
|
425
|
-
current_span = Datadog::Tracing.active_span
|
426
|
-
unless current_span.nil?
|
427
|
-
current_span.resource = payload[:query]
|
428
|
-
current_span.finish
|
429
|
-
end
|
430
|
-
end
|
431
|
-
```
|
432
|
-
### Enriching traces from nested methods
|
433
|
-
|
434
|
-
You can tag additional information to the current active span from any method. Note however that if the method is called and there is no span currently active `active_span` will be nil.
|
435
|
-
|
436
|
-
```ruby
|
437
|
-
# e.g. adding tag to active span
|
438
|
-
|
439
|
-
current_span = Datadog::Tracing.active_span
|
440
|
-
current_span.set_tag('my_tag', 'my_value') unless current_span.nil?
|
441
|
-
```
|
442
|
-
|
443
|
-
You can also get the current active trace using the `active_trace` method. This method will return `nil` if there is no active trace.
|
444
|
-
|
445
|
-
```ruby
|
446
|
-
# e.g. accessing active trace
|
447
|
-
|
448
|
-
current_trace = Datadog::Tracing.active_trace
|
449
|
-
```
|
450
|
-
|
451
|
-
## Integration instrumentation
|
452
|
-
|
453
|
-
Many popular libraries and frameworks are supported out-of-the-box, which can be auto-instrumented. Although they are not activated automatically, they can be easily activated and configured by using the `Datadog.configure` API:
|
454
|
-
|
455
|
-
```ruby
|
456
|
-
Datadog.configure do |c|
|
457
|
-
# Activates and configures an integration
|
458
|
-
c.tracing.instrument :integration_name, options
|
459
|
-
end
|
460
|
-
```
|
461
|
-
|
462
|
-
`options` is a `Hash` of integration-specific configuration settings.
|
463
|
-
|
464
|
-
For a list of available integrations, and their configuration options, please refer to the following:
|
465
|
-
|
466
|
-
<!--
|
467
|
-
Note: Please replicate any changes to this section also to
|
468
|
-
https://github.com/datadog/documentation/blob/master/content/en/tracing/setup_overview/compatibility_requirements/ruby.md
|
469
|
-
so that they remain in sync.
|
470
|
-
-->
|
471
|
-
|
472
|
-
| Name | Key | Versions Supported: MRI | Versions Supported: JRuby | How to configure | Gem source |
|
473
|
-
| -------------------------- | -------------------------- | ------------------------ | --------------------------| ----------------------------------- | ------------------------------------------------------------------------------ |
|
474
|
-
| Action Cable | `action_cable` | `>= 5.0` | `>= 5.0` | *[Link](#action-cable)* | *[Link](https://github.com/rails/rails/tree/master/actioncable)* |
|
475
|
-
| Action Mailer | `action_mailer` | `>= 5.0` | `>= 5.0` | *[Link](#action-mailer)* | *[Link](https://github.com/rails/rails/tree/master/actionmailer)* |
|
476
|
-
| Action Pack | `action_pack` | `>= 3.2` | `>= 3.2` | *[Link](#action-pack)* | *[Link](https://github.com/rails/rails/tree/master/actionpack)* |
|
477
|
-
| Action View | `action_view` | `>= 3.2` | `>= 3.2` | *[Link](#action-view)* | *[Link](https://github.com/rails/rails/tree/master/actionview)* |
|
478
|
-
| Active Job | `active_job` | `>= 4.2` | `>= 4.2` | *[Link](#active-job)* | *[Link](https://github.com/rails/rails/tree/master/activejob)* |
|
479
|
-
| Active Model Serializers | `active_model_serializers` | `>= 0.9` | `>= 0.9` | *[Link](#active-model-serializers)* | *[Link](https://github.com/rails-api/active_model_serializers)* |
|
480
|
-
| Active Record | `active_record` | `>= 3.2` | `>= 3.2` | *[Link](#active-record)* | *[Link](https://github.com/rails/rails/tree/master/activerecord)* |
|
481
|
-
| Active Support | `active_support` | `>= 3.2` | `>= 3.2` | *[Link](#active-support)* | *[Link](https://github.com/rails/rails/tree/master/activesupport)* |
|
482
|
-
| AWS | `aws` | `>= 2.0` | `>= 2.0` | *[Link](#aws)* | *[Link](https://github.com/aws/aws-sdk-ruby)* |
|
483
|
-
| Concurrent Ruby | `concurrent_ruby` | `>= 0.9` | `>= 0.9` | *[Link](#concurrent-ruby)* | *[Link](https://github.com/ruby-concurrency/concurrent-ruby)* |
|
484
|
-
| Dalli | `dalli` | `>= 2.0` | `>= 2.0` | *[Link](#dalli)* | *[Link](https://github.com/petergoldstein/dalli)* |
|
485
|
-
| DelayedJob | `delayed_job` | `>= 4.1` | `>= 4.1` | *[Link](#delayedjob)* | *[Link](https://github.com/collectiveidea/delayed_job)* |
|
486
|
-
| Elasticsearch | `elasticsearch` | `>= 1.0` | `>= 1.0` | *[Link](#elasticsearch)* | *[Link](https://github.com/elastic/elasticsearch-ruby)* |
|
487
|
-
| Ethon | `ethon` | `>= 0.11` | `>= 0.11` | *[Link](#ethon)* | *[Link](https://github.com/typhoeus/ethon)* |
|
488
|
-
| Excon | `excon` | `>= 0.50` | `>= 0.50` | *[Link](#excon)* | *[Link](https://github.com/excon/excon)* |
|
489
|
-
| Faraday | `faraday` | `>= 0.14` | `>= 0.14` | *[Link](#faraday)* | *[Link](https://github.com/lostisland/faraday)* |
|
490
|
-
| Grape | `grape` | `>= 1.0` | `>= 1.0` | *[Link](#grape)* | *[Link](https://github.com/ruby-grape/grape)* |
|
491
|
-
| GraphQL | `graphql` | `>= 1.7.9` | `>= 1.7.9` | *[Link](#graphql)* | *[Link](https://github.com/rmosolgo/graphql-ruby)* |
|
492
|
-
| gRPC | `grpc` | `>= 1.7` | *gem not available* | *[Link](#grpc)* | *[Link](https://github.com/grpc/grpc/tree/master/src/rubyc)* |
|
493
|
-
| http.rb | `httprb` | `>= 2.0` | `>= 2.0` | *[Link](#httprb)* | *[Link](https://github.com/httprb/http)* |
|
494
|
-
| httpclient | `httpclient` | `>= 2.2` | `>= 2.2` | *[Link](#httpclient)* | *[Link](https://github.com/nahi/httpclient)* |
|
495
|
-
| httpx | `httpx` | `>= 0.11` | `>= 0.11` | *[Link](#httpx)* | *[Link](https://gitlab.com/honeyryderchuck/httpx)* |
|
496
|
-
| Kafka | `ruby-kafka` | `>= 0.7.10` | `>= 0.7.10` | *[Link](#kafka)* | *[Link](https://github.com/zendesk/ruby-kafka)* |
|
497
|
-
| Makara (via Active Record) | `makara` | `>= 0.3.5` | `>= 0.3.5` | *[Link](#active-record)* | *[Link](https://github.com/instacart/makara)* |
|
498
|
-
| MongoDB | `mongo` | `>= 2.1` | `>= 2.1` | *[Link](#mongodb)* | *[Link](https://github.com/mongodb/mongo-ruby-driver)* |
|
499
|
-
| MySQL2 | `mysql2` | `>= 0.3.21` | *gem not available* | *[Link](#mysql2)* | *[Link](https://github.com/brianmario/mysql2)* |
|
500
|
-
| Net/HTTP | `http` | *(Any supported Ruby)* | *(Any supported Ruby)* | *[Link](#nethttp)* | *[Link](https://ruby-doc.org/stdlib-2.4.0/libdoc/net/http/rdoc/Net/HTTP.html)* |
|
501
|
-
| Postgres | `pg` | `>= 0.18.4` | *gem not available* | *[Link](#postgres)* | *[Link](https://github.com/ged/ruby-pg)* |
|
502
|
-
| Presto | `presto` | `>= 0.5.14` | `>= 0.5.14` | *[Link](#presto)* | *[Link](https://github.com/treasure-data/presto-client-ruby)* |
|
503
|
-
| Qless | `qless` | `>= 0.10.0` | `>= 0.10.0` | *[Link](#qless)* | *[Link](https://github.com/seomoz/qless)* |
|
504
|
-
| Que | `que` | `>= 1.0.0.beta2` | `>= 1.0.0.beta2` | *[Link](#que)* | *[Link](https://github.com/que-rb/que)* |
|
505
|
-
| Racecar | `racecar` | `>= 0.3.5` | `>= 0.3.5` | *[Link](#racecar)* | *[Link](https://github.com/zendesk/racecar)* |
|
506
|
-
| Rack | `rack` | `>= 1.1` | `>= 1.1` | *[Link](#rack)* | *[Link](https://github.com/rack/rack)* |
|
507
|
-
| Rails | `rails` | `>= 3.2` | `>= 3.2` | *[Link](#rails)* | *[Link](https://github.com/rails/rails)* |
|
508
|
-
| Rake | `rake` | `>= 12.0` | `>= 12.0` | *[Link](#rake)* | *[Link](https://github.com/ruby/rake)* |
|
509
|
-
| Redis | `redis` | `>= 3.2` | `>= 3.2` | *[Link](#redis)* | *[Link](https://github.com/redis/redis-rb)* |
|
510
|
-
| Resque | `resque` | `>= 1.0` | `>= 1.0` | *[Link](#resque)* | *[Link](https://github.com/resque/resque)* |
|
511
|
-
| Rest Client | `rest-client` | `>= 1.8` | `>= 1.8` | *[Link](#rest-client)* | *[Link](https://github.com/rest-client/rest-client)* |
|
512
|
-
| Sequel | `sequel` | `>= 3.41` | `>= 3.41` | *[Link](#sequel)* | *[Link](https://github.com/jeremyevans/sequel)* |
|
513
|
-
| Shoryuken | `shoryuken` | `>= 3.2` | `>= 3.2` | *[Link](#shoryuken)* | *[Link](https://github.com/phstc/shoryuken)* |
|
514
|
-
| Sidekiq | `sidekiq` | `>= 3.5.4` | `>= 3.5.4` | *[Link](#sidekiq)* | *[Link](https://github.com/mperham/sidekiq)* |
|
515
|
-
| Sinatra | `sinatra` | `>= 1.4` | `>= 1.4` | *[Link](#sinatra)* | *[Link](https://github.com/sinatra/sinatra)* |
|
516
|
-
| Sneakers | `sneakers` | `>= 2.12.0` | `>= 2.12.0` | *[Link](#sneakers)* | *[Link](https://github.com/jondot/sneakers)* |
|
517
|
-
| Sucker Punch | `sucker_punch` | `>= 2.0` | `>= 2.0` | *[Link](#sucker-punch)* | *[Link](https://github.com/brandonhilkert/sucker_punch)* |
|
518
|
-
|
519
|
-
#### CI Visibility
|
520
|
-
|
521
|
-
For Datadog CI Visibility, library instrumentation can be activated and configured by using the following `Datadog.configure` API:
|
522
|
-
|
523
|
-
```ruby
|
524
|
-
Datadog.configure do |c|
|
525
|
-
# Activates and configures an integration
|
526
|
-
c.ci.instrument :integration_name, options
|
527
|
-
end
|
528
|
-
```
|
529
|
-
|
530
|
-
`options` is a `Hash` of integration-specific configuration settings.
|
531
|
-
|
532
|
-
These are the available CI Visibility integrations:
|
533
|
-
|
534
|
-
| Name | Key | Versions Supported: MRI | Versions Supported: JRuby | How to configure | Gem source |
|
535
|
-
|-----------|------------|-------------------------|---------------------------|---------------------|-----------------------------------------------------|
|
536
|
-
| Cucumber | `cucumber` | `>= 3.0` | `>= 1.7.16` | *[Link](#cucumber)* | *[Link](https://github.com/cucumber/cucumber-ruby)* |
|
537
|
-
| RSpec | `rspec` | `>= 3.0.0` | `>= 3.0.0` | *[Link](#rspec)* | *[Link](https://github.com/rspec/rspec)* |
|
538
|
-
|
539
|
-
### Action Cable
|
540
|
-
|
541
|
-
The Action Cable integration traces broadcast messages and channel actions.
|
542
|
-
|
543
|
-
You can enable it through `Datadog.configure`:
|
544
|
-
|
545
|
-
```ruby
|
546
|
-
require 'ddtrace'
|
547
|
-
|
548
|
-
Datadog.configure do |c|
|
549
|
-
c.tracing.instrument :action_cable
|
550
|
-
end
|
551
|
-
```
|
552
|
-
|
553
|
-
### Action Mailer
|
554
|
-
|
555
|
-
The Action Mailer integration provides tracing for Rails 5 ActionMailer actions.
|
556
|
-
|
557
|
-
You can enable it through `Datadog.configure`:
|
558
|
-
|
559
|
-
```ruby
|
560
|
-
require 'ddtrace'
|
561
|
-
Datadog.configure do |c|
|
562
|
-
c.tracing.instrument :action_mailer, options
|
563
|
-
end
|
564
|
-
```
|
565
|
-
|
566
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
567
|
-
|
568
|
-
| Key | Description | Default |
|
569
|
-
| --- | ----------- | ------- |
|
570
|
-
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
|
571
|
-
| `email_data` | Whether or not to append additional email payload metadata to `action_mailer.deliver` spans. Fields include `['subject', 'to', 'from', 'bcc', 'cc', 'date', 'perform_deliveries']`. | `false` |
|
572
|
-
|
573
|
-
### Action Pack
|
574
|
-
|
575
|
-
Most of the time, Action Pack is set up as part of Rails, but it can be activated separately:
|
576
|
-
|
577
|
-
```ruby
|
578
|
-
require 'actionpack'
|
579
|
-
require 'ddtrace'
|
580
|
-
|
581
|
-
Datadog.configure do |c|
|
582
|
-
c.tracing.instrument :action_pack
|
583
|
-
end
|
584
|
-
```
|
585
|
-
|
586
|
-
### Action View
|
587
|
-
|
588
|
-
Most of the time, Action View is set up as part of Rails, but it can be activated separately:
|
589
|
-
|
590
|
-
```ruby
|
591
|
-
require 'actionview'
|
592
|
-
require 'ddtrace'
|
593
|
-
|
594
|
-
Datadog.configure do |c|
|
595
|
-
c.tracing.instrument :action_view, options
|
596
|
-
end
|
597
|
-
```
|
598
|
-
|
599
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
600
|
-
|
601
|
-
| Key | Description | Default |
|
602
|
-
| ---| --- | --- |
|
603
|
-
| `template_base_path` | Used when the template name is parsed. If you don't store your templates in the `views/` folder, you may need to change this value | `'views/'` |
|
604
|
-
|
605
|
-
### Active Job
|
606
|
-
|
607
|
-
Most of the time, Active Job is set up as part of Rails, but it can be activated separately:
|
608
|
-
|
609
|
-
```ruby
|
610
|
-
require 'active_job'
|
611
|
-
require 'ddtrace'
|
612
|
-
|
613
|
-
Datadog.configure do |c|
|
614
|
-
c.tracing.instrument :active_job
|
615
|
-
end
|
616
|
-
|
617
|
-
ExampleJob.perform_later
|
618
|
-
```
|
619
|
-
|
620
|
-
### Active Model Serializers
|
621
|
-
|
622
|
-
The Active Model Serializers integration traces the `serialize` event for version 0.9+ and the `render` event for version 0.10+.
|
623
|
-
|
624
|
-
```ruby
|
625
|
-
require 'active_model_serializers'
|
626
|
-
require 'ddtrace'
|
627
|
-
|
628
|
-
Datadog.configure do |c|
|
629
|
-
c.tracing.instrument :active_model_serializers
|
630
|
-
end
|
631
|
-
|
632
|
-
my_object = MyModel.new(name: 'my object')
|
633
|
-
ActiveModelSerializers::SerializableResource.new(test_obj).serializable_hash
|
634
|
-
```
|
635
|
-
|
636
|
-
### Active Record
|
637
|
-
|
638
|
-
Most of the time, Active Record is set up as part of a web framework (Rails, Sinatra...) however, it can be set up alone:
|
639
|
-
|
640
|
-
```ruby
|
641
|
-
require 'tmpdir'
|
642
|
-
require 'sqlite3'
|
643
|
-
require 'active_record'
|
644
|
-
require 'ddtrace'
|
645
|
-
|
646
|
-
Datadog.configure do |c|
|
647
|
-
c.tracing.instrument :active_record, options
|
648
|
-
end
|
649
|
-
|
650
|
-
Dir::Tmpname.create(['test', '.sqlite']) do |db|
|
651
|
-
conn = ActiveRecord::Base.establish_connection(adapter: 'sqlite3',
|
652
|
-
database: db)
|
653
|
-
conn.connection.execute('SELECT 42') # traced!
|
654
|
-
end
|
655
|
-
```
|
656
|
-
|
657
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
658
|
-
|
659
|
-
| Key | Description | Default |
|
660
|
-
| ---| --- | --- |
|
661
|
-
| `service_name` | Service name used for database portion of `active_record` instrumentation. | Name of database adapter (e.g. `'mysql2'`) |
|
662
|
-
|
663
|
-
**Configuring trace settings per database**
|
664
|
-
|
665
|
-
You can configure trace settings per database connection by using the `describes` option:
|
666
|
-
|
667
|
-
```ruby
|
668
|
-
# Provide a `:describes` option with a connection key.
|
669
|
-
# Any of the following keys are acceptable and equivalent to one another.
|
670
|
-
# If a block is provided, it yields a Settings object that
|
671
|
-
# accepts any of the configuration options listed above.
|
672
|
-
|
673
|
-
Datadog.configure do |c|
|
674
|
-
# Symbol matching your database connection in config/database.yml
|
675
|
-
# Only available if you are using Rails with ActiveRecord.
|
676
|
-
c.tracing.instrument :active_record, describes: :secondary_database, service_name: 'secondary-db'
|
677
|
-
|
678
|
-
# Block configuration pattern.
|
679
|
-
c.tracing.instrument :active_record, describes: :secondary_database do |second_db|
|
680
|
-
second_db.service_name = 'secondary-db'
|
681
|
-
end
|
682
|
-
|
683
|
-
# Connection string with the following connection settings:
|
684
|
-
# adapter, username, host, port, database
|
685
|
-
# Other fields are ignored.
|
686
|
-
c.tracing.instrument :active_record, describes: 'mysql2://root@127.0.0.1:3306/mysql', service_name: 'secondary-db'
|
687
|
-
|
688
|
-
# Hash with following connection settings:
|
689
|
-
# adapter, username, host, port, database
|
690
|
-
# Other fields are ignored.
|
691
|
-
c.tracing.instrument :active_record, describes: {
|
692
|
-
adapter: 'mysql2',
|
693
|
-
host: '127.0.0.1',
|
694
|
-
port: '3306',
|
695
|
-
database: 'mysql',
|
696
|
-
username: 'root'
|
697
|
-
},
|
698
|
-
service_name: 'secondary-db'
|
699
|
-
|
700
|
-
# If using the `makara` gem, it's possible to match on connection `role`:
|
701
|
-
c.tracing.instrument :active_record, describes: { makara_role: 'primary' }, service_name: 'primary-db'
|
702
|
-
c.tracing.instrument :active_record, describes: { makara_role: 'replica' }, service_name: 'secondary-db'
|
703
|
-
end
|
704
|
-
```
|
705
|
-
|
706
|
-
You can also create configurations based on partial matching of database connection fields:
|
707
|
-
|
708
|
-
```ruby
|
709
|
-
Datadog.configure do |c|
|
710
|
-
# Matches any connection on host `127.0.0.1`.
|
711
|
-
c.tracing.instrument :active_record, describes: { host: '127.0.0.1' }, service_name: 'local-db'
|
712
|
-
|
713
|
-
# Matches any `mysql2` connection.
|
714
|
-
c.tracing.instrument :active_record, describes: { adapter: 'mysql2'}, service_name: 'mysql-db'
|
715
|
-
|
716
|
-
# Matches any `mysql2` connection to the `reports` database.
|
717
|
-
#
|
718
|
-
# In case of multiple matching `describe` configurations, the latest one applies.
|
719
|
-
# In this case a connection with both adapter `mysql` and database `reports`
|
720
|
-
# will be configured `service_name: 'reports-db'`, not `service_name: 'mysql-db'`.
|
721
|
-
c.tracing.instrument :active_record, describes: { adapter: 'mysql2', database: 'reports'}, service_name: 'reports-db'
|
722
|
-
end
|
723
|
-
```
|
724
|
-
|
725
|
-
When multiple `describes` configurations match a connection, the latest configured rule that matches will be applied.
|
726
|
-
|
727
|
-
If ActiveRecord traces an event that uses a connection that matches a key defined by `describes`, it will use the trace settings assigned to that connection. If the connection does not match any of the described connections, it will use default settings defined by `c.tracing.instrument :active_record` instead.
|
728
|
-
|
729
|
-
### Active Support
|
730
|
-
|
731
|
-
Most of the time, Active Support is set up as part of Rails, but it can be activated separately:
|
732
|
-
|
733
|
-
```ruby
|
734
|
-
require 'activesupport'
|
735
|
-
require 'ddtrace'
|
736
|
-
|
737
|
-
Datadog.configure do |c|
|
738
|
-
c.tracing.instrument :active_support, options
|
739
|
-
end
|
740
|
-
|
741
|
-
cache = ActiveSupport::Cache::MemoryStore.new
|
742
|
-
cache.read('city')
|
743
|
-
```
|
744
|
-
|
745
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
746
|
-
|
747
|
-
| Key | Description | Default |
|
748
|
-
| ---| --- | --- |
|
749
|
-
| `cache_service` | Service name used for caching with `active_support` instrumentation. | `active_support-cache` |
|
750
|
-
|
751
|
-
### AWS
|
752
|
-
|
753
|
-
The AWS integration will trace every interaction (e.g. API calls) with AWS services (S3, ElastiCache etc.).
|
754
|
-
|
755
|
-
```ruby
|
756
|
-
require 'aws-sdk'
|
757
|
-
require 'ddtrace'
|
758
|
-
|
759
|
-
Datadog.configure do |c|
|
760
|
-
c.tracing.instrument :aws, options
|
761
|
-
end
|
762
|
-
|
763
|
-
# Perform traced call
|
764
|
-
Aws::S3::Client.new.list_buckets
|
765
|
-
```
|
766
|
-
|
767
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
768
|
-
|
769
|
-
| Key | Description | Default |
|
770
|
-
| --- | ----------- | ------- |
|
771
|
-
| `service_name` | Service name used for `aws` instrumentation | `'aws'` |
|
772
|
-
|
773
|
-
### Concurrent Ruby
|
774
|
-
|
775
|
-
The Concurrent Ruby integration adds support for context propagation when using `::Concurrent::Future`.
|
776
|
-
Making sure that code traced within the `Future#execute` will have correct parent set.
|
777
|
-
|
778
|
-
To activate your integration, use the `Datadog.configure` method:
|
779
|
-
|
780
|
-
```ruby
|
781
|
-
# Inside Rails initializer or equivalent
|
782
|
-
Datadog.configure do |c|
|
783
|
-
# Patches ::Concurrent::Future to use ExecutorService that propagates context
|
784
|
-
c.tracing.instrument :concurrent_ruby
|
785
|
-
end
|
786
|
-
|
787
|
-
# Pass context into code executed within Concurrent::Future
|
788
|
-
Datadog::Tracing.trace('outer') do
|
789
|
-
Concurrent::Future.execute { Datadog::Tracing.trace('inner') { } }.wait
|
790
|
-
end
|
791
|
-
```
|
792
|
-
|
793
|
-
### Cucumber
|
794
|
-
|
795
|
-
Cucumber integration will trace all executions of scenarios and steps when using `cucumber` framework.
|
796
|
-
|
797
|
-
To activate your integration, use the `Datadog.configure` method:
|
798
|
-
|
799
|
-
```ruby
|
800
|
-
require 'cucumber'
|
801
|
-
require 'ddtrace'
|
802
|
-
|
803
|
-
# Configure default Cucumber integration
|
804
|
-
Datadog.configure do |c|
|
805
|
-
c.ci.instrument :cucumber, options
|
806
|
-
end
|
807
|
-
|
808
|
-
# Example of how to attach tags from scenario to active span
|
809
|
-
Around do |scenario, block|
|
810
|
-
active_span = Datadog.configuration[:cucumber][:tracer].active_span
|
811
|
-
unless active_span.nil?
|
812
|
-
scenario.tags.filter { |tag| tag.include? ':' }.each do |tag|
|
813
|
-
active_span.set_tag(*tag.name.split(':', 2))
|
814
|
-
end
|
815
|
-
end
|
816
|
-
block.call
|
817
|
-
end
|
818
|
-
```
|
819
|
-
|
820
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
821
|
-
|
822
|
-
| Key | Description | Default |
|
823
|
-
| --- | ----------- | ------- |
|
824
|
-
| `enabled` | Defines whether Cucumber tests should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
|
825
|
-
| `service_name` | Service name used for `cucumber` instrumentation. | `'cucumber'` |
|
826
|
-
| `operation_name` | Operation name used for `cucumber` instrumentation. Useful if you want rename automatic trace metrics e.g. `trace.#{operation_name}.errors`. | `'cucumber.test'` |
|
827
|
-
|
828
|
-
### Dalli
|
829
|
-
|
830
|
-
Dalli integration will trace all calls to your `memcached` server:
|
831
|
-
|
832
|
-
```ruby
|
833
|
-
require 'dalli'
|
834
|
-
require 'ddtrace'
|
835
|
-
|
836
|
-
# Configure default Dalli tracing behavior
|
837
|
-
Datadog.configure do |c|
|
838
|
-
c.tracing.instrument :dalli, options
|
839
|
-
end
|
840
|
-
|
841
|
-
# Configure Dalli tracing behavior for single client
|
842
|
-
client = Dalli::Client.new('localhost:11211', options)
|
843
|
-
client.set('abc', 123)
|
844
|
-
```
|
845
|
-
|
846
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
847
|
-
|
848
|
-
| Key | Description | Default |
|
849
|
-
| --- | ----------- | ------- |
|
850
|
-
| `service_name` | Service name used for `dalli` instrumentation | `'memcached'` |
|
851
|
-
|
852
|
-
### DelayedJob
|
853
|
-
|
854
|
-
The DelayedJob integration uses lifecycle hooks to trace the job executions and enqueues.
|
855
|
-
|
856
|
-
You can enable it through `Datadog.configure`:
|
857
|
-
|
858
|
-
```ruby
|
859
|
-
require 'ddtrace'
|
860
|
-
|
861
|
-
Datadog.configure do |c|
|
862
|
-
c.tracing.instrument :delayed_job, options
|
863
|
-
end
|
864
|
-
```
|
865
|
-
|
866
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
867
|
-
|
868
|
-
| Key | Description | Default |
|
869
|
-
| --- | ----------- | ------- |
|
870
|
-
| `error_handler` | Custom error handler invoked when a job raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
|
871
|
-
|
872
|
-
### Elasticsearch
|
873
|
-
|
874
|
-
The Elasticsearch integration will trace any call to `perform_request` in the `Client` object:
|
875
|
-
|
876
|
-
```ruby
|
877
|
-
require 'elasticsearch/transport'
|
878
|
-
require 'ddtrace'
|
879
|
-
|
880
|
-
Datadog.configure do |c|
|
881
|
-
c.tracing.instrument :elasticsearch, options
|
882
|
-
end
|
883
|
-
|
884
|
-
# Perform a query to Elasticsearch
|
885
|
-
client = Elasticsearch::Client.new url: 'http://127.0.0.1:9200'
|
886
|
-
response = client.perform_request 'GET', '_cluster/health'
|
887
|
-
|
888
|
-
# In case you want to override the global configuration for a certain client instance
|
889
|
-
Datadog.configure_onto(client.transport, **options)
|
890
|
-
```
|
891
|
-
|
892
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
893
|
-
|
894
|
-
| Key | Description | Default |
|
895
|
-
| --- | ----------- | ------- |
|
896
|
-
| `quantize` | Hash containing options for quantization. May include `:show` with an Array of keys to not quantize (or `:all` to skip quantization), or `:exclude` with Array of keys to exclude entirely. | `{}` |
|
897
|
-
| `service_name` | Service name used for `elasticsearch` instrumentation | `'elasticsearch'` |
|
898
|
-
|
899
|
-
### Ethon
|
900
|
-
|
901
|
-
The `ethon` integration will trace any HTTP request through `Easy` or `Multi` objects. Note that this integration also supports `Typhoeus` library which is based on `Ethon`.
|
902
|
-
|
903
|
-
```ruby
|
904
|
-
require 'ddtrace'
|
905
|
-
|
906
|
-
Datadog.configure do |c|
|
907
|
-
c.tracing.instrument :ethon, options
|
908
|
-
|
909
|
-
# optionally, specify a different service name for hostnames matching a regex
|
910
|
-
c.tracing.instrument :ethon, describes: /user-[^.]+\.example\.com/ do |ethon|
|
911
|
-
ethon.service_name = 'user.example.com'
|
912
|
-
ethon.split_by_domain = false # Only necessary if split_by_domain is true by default
|
913
|
-
end
|
914
|
-
end
|
915
|
-
```
|
916
|
-
|
917
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
918
|
-
|
919
|
-
| Key | Description | Default |
|
920
|
-
| --- | ----------- | ------- |
|
921
|
-
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
|
922
|
-
| `service_name` | Service name for `ethon` instrumentation. | `'ethon'` |
|
923
|
-
| `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
|
924
|
-
|
925
|
-
### Excon
|
926
|
-
|
927
|
-
The `excon` integration is available through the `ddtrace` middleware:
|
928
|
-
|
929
|
-
```ruby
|
930
|
-
require 'excon'
|
931
|
-
require 'ddtrace'
|
932
|
-
|
933
|
-
# Configure default Excon tracing behavior
|
934
|
-
Datadog.configure do |c|
|
935
|
-
c.tracing.instrument :excon, options
|
936
|
-
|
937
|
-
# optionally, specify a different service name for hostnames matching a regex
|
938
|
-
c.tracing.instrument :excon, describes: /user-[^.]+\.example\.com/ do |excon|
|
939
|
-
excon.service_name = 'user.example.com'
|
940
|
-
excon.split_by_domain = false # Only necessary if split_by_domain is true by default
|
941
|
-
end
|
942
|
-
end
|
943
|
-
|
944
|
-
connection = Excon.new('https://example.com')
|
945
|
-
connection.get
|
946
|
-
```
|
947
|
-
|
948
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
949
|
-
|
950
|
-
| Key | Description | Default |
|
951
|
-
| --- | ----------- | ------- |
|
952
|
-
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
|
953
|
-
| `error_handler` | A `Proc` that accepts a `response` parameter. If it evaluates to a *truthy* value, the trace span is marked as an error. By default only sets 5XX responses as errors. | `nil` |
|
954
|
-
| `service_name` | Service name for Excon instrumentation. When provided to middleware for a specific connection, it applies only to that connection object. | `'excon'` |
|
955
|
-
| `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
|
956
|
-
|
957
|
-
**Configuring connections to use different settings**
|
958
|
-
|
959
|
-
If you use multiple connections with Excon, you can give each of them different settings by configuring their constructors with middleware:
|
960
|
-
|
961
|
-
```ruby
|
962
|
-
# Wrap the Datadog tracing middleware around the default middleware stack
|
963
|
-
Excon.new(
|
964
|
-
'http://example.com',
|
965
|
-
middlewares: Datadog::Tracing::Contrib::Excon::Middleware.with(options).around_default_stack
|
966
|
-
)
|
967
|
-
|
968
|
-
# Insert the middleware into a custom middleware stack.
|
969
|
-
# NOTE: Trace middleware must be inserted after ResponseParser!
|
970
|
-
Excon.new(
|
971
|
-
'http://example.com',
|
972
|
-
middlewares: [
|
973
|
-
Excon::Middleware::ResponseParser,
|
974
|
-
Datadog::Tracing::Contrib::Excon::Middleware.with(options),
|
975
|
-
Excon::Middleware::Idempotent
|
976
|
-
]
|
977
|
-
)
|
978
|
-
```
|
979
|
-
|
980
|
-
Where `options` is a Hash that contains any of the parameters listed in the table above.
|
981
|
-
|
982
|
-
### Faraday
|
983
|
-
|
984
|
-
The `faraday` integration is available through the `ddtrace` middleware:
|
985
|
-
|
986
|
-
```ruby
|
987
|
-
require 'faraday'
|
988
|
-
require 'ddtrace'
|
989
|
-
|
990
|
-
# Configure default Faraday tracing behavior
|
991
|
-
Datadog.configure do |c|
|
992
|
-
c.tracing.instrument :faraday, options
|
993
|
-
|
994
|
-
# optionally, specify a different service name for hostnames matching a regex
|
995
|
-
c.tracing.instrument :faraday, describes: /user-[^.]+\.example\.com/ do |faraday|
|
996
|
-
faraday.service_name = 'user.example.com'
|
997
|
-
faraday.split_by_domain = false # Only necessary if split_by_domain is true by default
|
998
|
-
end
|
999
|
-
end
|
1000
|
-
|
1001
|
-
# In case you want to override the global configuration for a certain client instance
|
1002
|
-
connection = Faraday.new('https://example.com') do |builder|
|
1003
|
-
builder.use(:ddtrace, options)
|
1004
|
-
builder.adapter Faraday.default_adapter
|
1005
|
-
end
|
1006
|
-
|
1007
|
-
connection.get('/foo')
|
1008
|
-
```
|
1009
|
-
|
1010
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
1011
|
-
|
1012
|
-
| Key | Description | Default |
|
1013
|
-
| --- | ----------- | ------- |
|
1014
|
-
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
|
1015
|
-
| `error_handler` | A `Proc` that accepts a `response` parameter. If it evaluates to a *truthy* value, the trace span is marked as an error. By default only sets 5XX responses as errors. | `nil` |
|
1016
|
-
| `service_name` | Service name for Faraday instrumentation. When provided to middleware for a specific connection, it applies only to that connection object. | `'faraday'` |
|
1017
|
-
| `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
|
1018
|
-
|
1019
|
-
### Grape
|
1020
|
-
|
1021
|
-
The Grape integration adds the instrumentation to Grape endpoints and filters. This integration can work side by side with other integrations like Rack and Rails.
|
1022
|
-
|
1023
|
-
To activate your integration, use the `Datadog.configure` method before defining your Grape application:
|
1024
|
-
|
1025
|
-
```ruby
|
1026
|
-
# api.rb
|
1027
|
-
require 'grape'
|
1028
|
-
require 'ddtrace'
|
1029
|
-
|
1030
|
-
Datadog.configure do |c|
|
1031
|
-
c.tracing.instrument :grape, options
|
1032
|
-
end
|
1033
|
-
|
1034
|
-
# Then define your application
|
1035
|
-
class RackTestingAPI < Grape::API
|
1036
|
-
desc 'main endpoint'
|
1037
|
-
get :success do
|
1038
|
-
'Hello world!'
|
1039
|
-
end
|
1040
|
-
end
|
1041
|
-
```
|
1042
|
-
|
1043
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
1044
|
-
|
1045
|
-
| Key | Description | Default |
|
1046
|
-
| --- | ----------- | ------- |
|
1047
|
-
| `enabled` | Defines whether Grape should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
|
1048
|
-
| `error_statuses`| Defines a status code or range of status codes which should be marked as errors. `'404,405,500-599'` or `[404,405,'500-599']` | `nil` |
|
1049
|
-
|
1050
|
-
### GraphQL
|
1051
|
-
|
1052
|
-
The GraphQL integration activates instrumentation for GraphQL queries.
|
1053
|
-
|
1054
|
-
To activate your integration, use the `Datadog.configure` method:
|
1055
|
-
|
1056
|
-
```ruby
|
1057
|
-
# Inside Rails initializer or equivalent
|
1058
|
-
Datadog.configure do |c|
|
1059
|
-
c.tracing.instrument :graphql, schemas: [YourSchema], options
|
1060
|
-
end
|
1061
|
-
|
1062
|
-
# Then run a GraphQL query
|
1063
|
-
YourSchema.execute(query, variables: {}, context: {}, operation_name: nil)
|
1064
|
-
```
|
1065
|
-
|
1066
|
-
The `use :graphql` method accepts the following parameters. Additional options can be substituted in for `options`:
|
1067
|
-
|
1068
|
-
| Key | Description | Default |
|
1069
|
-
| --- | ----------- | ------- |
|
1070
|
-
| `schemas` | Required. Array of `GraphQL::Schema` objects which to trace. Tracing will be added to all the schemas listed, using the options provided to this configuration. If you do not provide any, then tracing will not be activated. | `[]` |
|
1071
|
-
|
1072
|
-
**Manually configuring GraphQL schemas**
|
1073
|
-
|
1074
|
-
If you prefer to individually configure the tracer settings for a schema (e.g. you have multiple schemas with different service names), in the schema definition, you can add the following [using the GraphQL API](http://graphql-ruby.org/queries/tracing.html):
|
1075
|
-
|
1076
|
-
```ruby
|
1077
|
-
# Class-based schema
|
1078
|
-
class YourSchema < GraphQL::Schema
|
1079
|
-
use(
|
1080
|
-
GraphQL::Tracing::DataDogTracing,
|
1081
|
-
service: 'graphql'
|
1082
|
-
)
|
1083
|
-
end
|
1084
|
-
```
|
1085
|
-
|
1086
|
-
```ruby
|
1087
|
-
# .define-style schema
|
1088
|
-
YourSchema = GraphQL::Schema.define do
|
1089
|
-
use(
|
1090
|
-
GraphQL::Tracing::DataDogTracing,
|
1091
|
-
service: 'graphql'
|
1092
|
-
)
|
1093
|
-
end
|
1094
|
-
```
|
1095
|
-
|
1096
|
-
Or you can modify an already defined schema:
|
1097
|
-
|
1098
|
-
```ruby
|
1099
|
-
# Class-based schema
|
1100
|
-
YourSchema.use(
|
1101
|
-
GraphQL::Tracing::DataDogTracing,
|
1102
|
-
service: 'graphql'
|
1103
|
-
)
|
1104
|
-
```
|
1105
|
-
|
1106
|
-
```ruby
|
1107
|
-
# .define-style schema
|
1108
|
-
YourSchema.define do
|
1109
|
-
use(
|
1110
|
-
GraphQL::Tracing::DataDogTracing,
|
1111
|
-
service: 'graphql'
|
1112
|
-
)
|
1113
|
-
end
|
1114
|
-
```
|
1115
|
-
|
1116
|
-
Do *NOT* `use :graphql` in `Datadog.configure` if you choose to configure manually, as to avoid double tracing. These two means of configuring GraphQL tracing are considered mutually exclusive.
|
1117
|
-
|
1118
|
-
### gRPC
|
1119
|
-
|
1120
|
-
The `grpc` integration adds both client and server interceptors, which run as middleware before executing the service's remote procedure call. As gRPC applications are often distributed, the integration shares trace information between client and server.
|
1121
|
-
|
1122
|
-
To setup your integration, use the `Datadog.configure` method like so:
|
1123
|
-
|
1124
|
-
```ruby
|
1125
|
-
require 'grpc'
|
1126
|
-
require 'ddtrace'
|
1127
|
-
|
1128
|
-
Datadog.configure do |c|
|
1129
|
-
c.tracing.instrument :grpc, options
|
1130
|
-
end
|
1131
|
-
|
1132
|
-
# Server side
|
1133
|
-
server = GRPC::RpcServer.new
|
1134
|
-
server.add_http2_port('localhost:50051', :this_port_is_insecure)
|
1135
|
-
server.handle(Demo)
|
1136
|
-
server.run_till_terminated
|
1137
|
-
|
1138
|
-
# Client side
|
1139
|
-
client = Demo.rpc_stub_class.new('localhost:50051', :this_channel_is_insecure)
|
1140
|
-
client.my_endpoint(DemoMessage.new(contents: 'hello!'))
|
1141
|
-
```
|
1142
|
-
|
1143
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
1144
|
-
|
1145
|
-
| Key | Description | Default |
|
1146
|
-
| --- | ----------- | ------- |
|
1147
|
-
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
|
1148
|
-
| `service_name` | Service name used for `grpc` instrumentation | `'grpc'` |
|
1149
|
-
| `error_handler` | Custom error handler invoked when a request is an error. A `Proc` that accepts `span` and `error` parameters. Sets error on the span by default. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
|
1150
|
-
|
1151
|
-
**Configuring clients to use different settings**
|
1152
|
-
|
1153
|
-
In situations where you have multiple clients calling multiple distinct services, you may pass the Datadog interceptor directly, like so
|
1154
|
-
|
1155
|
-
```ruby
|
1156
|
-
configured_interceptor = Datadog::Tracing::Contrib::GRPC::DatadogInterceptor::Client.new do |c|
|
1157
|
-
c.service_name = "Alternate"
|
1158
|
-
end
|
1159
|
-
|
1160
|
-
alternate_client = Demo::Echo::Service.rpc_stub_class.new(
|
1161
|
-
'localhost:50052',
|
1162
|
-
:this_channel_is_insecure,
|
1163
|
-
:interceptors => [configured_interceptor]
|
1164
|
-
)
|
1165
|
-
```
|
1166
|
-
|
1167
|
-
The integration will ensure that the `configured_interceptor` establishes a unique tracing setup for that client instance.
|
1168
|
-
|
1169
|
-
### http.rb
|
1170
|
-
|
1171
|
-
The http.rb integration will trace any HTTP call using the Http.rb gem.
|
1172
|
-
|
1173
|
-
```ruby
|
1174
|
-
require 'http'
|
1175
|
-
require 'ddtrace'
|
1176
|
-
Datadog.configure do |c|
|
1177
|
-
c.tracing.instrument :httprb, options
|
1178
|
-
# optionally, specify a different service name for hostnames matching a regex
|
1179
|
-
c.tracing.instrument :httprb, describes: /user-[^.]+\.example\.com/ do |httprb|
|
1180
|
-
httprb.service_name = 'user.example.com'
|
1181
|
-
httprb.split_by_domain = false # Only necessary if split_by_domain is true by default
|
1182
|
-
end
|
1183
|
-
end
|
1184
|
-
```
|
1185
|
-
|
1186
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
1187
|
-
|
1188
|
-
| Key | Description | Default |
|
1189
|
-
| --- | ----------- | ------- |
|
1190
|
-
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
|
1191
|
-
| `service_name` | Service name for `httprb` instrumentation. | `'httprb'` |
|
1192
|
-
| `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
|
1193
|
-
|
1194
|
-
### httpclient
|
1195
|
-
|
1196
|
-
The httpclient integration will trace any HTTP call using the httpclient gem.
|
1197
|
-
|
1198
|
-
```ruby
|
1199
|
-
require 'httpclient'
|
1200
|
-
require 'ddtrace'
|
1201
|
-
Datadog.configure do |c|
|
1202
|
-
c.tracing.instrument :httpclient, options
|
1203
|
-
# optionally, specify a different service name for hostnames matching a regex
|
1204
|
-
c.tracing.instrument :httpclient, describes: /user-[^.]+\.example\.com/ do |httpclient|
|
1205
|
-
httpclient.service_name = 'user.example.com'
|
1206
|
-
httpclient.split_by_domain = false # Only necessary if split_by_domain is true by default
|
1207
|
-
end
|
1208
|
-
end
|
1209
|
-
```
|
1210
|
-
|
1211
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
1212
|
-
|
1213
|
-
| Key | Description | Default |
|
1214
|
-
| --- | ----------- | ------- |
|
1215
|
-
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
|
1216
|
-
| `service_name` | Service name for `httpclient` instrumentation. | `'httpclient'` |
|
1217
|
-
| `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
|
1218
|
-
|
1219
|
-
### httpx
|
1220
|
-
|
1221
|
-
`httpx` maintains its [own integration with `ddtrace`](https://honeyryderchuck.gitlab.io/httpx/wiki/Datadog-Adapter):
|
1222
|
-
|
1223
|
-
```ruby
|
1224
|
-
require "ddtrace"
|
1225
|
-
require "httpx/adapters/datadog"
|
1226
|
-
|
1227
|
-
Datadog.configure do |c|
|
1228
|
-
c.tracing.instrument :httpx
|
1229
|
-
|
1230
|
-
# optionally, specify a different service name for hostnames matching a regex
|
1231
|
-
c.tracing.instrument :httpx, describes: /user-[^.]+\.example\.com/ do |http|
|
1232
|
-
http.service_name = 'user.example.com'
|
1233
|
-
http.split_by_domain = false # Only necessary if split_by_domain is true by default
|
1234
|
-
end
|
1235
|
-
end
|
1236
|
-
```
|
1237
|
-
|
1238
|
-
### Kafka
|
1239
|
-
|
1240
|
-
The Kafka integration provides tracing of the `ruby-kafka` gem:
|
1241
|
-
|
1242
|
-
You can enable it through `Datadog.configure`:
|
1243
|
-
|
1244
|
-
```ruby
|
1245
|
-
require 'active_support/notifications' # required to enable 'ruby-kafka' instrumentation
|
1246
|
-
require 'kafka'
|
1247
|
-
require 'ddtrace'
|
1248
|
-
|
1249
|
-
Datadog.configure do |c|
|
1250
|
-
c.tracing.instrument :kafka
|
1251
|
-
end
|
1252
|
-
```
|
1253
|
-
|
1254
|
-
### MongoDB
|
1255
|
-
|
1256
|
-
The integration traces any `Command` that is sent from the [MongoDB Ruby Driver](https://github.com/mongodb/mongo-ruby-driver) to a MongoDB cluster. By extension, Object Document Mappers (ODM) such as Mongoid are automatically instrumented if they use the official Ruby driver. To activate the integration, simply:
|
1257
|
-
|
1258
|
-
```ruby
|
1259
|
-
require 'mongo'
|
1260
|
-
require 'ddtrace'
|
1261
|
-
|
1262
|
-
Datadog.configure do |c|
|
1263
|
-
c.tracing.instrument :mongo, options
|
1264
|
-
end
|
1265
|
-
|
1266
|
-
# Create a MongoDB client and use it as usual
|
1267
|
-
client = Mongo::Client.new([ '127.0.0.1:27017' ], :database => 'artists')
|
1268
|
-
collection = client[:people]
|
1269
|
-
collection.insert_one({ name: 'Steve' })
|
1270
|
-
|
1271
|
-
# In case you want to override the global configuration for a certain client instance
|
1272
|
-
Datadog.configure_onto(client, **options)
|
1273
|
-
```
|
1274
|
-
|
1275
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
1276
|
-
|
1277
|
-
| Key | Description | Default |
|
1278
|
-
| --- | ----------- | ------- |
|
1279
|
-
| `quantize` | Hash containing options for quantization. May include `:show` with an Array of keys to not quantize (or `:all` to skip quantization), or `:exclude` with Array of keys to exclude entirely. | `{ show: [:collection, :database, :operation] }` |
|
1280
|
-
| `service_name` | Service name used for `mongo` instrumentation | `'mongodb'` |
|
1281
|
-
|
1282
|
-
**Configuring trace settings per connection**
|
1283
|
-
|
1284
|
-
You can configure trace settings per connection by using the `describes` option:
|
1285
|
-
|
1286
|
-
```ruby
|
1287
|
-
# Provide a `:describes` option with a connection key.
|
1288
|
-
# Any of the following keys are acceptable and equivalent to one another.
|
1289
|
-
# If a block is provided, it yields a Settings object that
|
1290
|
-
# accepts any of the configuration options listed above.
|
1291
|
-
|
1292
|
-
Datadog.configure do |c|
|
1293
|
-
# Network connection string
|
1294
|
-
c.tracing.instrument :mongo, describes: '127.0.0.1:27017', service_name: 'mongo-primary'
|
1295
|
-
|
1296
|
-
# Network connection regular expression
|
1297
|
-
c.tracing.instrument :mongo, describes: /localhost.*/, service_name: 'mongo-secondary'
|
1298
|
-
end
|
1299
|
-
|
1300
|
-
client = Mongo::Client.new([ '127.0.0.1:27017' ], :database => 'artists')
|
1301
|
-
collection = client[:people]
|
1302
|
-
collection.insert_one({ name: 'Steve' })
|
1303
|
-
# Traced call will belong to `mongo-primary` service
|
1304
|
-
|
1305
|
-
client = Mongo::Client.new([ 'localhost:27017' ], :database => 'artists')
|
1306
|
-
collection = client[:people]
|
1307
|
-
collection.insert_one({ name: 'Steve' })
|
1308
|
-
# Traced call will belong to `mongo-secondary` service
|
1309
|
-
```
|
1310
|
-
|
1311
|
-
When multiple `describes` configurations match a connection, the latest configured rule that matches will be applied.
|
1312
|
-
|
1313
|
-
### MySQL2
|
1314
|
-
|
1315
|
-
The MySQL2 integration traces any SQL command sent through `mysql2` gem.
|
1316
|
-
|
1317
|
-
```ruby
|
1318
|
-
require 'mysql2'
|
1319
|
-
require 'ddtrace'
|
1320
|
-
|
1321
|
-
Datadog.configure do |c|
|
1322
|
-
c.tracing.instrument :mysql2, options
|
1323
|
-
end
|
1324
|
-
|
1325
|
-
client = Mysql2::Client.new(:host => "localhost", :username => "root")
|
1326
|
-
client.query("SELECT * FROM users WHERE group='x'")
|
1327
|
-
```
|
1328
|
-
|
1329
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
1330
|
-
|
1331
|
-
| Key | Description | Default |
|
1332
|
-
| --- | ----------- | ------- |
|
1333
|
-
| `service_name` | Service name used for `mysql2` instrumentation | `'mysql2'` |
|
1334
|
-
|
1335
|
-
### Net/HTTP
|
1336
|
-
|
1337
|
-
The Net/HTTP integration will trace any HTTP call using the standard lib Net::HTTP module.
|
1338
|
-
|
1339
|
-
```ruby
|
1340
|
-
require 'net/http'
|
1341
|
-
require 'ddtrace'
|
1342
|
-
|
1343
|
-
Datadog.configure do |c|
|
1344
|
-
c.tracing.instrument :http, options
|
1345
|
-
|
1346
|
-
# optionally, specify a different service name for hostnames matching a regex
|
1347
|
-
c.tracing.instrument :http, describes: /user-[^.]+\.example\.com/ do |http|
|
1348
|
-
http.service_name = 'user.example.com'
|
1349
|
-
http.split_by_domain = false # Only necessary if split_by_domain is true by default
|
1350
|
-
end
|
1351
|
-
end
|
1352
|
-
|
1353
|
-
Net::HTTP.start('127.0.0.1', 8080) do |http|
|
1354
|
-
request = Net::HTTP::Get.new '/index'
|
1355
|
-
response = http.request(request)
|
1356
|
-
end
|
1357
|
-
|
1358
|
-
content = Net::HTTP.get(URI('http://127.0.0.1/index.html'))
|
1359
|
-
```
|
1360
|
-
|
1361
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
1362
|
-
|
1363
|
-
| Key | Description | Default |
|
1364
|
-
| --- | ----------- | ------- |
|
1365
|
-
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
|
1366
|
-
| `service_name` | Service name used for `http` instrumentation | `'net/http'` |
|
1367
|
-
| `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
|
1368
|
-
|
1369
|
-
If you wish to configure each connection object individually, you may use the `Datadog.configure_onto` as it follows:
|
1370
|
-
|
1371
|
-
```ruby
|
1372
|
-
client = Net::HTTP.new(host, port)
|
1373
|
-
Datadog.configure_onto(client, **options)
|
1374
|
-
```
|
1375
|
-
### Postgres
|
1376
|
-
|
1377
|
-
The PG integration traces SQL commands sent through the `pg` gem via:
|
1378
|
-
* `exec`, `exec_params`, `exec_prepared`;
|
1379
|
-
* `async_exec`, `async_exec_params`, `async_exec_prepared`; or,
|
1380
|
-
* `sync_exec`, `sync_exec_params`, `sync_exec_prepared`
|
1381
|
-
|
1382
|
-
```ruby
|
1383
|
-
require 'pg'
|
1384
|
-
require 'ddtrace'
|
1385
|
-
|
1386
|
-
Datadog.configure do |c|
|
1387
|
-
c.tracing.instrument :pg, options
|
1388
|
-
end
|
1389
|
-
```
|
1390
|
-
|
1391
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
1392
|
-
|
1393
|
-
| Key | Description | Default |
|
1394
|
-
| --- | ----------- | ------- |
|
1395
|
-
| `service_name` | Service name used for `pg` instrumentation | `'pg'` |
|
1396
|
-
|
1397
|
-
### Presto
|
1398
|
-
|
1399
|
-
The Presto integration traces any SQL command sent through `presto-client` gem.
|
1400
|
-
|
1401
|
-
```ruby
|
1402
|
-
require 'presto-client'
|
1403
|
-
require 'ddtrace'
|
1404
|
-
|
1405
|
-
Datadog.configure do |c|
|
1406
|
-
c.tracing.instrument :presto, options
|
1407
|
-
end
|
1408
|
-
|
1409
|
-
client = Presto::Client.new(
|
1410
|
-
server: "localhost:8880",
|
1411
|
-
ssl: {verify: false},
|
1412
|
-
catalog: "native",
|
1413
|
-
schema: "default",
|
1414
|
-
time_zone: "US/Pacific",
|
1415
|
-
language: "English",
|
1416
|
-
http_debug: true,
|
1417
|
-
)
|
1418
|
-
|
1419
|
-
client.run("select * from system.nodes")
|
1420
|
-
```
|
1421
|
-
|
1422
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
1423
|
-
|
1424
|
-
| Key | Description | Default |
|
1425
|
-
| --- | ----------- | ------- |
|
1426
|
-
| `service_name` | Service name used for `presto` instrumentation | `'presto'` |
|
1427
|
-
|
1428
|
-
### Qless
|
1429
|
-
|
1430
|
-
The Qless integration uses lifecycle hooks to trace job executions.
|
1431
|
-
|
1432
|
-
To add tracing to a Qless job:
|
1433
|
-
|
1434
|
-
```ruby
|
1435
|
-
require 'ddtrace'
|
1436
|
-
|
1437
|
-
Datadog.configure do |c|
|
1438
|
-
c.tracing.instrument :qless, options
|
1439
|
-
end
|
1440
|
-
```
|
1441
|
-
|
1442
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
1443
|
-
|
1444
|
-
| Key | Description | Default |
|
1445
|
-
| --- | ----------- | ------- |
|
1446
|
-
| `tag_job_data` | Enable tagging with job arguments. true for on, false for off. | `false` |
|
1447
|
-
| `tag_job_tags` | Enable tagging with job tags. true for on, false for off. | `false` |
|
1448
|
-
|
1449
|
-
### Que
|
1450
|
-
|
1451
|
-
The Que integration is a middleware which will trace job executions.
|
1452
|
-
|
1453
|
-
You can enable it through `Datadog.configure`:
|
1454
|
-
|
1455
|
-
```ruby
|
1456
|
-
require 'ddtrace'
|
1457
|
-
|
1458
|
-
Datadog.configure do |c|
|
1459
|
-
c.tracing.instrument :que, options
|
1460
|
-
end
|
1461
|
-
```
|
1462
|
-
|
1463
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
1464
|
-
|
1465
|
-
| Key | Description | Default |
|
1466
|
-
| --- | ----------- | ------- |
|
1467
|
-
| `enabled` | Defines whether Que should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
|
1468
|
-
| `tag_args` | Enable tagging of a job's args field. `true` for on, `false` for off. | `false` |
|
1469
|
-
| `tag_data` | Enable tagging of a job's data field. `true` for on, `false` for off. | `false` |
|
1470
|
-
| `error_handler` | Custom error handler invoked when a job raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
|
1471
|
-
|
1472
|
-
### Racecar
|
1473
|
-
|
1474
|
-
The Racecar integration provides tracing for Racecar jobs.
|
1475
|
-
|
1476
|
-
You can enable it through `Datadog.configure`:
|
1477
|
-
|
1478
|
-
```ruby
|
1479
|
-
require 'ddtrace'
|
1480
|
-
|
1481
|
-
Datadog.configure do |c|
|
1482
|
-
c.tracing.instrument :racecar, options
|
1483
|
-
end
|
1484
|
-
```
|
1485
|
-
|
1486
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
1487
|
-
|
1488
|
-
| Key | Description | Default |
|
1489
|
-
| --- | ----------- | ------- |
|
1490
|
-
| `service_name` | Service name used for `racecar` instrumentation | `'racecar'` |
|
1491
|
-
|
1492
|
-
### Rack
|
1493
|
-
|
1494
|
-
The Rack integration provides a middleware that traces all requests before they reach the underlying framework or application. It responds to the Rack minimal interface, providing reasonable values that can be retrieved at the Rack level.
|
1495
|
-
|
1496
|
-
This integration is automatically activated with web frameworks like Rails. If you're using a plain Rack application, enable the integration it to your `config.ru`:
|
1497
|
-
|
1498
|
-
```ruby
|
1499
|
-
# config.ru example
|
1500
|
-
require 'ddtrace'
|
1501
|
-
|
1502
|
-
Datadog.configure do |c|
|
1503
|
-
c.tracing.instrument :rack, options
|
1504
|
-
end
|
1505
|
-
|
1506
|
-
use Datadog::Tracing::Contrib::Rack::TraceMiddleware
|
1507
|
-
|
1508
|
-
app = proc do |env|
|
1509
|
-
[ 200, {'Content-Type' => 'text/plain'}, ['OK'] ]
|
1510
|
-
end
|
1511
|
-
|
1512
|
-
run app
|
1513
|
-
```
|
1514
|
-
|
1515
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
1516
|
-
|
1517
|
-
| Key | Description | Default |
|
1518
|
-
| --- | ----------- | ------- |
|
1519
|
-
| `application` | Your Rack application. Required for `middleware_names`. | `nil` |
|
1520
|
-
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) so that this service trace is connected with a trace of another service if tracing headers are received | `true` |
|
1521
|
-
| `headers` | Hash of HTTP request or response headers to add as tags to the `rack.request`. Accepts `request` and `response` keys with Array values e.g. `['Last-Modified']`. Adds `http.request.headers.*` and `http.response.headers.*` tags respectively. | `{ response: ['Content-Type', 'X-Request-ID'] }` |
|
1522
|
-
| `middleware_names` | Enable this if you want to use the last executed middleware class as the resource name for the `rack` span. If enabled alongside the `rails` instrumention, `rails` takes precedence by setting the `rack` resource name to the active `rails` controller when applicable. Requires `application` option to use. | `false` |
|
1523
|
-
| `quantize` | Hash containing options for quantization. May include `:query` or `:fragment`. | `{}` |
|
1524
|
-
| `quantize.query` | Hash containing options for query portion of URL quantization. May include `:show` or `:exclude`. See options below. Option must be nested inside the `quantize` option. | `{}` |
|
1525
|
-
| `quantize.query.show` | Defines which values should always be shown. Shows no values by default. May be an Array of strings, or `:all` to show all values. Option must be nested inside the `query` option. | `nil` |
|
1526
|
-
| `quantize.query.exclude` | Defines which values should be removed entirely. Excludes nothing by default. May be an Array of strings, or `:all` to remove the query string entirely. Option must be nested inside the `query` option. | `nil` |
|
1527
|
-
| `quantize.fragment` | Defines behavior for URL fragments. Removes fragments by default. May be `:show` to show URL fragments. Option must be nested inside the `quantize` option. | `nil` |
|
1528
|
-
| `request_queuing` | Track HTTP request time spent in the queue of the frontend server. See [HTTP request queuing](#http-request-queuing) for setup details. Set to `true` to enable. | `false` |
|
1529
|
-
| `web_service_name` | Service name for frontend server request queuing spans. (e.g. `'nginx'`) | `'web-server'` |
|
1530
|
-
|
1531
|
-
**Configuring URL quantization behavior**
|
1532
|
-
|
1533
|
-
```ruby
|
1534
|
-
Datadog.configure do |c|
|
1535
|
-
# Default behavior: all values are quantized, fragment is removed.
|
1536
|
-
# http://example.com/path?category_id=1&sort_by=asc#featured --> http://example.com/path?category_id&sort_by
|
1537
|
-
# http://example.com/path?categories[]=1&categories[]=2 --> http://example.com/path?categories[]
|
1538
|
-
|
1539
|
-
# Show values for any query string parameter matching 'category_id' exactly
|
1540
|
-
# http://example.com/path?category_id=1&sort_by=asc#featured --> http://example.com/path?category_id=1&sort_by
|
1541
|
-
c.tracing.instrument :rack, quantize: { query: { show: ['category_id'] } }
|
1542
|
-
|
1543
|
-
# Show all values for all query string parameters
|
1544
|
-
# http://example.com/path?category_id=1&sort_by=asc#featured --> http://example.com/path?category_id=1&sort_by=asc
|
1545
|
-
c.tracing.instrument :rack, quantize: { query: { show: :all } }
|
1546
|
-
|
1547
|
-
# Totally exclude any query string parameter matching 'sort_by' exactly
|
1548
|
-
# http://example.com/path?category_id=1&sort_by=asc#featured --> http://example.com/path?category_id
|
1549
|
-
c.tracing.instrument :rack, quantize: { query: { exclude: ['sort_by'] } }
|
1550
|
-
|
1551
|
-
# Remove the query string entirely
|
1552
|
-
# http://example.com/path?category_id=1&sort_by=asc#featured --> http://example.com/path
|
1553
|
-
c.tracing.instrument :rack, quantize: { query: { exclude: :all } }
|
1554
|
-
|
1555
|
-
# Show URL fragments
|
1556
|
-
# http://example.com/path?category_id=1&sort_by=asc#featured --> http://example.com/path?category_id&sort_by#featured
|
1557
|
-
c.tracing.instrument :rack, quantize: { fragment: :show }
|
1558
|
-
end
|
1559
|
-
```
|
1560
|
-
|
1561
|
-
### Rails
|
1562
|
-
|
1563
|
-
The Rails integration will trace requests, database calls, templates rendering, and cache read/write/delete operations. The integration makes use of the Active Support Instrumentation, listening to the Notification API so that any operation instrumented by the API is traced.
|
1564
|
-
|
1565
|
-
To enable the Rails instrumentation, create an initializer file in your `config/initializers` folder:
|
1566
|
-
|
1567
|
-
```ruby
|
1568
|
-
# config/initializers/datadog.rb
|
1569
|
-
require 'ddtrace'
|
1570
|
-
|
1571
|
-
Datadog.configure do |c|
|
1572
|
-
c.tracing.instrument :rails, options
|
1573
|
-
end
|
1574
|
-
```
|
1575
|
-
|
1576
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
1577
|
-
|
1578
|
-
| Key | Description | Default |
|
1579
|
-
| --- | ----------- | ------- |
|
1580
|
-
| `cache_service` | Cache service name used when tracing cache activity | `'<app_name>-cache'` |
|
1581
|
-
| `database_service` | Database service name used when tracing database activity | `'<app_name>-<adapter_name>'` |
|
1582
|
-
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) so that this service trace is connected with a trace of another service if tracing headers are received | `true` |
|
1583
|
-
| `request_queuing` | Track HTTP request time spent in the queue of the frontend server. See [HTTP request queuing](#http-request-queuing) for setup details. Set to `true` to enable. | `false` |
|
1584
|
-
| `exception_controller` | Class or Module which identifies a custom exception controller class. Tracer provides improved error behavior when it can identify custom exception controllers. By default, without this option, it 'guesses' what a custom exception controller looks like. Providing this option aids this identification. | `nil` |
|
1585
|
-
| `middleware` | Add the trace middleware to the Rails application. Set to `false` if you don't want the middleware to load. | `true` |
|
1586
|
-
| `middleware_names` | Enables any short-circuited middleware requests to display the middleware name as a resource for the trace. | `false` |
|
1587
|
-
| `service_name` | Service name used when tracing application requests (on the `rack` level) | `'<app_name>'` (inferred from your Rails application namespace) |
|
1588
|
-
| `template_base_path` | Used when the template name is parsed. If you don't store your templates in the `views/` folder, you may need to change this value | `'views/'` |
|
1589
|
-
|
1590
|
-
**Supported versions**
|
1591
|
-
|
1592
|
-
| MRI Versions | JRuby Versions | Rails Versions |
|
1593
|
-
| ------------- | -------------- | -------------- |
|
1594
|
-
| 2.1 | | 3.2 - 4.2 |
|
1595
|
-
| 2.2 - 2.3 | | 3.2 - 5.2 |
|
1596
|
-
| 2.4 | | 4.2.8 - 5.2 |
|
1597
|
-
| 2.5 | | 4.2.8 - 6.1 |
|
1598
|
-
| 2.6 - 2.7 | 9.2 | 5.0 - 6.1 |
|
1599
|
-
| 3.0 | | 6.1 |
|
1600
|
-
|
1601
|
-
### Rake
|
1602
|
-
|
1603
|
-
You can add instrumentation around your Rake tasks by activating the `rake` integration. Each task and its subsequent subtasks will be traced.
|
1604
|
-
|
1605
|
-
To activate Rake task tracing, add the following to your `Rakefile`:
|
1606
|
-
|
1607
|
-
```ruby
|
1608
|
-
# At the top of your Rakefile:
|
1609
|
-
require 'rake'
|
1610
|
-
require 'ddtrace'
|
1611
|
-
|
1612
|
-
Datadog.configure do |c|
|
1613
|
-
c.tracing.instrument :rake, options
|
1614
|
-
end
|
1615
|
-
|
1616
|
-
task :my_task do
|
1617
|
-
# Do something task work here...
|
1618
|
-
end
|
1619
|
-
|
1620
|
-
Rake::Task['my_task'].invoke
|
1621
|
-
```
|
1622
|
-
|
1623
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
1624
|
-
|
1625
|
-
| Key | Description | Default |
|
1626
|
-
| --- | ----------- | ------- |
|
1627
|
-
| `enabled` | Defines whether Rake tasks should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
|
1628
|
-
| `quantize` | Hash containing options for quantization of task arguments. See below for more details and examples. | `{}` |
|
1629
|
-
| `service_name` | Service name used for `rake` instrumentation | `'rake'` |
|
1630
|
-
|
1631
|
-
**Configuring task quantization behavior**
|
1632
|
-
|
1633
|
-
```ruby
|
1634
|
-
Datadog.configure do |c|
|
1635
|
-
# Given a task that accepts :one, :two, :three...
|
1636
|
-
# Invoked with 'foo', 'bar', 'baz'.
|
1637
|
-
|
1638
|
-
# Default behavior: all arguments are quantized.
|
1639
|
-
# `rake.invoke.args` tag --> ['?']
|
1640
|
-
# `rake.execute.args` tag --> { one: '?', two: '?', three: '?' }
|
1641
|
-
c.tracing.instrument :rake
|
1642
|
-
|
1643
|
-
# Show values for any argument matching :two exactly
|
1644
|
-
# `rake.invoke.args` tag --> ['?']
|
1645
|
-
# `rake.execute.args` tag --> { one: '?', two: 'bar', three: '?' }
|
1646
|
-
c.tracing.instrument :rake, quantize: { args: { show: [:two] } }
|
1647
|
-
|
1648
|
-
# Show all values for all arguments.
|
1649
|
-
# `rake.invoke.args` tag --> ['foo', 'bar', 'baz']
|
1650
|
-
# `rake.execute.args` tag --> { one: 'foo', two: 'bar', three: 'baz' }
|
1651
|
-
c.tracing.instrument :rake, quantize: { args: { show: :all } }
|
1652
|
-
|
1653
|
-
# Totally exclude any argument matching :three exactly
|
1654
|
-
# `rake.invoke.args` tag --> ['?']
|
1655
|
-
# `rake.execute.args` tag --> { one: '?', two: '?' }
|
1656
|
-
c.tracing.instrument :rake, quantize: { args: { exclude: [:three] } }
|
1657
|
-
|
1658
|
-
# Remove the arguments entirely
|
1659
|
-
# `rake.invoke.args` tag --> ['?']
|
1660
|
-
# `rake.execute.args` tag --> {}
|
1661
|
-
c.tracing.instrument :rake, quantize: { args: { exclude: :all } }
|
1662
|
-
end
|
1663
|
-
```
|
1664
|
-
|
1665
|
-
### Redis
|
1666
|
-
|
1667
|
-
The Redis integration will trace simple calls as well as pipelines.
|
1668
|
-
|
1669
|
-
```ruby
|
1670
|
-
require 'redis'
|
1671
|
-
require 'ddtrace'
|
1672
|
-
|
1673
|
-
Datadog.configure do |c|
|
1674
|
-
c.tracing.instrument :redis, options
|
1675
|
-
end
|
1676
|
-
|
1677
|
-
# Perform Redis commands
|
1678
|
-
redis = Redis.new
|
1679
|
-
redis.set 'foo', 'bar'
|
1680
|
-
```
|
1681
|
-
|
1682
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
1683
|
-
|
1684
|
-
| Key | Description | Default |
|
1685
|
-
| --- | ----------- | ------- |
|
1686
|
-
| `service_name` | Service name used for `redis` instrumentation | `'redis'` |
|
1687
|
-
| `command_args` | Show the command arguments (e.g. `key` in `GET key`) as resource name and tag | true |
|
1688
|
-
|
1689
|
-
You can also set *per-instance* configuration as it follows:
|
1690
|
-
|
1691
|
-
```ruby
|
1692
|
-
require 'redis'
|
1693
|
-
require 'ddtrace'
|
1694
|
-
|
1695
|
-
Datadog.configure do |c|
|
1696
|
-
c.tracing.instrument :redis # Enabling integration instrumentation is still required
|
1697
|
-
end
|
1698
|
-
|
1699
|
-
customer_cache = Redis.new
|
1700
|
-
invoice_cache = Redis.new
|
1701
|
-
|
1702
|
-
Datadog.configure_onto(customer_cache, service_name: 'customer-cache')
|
1703
|
-
Datadog.configure_onto(invoice_cache, service_name: 'invoice-cache')
|
1704
|
-
|
1705
|
-
# Traced call will belong to `customer-cache` service
|
1706
|
-
customer_cache.get(...)
|
1707
|
-
# Traced call will belong to `invoice-cache` service
|
1708
|
-
invoice_cache.get(...)
|
1709
|
-
```
|
1710
|
-
|
1711
|
-
**Configuring trace settings per connection**
|
1712
|
-
|
1713
|
-
You can configure trace settings per connection by using the `describes` option:
|
1714
|
-
|
1715
|
-
```ruby
|
1716
|
-
# Provide a `:describes` option with a connection key.
|
1717
|
-
# Any of the following keys are acceptable and equivalent to one another.
|
1718
|
-
# If a block is provided, it yields a Settings object that
|
1719
|
-
# accepts any of the configuration options listed above.
|
1720
|
-
|
1721
|
-
Datadog.configure do |c|
|
1722
|
-
# The default configuration for any redis client
|
1723
|
-
c.tracing.instrument :redis, service_name: 'redis-default'
|
1724
|
-
|
1725
|
-
# The configuration matching a given unix socket.
|
1726
|
-
c.tracing.instrument :redis, describes: { url: 'unix://path/to/file' }, service_name: 'redis-unix'
|
1727
|
-
|
1728
|
-
# For network connections, only these fields are considered during matching:
|
1729
|
-
# scheme, host, port, db
|
1730
|
-
# Other fields are ignored.
|
1731
|
-
|
1732
|
-
# Network connection string
|
1733
|
-
c.tracing.instrument :redis, describes: 'redis://127.0.0.1:6379/0', service_name: 'redis-connection-string'
|
1734
|
-
c.tracing.instrument :redis, describes: { url: 'redis://127.0.0.1:6379/1' }, service_name: 'redis-connection-url'
|
1735
|
-
# Network client hash
|
1736
|
-
c.tracing.instrument :redis, describes: { host: 'my-host.com', port: 6379, db: 1, scheme: 'redis' }, service_name: 'redis-connection-hash'
|
1737
|
-
# Only a subset of the connection hash
|
1738
|
-
c.tracing.instrument :redis, describes: { host: ENV['APP_CACHE_HOST'], port: ENV['APP_CACHE_PORT'] }, service_name: 'redis-cache'
|
1739
|
-
c.tracing.instrument :redis, describes: { host: ENV['SIDEKIQ_CACHE_HOST'] }, service_name: 'redis-sidekiq'
|
1740
|
-
end
|
1741
|
-
```
|
1742
|
-
|
1743
|
-
When multiple `describes` configurations match a connection, the latest configured rule that matches will be applied.
|
1744
|
-
|
1745
|
-
### Resque
|
1746
|
-
|
1747
|
-
The Resque integration uses Resque hooks that wraps the `perform` method.
|
1748
|
-
|
1749
|
-
To add tracing to a Resque job:
|
1750
|
-
|
1751
|
-
```ruby
|
1752
|
-
require 'resque'
|
1753
|
-
require 'ddtrace'
|
1754
|
-
|
1755
|
-
Datadog.configure do |c|
|
1756
|
-
c.tracing.instrument :resque, **options
|
1757
|
-
end
|
1758
|
-
```
|
1759
|
-
|
1760
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
1761
|
-
|
1762
|
-
| Key | Description | Default |
|
1763
|
-
| --- | ----------- | ------- |
|
1764
|
-
| `error_handler` | Custom error handler invoked when a job raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
|
1765
|
-
|
1766
|
-
### Rest Client
|
1767
|
-
|
1768
|
-
The `rest-client` integration is available through the `ddtrace` middleware:
|
1769
|
-
|
1770
|
-
```ruby
|
1771
|
-
require 'rest_client'
|
1772
|
-
require 'ddtrace'
|
1773
|
-
|
1774
|
-
Datadog.configure do |c|
|
1775
|
-
c.tracing.instrument :rest_client, options
|
1776
|
-
end
|
1777
|
-
```
|
1778
|
-
|
1779
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
1780
|
-
|
1781
|
-
| Key | Description | Default |
|
1782
|
-
| --- | ----------- | ------- |
|
1783
|
-
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
|
1784
|
-
| `service_name` | Service name for `rest_client` instrumentation. | `'rest_client'` |
|
1785
|
-
| `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
|
1786
|
-
|
1787
|
-
### RSpec
|
1788
|
-
|
1789
|
-
RSpec integration will trace all executions of example groups and examples when using `rspec` test framework.
|
1790
|
-
|
1791
|
-
To activate your integration, use the `Datadog.configure` method:
|
1792
|
-
|
1793
|
-
```ruby
|
1794
|
-
require 'rspec'
|
1795
|
-
require 'ddtrace'
|
1796
|
-
|
1797
|
-
# Configure default RSpec integration
|
1798
|
-
Datadog.configure do |c|
|
1799
|
-
c.ci.instrument :rspec, options
|
1800
|
-
end
|
1801
|
-
```
|
1802
|
-
|
1803
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
1804
|
-
|
1805
|
-
| Key | Description | Default |
|
1806
|
-
| --- | ----------- | ------- |
|
1807
|
-
| `enabled` | Defines whether RSpec tests should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
|
1808
|
-
| `service_name` | Service name used for `rspec` instrumentation. | `'rspec'` |
|
1809
|
-
| `operation_name` | Operation name used for `rspec` instrumentation. Useful if you want rename automatic trace metrics e.g. `trace.#{operation_name}.errors`. | `'rspec.example'` |
|
1810
|
-
|
1811
|
-
### Sequel
|
1812
|
-
|
1813
|
-
The Sequel integration traces queries made to your database.
|
1814
|
-
|
1815
|
-
```ruby
|
1816
|
-
require 'sequel'
|
1817
|
-
require 'ddtrace'
|
1818
|
-
|
1819
|
-
# Connect to database
|
1820
|
-
database = Sequel.sqlite
|
1821
|
-
|
1822
|
-
# Create a table
|
1823
|
-
database.create_table :articles do
|
1824
|
-
primary_key :id
|
1825
|
-
String :name
|
1826
|
-
end
|
1827
|
-
|
1828
|
-
Datadog.configure do |c|
|
1829
|
-
c.tracing.instrument :sequel, options
|
1830
|
-
end
|
1831
|
-
|
1832
|
-
# Perform a query
|
1833
|
-
articles = database[:articles]
|
1834
|
-
articles.all
|
1835
|
-
```
|
1836
|
-
|
1837
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
1838
|
-
|
1839
|
-
| Key | Description | Default |
|
1840
|
-
| --- | ----------- | ------- |
|
1841
|
-
| `service_name` | Service name for `sequel` instrumentation | Name of database adapter (e.g. `'mysql2'`) |
|
1842
|
-
|
1843
|
-
**Configuring databases to use different settings**
|
1844
|
-
|
1845
|
-
If you use multiple databases with Sequel, you can give each of them different settings by configuring their respective `Sequel::Database` objects:
|
1846
|
-
|
1847
|
-
```ruby
|
1848
|
-
sqlite_database = Sequel.sqlite
|
1849
|
-
postgres_database = Sequel.connect('postgres://user:password@host:port/database_name')
|
1850
|
-
|
1851
|
-
# Configure each database with different service names
|
1852
|
-
Datadog.configure_onto(sqlite_database, service_name: 'my-sqlite-db')
|
1853
|
-
Datadog.configure_onto(postgres_database, service_name: 'my-postgres-db')
|
1854
|
-
```
|
1855
|
-
|
1856
|
-
### Shoryuken
|
1857
|
-
|
1858
|
-
The Shoryuken integration is a server-side middleware which will trace job executions.
|
1859
|
-
|
1860
|
-
You can enable it through `Datadog.configure`:
|
1861
|
-
|
1862
|
-
```ruby
|
1863
|
-
require 'ddtrace'
|
1864
|
-
|
1865
|
-
Datadog.configure do |c|
|
1866
|
-
c.tracing.instrument :shoryuken, options
|
1867
|
-
end
|
1868
|
-
```
|
1869
|
-
|
1870
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
1871
|
-
|
1872
|
-
| Key | Description | Default |
|
1873
|
-
| --- | ----------- | ------- |
|
1874
|
-
| `tag_body` | Tag spans with the SQS message body `true` or `false` | `false` |
|
1875
|
-
| `error_handler` | Custom error handler invoked when a job raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
|
1876
|
-
|
1877
|
-
### Sidekiq
|
1878
|
-
|
1879
|
-
The Sidekiq integration is a client-side & server-side middleware which will trace job queuing and executions respectively.
|
1880
|
-
|
1881
|
-
You can enable it through `Datadog.configure`:
|
1882
|
-
|
1883
|
-
```ruby
|
1884
|
-
require 'ddtrace'
|
1885
|
-
|
1886
|
-
Datadog.configure do |c|
|
1887
|
-
c.tracing.instrument :sidekiq, options
|
1888
|
-
end
|
1889
|
-
```
|
1890
|
-
|
1891
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
1892
|
-
|
1893
|
-
| Key | Description | Default |
|
1894
|
-
| --- | ----------- | ------- |
|
1895
|
-
| `tag_args` | Enable tagging of job arguments. `true` for on, `false` for off. | `false` |
|
1896
|
-
| `error_handler` | Custom error handler invoked when a job raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { \|span, error\| span.set_error(error) unless span.nil? }` |
|
1897
|
-
| `quantize` | Hash containing options for quantization of job arguments. | `{}` |
|
1898
|
-
|
1899
|
-
### Sinatra
|
1900
|
-
|
1901
|
-
The Sinatra integration traces requests and template rendering.
|
1902
|
-
|
1903
|
-
To start using the tracing client, make sure you import `ddtrace` and `use :sinatra` after either `sinatra` or `sinatra/base`, and before you define your application/routes:
|
1904
|
-
|
1905
|
-
#### Classic application
|
1906
|
-
|
1907
|
-
```ruby
|
1908
|
-
require 'sinatra'
|
1909
|
-
require 'ddtrace'
|
1910
|
-
|
1911
|
-
Datadog.configure do |c|
|
1912
|
-
c.tracing.instrument :sinatra, options
|
1913
|
-
end
|
1914
|
-
|
1915
|
-
get '/' do
|
1916
|
-
'Hello world!'
|
1917
|
-
end
|
1918
|
-
```
|
1919
|
-
|
1920
|
-
#### Modular application
|
1921
|
-
|
1922
|
-
```ruby
|
1923
|
-
require 'sinatra/base'
|
1924
|
-
require 'ddtrace'
|
1925
|
-
|
1926
|
-
Datadog.configure do |c|
|
1927
|
-
c.tracing.instrument :sinatra, options
|
1928
|
-
end
|
1929
|
-
|
1930
|
-
class NestedApp < Sinatra::Base
|
1931
|
-
register Datadog::Tracing::Contrib::Sinatra::Tracer
|
1932
|
-
|
1933
|
-
get '/nested' do
|
1934
|
-
'Hello from nested app!'
|
1935
|
-
end
|
1936
|
-
end
|
1937
|
-
|
1938
|
-
class App < Sinatra::Base
|
1939
|
-
register Datadog::Tracing::Contrib::Sinatra::Tracer
|
1940
|
-
|
1941
|
-
use NestedApp
|
1942
|
-
|
1943
|
-
get '/' do
|
1944
|
-
'Hello world!'
|
1945
|
-
end
|
1946
|
-
end
|
1947
|
-
```
|
1948
|
-
|
1949
|
-
Ensure you register `Datadog::Tracing::Contrib::Sinatra::Tracer` as a middleware before you mount your nested applications.
|
1950
|
-
|
1951
|
-
#### Instrumentation options
|
1952
|
-
|
1953
|
-
`options` is an optional `Hash` that accepts the following parameters:
|
1954
|
-
|
1955
|
-
| Key | Description | Default |
|
1956
|
-
| --- | ----------- | ------- |
|
1957
|
-
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) so that this service trace is connected with a trace of another service if tracing headers are received | `true` |
|
1958
|
-
| `headers` | Hash of HTTP request or response headers to add as tags to the `sinatra.request`. Accepts `request` and `response` keys with Array values e.g. `['Last-Modified']`. Adds `http.request.headers.*` and `http.response.headers.*` tags respectively. | `{ response: ['Content-Type', 'X-Request-ID'] }` |
|
1959
|
-
| `resource_script_names` | Prepend resource names with script name | `false` |
|
1960
|
-
|
1961
|
-
### Sneakers
|
1962
|
-
|
1963
|
-
The Sneakers integration is a server-side middleware which will trace job executions.
|
1964
|
-
|
1965
|
-
You can enable it through `Datadog.configure`:
|
1966
|
-
|
1967
|
-
```ruby
|
1968
|
-
require 'ddtrace'
|
1969
|
-
|
1970
|
-
Datadog.configure do |c|
|
1971
|
-
c.tracing.instrument :sneakers, options
|
1972
|
-
end
|
1973
|
-
```
|
1974
|
-
|
1975
|
-
Where `options` is an optional `Hash` that accepts the following parameters:
|
1976
|
-
|
1977
|
-
| Key | Description | Default |
|
1978
|
-
| --- | ----------- | ------- |
|
1979
|
-
| `enabled` | Defines whether Sneakers should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
|
1980
|
-
| `tag_body` | Enable tagging of job message. `true` for on, `false` for off. | `false` |
|
1981
|
-
| `error_handler` | Custom error handler invoked when a job raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
|
1982
|
-
|
1983
|
-
### Sucker Punch
|
1984
|
-
|
1985
|
-
The `sucker_punch` integration traces all scheduled jobs:
|
1986
|
-
|
1987
|
-
```ruby
|
1988
|
-
require 'ddtrace'
|
1989
|
-
|
1990
|
-
Datadog.configure do |c|
|
1991
|
-
c.tracing.instrument :sucker_punch
|
1992
|
-
end
|
1993
|
-
|
1994
|
-
# Execution of this job is traced
|
1995
|
-
LogJob.perform_async('login')
|
1996
|
-
```
|
1997
|
-
|
1998
|
-
## Additional configuration
|
1999
|
-
|
2000
|
-
To change the default behavior of Datadog tracing, you can set environment variables, or provide custom options inside a `Datadog.configure` block, e.g.:
|
2001
|
-
|
2002
|
-
```ruby
|
2003
|
-
Datadog.configure do |c|
|
2004
|
-
c.service = 'billing-api'
|
2005
|
-
c.env = ENV['RACK_ENV']
|
2006
|
-
|
2007
|
-
c.tracing.report_hostname = true
|
2008
|
-
c.tracing.test_mode.enabled = (ENV['RACK_ENV'] == 'test')
|
2009
|
-
end
|
2010
|
-
```
|
2011
|
-
|
2012
|
-
**Available configuration options:**
|
2013
|
-
|
2014
|
-
| Setting | Env Var | Default | Description |
|
2015
|
-
|---------------------------------------------------------|--------------------------------|-------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
2016
|
-
| **Global** | | | |
|
2017
|
-
| `agent.host` | `DD_AGENT_HOST` | `127.0.0.1` | Hostname of agent to where trace data will be sent. |
|
2018
|
-
| `agent.port` | `DD_TRACE_AGENT_PORT` | `8126` | Port of agent host to where trace data will be sent. |
|
2019
|
-
| | `DD_TRACE_AGENT_URL` | `nil` | Sets the URL endpoint where traces are sent. Has priority over `agent.host` and `agent.port`. |
|
2020
|
-
| `diagnostics.debug` | `DD_TRACE_DEBUG` | `false` | Enables or disables debug mode. Prints verbose logs. **NOT recommended for production or other sensitive environments.** See [Debugging and diagnostics](#debugging-and-diagnostics) for more details. |
|
2021
|
-
| `diagnostics.startup_logs.enabled` | `DD_TRACE_STARTUP_LOGS` | `nil` | Prints startup configuration and diagnostics to log. For assessing state of tracing at application startup. See [Debugging and diagnostics](#debugging-and-diagnostics) for more details. |
|
2022
|
-
| `env` | `DD_ENV` | `nil` | Your application environment. (e.g. `production`, `staging`, etc.) This value is set as a tag on all traces. |
|
2023
|
-
| `service` | `DD_SERVICE` | *Ruby filename* | Your application's default service name. (e.g. `billing-api`) This value is set as a tag on all traces. |
|
2024
|
-
| `tags` | `DD_TAGS` | `nil` | Custom tags in value pairs separated by `,` (e.g. `layer:api,team:intake`) These tags are set on all traces. See [Environment and tags](#environment-and-tags) for more details. |
|
2025
|
-
| `time_now_provider` | | `->{ Time.now }` | Changes how time is retrieved. See [Setting the time provider](#Setting the time provider) for more details. |
|
2026
|
-
| `version` | `DD_VERSION` | `nil` | Your application version (e.g. `2.5`, `202003181415`, `1.3-alpha`, etc.) This value is set as a tag on all traces. |
|
2027
|
-
| **Tracing** | | | |
|
2028
|
-
| `tracing.analytics.enabled` | `DD_TRACE_ANALYTICS_ENABLED` | `nil` | Enables or disables trace analytics. See [Sampling](#sampling) for more details. |
|
2029
|
-
| `tracing.distributed_tracing.propagation_extract_style` | `DD_PROPAGATION_STYLE_EXTRACT` | `['Datadog','B3','B3 single header']` | Distributed tracing header formats to extract. See [Distributed Tracing](#distributed-tracing) for more details. |
|
2030
|
-
| `tracing.distributed_tracing.propagation_inject_style` | `DD_PROPAGATION_STYLE_INJECT` | `['Datadog']` | Distributed tracing header formats to inject. See [Distributed Tracing](#distributed-tracing) for more details. |
|
2031
|
-
| `tracing.enabled` | `DD_TRACE_ENABLED` | `true` | Enables or disables tracing. If set to `false` instrumentation will still run, but no traces are sent to the trace agent. |
|
2032
|
-
| `tracing.instrument(<integration-name>, <options...>)` | | | Activates instrumentation for a specific library. See [Integration instrumentation](#integration-instrumentation) for more details. |
|
2033
|
-
| `tracing.log_injection` | `DD_LOGS_INJECTION` | `true` | Injects [Trace Correlation](#trace-correlation) information into Rails logs if present. Supports the default logger (`ActiveSupport::TaggedLogging`), `lograge`, and `semantic_logger`. |
|
2034
|
-
| `tracing.partial_flush.enabled` | | `false` | Enables or disables partial flushing. Partial flushing submits completed portions of a trace to the agent. Used when tracing instruments long running tasks (e.g. jobs) with many spans. |
|
2035
|
-
| `tracing.partial_flush.min_spans_threshold` | | `500` | The number of spans that must be completed in a trace before partial flushing submits those completed spans. |
|
2036
|
-
| `tracing.sampler` | | `nil` | Advanced usage only. Sets a custom `Datadog::Tracing::Sampling::Sampler` instance. If provided, the tracer will use this sampler to determine sampling behavior. See [Application-side sampling](#application-side-sampling) for details. |
|
2037
|
-
| `tracing.sampling.default_rate` | `DD_TRACE_SAMPLE_RATE` | `nil` | Sets the trace sampling rate between `0.0` (0%) and `1.0` (100%). See [Application-side sampling](#application-side-sampling) for details. |
|
2038
|
-
| `tracing.sampling.rate_limit` | `DD_TRACE_RATE_LIMIT` | `100` (per second) | Sets a maximum number of traces per second to sample. Set a rate limit to avoid the ingestion volume overages in the case of traffic spikes. |
|
2039
|
-
| `tracing.report_hostname` | `DD_TRACE_REPORT_HOSTNAME` | `false` | Adds hostname tag to traces. |
|
2040
|
-
| `tracing.test_mode.enabled` | `DD_TRACE_TEST_MODE_ENABLED` | `false` | Enables or disables test mode, for use of tracing in test suites. |
|
2041
|
-
| `tracing.test_mode.trace_flush` | | `nil` | Object that determines trace flushing behavior. |
|
2042
|
-
|
2043
|
-
#### Custom logging
|
2044
|
-
|
2045
|
-
By default, all logs are processed by the default Ruby logger. When using Rails, you should see the messages in your application log file.
|
2046
|
-
|
2047
|
-
Datadog client log messages are marked with `[ddtrace]` so you should be able to isolate them from other messages.
|
2048
|
-
|
2049
|
-
Additionally, it is possible to override the default logger and replace it by a custom one. This is done using the `log` setting.
|
2050
|
-
|
2051
|
-
```ruby
|
2052
|
-
f = File.new("my-custom.log", "w+") # Log messages should go there
|
2053
|
-
Datadog.configure do |c|
|
2054
|
-
c.logger.instance = Logger.new(f) # Overriding the default logger
|
2055
|
-
c.logger.level = ::Logger::INFO
|
2056
|
-
end
|
2057
|
-
|
2058
|
-
Datadog.logger.info { "this is typically called by tracing code" }
|
2059
|
-
```
|
2060
|
-
|
2061
|
-
#### Environment and tags
|
2062
|
-
|
2063
|
-
By default, the trace agent (not this library, but the program running in the background collecting data from various clients) uses the tags set in the agent config file. You can configure the application to automatically tag your traces and metrics, using the following environment variables:
|
2064
|
-
|
2065
|
-
- `DD_ENV`: Your application environment (e.g. `production`, `staging`, etc.)
|
2066
|
-
- `DD_SERVICE`: Your application's default service name (e.g. `billing-api`)
|
2067
|
-
- `DD_VERSION`: Your application version (e.g. `2.5`, `202003181415`, `1.3-alpha`, etc.)
|
2068
|
-
- `DD_TAGS`: Custom tags in value pairs separated by `,` (e.g. `layer:api,team:intake`)
|
2069
|
-
- If `DD_ENV`, `DD_SERVICE` or `DD_VERSION` are set, it will override any respective `env`/`service`/`version` tag defined in `DD_TAGS`.
|
2070
|
-
- If `DD_ENV`, `DD_SERVICE` or `DD_VERSION` are NOT set, tags defined in `DD_TAGS` will be used to populate `env`/`service`/`version` respectively.
|
2071
|
-
|
2072
|
-
These values can also be overridden at the tracer level:
|
2073
|
-
|
2074
|
-
```ruby
|
2075
|
-
Datadog.configure do |c|
|
2076
|
-
c.service = 'billing-api'
|
2077
|
-
c.env = 'test'
|
2078
|
-
c.tags = { 'team' => 'qa' }
|
2079
|
-
c.version = '1.3-alpha'
|
2080
|
-
end
|
2081
|
-
```
|
2082
|
-
|
2083
|
-
This enables you to set this value on a per application basis, so you can have for example several applications reporting for different environments on the same host.
|
2084
|
-
|
2085
|
-
Tags can also be set directly on individual spans, which will supersede any conflicting tags defined at the application level.
|
2086
|
-
|
2087
|
-
#### Debugging and diagnostics
|
2088
|
-
|
2089
|
-
There are two different suggested means of producing diagnostics for tracing:
|
2090
|
-
|
2091
|
-
##### Enabling debug mode
|
2092
|
-
|
2093
|
-
Switching the library into debug mode will produce verbose, detailed logs about tracing activity, including any suppressed errors. This output can be helpful in identifying errors, or confirming trace output to the agent.
|
2094
|
-
|
2095
|
-
You can enable this via `diagnostics.debug = true` or `DD_TRACE_DEBUG`.
|
2096
|
-
|
2097
|
-
```ruby
|
2098
|
-
Datadog.configure { |c| c.diagnostics.debug = true }
|
2099
|
-
```
|
2100
|
-
|
2101
|
-
**We do NOT recommend use of this feature in production or other sensitive environments**, as it can be very verbose under load. It's best to use this in a controlled environment where you can control application load.
|
2102
|
-
|
2103
|
-
##### Enabling startup logs
|
2104
|
-
|
2105
|
-
Startup logs produce a report of tracing state when the application is initially configured. This can be helpful for confirming that configuration and instrumentation is activated correctly.
|
2106
|
-
|
2107
|
-
You can enable this via `diagnostics.startup_logs.enabled = true` or `DD_TRACE_STARTUP_LOGS`.
|
2108
|
-
|
2109
|
-
```ruby
|
2110
|
-
Datadog.configure { |c| c.diagnostics.startup_logs.enabled = true }
|
2111
|
-
```
|
2112
|
-
|
2113
|
-
By default, this will be activated whenever `ddtrace` detects the application is running in a non-development environment.
|
2114
|
-
|
2115
|
-
### Sampling
|
2116
|
-
|
2117
|
-
#### Application-side sampling
|
2118
|
-
|
2119
|
-
While the trace agent can sample traces to reduce bandwidth usage, application-side sampling reduces the performance overhead.
|
2120
|
-
|
2121
|
-
The default sampling rate can be set between `0.0` (0%) and `1.0` (100%). Configure the rate in order to control the volume of traces sent to Datadog. When this configuration is not set, the Datadog agent will distribute a default sampling rate of 10 traces per second.
|
2122
|
-
|
2123
|
-
Set this value via `DD_TRACE_SAMPLE_RATE` or `Datadog.configure { |c| c.tracing.sampling.default_rate = <value> }`.
|
2124
|
-
|
2125
|
-
Alternatively, you may provide your own sampler. The `Datadog::Tracing::Sampling::RateSampler` samples a ratio of the traces. For example:
|
2126
|
-
|
2127
|
-
```ruby
|
2128
|
-
# Sample rate is between 0 (nothing sampled) to 1 (everything sampled).
|
2129
|
-
sampler = Datadog::Tracing::Sampling::RateSampler.new(0.5) # sample 50% of the traces
|
2130
|
-
|
2131
|
-
Datadog.configure do |c|
|
2132
|
-
c.tracing.sampler = sampler
|
2133
|
-
end
|
2134
|
-
```
|
2135
|
-
|
2136
|
-
See [Additional Configuration](#additional-configuration) for more details about these settings.
|
2137
|
-
|
2138
|
-
#### Priority sampling
|
2139
|
-
|
2140
|
-
Priority sampling decides whether to keep a trace by using a priority attribute propagated for distributed traces. Its value indicates to the Agent and the backend about how important the trace is.
|
2141
|
-
|
2142
|
-
The sampler can set the priority to the following values:
|
2143
|
-
|
2144
|
-
- `Datadog::Tracing::Sampling::Ext::Priority::AUTO_REJECT`: the sampler automatically decided to reject the trace.
|
2145
|
-
- `Datadog::Tracing::Sampling::Ext::Priority::AUTO_KEEP`: the sampler automatically decided to keep the trace.
|
2146
|
-
|
2147
|
-
Priority sampling is enabled by default. Enabling it ensures that your sampled distributed traces will be complete. Once enabled, the sampler will automatically assign a priority of 0 or 1 to traces, depending on their service and volume.
|
2148
|
-
|
2149
|
-
You can also set this priority manually to either drop a non-interesting trace or to keep an important one. For that, set the `TraceOperation#sampling_priority` to:
|
2150
|
-
|
2151
|
-
- `Datadog::Tracing::Sampling::Ext::Priority::USER_REJECT`: the user asked to reject the trace.
|
2152
|
-
- `Datadog::Tracing::Sampling::Ext::Priority::USER_KEEP`: the user asked to keep the trace.
|
2153
|
-
|
2154
|
-
When not using [distributed tracing](#distributed-tracing), you may change the priority at any time, as long as the trace incomplete. But it has to be done before any context propagation (fork, RPC calls) to be useful in a distributed context. Changing the priority after the context has been propagated causes different parts of a distributed trace to use different priorities. Some parts might be kept, some parts might be rejected, and this can cause the trace to be partially stored and remain incomplete.
|
2155
|
-
|
2156
|
-
For this reason, if you change the priority, we recommend you do it as early as possible.
|
2157
|
-
|
2158
|
-
To change the sampling priority, you can use the following methods:
|
2159
|
-
|
2160
|
-
```ruby
|
2161
|
-
# Rejects the active trace
|
2162
|
-
Datadog::Tracing.reject!
|
2163
|
-
|
2164
|
-
# Keeps the active trace
|
2165
|
-
Datadog::Tracing.keep!
|
2166
|
-
```
|
2167
|
-
|
2168
|
-
It's safe to use `Datadog::Tracing.reject!` and `Datadog::Tracing.keep!` when no trace is active.
|
2169
|
-
|
2170
|
-
You can also reject a specific trace instance:
|
2171
|
-
|
2172
|
-
```ruby
|
2173
|
-
# First, grab the active span
|
2174
|
-
trace = Datadog::Tracing.active_trace
|
2175
|
-
|
2176
|
-
# Rejects the trace
|
2177
|
-
trace.reject!
|
2178
|
-
|
2179
|
-
# Keeps the trace
|
2180
|
-
trace.keep!
|
2181
|
-
```
|
2182
|
-
|
2183
|
-
### Distributed Tracing
|
2184
|
-
|
2185
|
-
Distributed tracing allows traces to be propagated across multiple instrumented applications so that a request can be presented as a single trace, rather than a separate trace per service.
|
2186
|
-
|
2187
|
-
To trace requests across application boundaries, the following must be propagated between each application:
|
2188
|
-
|
2189
|
-
| Property | Type | Description |
|
2190
|
-
| --------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------- |
|
2191
|
-
| **Trace ID** | Integer | ID of the trace. This value should be the same across all requests that belong to the same trace. |
|
2192
|
-
| **Parent Span ID** | Integer | ID of the span in the service originating the request. This value will always be different for each request within a trace. |
|
2193
|
-
| **Sampling Priority** | Integer | Sampling priority level for the trace. This value should be the same across all requests that belong to the same trace. |
|
2194
|
-
|
2195
|
-
Such propagation can be visualized as:
|
2196
|
-
|
2197
|
-
```
|
2198
|
-
Service A:
|
2199
|
-
Trace ID: 100000000000000001
|
2200
|
-
Parent ID: 0
|
2201
|
-
Span ID: 100000000000000123
|
2202
|
-
Priority: 1
|
2203
|
-
|
2204
|
-
|
|
2205
|
-
| Service B Request:
|
2206
|
-
| Metadata:
|
2207
|
-
| Trace ID: 100000000000000001
|
2208
|
-
| Parent ID: 100000000000000123
|
2209
|
-
| Priority: 1
|
2210
|
-
|
|
2211
|
-
V
|
2212
|
-
|
2213
|
-
Service B:
|
2214
|
-
Trace ID: 100000000000000001
|
2215
|
-
Parent ID: 100000000000000123
|
2216
|
-
Span ID: 100000000000000456
|
2217
|
-
Priority: 1
|
2218
|
-
|
2219
|
-
|
|
2220
|
-
| Service C Request:
|
2221
|
-
| Metadata:
|
2222
|
-
| Trace ID: 100000000000000001
|
2223
|
-
| Parent ID: 100000000000000456
|
2224
|
-
| Priority: 1
|
2225
|
-
|
|
2226
|
-
V
|
2227
|
-
|
2228
|
-
Service C:
|
2229
|
-
Trace ID: 100000000000000001
|
2230
|
-
Parent ID: 100000000000000456
|
2231
|
-
Span ID: 100000000000000789
|
2232
|
-
Priority: 1
|
2233
|
-
```
|
2234
|
-
|
2235
|
-
**Via HTTP**
|
2236
|
-
|
2237
|
-
For HTTP requests between instrumented applications, this trace metadata is propagated by use of HTTP Request headers:
|
2238
|
-
|
2239
|
-
| Property | Type | HTTP Header name |
|
2240
|
-
| --------------------- | ------- | ----------------------------- |
|
2241
|
-
| **Trace ID** | Integer | `x-datadog-trace-id` |
|
2242
|
-
| **Parent Span ID** | Integer | `x-datadog-parent-id` |
|
2243
|
-
| **Sampling Priority** | Integer | `x-datadog-sampling-priority` |
|
2244
|
-
|
2245
|
-
Such that:
|
2246
|
-
|
2247
|
-
```
|
2248
|
-
Service A:
|
2249
|
-
Trace ID: 100000000000000001
|
2250
|
-
Parent ID: 0
|
2251
|
-
Span ID: 100000000000000123
|
2252
|
-
Priority: 1
|
2253
|
-
|
2254
|
-
|
|
2255
|
-
| Service B HTTP Request:
|
2256
|
-
| Headers:
|
2257
|
-
| x-datadog-trace-id: 100000000000000001
|
2258
|
-
| x-datadog-parent-id: 100000000000000123
|
2259
|
-
| x-datadog-sampling-priority: 1
|
2260
|
-
|
|
2261
|
-
V
|
2262
|
-
|
2263
|
-
Service B:
|
2264
|
-
Trace ID: 100000000000000001
|
2265
|
-
Parent ID: 100000000000000123
|
2266
|
-
Span ID: 100000000000000456
|
2267
|
-
Priority: 1
|
2268
|
-
|
2269
|
-
|
|
2270
|
-
| Service C HTTP Request:
|
2271
|
-
| Headers:
|
2272
|
-
| x-datadog-trace-id: 100000000000000001
|
2273
|
-
| x-datadog-parent-id: 100000000000000456
|
2274
|
-
| x-datadog-sampling-priority: 1
|
2275
|
-
|
|
2276
|
-
V
|
2277
|
-
|
2278
|
-
Service C:
|
2279
|
-
Trace ID: 100000000000000001
|
2280
|
-
Parent ID: 100000000000000456
|
2281
|
-
Span ID: 100000000000000789
|
2282
|
-
Priority: 1
|
2283
|
-
```
|
2284
|
-
|
2285
|
-
**Distributed header formats**
|
2286
|
-
|
2287
|
-
Tracing supports the following distributed trace formats:
|
2288
|
-
|
2289
|
-
- `Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_DATADOG` (Default)
|
2290
|
-
- `Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3`
|
2291
|
-
- `Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3_SINGLE_HEADER`
|
2292
|
-
|
2293
|
-
You can enable/disable the use of these formats via `Datadog.configure`:
|
2294
|
-
|
2295
|
-
```ruby
|
2296
|
-
Datadog.configure do |c|
|
2297
|
-
# List of header formats that should be extracted
|
2298
|
-
c.tracing.distributed_tracing.propagation_extract_style = [
|
2299
|
-
Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_DATADOG,
|
2300
|
-
Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3,
|
2301
|
-
Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3_SINGLE_HEADER
|
2302
|
-
|
2303
|
-
]
|
2304
|
-
|
2305
|
-
# List of header formats that should be injected
|
2306
|
-
c.tracing.distributed_tracing.propagation_inject_style = [
|
2307
|
-
Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_DATADOG
|
2308
|
-
]
|
2309
|
-
end
|
2310
|
-
```
|
2311
|
-
|
2312
|
-
**Activating distributed tracing for integrations**
|
2313
|
-
|
2314
|
-
Many integrations included in `ddtrace` support distributed tracing. Distributed tracing is enabled by default in Agent v7 and most versions of Agent v6. If needed, you can activate distributed tracing with configuration settings.
|
2315
|
-
|
2316
|
-
- If your application receives requests from services with distributed tracing activated, you must activate distributed tracing on the integrations that handle these requests (e.g. Rails)
|
2317
|
-
- If your application send requests to services with distributed tracing activated, you must activate distributed tracing on the integrations that send these requests (e.g. Faraday)
|
2318
|
-
- If your application both sends and receives requests implementing distributed tracing, it must activate all integrations that handle these requests.
|
2319
|
-
|
2320
|
-
For more details on how to activate distributed tracing for integrations, see their documentation:
|
2321
|
-
|
2322
|
-
- [Excon](#excon)
|
2323
|
-
- [Faraday](#faraday)
|
2324
|
-
- [Rest Client](#rest-client)
|
2325
|
-
- [Net/HTTP](#nethttp)
|
2326
|
-
- [Rack](#rack)
|
2327
|
-
- [Rails](#rails)
|
2328
|
-
- [Sinatra](#sinatra)
|
2329
|
-
- [http.rb](#httprb)
|
2330
|
-
- [httpclient](#httpclient)
|
2331
|
-
- [httpx](#httpx)
|
2332
|
-
|
2333
|
-
**Using the HTTP propagator**
|
2334
|
-
|
2335
|
-
To make the process of propagating this metadata easier, you can use the `Datadog::Tracing::Propagation::HTTP` module.
|
2336
|
-
|
2337
|
-
On the client:
|
2338
|
-
|
2339
|
-
```ruby
|
2340
|
-
Datadog::Tracing.trace('web.call') do |span, trace|
|
2341
|
-
# Inject trace headers into request headers (`env` must be a Hash)
|
2342
|
-
Datadog::Tracing::Propagation::HTTP.inject!(trace.to_digest, env)
|
2343
|
-
end
|
2344
|
-
```
|
2345
|
-
|
2346
|
-
On the server:
|
2347
|
-
|
2348
|
-
```ruby
|
2349
|
-
trace_digest = Datadog::Tracing::Propagation::HTTP.extract(request.env)
|
2350
|
-
|
2351
|
-
Datadog::Tracing.trace('web.work', continue_from: trace_digest) do |span|
|
2352
|
-
# Do web work...
|
2353
|
-
end
|
2354
|
-
```
|
2355
|
-
|
2356
|
-
### HTTP request queuing
|
2357
|
-
|
2358
|
-
Traces that originate from HTTP requests can be configured to include the time spent in a frontend web server or load balancer queue before the request reaches the Ruby application.
|
2359
|
-
|
2360
|
-
This feature is disabled by default. To activate it, you must add an `X-Request-Start` or `X-Queue-Start` header from your web server (i.e., Nginx). The following is an Nginx configuration example:
|
2361
|
-
|
2362
|
-
```
|
2363
|
-
# /etc/nginx/conf.d/ruby_service.conf
|
2364
|
-
server {
|
2365
|
-
listen 8080;
|
2366
|
-
|
2367
|
-
location / {
|
2368
|
-
proxy_set_header X-Request-Start "t=${msec}";
|
2369
|
-
proxy_pass http://web:3000;
|
2370
|
-
}
|
2371
|
-
}
|
2372
|
-
```
|
2373
|
-
|
2374
|
-
Then you must enable the request queuing feature, by setting `request_queuing: true`, in the integration handling the request. For Rack-based applications, see the [documentation](#rack) for details.
|
2375
|
-
|
2376
|
-
### Processing Pipeline
|
2377
|
-
|
2378
|
-
Some applications might require that traces be altered or filtered out before they are sent to Datadog. The processing pipeline allows you to create *processors* to define such behavior.
|
2379
|
-
|
2380
|
-
#### Filtering
|
2381
|
-
|
2382
|
-
You can use the `Datadog::Tracing::Pipeline::SpanFilter` processor to remove spans, when the block evaluates as truthy:
|
2383
|
-
|
2384
|
-
```ruby
|
2385
|
-
Datadog::Tracing.before_flush(
|
2386
|
-
# Remove spans that match a particular resource
|
2387
|
-
Datadog::Tracing::Pipeline::SpanFilter.new { |span| span.resource =~ /PingController/ },
|
2388
|
-
# Remove spans that are trafficked to localhost
|
2389
|
-
Datadog::Tracing::Pipeline::SpanFilter.new { |span| span.get_tag('host') == 'localhost' }
|
2390
|
-
)
|
2391
|
-
```
|
2392
|
-
|
2393
|
-
#### Processing
|
2394
|
-
|
2395
|
-
You can use the `Datadog::Tracing::Pipeline::SpanProcessor` processor to modify spans:
|
2396
|
-
|
2397
|
-
```ruby
|
2398
|
-
Datadog::Tracing.before_flush(
|
2399
|
-
# Strip matching text from the resource field
|
2400
|
-
Datadog::Tracing::Pipeline::SpanProcessor.new { |span| span.resource.gsub!(/password=.*/, '') }
|
2401
|
-
)
|
2402
|
-
```
|
2403
|
-
|
2404
|
-
#### Custom processor
|
2405
|
-
|
2406
|
-
Processors can be any object that responds to `#call` accepting `trace` as an argument (which is an `Array` of `Datadog::Span`s.)
|
2407
|
-
|
2408
|
-
For example, using the short-hand block syntax:
|
2409
|
-
|
2410
|
-
```ruby
|
2411
|
-
Datadog::Tracing.before_flush do |trace|
|
2412
|
-
# Processing logic...
|
2413
|
-
trace
|
2414
|
-
end
|
2415
|
-
```
|
2416
|
-
|
2417
|
-
For a custom processor class:
|
2418
|
-
|
2419
|
-
```ruby
|
2420
|
-
class MyCustomProcessor
|
2421
|
-
def call(trace)
|
2422
|
-
# Processing logic...
|
2423
|
-
trace
|
2424
|
-
end
|
2425
|
-
end
|
2426
|
-
|
2427
|
-
Datadog::Tracing.before_flush(MyCustomProcessor.new)
|
2428
|
-
```
|
2429
|
-
|
2430
|
-
In both cases, the processor method *must* return the `trace` object; this return value will be passed to the next processor in the pipeline.
|
2431
|
-
|
2432
|
-
### Trace correlation
|
2433
|
-
|
2434
|
-
In many cases, such as logging, it may be useful to correlate trace IDs to other events or data streams, for easier cross-referencing.
|
2435
|
-
|
2436
|
-
#### For logging in Rails applications
|
2437
|
-
|
2438
|
-
##### Automatic
|
2439
|
-
|
2440
|
-
For Rails applications using the default logger (`ActiveSupport::TaggedLogging`), `lograge` or `semantic_logger`, trace correlation injection is enabled by default.
|
2441
|
-
|
2442
|
-
It can be disabled by setting the environment variable `DD_LOGS_INJECTION=false`.
|
2443
|
-
|
2444
|
-
#### For logging in Ruby applications
|
2445
|
-
|
2446
|
-
To add correlation IDs to your logger, add a log formatter which retrieves the correlation IDs with `Datadog::Tracing.correlation`, then add them to the message.
|
2447
|
-
|
2448
|
-
To properly correlate with Datadog logging, be sure the following is present in the log message, in order as they appear:
|
2449
|
-
|
2450
|
-
- `dd.env=<ENV>`: Where `<ENV>` is equal to `Datadog::Tracing.correlation.env`. Omit if no environment is configured.
|
2451
|
-
- `dd.service=<SERVICE>`: Where `<SERVICE>` is equal to `Datadog::Tracing.correlation.service`. Omit if no default service name is configured.
|
2452
|
-
- `dd.version=<VERSION>`: Where `<VERSION>` is equal to `Datadog::Tracing.correlation.version`. Omit if no application version is configured.
|
2453
|
-
- `dd.trace_id=<TRACE_ID>`: Where `<TRACE_ID>` is equal to `Datadog::Tracing.correlation.trace_id` or `0` if no trace is active during logging.
|
2454
|
-
- `dd.span_id=<SPAN_ID>`: Where `<SPAN_ID>` is equal to `Datadog::Tracing.correlation.span_id` or `0` if no trace is active during logging.
|
2455
|
-
|
2456
|
-
`Datadog::Tracing.log_correlation` will return `dd.env=<ENV> dd.service=<SERVICE> dd.version=<VERSION> dd.trace_id=<TRACE_ID> dd.span_id=<SPAN_ID>`.
|
2457
|
-
|
2458
|
-
If a trace is not active and the application environment & version is not configured, it will return `dd.env= dd.service= dd.version= dd.trace_id=0 dd.span_id=0`.
|
2459
|
-
|
2460
|
-
An example of this in practice:
|
2461
|
-
|
2462
|
-
```ruby
|
2463
|
-
require 'ddtrace'
|
2464
|
-
require 'logger'
|
2465
|
-
|
2466
|
-
ENV['DD_ENV'] = 'production'
|
2467
|
-
ENV['DD_SERVICE'] = 'billing-api'
|
2468
|
-
ENV['DD_VERSION'] = '2.5.17'
|
2469
|
-
|
2470
|
-
logger = Logger.new(STDOUT)
|
2471
|
-
logger.progname = 'my_app'
|
2472
|
-
logger.formatter = proc do |severity, datetime, progname, msg|
|
2473
|
-
"[#{datetime}][#{progname}][#{severity}][#{Datadog::Tracing.log_correlation}] #{msg}\n"
|
2474
|
-
end
|
2475
|
-
|
2476
|
-
# When no trace is active
|
2477
|
-
logger.warn('This is an untraced operation.')
|
2478
|
-
# [2019-01-16 18:38:41 +0000][my_app][WARN][dd.env=production dd.service=billing-api dd.version=2.5.17 dd.trace_id=0 dd.span_id=0] This is an untraced operation.
|
2479
|
-
|
2480
|
-
# When a trace is active
|
2481
|
-
Datadog::Tracing.trace('my.operation') { logger.warn('This is a traced operation.') }
|
2482
|
-
# [2019-01-16 18:38:41 +0000][my_app][WARN][dd.env=production dd.service=billing-api dd.version=2.5.17 dd.trace_id=8545847825299552251 dd.span_id=3711755234730770098] This is a traced operation.
|
2483
|
-
```
|
2484
|
-
|
2485
|
-
### Configuring the transport layer
|
2486
|
-
|
2487
|
-
By default, `ddtrace` will connect to the agent using the first available settings in the listed priority:
|
2488
|
-
|
2489
|
-
1. Via any explicitly provided configuration settings (hostname/port/transport)
|
2490
|
-
2. Via Unix Domain Socket (UDS) located at `/var/run/datadog/apm.socket`
|
2491
|
-
3. Via HTTP over TCP to `127.0.0.1:8126`
|
2492
|
-
|
2493
|
-
However, the tracer can be configured to send its trace data to alternative destinations, or by alternative protocols.
|
2494
|
-
|
2495
|
-
#### Changing default agent hostname and port
|
2496
|
-
|
2497
|
-
To change the agent host or port, provide `DD_AGENT_HOST` and `DD_TRACE_AGENT_PORT`.
|
2498
|
-
|
2499
|
-
OR within a `Datadog.configure` block, provide the following settings:
|
2500
|
-
|
2501
|
-
```ruby
|
2502
|
-
Datadog.configure do |c|
|
2503
|
-
c.agent.host = '127.0.0.1'
|
2504
|
-
c.agent.port = 8126
|
2505
|
-
end
|
2506
|
-
```
|
2507
|
-
|
2508
|
-
See [Additional Configuration](#additional-configuration) for more details.
|
2509
|
-
|
2510
|
-
#### Using the Net::HTTP adapter
|
2511
|
-
|
2512
|
-
The `Net` adapter submits traces using `Net::HTTP` over TCP. It is the default transport adapter.
|
2513
|
-
|
2514
|
-
```ruby
|
2515
|
-
Datadog.configure do |c|
|
2516
|
-
c.tracing.transport_options = proc { |t|
|
2517
|
-
# Hostname, port, and additional options. :timeout is in seconds.
|
2518
|
-
t.adapter :net_http, '127.0.0.1', 8126, { timeout: 1 }
|
2519
|
-
}
|
2520
|
-
end
|
2521
|
-
```
|
2522
|
-
|
2523
|
-
#### Using the Unix Domain Socket (UDS) adapter
|
2524
|
-
|
2525
|
-
The `UnixSocket` adapter submits traces using `Net::HTTP` over Unix socket.
|
2526
|
-
|
2527
|
-
To use, first configure your trace agent to listen by Unix socket, then configure the tracer with:
|
2528
|
-
|
2529
|
-
```ruby
|
2530
|
-
Datadog.configure do |c|
|
2531
|
-
c.tracing.transport_options = proc { |t|
|
2532
|
-
# Provide local path to trace agent Unix socket
|
2533
|
-
t.adapter :unix, '/tmp/ddagent/trace.sock'
|
2534
|
-
}
|
2535
|
-
end
|
2536
|
-
```
|
2537
|
-
|
2538
|
-
#### Using the transport test adapter
|
2539
|
-
|
2540
|
-
The `Test` adapter is a no-op transport that can optionally buffer requests. For use in test suites or other non-production environments.
|
2541
|
-
|
2542
|
-
```ruby
|
2543
|
-
Datadog.configure do |c|
|
2544
|
-
c.tracing.transport_options = proc { |t|
|
2545
|
-
# Set transport to no-op mode. Does not retain traces.
|
2546
|
-
t.adapter :test
|
2547
|
-
|
2548
|
-
# Alternatively, you can provide a buffer to examine trace output.
|
2549
|
-
# The buffer must respond to '<<'.
|
2550
|
-
t.adapter :test, []
|
2551
|
-
}
|
2552
|
-
end
|
2553
|
-
```
|
2554
|
-
|
2555
|
-
#### Using a custom transport adapter
|
2556
|
-
|
2557
|
-
Custom adapters can be configured with:
|
2558
|
-
|
2559
|
-
```ruby
|
2560
|
-
Datadog.configure do |c|
|
2561
|
-
c.tracing.transport_options = proc { |t|
|
2562
|
-
# Initialize and pass an instance of the adapter
|
2563
|
-
custom_adapter = CustomAdapter.new
|
2564
|
-
t.adapter custom_adapter
|
2565
|
-
}
|
2566
|
-
end
|
2567
|
-
```
|
2568
|
-
|
2569
|
-
### Setting the time provider
|
2570
|
-
|
2571
|
-
By default, tracing uses a monotonic clock to measure the duration of spans, and timestamps (`->{ Time.now }`) for the start and end time.
|
2572
|
-
|
2573
|
-
When testing, it might be helpful to use a different time provider.
|
2574
|
-
|
2575
|
-
To change the function that provides timestamps, configure the following:
|
2576
|
-
|
2577
|
-
```ruby
|
2578
|
-
Datadog.configure do |c|
|
2579
|
-
# For Timecop, for example, `->{ Time.now_without_mock_time }` allows the tracer to use the real wall time.
|
2580
|
-
c.time_now_provider = -> { Time.now_without_mock_time }
|
2581
|
-
end
|
2582
|
-
```
|
2583
|
-
|
2584
|
-
Span duration calculation will still use the system monotonic clock when available, thus not being affected by this setting.
|
2585
|
-
|
2586
|
-
### Metrics
|
2587
|
-
|
2588
|
-
The tracer and its integrations can produce some additional metrics that can provide useful insight into the performance of your application. These metrics are collected with `dogstatsd-ruby`, and can be sent to the same Datadog agent to which you send your traces.
|
2589
|
-
|
2590
|
-
To configure your application for metrics collection:
|
2591
|
-
|
2592
|
-
1. [Configure your Datadog agent for StatsD](https://docs.datadoghq.com/developers/dogstatsd/#setup)
|
2593
|
-
2. Add `gem 'dogstatsd-ruby', '~> 5.3'` to your Gemfile
|
2594
|
-
|
2595
|
-
#### For application runtime
|
2596
|
-
|
2597
|
-
If runtime metrics are configured, the trace library will automatically collect and send metrics about the health of your application.
|
2598
|
-
|
2599
|
-
To configure runtime metrics, add the following configuration:
|
2600
|
-
|
2601
|
-
```ruby
|
2602
|
-
# config/initializers/datadog.rb
|
2603
|
-
require 'datadog/statsd'
|
2604
|
-
require 'ddtrace'
|
2605
|
-
|
2606
|
-
Datadog.configure do |c|
|
2607
|
-
# To enable runtime metrics collection, set `true`. Defaults to `false`
|
2608
|
-
# You can also set DD_RUNTIME_METRICS_ENABLED=true to configure this.
|
2609
|
-
c.runtime_metrics.enabled = true
|
2610
|
-
|
2611
|
-
# Optionally, you can configure the Statsd instance used for sending runtime metrics.
|
2612
|
-
# Statsd is automatically configured with default settings if `dogstatsd-ruby` is available.
|
2613
|
-
# You can configure with host and port of Datadog agent; defaults to 'localhost:8125'.
|
2614
|
-
c.runtime_metrics.statsd = Datadog::Statsd.new
|
2615
|
-
end
|
2616
|
-
```
|
2617
|
-
|
2618
|
-
See the [Dogstatsd documentation](https://www.rubydoc.info/github/DataDog/dogstatsd-ruby/master/frames) for more details about configuring `Datadog::Statsd`.
|
2619
|
-
|
2620
|
-
The stats are VM specific and will include:
|
2621
|
-
|
2622
|
-
| Name | Type | Description | Available on |
|
2623
|
-
| -------------------------- | ------- | -------------------------------------------------------- | ------------ |
|
2624
|
-
| `runtime.ruby.class_count` | `gauge` | Number of classes in memory space. | CRuby |
|
2625
|
-
| `runtime.ruby.gc.*` | `gauge` | Garbage collection statistics: collected from `GC.stat`. | All runtimes |
|
2626
|
-
| `runtime.ruby.thread_count` | `gauge` | Number of threads. | All runtimes |
|
2627
|
-
| `runtime.ruby.global_constant_state` | `gauge` | Global constant cache generation. | CRuby |
|
2628
|
-
| `runtime.ruby.global_method_state` | `gauge` | [Global method cache generation.](https://tenderlovemaking.com/2015/12/23/inline-caching-in-mri.html) | [CRuby < 3.0.0](https://docs.ruby-lang.org/en/3.0.0/NEWS_md.html#label-Implementation+improvements) |
|
2629
|
-
|
2630
|
-
In addition, all metrics include the following tags:
|
2631
|
-
|
2632
|
-
| Name | Description |
|
2633
|
-
| ------------ | ------------------------------------------------------- |
|
2634
|
-
| `language` | Programming language traced. (e.g. `ruby`) |
|
2635
|
-
| `service` | List of services this associated with this metric. |
|
2636
|
-
|
2637
|
-
### OpenTracing
|
2638
|
-
|
2639
|
-
For setting up Datadog with OpenTracing, see our [Configuring OpenTracing](#configuring-opentracing) section for details.
|
2640
|
-
|
2641
|
-
**Configuring Datadog tracer settings**
|
2642
|
-
|
2643
|
-
The underlying Datadog tracer can be configured by passing options (which match `Datadog::Tracer`) when configuring the global tracer:
|
2644
|
-
|
2645
|
-
```ruby
|
2646
|
-
# Where `options` is a Hash of options provided to Datadog::Tracer
|
2647
|
-
OpenTracing.global_tracer = Datadog::OpenTracer::Tracer.new(**options)
|
2648
|
-
```
|
2649
|
-
|
2650
|
-
It can also be configured by using `Datadog.configure` described in the [Additional Configuration](#additional-configuration) section.
|
2651
|
-
|
2652
|
-
**Activating and configuring integrations**
|
2653
|
-
|
2654
|
-
By default, configuring OpenTracing with Datadog will not automatically activate any additional instrumentation provided by Datadog. You will only receive spans and traces from OpenTracing instrumentation you have in your application.
|
2655
|
-
|
2656
|
-
However, additional instrumentation provided by Datadog can be activated alongside OpenTracing using `Datadog.configure`, which can be used to enhance your tracing further. To activate this, see [Integration instrumentation](#integration-instrumentation) for more details.
|
2657
|
-
|
2658
|
-
**Supported serialization formats**
|
2659
|
-
|
2660
|
-
| Type | Supported? | Additional information |
|
2661
|
-
| ------------------------------ | ---------- | ---------------------- |
|
2662
|
-
| `OpenTracing::FORMAT_TEXT_MAP` | Yes | |
|
2663
|
-
| `OpenTracing::FORMAT_RACK` | Yes | Because of the loss of resolution in the Rack format, please note that baggage items with names containing either upper case characters or `-` will be converted to lower case and `_` in a round-trip respectively. We recommend avoiding these characters or accommodating accordingly on the receiving end. |
|
2664
|
-
| `OpenTracing::FORMAT_BINARY` | No | |
|
2665
|
-
|
2666
|
-
### Profiling
|
2667
|
-
|
2668
|
-
`ddtrace` can produce profiles that measure method-level application resource usage within production environments. These profiles can give insight into resources spent in Ruby code outside of existing trace instrumentation.
|
2669
|
-
|
2670
|
-
**Setup**
|
2671
|
-
|
2672
|
-
To get started with profiling, follow the [Enabling the Ruby Profiler](https://docs.datadoghq.com/tracing/profiler/enabling/ruby/) guide.
|
2673
|
-
|
2674
|
-
#### Troubleshooting
|
2675
|
-
|
2676
|
-
If you run into issues with profiling, please check the [Profiler Troubleshooting Guide](https://docs.datadoghq.com/tracing/profiler/profiler_troubleshooting/?code-lang=ruby).
|
2677
|
-
|
2678
|
-
#### Profiling Resque jobs
|
2679
|
-
|
2680
|
-
When profiling [Resque](https://github.com/resque/resque) jobs, you should set the `RUN_AT_EXIT_HOOKS=1` option described in the [Resque](https://github.com/resque/resque/blob/v2.0.0/docs/HOOKS.md#worker-hooks) documentation.
|
2681
|
-
|
2682
|
-
Without this flag, profiles for short-lived Resque jobs will not be available as Resque kills worker processes before they have a chance to submit this information.
|
2683
|
-
|
2684
|
-
## Known issues and suggested configurations
|
2685
|
-
|
2686
|
-
### Payload too large
|
2687
|
-
|
2688
|
-
By default, Datadog limits the size of trace payloads to prevent memory overhead within instrumented applications. As a result, traces containing thousands of operations may not be sent to Datadog.
|
2689
|
-
|
2690
|
-
If traces are missing, enable [debug mode](#debugging-and-diagnostics) to check if messages containing `"Dropping trace. Payload too large"` are logged.
|
2691
|
-
|
2692
|
-
Since debug mode is verbose, **Datadog does not recommend leaving this enabled or enabling this in production.** Disable it after confirming. You can inspect the [Datadog Agent logs](https://docs.datadoghq.com/agent/guide/agent-log-files/) for similar messages.
|
2693
|
-
|
2694
|
-
If you have confirmed that traces are dropped due to large payloads, then enable the [partial_flush](#additional-configuration) setting to break down large traces into smaller chunks.
|
2695
|
-
|
2696
|
-
### Stack level too deep
|
2697
|
-
|
2698
|
-
Datadog tracing collects trace data by adding instrumentation into other common libraries (e.g. Rails, Rack, etc.) Some libraries provide APIs to add this instrumentation, but some do not. In order to add instrumentation into libraries lacking an instrumentation API, Datadog uses a technique called "monkey-patching" to modify the code of that library.
|
2699
|
-
|
2700
|
-
In Ruby version 1.9.3 and earlier, "monkey-patching" often involved the use of [`alias_method`](https://ruby-doc.org/core-3.0.0/Module.html#method-i-alias_method), also known as *method rewriting*, to destructively replace existing Ruby methods. However, this practice would often create conflicts & errors if two libraries attempted to "rewrite" the same method. (e.g. two different APM packages trying to instrument the same method.)
|
2701
|
-
|
2702
|
-
In Ruby 2.0, the [`Module#prepend`](https://ruby-doc.org/core-3.0.0/Module.html#method-i-prepend) feature was introduced. This feature avoids destructive method rewriting and allows multiple "monkey patches" on the same method. Consequently, it has become the safest, preferred means to "monkey patch" code.
|
2703
|
-
|
2704
|
-
Datadog instrumentation almost exclusively uses the `Module#prepend` feature to add instrumentation non-destructively. However, some other libraries (typically those supporting Ruby < 2.0) still use `alias_method` which can create conflicts with Datadog instrumentation, often resulting in `SystemStackError` or `stack level too deep` errors.
|
2705
|
-
|
2706
|
-
As the implementation of `alias_method` exists within those libraries, Datadog generally cannot fix them. However, some libraries have known workarounds:
|
2707
|
-
|
2708
|
-
* `rack-mini-profiler`: [Net::HTTP stack level too deep errors](https://github.com/MiniProfiler/rack-mini-profiler#nethttp-stack-level-too-deep-errors).
|
2709
|
-
|
2710
|
-
For libraries without a known workaround, consider removing the library using `alias` or `Module#alias_method` or separating libraries into different environments for testing.
|
2711
|
-
|
2712
|
-
For any further questions or to report an occurence of this issue, please [reach out to Datadog support](https://docs.datadoghq.com/help)
|