Skip to content

Commit

Permalink
Remove instrumented httpoison module
Browse files Browse the repository at this point in the history
  • Loading branch information
binaryseed committed Jan 7, 2025
1 parent 2d7eeae commit 9807849
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 150 deletions.
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ defmodule MyExternalService do
end
```

#### Pre-Instrumented Modules
#### Mix Tasks

`NewRelic.Instrumented.Mix.Task` To enable the agent and record an Other Transaction during a `Mix.Task`, simply `use NewRelic.Instrumented.Mix.Task`. This will ensure the agent is properly started, records a Transaction, and is shut down.

Expand All @@ -175,13 +175,6 @@ defmodule Mix.Tasks.Example do
end
```

`NewRelic.Instrumented.HTTPoison` Automatically wraps HTTP calls in a span, and adds an outbound header to track the request as part of a Distributed Trace.

```elixir
alias NewRelic.Instrumented.HTTPoison
HTTPoison.get("http://www.example.com")
```

#### Other Transactions

You may start an "Other" Transaction for non-HTTP related work. This could used be while consuming from a message queue, for example.
Expand Down
4 changes: 2 additions & 2 deletions lib/new_relic.ex
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ defmodule NewRelic do
```elixir
NewRelic.set_span(:generic, some: "attribute")
NewRelic.set_span(:http, url: "https://elixir-lang.org", method: "GET", component: "HTTPoison")
NewRelic.set_span(:http, url: "https://elixir-lang.org", method: "GET", component: "HttpClient")
NewRelic.set_span(:datastore, statement: statement, instance: instance, address: address,
hostname: hostname, component: component)
Expand All @@ -197,7 +197,7 @@ defmodule NewRelic do
of an incoming Distributed Trace, but outgoing requests need an extra header:
```elixir
HTTPoison.get(url, ["x-api-key": "secret"] ++ NewRelic.distributed_trace_headers(:http))
Req.get(url, headers: ["x-api-key": "secret"] ++ NewRelic.distributed_trace_headers(:http))
```
## Notes
Expand Down
132 changes: 0 additions & 132 deletions lib/new_relic/instrumented/httpoison.ex

This file was deleted.

8 changes: 4 additions & 4 deletions test/infinite_tracing_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ defmodule InfiniteTracingTest do
@trace {:http_request, category: :external}
def http_request do
Process.sleep(10)
NewRelic.set_span(:http, url: "http://example.com", method: "GET", component: "HTTPoison")
NewRelic.set_span(:http, url: "http://example.com", method: "GET", component: "HttpClient")
"bar"
end
end
Expand Down Expand Up @@ -169,7 +169,7 @@ defmodule InfiniteTracingTest do

nested_external_span =
Enum.find(spans, fn %{attributes: attr} ->
attr[:name] == "External/example.com/HTTPoison/GET"
attr[:name] == "External/example.com/HttpClient/GET"
end)

[[_intrinsics, tx_event]] = TestHelper.gather_harvest(Collector.TransactionEvent.Harvester)
Expand Down Expand Up @@ -242,11 +242,11 @@ defmodule InfiniteTracingTest do
assert nested_external_span.attributes[:"duration.ms"] >= 10
assert nested_external_span.attributes[:"duration.ms"] < 20
assert nested_external_span.attributes[:category] == "http"
assert nested_external_span.attributes[:name] == "External/example.com/HTTPoison/GET"
assert nested_external_span.attributes[:name] == "External/example.com/HttpClient/GET"
assert nested_external_span.attributes[:"http.url"] == "http://example.com"
assert nested_external_span.attributes[:"http.method"] == "GET"
assert nested_external_span.attributes[:"span.kind"] == "client"
assert nested_external_span.attributes[:component] == "HTTPoison"
assert nested_external_span.attributes[:component] == "HttpClient"
assert nested_external_span.attributes[:"tracer.args"] |> is_binary
assert nested_external_span.attributes[:"tracer.reductions"] |> is_number
assert nested_external_span.attributes[:"tracer.reductions"] > 1
Expand Down
8 changes: 4 additions & 4 deletions test/span_event_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ defmodule SpanEventTest do
@trace {:http_request, category: :external}
def http_request do
Process.sleep(10)
NewRelic.set_span(:http, url: "http://example.com", method: "GET", component: "HTTPoison")
NewRelic.set_span(:http, url: "http://example.com", method: "GET", component: "HttpClient")
"bar"
end
end
Expand Down Expand Up @@ -168,7 +168,7 @@ defmodule SpanEventTest do

[http_request, _, _] =
Enum.find(span_events, fn [ev, _, _] ->
ev[:name] == "External/example.com/HTTPoison/GET"
ev[:name] == "External/example.com/HttpClient/GET"
end)

assert function[:category] == "generic"
Expand Down Expand Up @@ -215,7 +215,7 @@ defmodule SpanEventTest do

[nested_external_event, _, _] =
Enum.find(span_events, fn [ev, _, _] ->
ev[:name] == "External/example.com/HTTPoison/GET"
ev[:name] == "External/example.com/HttpClient/GET"
end)

[[_intrinsics, tx_event]] = TestHelper.gather_harvest(Collector.TransactionEvent.Harvester)
Expand Down Expand Up @@ -278,7 +278,7 @@ defmodule SpanEventTest do
assert nested_external_event[:"http.url"] == "http://example.com"
assert nested_external_event[:"http.method"] == "GET"
assert nested_external_event[:"span.kind"] == "client"
assert nested_external_event[:component] == "HTTPoison"
assert nested_external_event[:component] == "HttpClient"
assert nested_external_event[:"tracer.reductions"] |> is_number
assert nested_external_event[:"tracer.reductions"] > 1

Expand Down

0 comments on commit 9807849

Please sign in to comment.