Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CIAPP-2959] CI visibility protocol and agentless mode support #33

Merged
merged 45 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
0cf248e
implement CI's own instrument method, remove dependency on Datadog::T…
anmarchenko Sep 15, 2023
4831625
continuing decoupling with Tracing where possible
anmarchenko Sep 15, 2023
e7a1218
migrate patchable and configurable logic for integration from tracing
anmarchenko Sep 18, 2023
54de03b
fix law of demeter violation between settings and integration
anmarchenko Sep 18, 2023
ebfad99
simplify registry and remove RegisteredIntegration struct
anmarchenko Sep 18, 2023
003eb82
clean up "CI mode activated" shared context and remove hacky access t…
anmarchenko Sep 18, 2023
f741f3a
agentless_mode_enabled and api_key settings
anmarchenko Sep 18, 2023
48f786b
rename Ci::Test to CI::Recorder
anmarchenko Sep 18, 2023
0eede7c
trace serializers structure
anmarchenko Sep 18, 2023
a4be724
serializer must handle TraceSegment
anmarchenko Sep 18, 2023
82534bc
add msgpack to dependencies
anmarchenko Sep 19, 2023
2a854ff
early structure for test visibility, transports and events
anmarchenko Sep 19, 2023
cd2d070
move contrib tracer helpers to common helpers;
anmarchenko Sep 20, 2023
0ce035b
serializable span event
anmarchenko Sep 20, 2023
040773c
extract serialization logic to the base serializer
anmarchenko Sep 20, 2023
622305a
fix static type checks
anmarchenko Sep 21, 2023
777899f
cleaning up tests, test serialization of failed test event
anmarchenko Sep 21, 2023
648e839
test serializers with custom metrics and custom tags
anmarchenko Sep 21, 2023
896b299
test serialization of start and duration fields
anmarchenko Sep 21, 2023
6d3358c
remove api_key configuration option as it already exists in ddtrace c…
anmarchenko Sep 21, 2023
cde9e0d
add http transport
anmarchenko Sep 21, 2023
7faa73e
test visibility transport - first stab
anmarchenko Sep 22, 2023
64be17c
construct agentless transport in CI component
anmarchenko Sep 22, 2023
abc35e0
make content fields and size calculation constants to save time and m…
anmarchenko Sep 22, 2023
f6e06c4
fixes to make agentless mode work
anmarchenko Sep 22, 2023
688eee3
use async writer
anmarchenko Sep 25, 2023
126fd87
filter invalid events (implement validation later)
anmarchenko Sep 25, 2023
6f14125
use async test mode from ddtrace tracing module
anmarchenko Sep 26, 2023
a3aafba
spec for test visibility transport
anmarchenko Sep 27, 2023
20b7a22
empty events list case for transport
anmarchenko Sep 27, 2023
097cf4d
fix payload packing on jruby
anmarchenko Sep 27, 2023
d8b473a
test components setup
anmarchenko Sep 27, 2023
62f1845
event validation, optimize serializable events creation
anmarchenko Sep 27, 2023
ac867ce
introduce factories concept for serializers
anmarchenko Sep 28, 2023
2aba5f3
move Flush to the test_visibility module
anmarchenko Sep 28, 2023
dd40bb8
preparation for enabling chunking: directly encode spans to msgpack
anmarchenko Sep 28, 2023
327d1df
add chunking to make sure request size is not bigger than 4Mb
anmarchenko Sep 28, 2023
3272d7c
gzip encoding for citestcycle intake requests
anmarchenko Sep 28, 2023
d8cf27f
remove headers logging for security reasons;
anmarchenko Sep 28, 2023
d1b1495
agentless mode and additional configuration readme
anmarchenko Sep 29, 2023
1949268
log when events are too large to be submitted
anmarchenko Sep 29, 2023
6cc85b6
make agentless intake URL configurable in order to use it in test-env…
anmarchenko Sep 29, 2023
98b0f06
cleanup and code review suggestions
anmarchenko Oct 2, 2023
d69bfef
add env tag to metadata
anmarchenko Oct 2, 2023
db394f0
extract build_agentless_transport method
anmarchenko Oct 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ gem "ddtrace"

