Skip to content

Commit bd9ed96

Browse files
committed
Merge branch 'yann/metric-query' into staging
2 parents 252ceee + cff788a commit bd9ed96

File tree

341 files changed

+5812
-1740
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

341 files changed

+5812
-1740
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ vendor/*
1313
.idea
1414
output.tgz
1515
remote-compile.sh
16+
code_test
17+
tested.code

Checks

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
check :no_api_keys do
3+
self.output_filenames.each do |fn|
4+
if match=File.read(fn).force_encoding("ISO-8859-1").encode("utf-8", replace: nil).match(/\b([0-9a-f]){32}(?<!9775a026f1ca7d1c6c5af9d94d9595a4)(?![0-9a-f])/)
5+
self.add_issue("API Key in here!! - #{match}\nPlease use 9775a026f1ca7d1c6c5af9d94d9595a4 as the API Key", :subject => fn)
6+
end
7+
end
8+
end

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ group :development do
1717
gem 'rack-contrib'
1818
gem 'rack-livereload'
1919
gem 'guard-rake'
20+
gem 'digest'
2021
end

Gemfile.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ GEM
99
colored (1.2)
1010
cri (2.6.1)
1111
colored (~> 1.2)
12+
digest (0.0.1)
1213
dogapi (1.13.0)
1314
json (>= 1.5.1)
1415
em-websocket (0.5.1)
@@ -105,6 +106,7 @@ PLATFORMS
105106

106107
DEPENDENCIES
107108
builder
109+
digest
108110
dogapi (~> 1.13.0)
109111
guard-livereload
110112
guard-nanoc

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ for any bad links, and refresh your browser.
4141

4242
Before you push, make sure you verify there are no bad links.
4343

44-
# Your final step should be to exit rake, then run ```rake clean``` then ```rake```. If there are no errors, then and only then push and merge. If there are errors, please don't merge
44+
# Your final step should be to exit rake, then run ```rake clean``` then ```rake```. If there are no errors, then and only then push and merge. If there are errors, please don't merge. If you have been working on code samples, run ```rake clean``` then ```rake test```. If you didn't work on code samples, don't bother with test.
45+
46+
If you are using rake test, you need an environment variable for DD_API_KEY and DD_APP_KEY. These should be for a test account that does not include dozens of people. There are several samples that mute and unmute everything. Everyone in the org will be notified. If you are the only one in the org, you won't be getting angry emails from others asking you to stop muting everything.
4547

4648
## How to add a new integration
4749

Rakefile

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
require 'rake/clean'
22

3-
CLEAN.include(%w(output tmp))
3+
4+
CLEAN.include(%w(output tmp code_test tested.code))
45

56
CODE_SNIPPETS = 'code_snippets'
7+
CODE_TEST = 'code_test'
68

79
desc 'Check site links'
810
task :checks do
9-
sh 'bundle exec nanoc check ilinks stale'
11+
sh 'bundle exec nanoc check ilinks stale no_api_keys'
1012
end
1113

1214
desc 'Build documentation site'
@@ -43,19 +45,56 @@ end
4345

4446
desc 'test the code snippets'
4547
task :test do
48+
require 'digest/md5'
49+
sh("rm -rf #{CODE_TEST}")
50+
sh("mkdir #{CODE_TEST}")
4651
filetype_to_command = {
47-
'py' => 'python',
4852
'sh' => 'sh',
53+
'py' => 'python',
4954
'rb' => 'ruby'
5055
}
51-
filetype_to_command.each do |t, cmd|
52-
puts '=' * 10
53-
puts "Testing #{t} code snippets"
54-
files = Dir.glob("#{CODE_SNIPPETS}/*.#{t}")
55-
files.each do |f|
56-
sh("#{cmd} #{f}")
56+
begin
57+
unless File.exist?('tested.code')
58+
File.open("tested.code", "w") {}
59+
end
60+
filetype_to_command.each do |t, cmd|
61+
puts '=' * 10
62+
puts "Testing #{t} code snippets"
63+
files = Dir.glob("#{CODE_SNIPPETS}/*.#{t}")
64+
files.each do |f|
65+
# sh("cp #{f} #{CODE_TEST}/")
66+
text = File.read(f)
67+
new_contents = text.gsub(/9775a026f1ca7d1c6c5af9d94d9595a4/, ENV['DD_API_KEY'])
68+
new_contents = new_contents.gsub(/87ce4a24b5553d2e482ea8a8500e71b8ad4554ff/, ENV['DD_APP_KEY'])
69+
if cmd == 'sh'
70+
new_contents << 'echo $?'
71+
end
72+
File.open("#{CODE_TEST}/#{File.basename(f)}", "w") {|file| file.puts new_contents}
73+
end
74+
testfiles = Dir.glob("#{CODE_TEST}/*.#{t}")
75+
testfiles.each do |f|
76+
unless f.include?('guides-')
77+
md5 = Digest::MD5.file(f).hexdigest
78+
if File.read('tested.code').include?("#{f} #{md5}\n")
79+
print "Already tested #{f}"
80+
else
81+
starttime = Time.now()
82+
sh("#{cmd} #{f}")
83+
totaltime = Time.now() - starttime
84+
print "\nExecution Time: #{totaltime}s\n"
85+
open('tested.code', 'a') do |file|
86+
file << "#{f} #{md5}\n"
87+
end
88+
end
89+
sh("rm #{f}")
90+
end
91+
end
5792
end
93+
rescue Exception => e
94+
sh("rm -rf #{CODE_TEST}")
95+
raise e
5896
end
97+
sh("rm -rf #{CODE_TEST}")
5998
end
6099

61100
desc 'Run Guard, autobuilds/reloads site'

Rules

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ require './lib/rule_helper'
1919
preprocess do
2020
create_tag_pages(example_items,{:identifier => "/examples/%%tag%%/"})
2121
create_tag_pages(video_items,{:identifier => "/videos/%%tag%%/"})
22+
create_tag_pages(ja_example_items,{:identifier => "/ja/examples/%%tag%%/", :template => "example-subindex-ja"})
23+
create_tag_pages(ja_video_items,{:identifier => "/ja/videos/%%tag%%/", :template => "video-subindex-ja"})
2224
end
2325

2426
compile 'sitemap' do
@@ -66,13 +68,21 @@ compile '*' do
6668
layout 'shell'
6769
when id.match('/ja/guides/basic_agent_usage/')
6870
layout 'basic_agent_usage-ja'
69-
when id.match('/guides/basic_agent_usage/')
70-
layout 'basic_agent_usage'
71+
when id.match('/ja/integrations') && @item[:kind] == 'integration' && @item[:language] == 'ja'
72+
layout 'integration_layout-ja'
73+
when id.match('/ja/examples/') && @item[:kind] == 'example' && @item[:language] == 'ja'
74+
layout 'examplelayout-ja'
75+
when id.match('/ja/videos/') && @item[:kind] == 'video' && @item[:language] == 'ja'
76+
layout 'videolayout-ja'
77+
when id.match('/ja/guides/') && @item[:kind] == 'guide' && @item[:language] == 'ja'
78+
layout 'guide_layout-ja'
7179
when id.match('/ja/')
7280
layout 'default-ja'
81+
when id.match('/guides/basic_agent_usage/')
82+
layout 'basic_agent_usage'
7383
when id.match('/integrations') && @item[:kind] == 'integration'
7484
layout 'integration_layout'
75-
when id.match('/examples/') && @item[:kind] == 'example'
85+
when id.match('/examples/') && @item[:kind] == 'example'
7686
layout 'examplelayout'
7787
when id.match('/videos/') && @item[:kind] == 'video'
7888
layout 'videolayout'

code_snippets/api-alert-create.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

code_snippets/api-alert-create.rb

Lines changed: 0 additions & 10 deletions
This file was deleted.

code_snippets/api-alert-create.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)