Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
binaryseed committed Dec 27, 2024
1 parent 2c0149f commit f1b5cb0
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 15 deletions.
4 changes: 4 additions & 0 deletions lib/new_relic/transaction/complete.ex
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ defmodule NewRelic.Transaction.Complete do
trace_id: tx_attrs[:traceId],
parent_id: tx_attrs[:parentSpanId],
name: tx_attrs[:name],
sampled: tx_attrs[:sampled],
priority: tx_attrs[:priority],
category: "generic",
entry_point: true,
timestamp: tx_attrs[:start_time],
Expand All @@ -247,6 +249,8 @@ defmodule NewRelic.Transaction.Complete do
trace_id: tx_attrs[:traceId],
category: "generic",
name: "Transaction Root Process",
sampled: tx_attrs[:sampled],
priority: tx_attrs[:priority],
parent_id: tx_attrs[:guid],
timestamp: tx_attrs[:start_time],
duration: tx_attrs[:duration_s],
Expand Down
3 changes: 3 additions & 0 deletions lib/new_relic/util.ex
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ defmodule NewRelic.Util do
{_key, nil} ->
[]

{_key, ""} ->
[]

{key, value} when is_number(value) when is_boolean(value) ->
[{key, value}]

Expand Down
2 changes: 1 addition & 1 deletion test/infinite_tracing_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ defmodule InfiniteTracingTest do

tx_span =
Enum.find(spans, fn %{attributes: attr} ->
attr[:category] == "Transaction"
attr[:"nr.entryPoint"] == true
end)

tx_root_process_span =
Expand Down
14 changes: 7 additions & 7 deletions test/instrumented/task_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ defmodule InstrumentedTaskTest do

spansaction =
Enum.find(spans, fn %{attributes: attr} ->
attr[:category] == "Transaction"
attr[:"nr.entryPoint"] == true
end)

refute spansaction.attributes[:not_instrumented]
Expand Down Expand Up @@ -108,7 +108,7 @@ defmodule InstrumentedTaskTest do

spansaction =
Enum.find(spans, fn %{attributes: attr} ->
attr[:category] == "Transaction"
attr[:"nr.entryPoint"] == true
end)

refute spansaction.attributes[:not_instrumented]
Expand Down Expand Up @@ -168,7 +168,7 @@ defmodule InstrumentedTaskTest do

spansaction =
Enum.find(spans, fn %{attributes: attr} ->
attr[:category] == "Transaction"
attr[:"nr.entryPoint"] == true
end)

refute spansaction.attributes[:not_instrumented]
Expand Down Expand Up @@ -250,7 +250,7 @@ defmodule InstrumentedTaskTest do

spansaction =
Enum.find(spans, fn %{attributes: attr} ->
attr[:category] == "Transaction"
attr[:"nr.entryPoint"] == true
end)

refute spansaction.attributes[:not_instrumented]
Expand Down Expand Up @@ -322,7 +322,7 @@ defmodule InstrumentedTaskTest do

spansaction =
Enum.find(spans, fn %{attributes: attr} ->
attr[:category] == "Transaction"
attr[:"nr.entryPoint"] == true
end)

refute spansaction.attributes[:not_instrumented]
Expand Down Expand Up @@ -385,7 +385,7 @@ defmodule InstrumentedTaskTest do

spansaction =
Enum.find(spans, fn %{attributes: attr} ->
attr[:category] == "Transaction"
attr[:"nr.entryPoint"] == true
end)

refute spansaction.attributes[:not_instrumented]
Expand Down Expand Up @@ -414,7 +414,7 @@ defmodule InstrumentedTaskTest do

spansaction =
Enum.find(spans, fn %{attributes: attr} ->
attr[:category] == "Transaction"
attr[:"nr.entryPoint"] == true
end)

refute spansaction.attributes[:not_instrumented]
Expand Down
6 changes: 3 additions & 3 deletions test/other_transaction_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ defmodule OtherTransactionTest do
)

span_events = TestHelper.gather_harvest(Collector.SpanEvent.Harvester)
assert length(span_events) == 3
assert length(span_events) == 4

TestHelper.pause_harvest_cycle(Collector.TransactionEvent.HarvestCycle)
TestHelper.pause_harvest_cycle(Collector.TransactionTrace.HarvestCycle)
Expand Down Expand Up @@ -200,7 +200,7 @@ defmodule OtherTransactionTest do