gem "pry"
gem "rake"
gem "rspec"
gem "os"

gem "climate_control"

gem "rspec"
gem "rspec-collection_matchers"
gem "rspec_junit_formatter"
gem "appraisal"
gem "timecop"

gem "standard", "~> 1.31.0"

gem "yard"
Expand Down
1 change: 1 addition & 0 deletions LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Component,Origin,License,Copyright
dd-trace-rb,https://github.com/DataDog/dd-trace-rb,Apache 2.0,"Copyright 2016-Present Datadog, Inc."
msgpack,https://rubygems.org/gems/msgpack,Apache-2.0,"Copyright (c) 2008-2015 Sadayuki Furuhashi"
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,72 @@ end
| `service_name` | Service name used for `cucumber` instrumentation. | `'cucumber'` |
| `operation_name` | Operation name used for `cucumber` instrumentation. Useful if you want rename automatic trace metrics e.g. `trace.#{operation_name}.errors`. | `'cucumber.test'` |

## Agentless mode

If you are using a cloud CI provider without access to the underlying worker nodes, such as GitHub Actions or CircleCI, configure the library to use the Agentless mode. For this, set the following environment variables:
`DD_CIVISIBILITY_AGENTLESS_ENABLED=true (Required)` and `DD_API_KEY=your_secret_api_key (Required)`.

Additionally, configure which [Datadog site](https://docs.datadoghq.com/getting_started/site/) you want to send data to:
`DD_SITE=your.datadoghq.com` (datadoghq.com by default).

Agentless mode can be enabled via `Datadog.configure` (but don't forget to set DD_API_KEY environment variable):
anmarchenko marked this conversation as resolved.
Show resolved Hide resolved

```ruby
Datadog.configure { |c| c.ci.agentless_mode_enabled = true }
```

## Additional configuration

### Add tracing instrumentations

It can be useful to have rich tracing information about your tests that includes time spent performing database operations
or other external calls like here:

![Test trace with redis instrumented](./docs/screenshots/test-trace-with-redis.png)
juan-fernandez marked this conversation as resolved.
Show resolved Hide resolved

In order to achieve this you can configure ddtrace instrumentations in your configure block:

```ruby
Datadog.configure do |c|
# ... ci configs and instrumentation here ...
c.instrument :redis
c.instrument :pg
end
```

...or enable auto instrumentation in your test_helper/spec_helper:

```ruby
require "ddtrace/auto_instrument"
```

Note: in CI mode these traces are going to be submitted to CI visibility backend,
they will **not** be submitted to Datadog APM.
anmarchenko marked this conversation as resolved.
Show resolved Hide resolved

For the full list of available instrumentations see [ddtrace documentation](https://github.com/DataDog/dd-trace-rb/blob/master/docs/GettingStarted.md)

### Disabling startup logs

Startup logs produce a report of tracing state when the application is initially configured.
These logs are activated by default in test mode, if you don't want them you can disable this
juan-fernandez marked this conversation as resolved.
Show resolved Hide resolved
via `diagnostics.startup_logs.enabled = false` or `DD_TRACE_STARTUP_LOGS=0`.

```ruby
Datadog.configure { |c| c.diagnostics.startup_logs.enabled = false }
```

### Enabling debug mode

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, confirming trace output, or catching HTTP transport issues.

You can enable this via `diagnostics.debug = true` or `DD_TRACE_DEBUG`.
anmarchenko marked this conversation as resolved.
Show resolved Hide resolved

```ruby
Datadog.configure { |c| c.diagnostics.debug = true }
```

**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.
juan-fernandez marked this conversation as resolved.
Show resolved Hide resolved

## Contributing

See [development guide](/docs/DevelopmentGuide.md), [static typing guide](docs/StaticTypingGuide.md) and [contributing guidelines](/CONTRIBUTING.md).
Expand Down
2 changes: 2 additions & 0 deletions Steepfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ target :lib do
check "lib"

ignore "lib/datadog/ci/configuration/settings.rb"
ignore "lib/datadog/ci/transport/gzip.rb"

library "pathname"
library "json"
Expand All @@ -18,4 +19,5 @@ target :lib do
library "open3"
library "rspec"
library "cucumber"
library "msgpack"
end
2 changes: 2 additions & 0 deletions datadog-ci.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ Gem::Specification.new do |spec|
]].select { |fn| File.file?(fn) } # We don't want directories, only files

spec.require_paths = ["lib"]

spec.add_dependency "msgpack"
end
Binary file added docs/screenshots/test-trace-with-redis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion gemfiles/jruby_9.4.0.0_cucumber_3.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ source "https://rubygems.org"
gem "ddtrace"
gem "pry"
gem "rake"
gem "rspec"
gem "os"
gem "climate_control"
gem "rspec"
gem "rspec-collection_matchers"
gem "rspec_junit_formatter"
gem "appraisal"
gem "timecop"
gem "standard", "~> 1.31.0"
gem "yard"
gem "webrick"
Expand Down
3 changes: 3 additions & 0 deletions gemfiles/jruby_9.4.0.0_cucumber_3.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ PATH
remote: ..
specs:
datadog-ci (0.1.1)
msgpack

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -126,6 +127,7 @@ GEM
lint_roller (~> 1.1)
rubocop-performance (~> 1.19.0)
thor (1.2.2)
timecop (0.9.8)
unicode-display_width (2.4.2)
webrick (1.8.1)
yard (0.9.34)
Expand All @@ -149,6 +151,7 @@ DEPENDENCIES
simplecov
simplecov-cobertura (~> 2.1.0)
standard (~> 1.31.0)
timecop
webrick
yard

Expand Down
3 changes: 2 additions & 1 deletion gemfiles/jruby_9.4.0.0_cucumber_4.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ source "https://rubygems.org"
gem "ddtrace"
gem "pry"
gem "rake"
gem "rspec"
gem "os"
gem "climate_control"
gem "rspec"
gem "rspec-collection_matchers"
gem "rspec_junit_formatter"
gem "appraisal"
gem "timecop"
gem "standard", "~> 1.31.0"
gem "yard"
gem "webrick"
Expand Down
3 changes: 3 additions & 0 deletions gemfiles/jruby_9.4.0.0_cucumber_4.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ PATH
remote: ..
specs:
datadog-ci (0.1.1)
msgpack

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -156,6 +157,7 @@ GEM
ffi (~> 1.1)
thor (1.2.2)
thread_safe (0.3.6-java)
timecop (0.9.8)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.4.2)
Expand All @@ -181,6 +183,7 @@ DEPENDENCIES
simplecov
simplecov-cobertura (~> 2.1.0)
standard (~> 1.31.0)
timecop
webrick
yard

