You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The experimental open-source Elixir agent allows you to monitor your `Elixir` applications with New Relic. It helps you track transactions, distributed traces, other parts of your application's behavior, and provides an overview of underlying [BEAM activity](https://github.com/newrelic/elixir_agent/wiki/BEAM-stats-page).
10
+
The experimental open-source Elixir agent allows you to monitor your `Elixir` applications with New Relic. It helps you track transactions, distributed traces, other parts of your application's behavior, and provides an overview of underlying BEAM activity.
11
11
12
12
[View the Documentation](https://hexdocs.pm/new_relic_agent)
13
13
@@ -50,7 +50,7 @@ If using an Elixir version before 1.18.x, please also add `:jason` to your depen
50
50
51
51
## Configuration
52
52
53
-
You need to set a few required configuration keys so we can authenticate properly.
53
+
You need to set two required configuration keys so we can authenticate properly.
54
54
55
55
#### Via Application config
56
56
@@ -67,18 +67,7 @@ You can also configure these attributes via `ENV` vars, which helps keep secrets
67
67
*`NEW_RELIC_APP_NAME`
68
68
*`NEW_RELIC_LICENSE_KEY`
69
69
70
-
#### HTTP Client Settings
71
-
72
-
`:httpc` client settings can be overridden if needed. For example, the HTTP connect timeout can be increased which can help alleviate errors related to timeouts connecting to New Relic:
73
-
74
-
```elixir
75
-
config :new_relic_agent,
76
-
app_name:"My App",
77
-
license_key:"license_key",
78
-
httpc_request_options: [connect_timeout:5000]
79
-
```
80
-
81
-
## Telemetry-based Instrumentation
70
+
## Telemetry-based auto-instrumentation
82
71
83
72
Some common Elixir packages are auto-instrumented via [`telemetry`](https://github.com/beam-telemetry/telemetry)
84
73
@@ -91,67 +80,39 @@ Some common Elixir packages are auto-instrumented via [`telemetry`](https://gith
91
80
*[`Oban`](https://github.com/oban-bg/oban): See [NewRelic.Telemetry.Oban](https://hexdocs.pm/new_relic_agent/NewRelic.Telemetry.Oban.html) for details.
92
81
*[`Absinthe`](https://github.com/absinthe-graphql/absinthe): See [NewRelic.Telemetry.Absinthe](https://hexdocs.pm/new_relic_agent/NewRelic.Telemetry.Absinthe.html) for details.
93
82
94
-
## Agent features
83
+
## Opt-In agent features
95
84
96
-
There are a few agent features that can be enabled via configuration. Please see the documentation for more information.
85
+
There are a few advanced agent features that can be enabled via configuration. Please see the documentation for more information.
97
86
98
-
*[Logs In Context](https://hexdocs.pm/new_relic_agent/NewRelic.Config.html#feature/1-logs-in-context)
*[Logs In Context](https://hexdocs.pm/new_relic_agent/NewRelic.Config.html#feature/1-logs-in-context) - See your logs in the context of the Transaction / Distributed Trace where they originated.
88
+
*[Infinite Tracing](https://hexdocs.pm/new_relic_agent/NewRelic.Config.html#feature/1-infinite-tracing) - Use a New Relic Trace Observer to get tail based sampling of Distributed Traces.
Transactions are the main unit of work reported to New Relic. `Plug` and `Phoenix` instrumentation automatically report a Web Transaction for each request. `Oban` instrumentation reports an "Other" Transaction for each job. You can also report custom transactions for work done in your app.
95
+
Transactions are the main unit of work reported to New Relic. `Plug` and `Phoenix` instrumentation automatically report a Web Transaction for each request. `Oban` instrumentation reports an "Other" Transaction for each job.
107
96
108
-
These Transactions will propagate to any process spawned and linked (ex: `Task.async`), but will _not_ follow a process that isn't linked (ex: `Task.Supervisor.async_nolink`).
109
-
110
-
---
111
-
112
-
To manually connect a Transaction to an unlinked process, you can use `NewRelic.get_transaction` and `NewRelic.connect_to_transaction`. See the docs for those functions for further details.
97
+
You may start an Custom "Other" Transaction for work outside auto-instrumented systems. This could used be while consuming from a message queue, for example.
113
98
114
99
```elixir
115
-
tx =NewRelic.get_transaction()
116
-
117
-
spawn(fn->
118
-
NewRelic.connect_to_transaction(tx)
119
-
# ...
120
-
end)
121
-
```
122
-
123
-
---
124
-
125
-
To exclude a process from the Transaction:
100
+
defmoduleWorkerdo
101
+
useNewRelic.Tracer
126
102
127
-
```elixir
128
-
Task.async(fn->
129
-
NewRelic.exclude_from_transaction()
130
-
Work.wont_be_tracked()
131
-
end)
103
+
defprocess_messagesdo
104
+
NewRelic.other_transaction("Worker", "ProcessMessages") do
105
+
# ...
106
+
end
107
+
end
108
+
end
132
109
```
133
110
134
-
---
111
+
#### Transaction propagation
135
112
136
-
To prevent reporting an individual transaction:
113
+
Transactions will propagate to any process spawned and linked (ex: `Task.async`), but will _not_ follow a process that isn't linked (ex: `Task.Supervisor.async_nolink`).
137
114
138
-
```elixir
139
-
NewRelic.ignore_transaction()
140
-
```
141
-
142
-
You can configure some paths to be automatically ignored:
143
-
144
-
```elixir
145
-
config :new_relic_agent,
146
-
ignore_paths: [
147
-
"/health",
148
-
~r/longpoll/
149
-
]
150
-
```
151
-
152
-
---
153
-
154
-
If you are using a `Task` to spawn work, you can use the pre-instrumented `NewRelic.Instrumented.Task` convenience module to make this easier. Just `alias` it in your module and all your Tasks will be instrumented. You may also use the functions directly.
115
+
If you are using a `Task.Supervisor.async_nolink` to spawn work, you can use the pre-instrumented `NewRelic.Instrumented.Task` wrapper module to make this easier. Just `alias` it in your module and all your Tasks will be instrumented. You may also use the functions directly.
For more fine grained control of Transaction propagation, check out the following functions:
165
126
166
-
You may start an "Other" Transaction for non-HTTP related work. This could used be while consuming from a message queue, for example.
127
+
*`NewRelic.exclude_from_transaction/0`
128
+
*`NewRelic.ignore_transaction/0`
129
+
*`NewRelic.get_transaction/0`
130
+
*`NewRelic.connect_to_transaction/1`
131
+
*`NewRelic.disconnect_from_transaction/0`
167
132
168
-
```elixir
169
-
defmoduleWorkerdo
170
-
useNewRelic.Tracer
133
+
#### Function tracing
171
134
172
-
defprocess_messagesdo
173
-
NewRelic.other_transaction("Worker", "ProcessMessages") do
174
-
# ...
175
-
end
176
-
end
177
-
end
178
-
```
179
-
180
-
#### Function Tracing
181
-
182
-
`NewRelic.Tracer` enables detailed Function tracing. Annotate a function and it'll show up as a span in Transaction Traces / Distributed Traces, and we'll collect aggregate stats about it. Install it by adding `use NewRelic.Tracer` to any module, and annotating any function with an `@trace` module attribute
135
+
`NewRelic.Tracer` enables detailed function tracing. Annotate a function and it'll show up as a span in Transaction Traces / Distributed Traces, and we'll collect aggregate stats about it. Install it by adding `use NewRelic.Tracer` to any module, and annotating any function with an `@trace` module attribute.
183
136
184
137
```elixir
185
138
defmoduleMyModuledo
@@ -213,7 +166,7 @@ end
213
166
214
167
#### Distributed Tracing
215
168
216
-
Requests to other services can be connected with an additional outgoing header.
169
+
Incoming Distributed Traces are automatically connected if incoming HTTP requests have trace headers. Requests to other services can be connected with an additional outgoing header.
217
170
218
171
```elixir
219
172
defmoduleMyExternalServicedo
@@ -239,6 +192,31 @@ defmodule Mix.Tasks.Example do
239
192
end
240
193
```
241
194
195
+
## Advanced configuration
196
+
197
+
#### HTTP client settings
198
+
199
+
`:httpc` client settings can be overridden if needed. For example, the HTTP connect timeout can be increased which can help alleviate errors related to timeouts connecting to New Relic:
200
+
201
+
```elixir
202
+
config :new_relic_agent,
203
+
app_name:"My App",
204
+
license_key:"license_key",
205
+
httpc_request_options: [connect_timeout:5000]
206
+
```
207
+
208
+
#### Ignore paths
209
+
210
+
You can configure some paths to be automatically ignored:
211
+
212
+
```elixir
213
+
config :new_relic_agent,
214
+
ignore_paths: [
215
+
"/health",
216
+
~r/longpoll/
217
+
]
218
+
```
219
+
242
220
#### Disabling
243
221
244
222
If you want to disable the agent, you can do it in two different ways:
0 commit comments