Skip to content

Commit

Permalink
chore: add language identifiers, fix code sample
Browse files Browse the repository at this point in the history
the config sample didn't make any sense, broke it up into lines
  • Loading branch information
brnhensley committed May 29, 2023
1 parent e65fbf8 commit 73bcaf8
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ redirects:

## Syntax

```
```py
newrelic.agent.register_data_source(source, application=None, name=None, settings=None, **properties)
```

Expand Down Expand Up @@ -43,8 +43,15 @@ For more about these fields and some general usage tips, see [Pre-aggregated met
<Callout variant="tip">
You can also accomplish the same result using [agent configuration](/docs/agents/python-agent/installation-configuration/python-agent-configuration), which doesn't require you to change your code. To add the data source in this way, add a section in the config file with the prefix `data-source:`, followed by a unique value to distinguish the section for that of another data source if more than one is specified. Here's an example:

```
[data-source:memory-usage]enabled = truefunction = samplers:memory_metrics# application = ...# name = ...[data-source:cpu-usage]enabled = truefunction = samplers:CPUMetricsDataSource# application = ...# name = ...
```ini
[data-source:memory-usage]enabled = true
function = samplers:memory_metrics
# application = ...
# name = ...
[data-source:cpu-usage]enabled = true
function = samplers:CPUMetricsDataSource
# application = ...
# name = ...
```

If the data source was specified by a function, then the name would be `module:function`. If a class, then it would be: `module:class`. The module must be able to be found using the Python module search path.
Expand Down Expand Up @@ -142,7 +149,7 @@ None.

Here's an example of some app code that generates custom metric data:

```
```py
@newrelic.agent.data_source_generator(name='External')
def services():
# code goes here
Expand All @@ -159,7 +166,7 @@ if __name__ == '__main__':

### Memory usage from data source [#data-source-memory]

```
```py
import psutil
import os

Expand Down

0 comments on commit 73bcaf8

Please sign in to comment.