Expand Down
3 changes: 2 additions & 1 deletion gemfiles/jruby_9.4.0.0_cucumber_5.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ source "https://rubygems.org"
gem "ddtrace"
gem "pry"
gem "rake"
gem "rspec"
gem "os"
gem "climate_control"
gem "rspec"
gem "rspec-collection_matchers"
gem "rspec_junit_formatter"
gem "appraisal"
gem "timecop"
gem "standard", "~> 1.31.0"
gem "yard"
gem "webrick"
Expand Down
3 changes: 3 additions & 0 deletions gemfiles/jruby_9.4.0.0_cucumber_5.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ PATH
remote: ..
specs:
datadog-ci (0.1.1)
msgpack

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -156,6 +157,7 @@ GEM
ffi (~> 1.1)
thor (1.2.2)
thread_safe (0.3.6-java)
timecop (0.9.8)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.4.2)
Expand All @@ -181,6 +183,7 @@ DEPENDENCIES
simplecov
simplecov-cobertura (~> 2.1.0)
standard (~> 1.31.0)
timecop
webrick
yard

Expand Down
3 changes: 2 additions & 1 deletion gemfiles/jruby_9.4.0.0_cucumber_6.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ source "https://rubygems.org"
gem "ddtrace"
gem "pry"
gem "rake"
gem "rspec"
gem "os"
gem "climate_control"
gem "rspec"
gem "rspec-collection_matchers"
gem "rspec_junit_formatter"
gem "appraisal"
gem "timecop"
gem "standard", "~> 1.31.0"
gem "yard"
gem "webrick"
Expand Down
3 changes: 3 additions & 0 deletions gemfiles/jruby_9.4.0.0_cucumber_6.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ PATH
remote: ..
specs:
datadog-ci (0.1.1)
msgpack

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -160,6 +161,7 @@ GEM
ffi (~> 1.1)
thor (1.2.2)
thread_safe (0.3.6-java)
timecop (0.9.8)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.4.2)
Expand All @@ -185,6 +187,7 @@ DEPENDENCIES
simplecov
simplecov-cobertura (~> 2.1.0)
standard (~> 1.31.0)
timecop
webrick
yard

