Skip to content

Commit

Permalink
Db/agent5 apm (#203)
Browse files Browse the repository at this point in the history
* Enable trace agent for windows/agent5

* Replace datadog-trace-agent definition with the one from agent6

* Modify existing recipe to do Windows in the same manner

* Add service definition to msi

* Fix declaration of extra_package_dir for integration package builds

* Work around 'docs' directory, which isn't a check directory and confuses
the build when we build all checks
  • Loading branch information
derekwbrown authored and olivielpeau committed Nov 1, 2017
1 parent aa59304 commit 9d1d3c3
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 16 deletions.
3 changes: 2 additions & 1 deletion Rakefile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def windows?()
PROJECT_DIR='/dd-agent-omnibus'
FSROOT="/"
end
default_skip_checks=['docs']

default_skip_checks = ['docs']

Expand Down Expand Up @@ -86,7 +87,7 @@ def windows?()
checks.each do |check|
check.slice! "/#{ENV['INTEGRATIONS_REPO']}/"
check.slice! "/"
unless skip_checks.include? check
unless ((skip_checks.include? check) || (default_skip_checks.include? check))
prepare_and_execute_build(check)
Rake::Task["agent:clean"].invoke
end
Expand Down
4 changes: 3 additions & 1 deletion config/projects/datadog-agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,10 @@
if windows?
dependency 'datadog-upgrade-helper'
end

dependency 'datadog-trace-agent'

if linux?
dependency 'datadog-trace-agent'
dependency 'datadog-process-agent'
end

Expand Down
60 changes: 46 additions & 14 deletions config/software/datadog-trace-agent.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
name "datadog-trace-agent"

require "./lib/ostools.rb"
require 'pathname'

source git: 'https://github.com/DataDog/datadog-trace-agent.git'

trace_agent_branch = ENV['TRACE_AGENT_BRANCH']
Expand All @@ -14,19 +18,36 @@

dd_agent_version = ENV['AGENT_VERSION']

gourl = "https://storage.googleapis.com/golang/go1.8.linux-amd64.tar.gz"
goout = "go.tar.gz"
godir = "/usr/local/go18"
gobin = "#{godir}/go/bin/go"
gopath = "#{Omnibus::Config.cache_dir}/src/#{name}"

agent_source_dir = "#{Omnibus::Config.source_dir}/datadog-trace-agent"
glide_cache_dir = "#{gopath}/src/github.com/Masterminds/glide"
agent_cache_dir = "#{gopath}/src/github.com/DataDog/datadog-trace-agent"
if windows?
trace_agent_bin = "trace-agent.exe"
gourl = "https://storage.googleapis.com/golang/go1.8.1.windows-amd64.zip"
goout = "go.zip"
godir = "c:/go18"
gobin = "#{godir}/go/bin/go"
gopath = "#{Omnibus::Config.cache_dir}/src/#{name}"

agent_source_dir = "#{Omnibus::Config.source_dir}/datadog-trace-agent"
glide_cache_dir = "#{gopath}/src/github.com/Masterminds/glide"
agent_cache_dir = "#{gopath}/src/github.com/DataDog/datadog-trace-agent"

else
trace_agent_bin = "trace-agent"
gourl = "https://storage.googleapis.com/golang/go1.8.linux-amd64.tar.gz"
goout = "go.tar.gz"
godir = "/usr/local/go18"
gobin = "#{godir}/go/bin/go"
gopath = "#{Omnibus::Config.cache_dir}/src/#{name}"

agent_source_dir = "#{Omnibus::Config.source_dir}/datadog-trace-agent"
glide_cache_dir = "#{gopath}/src/github.com/Masterminds/glide"
agent_cache_dir = "#{gopath}/src/github.com/DataDog/datadog-trace-agent"

end

env = {
"GOPATH" => gopath,
"GOROOT" => "/usr/local/go18/go",
"GOROOT" => "#{godir}/go",
"PATH" => "#{godir}/go/bin:#{ENV["PATH"]}",
"TRACE_AGENT_VERSION" => dd_agent_version, # used by gorake.rb in the trace-agent
"TRACE_AGENT_ADD_BUILD_VARS" => trace_agent_add_build_vars.to_s(),
Expand All @@ -37,13 +58,22 @@

# download go
command "curl #{gourl} -o #{goout}"

delete godir
mkdir godir
command "tar zxfv #{goout} -C #{godir}"

if windows?
command "7z x -o#{godir} #{goout} "
else
command "tar zxfv #{goout} -C #{godir}"
end
delete goout

# Put datadog-trace-agent into a valid GOPATH
mkdir "#{gopath}/src/github.com/DataDog/"
delete "#{gopath}/src/github.com/DataDog/datadog-trace-agent"
move agent_source_dir, "#{gopath}/src/github.com/DataDog/"
mkdir "#{gopath}/src/github.com/DataDog/datadog-trace-agent"
move "#{agent_source_dir}/*", "#{gopath}/src/github.com/DataDog/datadog-trace-agent"

# Checkout datadog-trace-agent's build dependencies
command "#{gobin} get -d github.com/Masterminds/glide", :env => env, :cwd => agent_cache_dir
Expand All @@ -53,12 +83,14 @@
command "#{gobin} install github.com/Masterminds/glide", :env => env, :cwd => glide_cache_dir

# Build datadog-trace-agent
command "$GOPATH/bin/glide install", :env => env, :cwd => agent_cache_dir
command "#{gopath}/bin/glide install", :env => env, :cwd => agent_cache_dir
if rhel? # temporary workaround for RHEL 5 build issue with the regular `build -a` command
command "rake install", :env => env, :cwd => agent_cache_dir
command "mv $GOPATH/bin/trace-agent #{install_dir}/bin/trace-agent", :env => env, :cwd => agent_cache_dir
command "mv $GOPATH/bin/#{trace_agent_bin} #{install_dir}/bin/#{trace_agent_bin}", :env => env, :cwd => agent_cache_dir
else
command "rake build", :env => env, :cwd => agent_cache_dir
command "mv ./trace-agent #{install_dir}/bin/trace-agent", :env => env, :cwd => agent_cache_dir
command "mv ./#{trace_agent_bin} #{install_dir}/bin/#{trace_agent_bin}", :env => env, :cwd => agent_cache_dir
end
# clean up extra go compiler
delete godir
end
29 changes: 29 additions & 0 deletions resources/datadog-agent/msi/source.wxs.erb
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,34 @@
<RemoveFolder Id="APPLICATIONROOTDIRECTORY" On="uninstall" />
</Component>
</Directory>
<Directory Id="BIN" Name="bin">
<!-- Windows service declaration for APM agent -->
<Component Id="DATADOGAPMSERVICE" Guid="a8e611fa-aedb-4c16-969c-bb827af0bd53">
<File Id="trace_agent.exe"
Name="trace-agent.exe"
Vital="yes"
KeyPath="yes"
DiskId="1"
Source="$(var.InstallDir)/bin/trace-agent.exe"/>
<ServiceInstall Id="DatadogAPMServiceInstaller"
DisplayName="Datadog Trace Agent"
Description="Send metrics to Datadog"
Name="datadog-trace-agent"
ErrorControl="ignore"
Start="demand"
Type="ownProcess"
Vital="yes"
Interactive="no"
Account="LocalSystem">
<ServiceDependency Id="datadogagent" />
</ServiceInstall>
<ServiceControl Id="DatadogAPMStartService"
Name="datadog-trace-agent"
Stop="both"
Remove="uninstall"
Wait="no" />
</Component>
</Directory>
</DirectoryRef>

<!-- Datadog Agent specific directory definitions -->
Expand Down Expand Up @@ -268,6 +296,7 @@
<ComponentRef Id="checks.d" />
<ComponentRef Id="ApplicationShortcut" />
<ComponentRef Id="DATADOGAGENTSERVICE" />
<ComponentRef Id="DATADOGAPMSERVICE" />
<ComponentGroupRef Id="ExtraEXAMPLECONFSLOCATION" />
<ComponentRef Id="CleanupMainApplicationFolder" />
<ComponentRef Id="RegisterConfVariables" />
Expand Down

0 comments on commit 9d1d3c3

Please sign in to comment.