spansaction =
Enum.find(spans, fn %{attributes: attr} ->
attr[:category] == "Transaction" && attr[:name] == "Test/Error"
attr[:"nr.entryPoint"] == true && attr[:name] == "Test/Error"
end)

assert spansaction.attributes[:error]
Expand Down Expand Up @@ -241,7 +241,7 @@ defmodule OtherTransactionTest do

spansaction =
Enum.find(spans, fn %{attributes: attr} ->
attr[:category] == "Transaction" && attr[:name] == "Test/ExpectedError"
attr[:"nr.entryPoint"] == true && attr[:name] == "Test/ExpectedError"
end)

refute spansaction.attributes[:error]
Expand Down
4 changes: 2 additions & 2 deletions test/sidecar_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ defmodule SidecarTest do

spansaction =
Enum.find(spans, fn %{attributes: attr} ->
attr[:category] == "Transaction"
attr[:"nr.entryPoint"] == true
end)

assert spansaction.attributes[:root] == "YES"
Expand Down Expand Up @@ -352,7 +352,7 @@ defmodule SidecarTest do

spansaction =
Enum.find(spans, fn %{attributes: attr} ->
attr[:category] == "Transaction" && attr[:name] == "Test/double_connect_test"
attr[:"nr.entryPoint"] == true && attr[:name] == "Test/double_connect_test"
end)

assert spansaction.attributes[:root] == "YES"
Expand Down
12 changes: 10 additions & 2 deletions test/span_event_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,12 @@ defmodule SpanEventTest do

span_events = TestHelper.gather_harvest(Collector.SpanEvent.Harvester)

[tx_root_process_event, _, _] =
[spansaction_event, _, _] =
Enum.find(span_events, fn [ev, _, _] -> ev[:"nr.entryPoint"] == true end)

[tx_root_process_event, _, _] =
Enum.find(span_events, fn [ev, _, _] -> ev[:parentId] == spansaction_event[:guid] end)

[request_process_event, _, _] =
Enum.find(span_events, fn [ev, _, _] -> ev[:parentId] == tx_root_process_event[:guid] end)

Expand All @@ -220,13 +223,15 @@ defmodule SpanEventTest do
assert tx_event[:parentId] == "7d3efb1b173fecfa"

assert tx_event[:traceId] == "d6b4ba0c3a712ca"
assert spansaction_event[:traceId] == "d6b4ba0c3a712ca"
assert tx_root_process_event[:traceId] == "d6b4ba0c3a712ca"
assert request_process_event[:traceId] == "d6b4ba0c3a712ca"
assert function_event[:traceId] == "d6b4ba0c3a712ca"
assert nested_function_event[:traceId] == "d6b4ba0c3a712ca"
assert task_event[:traceId] == "d6b4ba0c3a712ca"
assert nested_external_event[:traceId] == "d6b4ba0c3a712ca"

assert spansaction_event[:transactionId] == tx_event[:guid]
assert tx_root_process_event[:transactionId] == tx_event[:guid]
assert request_process_event[:transactionId] == tx_event[:guid]
assert function_event[:transactionId] == tx_event[:guid]
Expand All @@ -235,6 +240,7 @@ defmodule SpanEventTest do
assert nested_external_event[:transactionId] == tx_event[:guid]

assert tx_event[:sampled] == true
assert spansaction_event[:sampled] == true
assert tx_root_process_event[:sampled] == true
assert request_process_event[:sampled] == true
assert function_event[:sampled] == true
Expand All @@ -243,6 +249,7 @@ defmodule SpanEventTest do
assert nested_external_event[:sampled] == true

assert tx_event[:priority] == 0.987654
assert spansaction_event[:priority] == 0.987654
assert tx_root_process_event[:priority] == 0.987654
assert request_process_event[:priority] == 0.987654
assert function_event[:priority] == 0.987654
Expand All @@ -255,7 +262,8 @@ defmodule SpanEventTest do
assert function_event[:"tracer.reductions"] |> is_number
assert function_event[:"tracer.reductions"] > 1

assert tx_root_process_event[:parentId] == "5f474d64b9cc9b2a"
assert spansaction_event[:parentId] == "5f474d64b9cc9b2a"
assert tx_root_process_event[:parentId] == spansaction_event[:guid]
assert request_process_event[:parentId] == tx_root_process_event[:guid]
assert function_event[:parentId] == request_process_event[:guid]
assert nested_function_event[:parentId] == function_event[:guid]
Expand Down

0 comments on commit f1b5cb0

Please sign in to comment.