Expand Down
3 changes: 2 additions & 1 deletion gemfiles/jruby_9.4.0.0_cucumber_7.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ source "https://rubygems.org"
gem "ddtrace"
gem "pry"
gem "rake"
gem "rspec"
gem "os"
gem "climate_control"
gem "rspec"
gem "rspec-collection_matchers"
gem "rspec_junit_formatter"
gem "appraisal"
gem "timecop"
gem "standard", "~> 1.31.0"
gem "yard"
gem "webrick"
Expand Down
3 changes: 3 additions & 0 deletions gemfiles/jruby_9.4.0.0_cucumber_7.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ PATH
remote: ..
specs:
datadog-ci (0.1.1)
msgpack

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -142,6 +143,7 @@ GEM
sys-uname (1.2.3)
ffi (~> 1.1)
thor (1.2.2)
timecop (0.9.8)
unicode-display_width (2.4.2)
webrick (1.8.1)
yard (0.9.34)
Expand All @@ -165,6 +167,7 @@ DEPENDENCIES
simplecov
simplecov-cobertura (~> 2.1.0)
standard (~> 1.31.0)
timecop
webrick
yard

Expand Down
3 changes: 2 additions & 1 deletion gemfiles/jruby_9.4.0.0_cucumber_8.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ source "https://rubygems.org"
gem "ddtrace"
gem "pry"
gem "rake"
gem "rspec"
gem "os"
gem "climate_control"
gem "rspec"
gem "rspec-collection_matchers"
gem "rspec_junit_formatter"
gem "appraisal"
gem "timecop"
gem "standard", "~> 1.31.0"
gem "yard"
gem "webrick"
Expand Down
3 changes: 3 additions & 0 deletions gemfiles/jruby_9.4.0.0_cucumber_8.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ PATH
remote: ..
specs:
datadog-ci (0.1.1)
msgpack

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -136,6 +137,7 @@ GEM
sys-uname (1.2.3)
ffi (~> 1.1)
thor (1.2.2)
timecop (0.9.8)
unicode-display_width (2.4.2)
webrick (1.8.1)
yard (0.9.34)
Expand All @@ -159,6 +161,7 @@ DEPENDENCIES
simplecov
simplecov-cobertura (~> 2.1.0)
standard (~> 1.31.0)
timecop
webrick
yard

Expand Down
3 changes: 2 additions & 1 deletion gemfiles/jruby_9.4.0.0_minitest_5.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ source "https://rubygems.org"
gem "ddtrace"
gem "pry"
gem "rake"
gem "rspec"
gem "os"
gem "climate_control"
gem "rspec"
gem "rspec-collection_matchers"
gem "rspec_junit_formatter"
gem "appraisal"
gem "timecop"
gem "standard", "~> 1.31.0"
gem "yard"
gem "webrick"
Expand Down
3 changes: 3 additions & 0 deletions gemfiles/jruby_9.4.0.0_minitest_5.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ PATH
remote: ..
specs:
datadog-ci (0.1.1)
msgpack

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -106,6 +107,7 @@ GEM
lint_roller (~> 1.1)
rubocop-performance (~> 1.19.0)
thor (1.2.2)
timecop (0.9.8)
unicode-display_width (2.4.2)
webrick (1.8.1)
yard (0.9.34)
Expand All @@ -129,6 +131,7 @@ DEPENDENCIES
simplecov
simplecov-cobertura (~> 2.1.0)
standard (~> 1.31.0)
timecop
webrick
yard

Expand Down
Loading