ddtrace 0.44.0 → 0.48.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +183 -15
- data/.circleci/images/primary/Dockerfile-2.0.0 +11 -1
- data/.circleci/images/primary/Dockerfile-2.1.10 +11 -1
- data/.circleci/images/primary/Dockerfile-2.2.10 +11 -1
- data/.circleci/images/primary/Dockerfile-2.3.8 +10 -0
- data/.circleci/images/primary/Dockerfile-2.4.6 +10 -0
- data/.circleci/images/primary/Dockerfile-2.5.6 +10 -0
- data/.circleci/images/primary/Dockerfile-2.6.4 +10 -0
- data/.circleci/images/primary/Dockerfile-2.7.0 +10 -0
- data/.circleci/images/primary/Dockerfile-jruby-9.2-latest +88 -0
- data/.circleci/images/primary/{Dockerfile-jruby-9.2 → Dockerfile-jruby-9.2.0.0} +1 -5
- data/.circleci/images/primary/Dockerfile-truffleruby-21.0.0 +73 -0
- data/.github/workflows/create-next-milestone.yml +2 -2
- data/.gitlab-ci.yml +18 -18
- data/.rubocop.yml +269 -7
- data/.rubocop_todo.yml +438 -0
- data/.simplecov +6 -0
- data/Appraisals +87 -9
- data/CHANGELOG.md +238 -1
- data/Gemfile +63 -3
- data/LICENSE-3rdparty.csv +2 -0
- data/README.md +1 -0
- data/Rakefile +65 -25
- data/bin/ddtracerb +15 -0
- data/ddtrace.gemspec +9 -36
- data/docker-compose.yml +75 -7
- data/docs/DevelopmentGuide.md +28 -0
- data/docs/GettingStarted.md +162 -68
- data/docs/ProfilingDevelopment.md +88 -0
- data/integration/README.md +67 -0
- data/integration/apps/rack/.dockerignore +1 -0
- data/integration/apps/rack/.envrc.sample +1 -0
- data/integration/apps/rack/.gitignore +4 -0
- data/integration/apps/rack/.rspec +1 -0
- data/integration/apps/rack/Dockerfile +28 -0
- data/integration/apps/rack/Dockerfile-ci +11 -0
- data/integration/apps/rack/Gemfile +24 -0
- data/integration/apps/rack/README.md +93 -0
- data/integration/apps/rack/app/acme.rb +80 -0
- data/integration/apps/rack/app/datadog.rb +17 -0
- data/integration/apps/rack/bin/run +22 -0
- data/integration/apps/rack/bin/setup +17 -0
- data/integration/apps/rack/bin/test +24 -0
- data/integration/apps/rack/config.ru +6 -0
- data/integration/apps/rack/config/puma.rb +14 -0
- data/integration/apps/rack/config/unicorn.rb +23 -0
- data/integration/apps/rack/docker-compose.ci.yml +62 -0
- data/integration/apps/rack/docker-compose.yml +78 -0
- data/integration/apps/rack/script/build-images +38 -0
- data/integration/apps/rack/script/ci +50 -0
- data/integration/apps/rack/spec/integration/basic_spec.rb +10 -0
- data/integration/apps/rack/spec/spec_helper.rb +16 -0
- data/integration/apps/rack/spec/support/integration_helper.rb +22 -0
- data/integration/apps/rails-five/.dockerignore +1 -0
- data/integration/apps/rails-five/.env +3 -0
- data/integration/apps/rails-five/.envrc.sample +1 -0
- data/integration/apps/rails-five/.gitignore +30 -0
- data/integration/apps/rails-five/Dockerfile +25 -0
- data/integration/apps/rails-five/Dockerfile-ci +11 -0
- data/integration/apps/rails-five/Gemfile +104 -0
- data/integration/apps/rails-five/README.md +94 -0
- data/integration/apps/rails-five/Rakefile +6 -0
- data/integration/apps/rails-five/app/channels/application_cable/channel.rb +4 -0
- data/integration/apps/rails-five/app/channels/application_cable/connection.rb +4 -0
- data/integration/apps/rails-five/app/controllers/application_controller.rb +2 -0
- data/integration/apps/rails-five/app/controllers/basic_controller.rb +36 -0
- data/integration/apps/rails-five/app/controllers/concerns/.keep +0 -0
- data/integration/apps/rails-five/app/controllers/health_controller.rb +9 -0
- data/integration/apps/rails-five/app/controllers/jobs_controller.rb +12 -0
- data/integration/apps/rails-five/app/jobs/application_job.rb +2 -0
- data/integration/apps/rails-five/app/jobs/test_job.rb +12 -0
- data/integration/apps/rails-five/app/mailers/application_mailer.rb +4 -0
- data/integration/apps/rails-five/app/models/application_record.rb +3 -0
- data/integration/apps/rails-five/app/models/concerns/.keep +0 -0
- data/integration/apps/rails-five/app/models/test.rb +2 -0
- data/integration/apps/rails-five/app/views/layouts/mailer.html.erb +13 -0
- data/integration/apps/rails-five/app/views/layouts/mailer.text.erb +1 -0
- data/integration/apps/rails-five/bin/bundle +3 -0
- data/integration/apps/rails-five/bin/rails +9 -0
- data/integration/apps/rails-five/bin/rake +9 -0
- data/integration/apps/rails-five/bin/run +24 -0
- data/integration/apps/rails-five/bin/setup +27 -0
- data/integration/apps/rails-five/bin/spring +17 -0
- data/integration/apps/rails-five/bin/test +21 -0
- data/integration/apps/rails-five/bin/update +28 -0
- data/integration/apps/rails-five/config.ru +5 -0
- data/integration/apps/rails-five/config/application.rb +97 -0
- data/integration/apps/rails-five/config/boot.rb +4 -0
- data/integration/apps/rails-five/config/cable.yml +10 -0
- data/integration/apps/rails-five/config/credentials.yml.enc +1 -0
- data/integration/apps/rails-five/config/database.yml +28 -0
- data/integration/apps/rails-five/config/environment.rb +5 -0
- data/integration/apps/rails-five/config/environments/development.rb +51 -0
- data/integration/apps/rails-five/config/environments/production.rb +82 -0
- data/integration/apps/rails-five/config/environments/test.rb +43 -0
- data/integration/apps/rails-five/config/initializers/datadog.rb +18 -0
- data/integration/apps/rails-five/config/initializers/filter_parameter_logging.rb +4 -0
- data/integration/apps/rails-five/config/initializers/resque.rb +4 -0
- data/integration/apps/rails-five/config/initializers/rollbar.rb +5 -0
- data/integration/apps/rails-five/config/initializers/wrap_parameters.rb +14 -0
- data/integration/apps/rails-five/config/locales/en.yml +33 -0
- data/integration/apps/rails-five/config/puma.rb +24 -0
- data/integration/apps/rails-five/config/routes.rb +11 -0
- data/integration/apps/rails-five/config/spring.rb +6 -0
- data/integration/apps/rails-five/config/unicorn.rb +29 -0
- data/integration/apps/rails-five/db/migrate/20190927215052_create_tests.rb +11 -0
- data/integration/apps/rails-five/db/schema.rb +23 -0
- data/integration/apps/rails-five/db/seeds.rb +7 -0
- data/integration/apps/rails-five/docker-compose.ci.yml +98 -0
- data/integration/apps/rails-five/docker-compose.yml +100 -0
- data/integration/apps/rails-five/lib/tasks/.keep +0 -0
- data/integration/apps/rails-five/log/.keep +0 -0
- data/integration/apps/rails-five/public/robots.txt +1 -0
- data/integration/apps/rails-five/script/build-images +35 -0
- data/integration/apps/rails-five/script/ci +50 -0
- data/integration/apps/rails-five/spec/integration/basic_spec.rb +10 -0
- data/integration/apps/rails-five/spec/spec_helper.rb +16 -0
- data/integration/apps/rails-five/spec/support/integration_helper.rb +22 -0
- data/integration/apps/rails-five/storage/.keep +0 -0
- data/integration/apps/rails-five/tmp/.keep +0 -0
- data/integration/apps/rails-five/vendor/.keep +0 -0
- data/integration/apps/ruby/.dockerignore +1 -0
- data/integration/apps/ruby/.envrc.sample +1 -0
- data/integration/apps/ruby/.gitignore +2 -0
- data/integration/apps/ruby/Dockerfile +25 -0
- data/integration/apps/ruby/Dockerfile-ci +11 -0
- data/integration/apps/ruby/Gemfile +11 -0
- data/integration/apps/ruby/README.md +70 -0
- data/integration/apps/ruby/agent.yaml +3 -0
- data/integration/apps/ruby/app/datadog.rb +13 -0
- data/integration/apps/ruby/app/fibonacci.rb +58 -0
- data/integration/apps/ruby/bin/run +20 -0
- data/integration/apps/ruby/bin/setup +17 -0
- data/integration/apps/ruby/bin/test +21 -0
- data/integration/apps/ruby/docker-compose.ci.yml +51 -0
- data/integration/apps/ruby/docker-compose.yml +63 -0
- data/integration/apps/ruby/script/build-images +38 -0
- data/integration/apps/ruby/script/ci +50 -0
- data/integration/images/agent/Dockerfile +2 -0
- data/integration/images/agent/agent.yaml +3 -0
- data/integration/images/include/datadog/analyzer.rb +71 -0
- data/integration/images/include/datadog/demo_env.rb +101 -0
- data/integration/images/include/http-health-check +33 -0
- data/integration/images/ruby/2.0/Dockerfile +54 -0
- data/integration/images/ruby/2.1/Dockerfile +54 -0
- data/integration/images/ruby/2.2/Dockerfile +54 -0
- data/integration/images/ruby/2.3/Dockerfile +70 -0
- data/integration/images/ruby/2.4/Dockerfile +54 -0
- data/integration/images/ruby/2.5/Dockerfile +54 -0
- data/integration/images/ruby/2.6/Dockerfile +54 -0
- data/integration/images/ruby/2.7/Dockerfile +54 -0
- data/integration/images/ruby/3.0/Dockerfile +54 -0
- data/integration/images/wrk/Dockerfile +33 -0
- data/integration/images/wrk/scripts/entrypoint.sh +17 -0
- data/integration/images/wrk/scripts/scenarios/basic/default.lua +1 -0
- data/integration/images/wrk/scripts/scenarios/basic/fibonacci.lua +1 -0
- data/integration/script/build-images +43 -0
- data/lib/ddtrace.rb +8 -5
- data/lib/ddtrace/analytics.rb +2 -0
- data/lib/ddtrace/auto_instrument.rb +3 -0
- data/lib/ddtrace/auto_instrument_base.rb +6 -0
- data/lib/ddtrace/buffer.rb +4 -4
- data/lib/ddtrace/configuration.rb +121 -26
- data/lib/ddtrace/configuration/base.rb +1 -1
- data/lib/ddtrace/configuration/components.rb +87 -5
- data/lib/ddtrace/configuration/option_definition.rb +1 -3
- data/lib/ddtrace/configuration/options.rb +4 -7
- data/lib/ddtrace/configuration/settings.rb +48 -3
- data/lib/ddtrace/context.rb +5 -6
- data/lib/ddtrace/context_provider.rb +0 -1
- data/lib/ddtrace/contrib/action_cable/event.rb +1 -0
- data/lib/ddtrace/contrib/action_cable/integration.rb +7 -0
- data/lib/ddtrace/contrib/action_pack/action_controller/instrumentation.rb +1 -3
- data/lib/ddtrace/contrib/action_pack/integration.rb +7 -0
- data/lib/ddtrace/contrib/action_view/event.rb +1 -1
- data/lib/ddtrace/contrib/action_view/integration.rb +7 -0
- data/lib/ddtrace/contrib/action_view/utils.rb +1 -1
- data/lib/ddtrace/contrib/active_record/configuration/makara_resolver.rb +30 -0
- data/lib/ddtrace/contrib/active_record/configuration/resolver.rb +107 -18
- data/lib/ddtrace/contrib/active_record/integration.rb +7 -0
- data/lib/ddtrace/contrib/active_record/utils.rb +57 -20
- data/lib/ddtrace/contrib/active_support/integration.rb +7 -1
- data/lib/ddtrace/contrib/active_support/notifications/event.rb +2 -1
- data/lib/ddtrace/contrib/active_support/notifications/subscriber.rb +1 -0
- data/lib/ddtrace/contrib/active_support/notifications/subscription.rb +9 -5
- data/lib/ddtrace/contrib/auto_instrument.rb +49 -0
- data/lib/ddtrace/contrib/aws/patcher.rb +1 -0
- data/lib/ddtrace/contrib/aws/services.rb +2 -0
- data/lib/ddtrace/contrib/configurable.rb +63 -39
- data/lib/ddtrace/contrib/configuration/resolver.rb +70 -5
- data/lib/ddtrace/contrib/configuration/resolvers/pattern_resolver.rb +19 -20
- data/lib/ddtrace/contrib/configuration/settings.rb +7 -6
- data/lib/ddtrace/contrib/cucumber/configuration/settings.rb +0 -10
- data/lib/ddtrace/contrib/cucumber/ext.rb +0 -2
- data/lib/ddtrace/contrib/cucumber/formatter.rb +5 -11
- data/lib/ddtrace/contrib/cucumber/integration.rb +5 -0
- data/lib/ddtrace/contrib/dalli/patcher.rb +0 -38
- data/lib/ddtrace/contrib/delayed_job/plugin.rb +0 -1
- data/lib/ddtrace/contrib/elasticsearch/patcher.rb +1 -0
- data/lib/ddtrace/contrib/elasticsearch/quantize.rb +3 -2
- data/lib/ddtrace/contrib/ethon/easy_patch.rb +10 -9
- data/lib/ddtrace/contrib/excon/middleware.rb +2 -6
- data/lib/ddtrace/contrib/extensions.rb +53 -3
- data/lib/ddtrace/contrib/faraday/middleware.rb +1 -3
- data/lib/ddtrace/contrib/faraday/patcher.rb +0 -36
- data/lib/ddtrace/contrib/grape/endpoint.rb +8 -15
- data/lib/ddtrace/contrib/grape/patcher.rb +0 -42
- data/lib/ddtrace/contrib/grpc/datadog_interceptor.rb +8 -8
- data/lib/ddtrace/contrib/grpc/datadog_interceptor/server.rb +1 -0
- data/lib/ddtrace/contrib/grpc/patcher.rb +0 -36
- data/lib/ddtrace/contrib/http/circuit_breaker.rb +1 -3
- data/lib/ddtrace/contrib/http/instrumentation.rb +5 -5
- data/lib/ddtrace/contrib/httpclient/configuration/settings.rb +32 -0
- data/lib/ddtrace/contrib/httpclient/ext.rb +17 -0
- data/lib/ddtrace/contrib/httpclient/instrumentation.rb +147 -0
- data/lib/ddtrace/contrib/httpclient/integration.rb +43 -0
- data/lib/ddtrace/contrib/httpclient/patcher.rb +38 -0
- data/lib/ddtrace/contrib/httprb/instrumentation.rb +14 -20
- data/lib/ddtrace/contrib/httprb/patcher.rb +5 -2
- data/lib/ddtrace/contrib/mongodb/instrumentation.rb +2 -0
- data/lib/ddtrace/contrib/mongodb/subscribers.rb +2 -3
- data/lib/ddtrace/contrib/patchable.rb +18 -7
- data/lib/ddtrace/contrib/patcher.rb +9 -6
- data/lib/ddtrace/contrib/presto/patcher.rb +5 -2
- data/lib/ddtrace/contrib/qless/qless_job.rb +1 -0
- data/lib/ddtrace/contrib/qless/tracer_cleaner.rb +1 -0
- data/lib/ddtrace/contrib/que/ext.rb +19 -19
- data/lib/ddtrace/contrib/que/tracer.rb +1 -1
- data/lib/ddtrace/contrib/racecar/event.rb +1 -0
- data/lib/ddtrace/contrib/rack/configuration/settings.rb +3 -3
- data/lib/ddtrace/contrib/rack/integration.rb +7 -0
- data/lib/ddtrace/contrib/rack/middlewares.rb +6 -11
- data/lib/ddtrace/contrib/rack/patcher.rb +1 -3
- data/lib/ddtrace/contrib/rack/request_queue.rb +6 -1
- data/lib/ddtrace/contrib/rails/auto_instrument_railtie.rb +10 -0
- data/lib/ddtrace/contrib/rails/patcher.rb +6 -2
- data/lib/ddtrace/contrib/rails/utils.rb +4 -0
- data/lib/ddtrace/contrib/rake/instrumentation.rb +4 -2
- data/lib/ddtrace/contrib/rake/integration.rb +1 -1
- data/lib/ddtrace/contrib/redis/configuration/resolver.rb +11 -4
- data/lib/ddtrace/contrib/redis/quantize.rb +1 -0
- data/lib/ddtrace/contrib/redis/vendor/LICENSE +20 -0
- data/lib/ddtrace/contrib/redis/vendor/resolver.rb +6 -7
- data/lib/ddtrace/contrib/registry.rb +2 -2
- data/lib/ddtrace/contrib/resque/configuration/settings.rb +17 -1
- data/lib/ddtrace/contrib/resque/integration.rb +1 -1
- data/lib/ddtrace/contrib/resque/patcher.rb +4 -4
- data/lib/ddtrace/contrib/resque/resque_job.rb +24 -1
- data/lib/ddtrace/contrib/rest_client/request_patch.rb +1 -3
- data/lib/ddtrace/contrib/rspec/configuration/settings.rb +0 -10
- data/lib/ddtrace/contrib/rspec/example.rb +24 -10
- data/lib/ddtrace/contrib/rspec/ext.rb +0 -3
- data/lib/ddtrace/contrib/rspec/integration.rb +6 -1
- data/lib/ddtrace/contrib/rspec/patcher.rb +0 -2
- data/lib/ddtrace/contrib/sequel/utils.rb +5 -6
- data/lib/ddtrace/contrib/shoryuken/configuration/settings.rb +1 -0
- data/lib/ddtrace/contrib/shoryuken/tracer.rb +7 -4
- data/lib/ddtrace/contrib/sidekiq/server_tracer.rb +2 -7
- data/lib/ddtrace/contrib/sidekiq/tracing.rb +0 -1
- data/lib/ddtrace/contrib/sinatra/env.rb +1 -3
- data/lib/ddtrace/contrib/sinatra/headers.rb +1 -3
- data/lib/ddtrace/contrib/sinatra/tracer.rb +1 -3
- data/lib/ddtrace/contrib/sinatra/tracer_middleware.rb +3 -3
- data/lib/ddtrace/contrib/sneakers/ext.rb +11 -11
- data/lib/ddtrace/contrib/sneakers/tracer.rb +2 -4
- data/lib/ddtrace/contrib/status_code_matcher.rb +5 -3
- data/lib/ddtrace/correlation.rb +1 -0
- data/lib/ddtrace/diagnostics/environment_logger.rb +3 -2
- data/lib/ddtrace/distributed_tracing/headers/headers.rb +1 -0
- data/lib/ddtrace/distributed_tracing/headers/helpers.rb +1 -3
- data/lib/ddtrace/error.rb +2 -0
- data/lib/ddtrace/ext/ci.rb +43 -10
- data/lib/ddtrace/ext/distributed.rb +1 -1
- data/lib/ddtrace/ext/git.rb +0 -1
- data/lib/ddtrace/ext/http.rb +1 -1
- data/lib/ddtrace/ext/profiling.rb +52 -0
- data/lib/ddtrace/ext/runtime.rb +3 -1
- data/lib/ddtrace/ext/transport.rb +1 -0
- data/lib/ddtrace/forced_tracing.rb +2 -0
- data/lib/ddtrace/logger.rb +1 -1
- data/lib/ddtrace/metrics.rb +14 -6
- data/lib/ddtrace/opentracer/distributed_headers.rb +3 -0
- data/lib/ddtrace/opentracer/span.rb +2 -6
- data/lib/ddtrace/opentracer/thread_local_scope.rb +1 -0
- data/lib/ddtrace/patcher.rb +25 -4
- data/lib/ddtrace/pin.rb +8 -61
- data/lib/ddtrace/pipeline/span_filter.rb +1 -1
- data/lib/ddtrace/profiling.rb +54 -0
- data/lib/ddtrace/profiling/backtrace_location.rb +32 -0
- data/lib/ddtrace/profiling/buffer.rb +41 -0
- data/lib/ddtrace/profiling/collectors/stack.rb +253 -0
- data/lib/ddtrace/profiling/encoding/profile.rb +31 -0
- data/lib/ddtrace/profiling/event.rb +13 -0
- data/lib/ddtrace/profiling/events/stack.rb +102 -0
- data/lib/ddtrace/profiling/exporter.rb +23 -0
- data/lib/ddtrace/profiling/ext/cpu.rb +54 -0
- data/lib/ddtrace/profiling/ext/cthread.rb +134 -0
- data/lib/ddtrace/profiling/ext/forking.rb +97 -0
- data/lib/ddtrace/profiling/flush.rb +41 -0
- data/lib/ddtrace/profiling/pprof/builder.rb +121 -0
- data/lib/ddtrace/profiling/pprof/converter.rb +85 -0
- data/lib/ddtrace/profiling/pprof/message_set.rb +12 -0
- data/lib/ddtrace/profiling/pprof/payload.rb +18 -0
- data/lib/ddtrace/profiling/pprof/pprof.proto +212 -0
- data/lib/ddtrace/profiling/pprof/pprof_pb.rb +81 -0
- data/lib/ddtrace/profiling/pprof/stack_sample.rb +90 -0
- data/lib/ddtrace/profiling/pprof/string_table.rb +10 -0
- data/lib/ddtrace/profiling/pprof/template.rb +114 -0
- data/lib/ddtrace/profiling/preload.rb +3 -0
- data/lib/ddtrace/profiling/profiler.rb +28 -0
- data/lib/ddtrace/profiling/recorder.rb +87 -0
- data/lib/ddtrace/profiling/scheduler.rb +84 -0
- data/lib/ddtrace/profiling/tasks/setup.rb +77 -0
- data/lib/ddtrace/profiling/transport/client.rb +12 -0
- data/lib/ddtrace/profiling/transport/http.rb +122 -0
- data/lib/ddtrace/profiling/transport/http/api.rb +43 -0
- data/lib/ddtrace/profiling/transport/http/api/endpoint.rb +90 -0
- data/lib/ddtrace/profiling/transport/http/api/instance.rb +36 -0
- data/lib/ddtrace/profiling/transport/http/api/spec.rb +40 -0
- data/lib/ddtrace/profiling/transport/http/builder.rb +28 -0
- data/lib/ddtrace/profiling/transport/http/client.rb +33 -0
- data/lib/ddtrace/profiling/transport/http/response.rb +21 -0
- data/lib/ddtrace/profiling/transport/io.rb +30 -0
- data/lib/ddtrace/profiling/transport/io/client.rb +27 -0
- data/lib/ddtrace/profiling/transport/io/response.rb +16 -0
- data/lib/ddtrace/profiling/transport/parcel.rb +17 -0
- data/lib/ddtrace/profiling/transport/request.rb +15 -0
- data/lib/ddtrace/profiling/transport/response.rb +8 -0
- data/lib/ddtrace/propagation/grpc_propagator.rb +1 -0
- data/lib/ddtrace/propagation/http_propagator.rb +17 -2
- data/lib/ddtrace/quantization/http.rb +1 -0
- data/lib/ddtrace/runtime/cgroup.rb +2 -2
- data/lib/ddtrace/runtime/container.rb +32 -26
- data/lib/ddtrace/runtime/identity.rb +8 -0
- data/lib/ddtrace/sampler.rb +1 -1
- data/lib/ddtrace/sampling/rule_sampler.rb +4 -9
- data/lib/ddtrace/span.rb +7 -7
- data/lib/ddtrace/sync_writer.rb +12 -12
- data/lib/ddtrace/tasks/exec.rb +48 -0
- data/lib/ddtrace/tasks/help.rb +14 -0
- data/lib/ddtrace/tracer.rb +28 -5
- data/lib/ddtrace/transport/http.rb +15 -8
- data/lib/ddtrace/transport/http/adapters/net.rb +27 -8
- data/lib/ddtrace/transport/http/adapters/registry.rb +1 -0
- data/lib/ddtrace/transport/http/adapters/unix_socket.rb +2 -4
- data/lib/ddtrace/transport/http/builder.rb +7 -1
- data/lib/ddtrace/transport/http/env.rb +8 -0
- data/lib/ddtrace/transport/http/traces.rb +2 -3
- data/lib/ddtrace/transport/io.rb +1 -1
- data/lib/ddtrace/transport/io/client.rb +15 -8
- data/lib/ddtrace/transport/io/response.rb +1 -3
- data/lib/ddtrace/transport/io/traces.rb +6 -0
- data/lib/ddtrace/transport/parcel.rb +4 -0
- data/lib/ddtrace/transport/traces.rb +18 -1
- data/lib/ddtrace/utils/compression.rb +27 -0
- data/lib/ddtrace/utils/object_set.rb +41 -0
- data/lib/ddtrace/utils/only_once.rb +40 -0
- data/lib/ddtrace/utils/sequence.rb +17 -0
- data/lib/ddtrace/utils/string_table.rb +45 -0
- data/lib/ddtrace/utils/time.rb +32 -1
- data/lib/ddtrace/vendor/active_record/MIT-LICENSE +20 -0
- data/lib/ddtrace/vendor/multipart-post/LICENSE +11 -0
- data/lib/ddtrace/vendor/multipart-post/multipart.rb +12 -0
- data/lib/ddtrace/vendor/multipart-post/multipart/post.rb +8 -0
- data/lib/ddtrace/vendor/multipart-post/multipart/post/composite_read_io.rb +116 -0
- data/lib/ddtrace/vendor/multipart-post/multipart/post/multipartable.rb +57 -0
- data/lib/ddtrace/vendor/multipart-post/multipart/post/parts.rb +135 -0
- data/lib/ddtrace/vendor/multipart-post/multipart/post/version.rb +9 -0
- data/lib/ddtrace/vendor/multipart-post/net/http/post/multipart.rb +32 -0
- data/lib/ddtrace/version.rb +3 -1
- data/lib/ddtrace/workers.rb +5 -0
- data/lib/ddtrace/workers/async.rb +11 -3
- data/lib/ddtrace/workers/loop.rb +17 -3
- data/lib/ddtrace/workers/polling.rb +1 -0
- data/lib/ddtrace/workers/queue.rb +1 -0
- data/lib/ddtrace/workers/runtime_metrics.rb +14 -1
- data/lib/ddtrace/workers/trace_writer.rb +10 -10
- data/lib/ddtrace/writer.rb +7 -4
- metadata +213 -379
- data/lib/ddtrace/augmentation.rb +0 -13
- data/lib/ddtrace/augmentation/method_wrapper.rb +0 -20
- data/lib/ddtrace/augmentation/method_wrapping.rb +0 -38
- data/lib/ddtrace/augmentation/shim.rb +0 -102
- data/lib/ddtrace/contrib/rspec/example_group.rb +0 -61
- data/lib/ddtrace/monkey.rb +0 -58
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'ddtrace/ext/profiling'
|
2
|
+
|
3
|
+
module Datadog
|
4
|
+
module Profiling
|
5
|
+
module Pprof
|
6
|
+
# Base class for converters that convert profiling events to pprof
|
7
|
+
class Converter
|
8
|
+
attr_reader \
|
9
|
+
:builder
|
10
|
+
|
11
|
+
# Override in child class to define sample types
|
12
|
+
# this converter uses when building samples.
|
13
|
+
def self.sample_value_types
|
14
|
+
raise NotImplementedError
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(builder, sample_type_mappings)
|
18
|
+
@builder = builder
|
19
|
+
@sample_type_mappings = sample_type_mappings
|
20
|
+
end
|
21
|
+
|
22
|
+
def group_events(events)
|
23
|
+
# Event grouping in format:
|
24
|
+
# [key, EventGroup]
|
25
|
+
event_groups = {}
|
26
|
+
|
27
|
+
events.each do |event|
|
28
|
+
key = yield(event)
|
29
|
+
values = build_sample_values(event)
|
30
|
+
|
31
|
+
unless key.nil?
|
32
|
+
if event_groups.key?(key)
|
33
|
+
# Update values for group
|
34
|
+
group_values = event_groups[key].values
|
35
|
+
group_values.each_with_index do |group_value, i|
|
36
|
+
group_values[i] = group_value + values[i]
|
37
|
+
end
|
38
|
+
else
|
39
|
+
# Add new group
|
40
|
+
event_groups[key] = EventGroup.new(event, values)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
event_groups
|
46
|
+
end
|
47
|
+
|
48
|
+
def add_events!(events)
|
49
|
+
raise NotImplementedError
|
50
|
+
end
|
51
|
+
|
52
|
+
def sample_value_index(type)
|
53
|
+
index = @sample_type_mappings[type]
|
54
|
+
raise UnknownSampleTypeMappingError, type unless index
|
55
|
+
|
56
|
+
index
|
57
|
+
end
|
58
|
+
|
59
|
+
def build_sample_values(stack_sample)
|
60
|
+
# Build a value array that matches the length of the sample types
|
61
|
+
# Populate all values with "no value" by default
|
62
|
+
Array.new(@sample_type_mappings.length, Datadog::Ext::Profiling::Pprof::SAMPLE_VALUE_NO_VALUE)
|
63
|
+
end
|
64
|
+
|
65
|
+
# Represents a grouped event
|
66
|
+
# 'sample' is an example event object from the group.
|
67
|
+
# 'values' is the the summation of the group's sample values
|
68
|
+
EventGroup = Struct.new(:sample, :values)
|
69
|
+
|
70
|
+
# Error when the mapping of a sample type to value index is unknown
|
71
|
+
class UnknownSampleTypeMappingError < StandardError
|
72
|
+
attr_reader :type
|
73
|
+
|
74
|
+
def initialize(type)
|
75
|
+
@type = type
|
76
|
+
end
|
77
|
+
|
78
|
+
def message
|
79
|
+
"Mapping for sample value type '#{type}' to index is unknown."
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Datadog
|
2
|
+
module Profiling
|
3
|
+
module Pprof
|
4
|
+
# Pprof output data.
|
5
|
+
# Includes encoded data and list of types.
|
6
|
+
Payload = Struct.new(:data, :types) do
|
7
|
+
def initialize(*args)
|
8
|
+
super
|
9
|
+
self.types = types || []
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_s
|
13
|
+
data
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,212 @@
|
|
1
|
+
// Copyright 2016 Google Inc. All Rights Reserved.
|
2
|
+
//
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
// you may not use this file except in compliance with the License.
|
5
|
+
// You may obtain a copy of the License at
|
6
|
+
//
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
//
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
// See the License for the specific language governing permissions and
|
13
|
+
// limitations under the License.
|
14
|
+
|
15
|
+
// Profile is a common stacktrace profile format.
|
16
|
+
//
|
17
|
+
// Measurements represented with this format should follow the
|
18
|
+
// following conventions:
|
19
|
+
//
|
20
|
+
// - Consumers should treat unset optional fields as if they had been
|
21
|
+
// set with their default value.
|
22
|
+
//
|
23
|
+
// - When possible, measurements should be stored in "unsampled" form
|
24
|
+
// that is most useful to humans. There should be enough
|
25
|
+
// information present to determine the original sampled values.
|
26
|
+
//
|
27
|
+
// - On-disk, the serialized proto must be gzip-compressed.
|
28
|
+
//
|
29
|
+
// - The profile is represented as a set of samples, where each sample
|
30
|
+
// references a sequence of locations, and where each location belongs
|
31
|
+
// to a mapping.
|
32
|
+
// - There is a N->1 relationship from sample.location_id entries to
|
33
|
+
// locations. For every sample.location_id entry there must be a
|
34
|
+
// unique Location with that id.
|
35
|
+
// - There is an optional N->1 relationship from locations to
|
36
|
+
// mappings. For every nonzero Location.mapping_id there must be a
|
37
|
+
// unique Mapping with that id.
|
38
|
+
|
39
|
+
syntax = "proto3";
|
40
|
+
|
41
|
+
package perftools.profiles;
|
42
|
+
|
43
|
+
option java_package = "com.google.perftools.profiles";
|
44
|
+
option java_outer_classname = "ProfileProto";
|
45
|
+
|
46
|
+
message Profile {
|
47
|
+
// A description of the samples associated with each Sample.value.
|
48
|
+
// For a cpu profile this might be:
|
49
|
+
// [["cpu","nanoseconds"]] or [["wall","seconds"]] or [["syscall","count"]]
|
50
|
+
// For a heap profile, this might be:
|
51
|
+
// [["allocations","count"], ["space","bytes"]],
|
52
|
+
// If one of the values represents the number of events represented
|
53
|
+
// by the sample, by convention it should be at index 0 and use
|
54
|
+
// sample_type.unit == "count".
|
55
|
+
repeated ValueType sample_type = 1;
|
56
|
+
// The set of samples recorded in this profile.
|
57
|
+
repeated Sample sample = 2;
|
58
|
+
// Mapping from address ranges to the image/binary/library mapped
|
59
|
+
// into that address range. mapping[0] will be the main binary.
|
60
|
+
repeated Mapping mapping = 3;
|
61
|
+
// Useful program location
|
62
|
+
repeated Location location = 4;
|
63
|
+
// Functions referenced by locations
|
64
|
+
repeated Function function = 5;
|
65
|
+
// A common table for strings referenced by various messages.
|
66
|
+
// string_table[0] must always be "".
|
67
|
+
repeated string string_table = 6;
|
68
|
+
// frames with Function.function_name fully matching the following
|
69
|
+
// regexp will be dropped from the samples, along with their successors.
|
70
|
+
int64 drop_frames = 7; // Index into string table.
|
71
|
+
// frames with Function.function_name fully matching the following
|
72
|
+
// regexp will be kept, even if it matches drop_functions.
|
73
|
+
int64 keep_frames = 8; // Index into string table.
|
74
|
+
|
75
|
+
// The following fields are informational, do not affect
|
76
|
+
// interpretation of results.
|
77
|
+
|
78
|
+
// Time of collection (UTC) represented as nanoseconds past the epoch.
|
79
|
+
int64 time_nanos = 9;
|
80
|
+
// Duration of the profile, if a duration makes sense.
|
81
|
+
int64 duration_nanos = 10;
|
82
|
+
// The kind of events between sampled ocurrences.
|
83
|
+
// e.g [ "cpu","cycles" ] or [ "heap","bytes" ]
|
84
|
+
ValueType period_type = 11;
|
85
|
+
// The number of events between sampled occurrences.
|
86
|
+
int64 period = 12;
|
87
|
+
// Freeform text associated to the profile.
|
88
|
+
repeated int64 comment = 13; // Indices into string table.
|
89
|
+
// Index into the string table of the type of the preferred sample
|
90
|
+
// value. If unset, clients should default to the last sample value.
|
91
|
+
int64 default_sample_type = 14;
|
92
|
+
}
|
93
|
+
|
94
|
+
// ValueType describes the semantics and measurement units of a value.
|
95
|
+
message ValueType {
|
96
|
+
int64 type = 1; // Index into string table.
|
97
|
+
int64 unit = 2; // Index into string table.
|
98
|
+
}
|
99
|
+
|
100
|
+
// Each Sample records values encountered in some program
|
101
|
+
// context. The program context is typically a stack trace, perhaps
|
102
|
+
// augmented with auxiliary information like the thread-id, some
|
103
|
+
// indicator of a higher level request being handled etc.
|
104
|
+
message Sample {
|
105
|
+
// The ids recorded here correspond to a Profile.location.id.
|
106
|
+
// The leaf is at location_id[0].
|
107
|
+
repeated uint64 location_id = 1;
|
108
|
+
// The type and unit of each value is defined by the corresponding
|
109
|
+
// entry in Profile.sample_type. All samples must have the same
|
110
|
+
// number of values, the same as the length of Profile.sample_type.
|
111
|
+
// When aggregating multiple samples into a single sample, the
|
112
|
+
// result has a list of values that is the elemntwise sum of the
|
113
|
+
// lists of the originals.
|
114
|
+
repeated int64 value = 2;
|
115
|
+
// label includes additional context for this sample. It can include
|
116
|
+
// things like a thread id, allocation size, etc
|
117
|
+
repeated Label label = 3;
|
118
|
+
}
|
119
|
+
|
120
|
+
message Label {
|
121
|
+
int64 key = 1; // Index into string table
|
122
|
+
|
123
|
+
// At most one of the following must be present
|
124
|
+
int64 str = 2; // Index into string table
|
125
|
+
int64 num = 3;
|
126
|
+
|
127
|
+
// Should only be present when num is present.
|
128
|
+
// Specifies the units of num.
|
129
|
+
// Use arbitrary string (for example, "requests") as a custom count unit.
|
130
|
+
// If no unit is specified, consumer may apply heuristic to deduce the unit.
|
131
|
+
// Consumers may also interpret units like "bytes" and "kilobytes" as memory
|
132
|
+
// units and units like "seconds" and "nanoseconds" as time units,
|
133
|
+
// and apply appropriate unit conversions to these.
|
134
|
+
int64 num_unit = 4; // Index into string table
|
135
|
+
}
|
136
|
+
|
137
|
+
message Mapping {
|
138
|
+
// Unique nonzero id for the mapping.
|
139
|
+
uint64 id = 1;
|
140
|
+
// Address at which the binary (or DLL) is loaded into memory.
|
141
|
+
uint64 memory_start = 2;
|
142
|
+
// The limit of the address range occupied by this mapping.
|
143
|
+
uint64 memory_limit = 3;
|
144
|
+
// Offset in the binary that corresponds to the first mapped address.
|
145
|
+
uint64 file_offset = 4;
|
146
|
+
// The object this entry is loaded from. This can be a filename on
|
147
|
+
// disk for the main binary and shared libraries, or virtual
|
148
|
+
// abstractions like "[vdso]".
|
149
|
+
int64 filename = 5; // Index into string table
|
150
|
+
// A string that uniquely identifies a particular program version
|
151
|
+
// with high probability. E.g., for binaries generated by GNU tools,
|
152
|
+
// it could be the contents of the .note.gnu.build-id field.
|
153
|
+
int64 build_id = 6; // Index into string table
|
154
|
+
|
155
|
+
// The following fields indicate the resolution of symbolic info.
|
156
|
+
bool has_functions = 7;
|
157
|
+
bool has_filenames = 8;
|
158
|
+
bool has_line_numbers = 9;
|
159
|
+
bool has_inline_frames = 10;
|
160
|
+
}
|
161
|
+
|
162
|
+
// Describes function and line table debug information.
|
163
|
+
message Location {
|
164
|
+
// Unique nonzero id for the location. A profile could use
|
165
|
+
// instruction addresses or any integer sequence as ids.
|
166
|
+
uint64 id = 1;
|
167
|
+
// The id of the corresponding profile.Mapping for this location.
|
168
|
+
// It can be unset if the mapping is unknown or not applicable for
|
169
|
+
// this profile type.
|
170
|
+
uint64 mapping_id = 2;
|
171
|
+
// The instruction address for this location, if available. It
|
172
|
+
// should be within [Mapping.memory_start...Mapping.memory_limit]
|
173
|
+
// for the corresponding mapping. A non-leaf address may be in the
|
174
|
+
// middle of a call instruction. It is up to display tools to find
|
175
|
+
// the beginning of the instruction if necessary.
|
176
|
+
uint64 address = 3;
|
177
|
+
// Multiple line indicates this location has inlined functions,
|
178
|
+
// where the last entry represents the caller into which the
|
179
|
+
// preceding entries were inlined.
|
180
|
+
//
|
181
|
+
// E.g., if memcpy() is inlined into printf:
|
182
|
+
// line[0].function_name == "memcpy"
|
183
|
+
// line[1].function_name == "printf"
|
184
|
+
repeated Line line = 4;
|
185
|
+
// Provides an indication that multiple symbols map to this location's
|
186
|
+
// address, for example due to identical code folding by the linker. In that
|
187
|
+
// case the line information above represents one of the multiple
|
188
|
+
// symbols. This field must be recomputed when the symbolization state of the
|
189
|
+
// profile changes.
|
190
|
+
bool is_folded = 5;
|
191
|
+
}
|
192
|
+
|
193
|
+
message Line {
|
194
|
+
// The id of the corresponding profile.Function for this line.
|
195
|
+
uint64 function_id = 1;
|
196
|
+
// Line number in source code.
|
197
|
+
int64 line = 2;
|
198
|
+
}
|
199
|
+
|
200
|
+
message Function {
|
201
|
+
// Unique nonzero id for the function.
|
202
|
+
uint64 id = 1;
|
203
|
+
// Name of the function, in human-readable form if available.
|
204
|
+
int64 name = 2; // Index into string table
|
205
|
+
// Name of the function, as identified by the system.
|
206
|
+
// For instance, it can be a C++ mangled name.
|
207
|
+
int64 system_name = 3; // Index into string table
|
208
|
+
// Source file containing the function.
|
209
|
+
int64 filename = 4; // Index into string table
|
210
|
+
// Line number in source file.
|
211
|
+
int64 start_line = 5;
|
212
|
+
}
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# source: lib/ddtrace/profiling/pprof/pprof.proto
|
3
|
+
|
4
|
+
require 'google/protobuf'
|
5
|
+
|
6
|
+
Google::Protobuf::DescriptorPool.generated_pool.build do
|
7
|
+
add_message "perftools.profiles.Profile" do
|
8
|
+
repeated :sample_type, :message, 1, "perftools.profiles.ValueType"
|
9
|
+
repeated :sample, :message, 2, "perftools.profiles.Sample"
|
10
|
+
repeated :mapping, :message, 3, "perftools.profiles.Mapping"
|
11
|
+
repeated :location, :message, 4, "perftools.profiles.Location"
|
12
|
+
repeated :function, :message, 5, "perftools.profiles.Function"
|
13
|
+
repeated :string_table, :string, 6
|
14
|
+
optional :drop_frames, :int64, 7
|
15
|
+
optional :keep_frames, :int64, 8
|
16
|
+
optional :time_nanos, :int64, 9
|
17
|
+
optional :duration_nanos, :int64, 10
|
18
|
+
optional :period_type, :message, 11, "perftools.profiles.ValueType"
|
19
|
+
optional :period, :int64, 12
|
20
|
+
repeated :comment, :int64, 13
|
21
|
+
optional :default_sample_type, :int64, 14
|
22
|
+
end
|
23
|
+
add_message "perftools.profiles.ValueType" do
|
24
|
+
optional :type, :int64, 1
|
25
|
+
optional :unit, :int64, 2
|
26
|
+
end
|
27
|
+
add_message "perftools.profiles.Sample" do
|
28
|
+
repeated :location_id, :uint64, 1
|
29
|
+
repeated :value, :int64, 2
|
30
|
+
repeated :label, :message, 3, "perftools.profiles.Label"
|
31
|
+
end
|
32
|
+
add_message "perftools.profiles.Label" do
|
33
|
+
optional :key, :int64, 1
|
34
|
+
optional :str, :int64, 2
|
35
|
+
optional :num, :int64, 3
|
36
|
+
optional :num_unit, :int64, 4
|
37
|
+
end
|
38
|
+
add_message "perftools.profiles.Mapping" do
|
39
|
+
optional :id, :uint64, 1
|
40
|
+
optional :memory_start, :uint64, 2
|
41
|
+
optional :memory_limit, :uint64, 3
|
42
|
+
optional :file_offset, :uint64, 4
|
43
|
+
optional :filename, :int64, 5
|
44
|
+
optional :build_id, :int64, 6
|
45
|
+
optional :has_functions, :bool, 7
|
46
|
+
optional :has_filenames, :bool, 8
|
47
|
+
optional :has_line_numbers, :bool, 9
|
48
|
+
optional :has_inline_frames, :bool, 10
|
49
|
+
end
|
50
|
+
add_message "perftools.profiles.Location" do
|
51
|
+
optional :id, :uint64, 1
|
52
|
+
optional :mapping_id, :uint64, 2
|
53
|
+
optional :address, :uint64, 3
|
54
|
+
repeated :line, :message, 4, "perftools.profiles.Line"
|
55
|
+
optional :is_folded, :bool, 5
|
56
|
+
end
|
57
|
+
add_message "perftools.profiles.Line" do
|
58
|
+
optional :function_id, :uint64, 1
|
59
|
+
optional :line, :int64, 2
|
60
|
+
end
|
61
|
+
add_message "perftools.profiles.Function" do
|
62
|
+
optional :id, :uint64, 1
|
63
|
+
optional :name, :int64, 2
|
64
|
+
optional :system_name, :int64, 3
|
65
|
+
optional :filename, :int64, 4
|
66
|
+
optional :start_line, :int64, 5
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
module Perftools
|
71
|
+
module Profiles
|
72
|
+
Profile = Google::Protobuf::DescriptorPool.generated_pool.lookup("perftools.profiles.Profile").msgclass
|
73
|
+
ValueType = Google::Protobuf::DescriptorPool.generated_pool.lookup("perftools.profiles.ValueType").msgclass
|
74
|
+
Sample = Google::Protobuf::DescriptorPool.generated_pool.lookup("perftools.profiles.Sample").msgclass
|
75
|
+
Label = Google::Protobuf::DescriptorPool.generated_pool.lookup("perftools.profiles.Label").msgclass
|
76
|
+
Mapping = Google::Protobuf::DescriptorPool.generated_pool.lookup("perftools.profiles.Mapping").msgclass
|
77
|
+
Location = Google::Protobuf::DescriptorPool.generated_pool.lookup("perftools.profiles.Location").msgclass
|
78
|
+
Line = Google::Protobuf::DescriptorPool.generated_pool.lookup("perftools.profiles.Line").msgclass
|
79
|
+
Function = Google::Protobuf::DescriptorPool.generated_pool.lookup("perftools.profiles.Function").msgclass
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'ddtrace/ext/profiling'
|
2
|
+
require 'ddtrace/profiling/events/stack'
|
3
|
+
require 'ddtrace/profiling/pprof/builder'
|
4
|
+
require 'ddtrace/profiling/pprof/converter'
|
5
|
+
|
6
|
+
module Datadog
|
7
|
+
module Profiling
|
8
|
+
module Pprof
|
9
|
+
# Builds a profile from a StackSample
|
10
|
+
class StackSample < Converter
|
11
|
+
SAMPLE_TYPES = {
|
12
|
+
cpu_time_ns: [
|
13
|
+
Datadog::Ext::Profiling::Pprof::VALUE_TYPE_CPU,
|
14
|
+
Datadog::Ext::Profiling::Pprof::VALUE_UNIT_NANOSECONDS
|
15
|
+
],
|
16
|
+
wall_time_ns: [
|
17
|
+
Datadog::Ext::Profiling::Pprof::VALUE_TYPE_WALL,
|
18
|
+
Datadog::Ext::Profiling::Pprof::VALUE_UNIT_NANOSECONDS
|
19
|
+
]
|
20
|
+
}.freeze
|
21
|
+
|
22
|
+
def self.sample_value_types
|
23
|
+
SAMPLE_TYPES
|
24
|
+
end
|
25
|
+
|
26
|
+
def add_events!(stack_samples)
|
27
|
+
new_samples = build_samples(stack_samples)
|
28
|
+
builder.samples.concat(new_samples)
|
29
|
+
end
|
30
|
+
|
31
|
+
def stack_sample_group_key(stack_sample)
|
32
|
+
stack_sample.hash
|
33
|
+
end
|
34
|
+
|
35
|
+
def build_samples(stack_samples)
|
36
|
+
groups = group_events(stack_samples, &method(:stack_sample_group_key))
|
37
|
+
groups.collect do |_group_key, group|
|
38
|
+
build_sample(group.sample, group.values)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def build_sample(stack_sample, values)
|
43
|
+
locations = builder.build_locations(
|
44
|
+
stack_sample.frames,
|
45
|
+
stack_sample.total_frame_count
|
46
|
+
)
|
47
|
+
|
48
|
+
Perftools::Profiles::Sample.new(
|
49
|
+
location_id: locations.collect(&:id),
|
50
|
+
value: values,
|
51
|
+
label: build_sample_labels(stack_sample)
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
def build_sample_values(stack_sample)
|
56
|
+
no_value = Datadog::Ext::Profiling::Pprof::SAMPLE_VALUE_NO_VALUE
|
57
|
+
values = super(stack_sample)
|
58
|
+
values[sample_value_index(:cpu_time_ns)] = stack_sample.cpu_time_interval_ns || no_value
|
59
|
+
values[sample_value_index(:wall_time_ns)] = stack_sample.wall_time_interval_ns || no_value
|
60
|
+
values
|
61
|
+
end
|
62
|
+
|
63
|
+
def build_sample_labels(stack_sample)
|
64
|
+
labels = [
|
65
|
+
Perftools::Profiles::Label.new(
|
66
|
+
key: builder.string_table.fetch(Datadog::Ext::Profiling::Pprof::LABEL_KEY_THREAD_ID),
|
67
|
+
str: builder.string_table.fetch(stack_sample.thread_id.to_s)
|
68
|
+
)
|
69
|
+
]
|
70
|
+
|
71
|
+
unless stack_sample.trace_id.nil? || stack_sample.trace_id.zero?
|
72
|
+
labels << Perftools::Profiles::Label.new(
|
73
|
+
key: builder.string_table.fetch(Datadog::Ext::Profiling::Pprof::LABEL_KEY_TRACE_ID),
|
74
|
+
str: builder.string_table.fetch(stack_sample.trace_id.to_s)
|
75
|
+
)
|
76
|
+
end
|
77
|
+
|
78
|
+
unless stack_sample.span_id.nil? || stack_sample.span_id.zero?
|
79
|
+
labels << Perftools::Profiles::Label.new(
|
80
|
+
key: builder.string_table.fetch(Datadog::Ext::Profiling::Pprof::LABEL_KEY_SPAN_ID),
|
81
|
+
str: builder.string_table.fetch(stack_sample.span_id.to_s)
|
82
|
+
)
|
83
|
+
end
|
84
|
+
|
85
|
+
labels
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|