Skip to content

Commit

Permalink
enable datadog apm tracing. #420
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Feb 17, 2020
1 parent e9e7474 commit c90ccfe
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ source "https://rubygems.org"
gem "rails", "~> 5.2.0"
gem "bootsnap", "~> 1.4", ">= 1.4.4", require: false
gem "mysql2", "~> 0.4.4"
gem 'ddtrace', '~> 0.32.0'
gem "dotenv"
gem "rake", "~> 12.0"
gem "oj", ">= 2.8.3"
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ GEM
addressable
dalli (2.7.10)
database_cleaner (1.8.2)
ddtrace (0.32.0)
msgpack
debug_inspector (0.0.3)
diff-lcs (1.3)
diffy (3.3.0)
Expand Down Expand Up @@ -580,6 +582,7 @@ DEPENDENCIES
crawler_detect
dalli (~> 2.7, >= 2.7.6)
database_cleaner
ddtrace (~> 0.32.0)
diffy (~> 3.2, >= 3.2.1)
dotenv
elasticsearch (~> 7.1.0)
Expand Down
5 changes: 5 additions & 0 deletions config/initializers/datadog-tracer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

Datadog.configure do |c|
c.use :rails, service_name: "client-api"
end
35 changes: 35 additions & 0 deletions spec/graphql/types/query_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,39 @@
expect(response.dig("data", "datasets", "nodes", 0, "id")).to eq(datasets.first.identifier)
end
end

describe "query for citationCount", elasticsearch: true do
let(:client) { create(:client) }
let(:doi) { create(:doi, client: client, aasm_state: "findable") }
let(:source_doi) { create(:doi, client: client, aasm_state: "findable") }
let(:source_doi2) { create(:doi, client: client, aasm_state: "findable") }
let!(:citation_event) { create(:event_for_datacite_crossref, subj_id: "https://doi.org/#{doi.doi}", obj_id: "https://doi.org/#{source_doi.doi}", relation_type_id: "is-referenced-by", occurred_at: "2015-06-13T16:14:19Z") }
let!(:citation_event2) { create(:event_for_datacite_crossref, subj_id: "https://doi.org/#{doi.doi}", obj_id: "https://doi.org/#{source_doi2.doi}", relation_type_id: "is-referenced-by", occurred_at: "2016-06-13T16:14:19Z") }

before do
Doi.import
Event.import
sleep 1
end

let(:query) do
%(query {
datasets {
totalCount
nodes {
id
citationCount
}
}
})
end

it "returns all datasets" do
response = LupoSchema.execute(query).as_json

expect(response.dig("data", "datasets", "totalCount")).to eq(3)
expect(response.dig("data", "datasets", "nodes").length).to eq(3)
expect(response.dig("data", "datasets", "nodes", 0, "citationCount")).to eq(2)
end
end
end

0 comments on commit c90ccfe

Please sign in to comment.