Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove instrumented httpoison module #476

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
@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 @@ -126,7 +126,7 @@
|> Base.encode64()
end

test "report span events via function tracer inside transaction inside a DT" do

Check failure on line 129 in test/infinite_tracing_test.exs

View workflow job for this annotation

GitHub Actions / Unit Tests - Elixir 1.16 / OTP 26

test report span events via function tracer inside transaction inside a DT (InfiniteTracingTest)
TestHelper.restart_harvest_cycle(TelemetrySdk.Spans.HarvestCycle)
TestHelper.restart_harvest_cycle(Collector.TransactionEvent.HarvestCycle)

Expand Down Expand Up @@ -169,7 +169,7 @@

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 @@
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 @@
@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 @@

[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 All @@ -182,7 +182,7 @@
TestHelper.pause_harvest_cycle(Collector.TransactionEvent.HarvestCycle)
end

test "report span events via function tracer inside transaction inside a DT" do

Check failure on line 185 in test/span_event_test.exs

View workflow job for this annotation

GitHub Actions / Unit Tests - Elixir 1.16 / OTP 26

test report span events via function tracer inside transaction inside a DT (SpanEventTest)
TestHelper.restart_harvest_cycle(Collector.SpanEvent.HarvestCycle)
TestHelper.restart_harvest_cycle(Collector.TransactionEvent.HarvestCycle)

Expand Down Expand Up @@ -215,7 +215,7 @@

[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 @@
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
Loading