Skip to content

Commit

Permalink
Merge pull request #3979 from DataDog/ivoanjo/fix-profiler-specs-ruby…
Browse files Browse the repository at this point in the history
…-head

[NO-TICKET] Profiling: Minor cleanup to error messages
  • Loading branch information
ivoanjo authored Oct 7, 2024
2 parents 56038a3 + dcf347e commit 272a75c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 29 deletions.
2 changes: 1 addition & 1 deletion lib/datadog/profiling/http_transport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def do_export(
end

def config_without_api_key
[exporter_configuration[0..1]].to_h
"#{exporter_configuration[0]}: #{exporter_configuration[1]}"
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion sig/datadog/profiling/http_transport.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ module Datadog
::String info_json,
) -> [:ok | :error, ::Integer | ::String]

def config_without_api_key: () -> ::Hash[:agent | :agentless, ::String]
def config_without_api_key: () -> ::String
end
end
end
29 changes: 2 additions & 27 deletions spec/datadog/profiling/http_transport_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@

it "logs an error message" do
expect(Datadog.logger).to receive(:error).with(
'Failed to report profiling data ({:agent=>"http://192.168.0.1:12345/"}): ' \
"Failed to report profiling data (agent: http://192.168.0.1:12345/): " \
"server returned unexpected HTTP 500 status code"
)

Expand All @@ -252,7 +252,7 @@

it "logs an error message" do
expect(Datadog.logger).to receive(:error)
.with('Failed to report profiling data ({:agent=>"http://192.168.0.1:12345/"}): Some error message')
.with("Failed to report profiling data (agent: http://192.168.0.1:12345/): Some error message")

export
end
Expand All @@ -270,31 +270,6 @@
end
end

describe "#config_without_api_key" do
subject(:config_without_api_key) { http_transport.send(:config_without_api_key) }

context "when using agentless mode" do
let(:site) { "test.datadoghq.com" }
let(:api_key) { SecureRandom.uuid }

around do |example|
ClimateControl.modify("DD_PROFILING_AGENTLESS" => "true") do
example.run
end
end

it "returns the mode and site, but not the api key" do
is_expected.to eq(agentless: "test.datadoghq.com")
end
end

context "when using agent mode" do
it "returns the mode the agent url" do
is_expected.to eq(agent: "http://192.168.0.1:12345/")
end
end
end

describe "#exporter_configuration" do
it "returns the current exporter configuration" do
expect(http_transport.exporter_configuration).to eq [:agent, "http://192.168.0.1:12345/"]
Expand Down

0 comments on commit 272a75c

Please sign in to comment.