Skip to content

Commit

Permalink
Add automatic attributes to the Spansaction (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
binaryseed authored Feb 18, 2021
1 parent 4e87748 commit 670d602
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/new_relic/transaction/complete.ex
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ defmodule NewRelic.Transaction.Complete do
timestamp: tx_attrs[:start_time],
duration: tx_attrs[:duration_s],
category_attributes:
Map.drop(tx_attrs, @spansaction_exclude_attrs)
tx_attrs
|> Map.drop(@spansaction_exclude_attrs)
|> Map.merge(NewRelic.Config.automatic_attributes())
|> maybe_add(:tracingVendors, tx_attrs[:tracingVendors])
|> maybe_add(:trustedParentId, tx_attrs[:trustedParentId])
},
Expand Down
7 changes: 6 additions & 1 deletion test/infinite_tracing_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ defmodule InfiniteTracingTest do
TestHelper.update(:nr_config,
license_key: "dummy_key",
harvest_enabled: true,
trace_mode: :infinite
trace_mode: :infinite,
automatic_attributes: %{auto: "attribute"}
)

send(DistributedTrace.BackoffSampler, :reset)
Expand Down Expand Up @@ -249,6 +250,10 @@ defmodule InfiniteTracingTest do
assert nested_function_span.attributes[:category] == "generic"
assert nested_function_span.attributes[:name] == "InfiniteTracingTest.Traced.do_hello/0"

# Automatic attributes assigned to the Transaction and Spansaction
assert tx_event[:auto] == "attribute"
assert tx_span.attributes[:auto] == "attribute"

# Ensure these will encode properly
Jason.encode!(tx_event)
Jason.encode!(spans)
Expand Down

0 comments on commit 670d602

Please sign in to comment.