Skip to content

Commit

Permalink
Merge pull request #13255 from brnhensley/patch-4
Browse files Browse the repository at this point in the history
chore: add language identifiers to python API/custom inst docs
  • Loading branch information
nbaenam committed May 30, 2023
2 parents 53cd95c + 207375f commit 21d83b5
Show file tree
Hide file tree
Showing 49 changed files with 286 additions and 275 deletions.
Expand Up @@ -151,24 +151,24 @@ Infinite Tracing configuration settings include the standard distributed tracing
<td>
Pull down the libraries with this installation command, and then set up the configuration file or environment variables:

```
```bash
pip install newrelic[infinite-tracing]
```

**General configuration options:**

Configuration file (`newrelic.ini`):

```
```ini
distributed_tracing.enabled = true
infinite_tracing.trace_observer_host = YOUR_TRACE_OBSERVER_HOST
```

Environment variables:

```
```ini
NEW_RELIC_DISTRIBUTED_TRACING_ENABLED = true
NEW_RELIC_INFINITE_TRACING_TRACE_OBSERVER_HOST = "<a href="/docs/understand-dependencies/distributed-tracing/infinite-tracing/set-trace-observer#ui-endpoints">YOUR_TRACE_OBSERVER_HOST</a>"
NEW_RELIC_INFINITE_TRACING_TRACE_OBSERVER_HOST = "YOUR_TRACE_OBSERVER_HOST"
```

**Batching and compression configuration options:**
Expand All @@ -177,14 +177,14 @@ Infinite Tracing configuration settings include the standard distributed tracing

Configuration file (`newrelic.ini`):

```
```ini
infinite_tracing.batching = true # Send spans to the trace observer in batches rather than one by one
infinite_tracing.compression = true # Enable gzip compression for data sent via infinite tracing
```

Environment variables:

```
```ini
NEW_RELIC_INFINITE_TRACING_BATCHING = true
NEW_RELIC_INFINITE_TRACING_COMPRESSION = true
```
Expand Down Expand Up @@ -302,13 +302,13 @@ If you've been using an older agent without distributed tracing, before turning
<td>
Configuration file (`newrelic.ini`):

```
```ini
distributed_tracing.enabled = true
```

Environment variable:

```
```ini
NEW_RELIC_DISTRIBUTED_TRACING_ENABLED=true
```
</td>
Expand Down
Expand Up @@ -425,7 +425,7 @@ If no environment is specified, the agent will use the default settings as speci

The basic structure of the configuration file is:

```py
```ini
[newrelic]
... default settings

Expand Down Expand Up @@ -991,15 +991,15 @@ These settings are available in the agent configuration file.
</tbody>
</table>

Adds [tags](/docs/apm/new-relic-apm/maintenance/labels-categories-organize-your-apps-servers). Specify name:value separated by a colon `:`, and separate additional tags with semicolons `;`.
Adds [tags](/docs/apm/new-relic-apm/maintenance/labels-categories-organize-your-apps-servers). Specify _name:value_ separated by a colon `:`, and separate additional tags with semicolons `;`.

<CollapserGroup>
<Collapser
id="example-2-labels"
title="Two tags"
>
```py
Server:One;Data Center:Primary
```ini
labels = Server:One;Data Center:Primary
```
</Collapser>
</CollapserGroup>
Expand Down Expand Up @@ -1866,7 +1866,7 @@ For more information about transaction traces, see [Transaction traces](/docs/tr
my-app/newrelic.ini
</b>

```py
```ini
[newrelic]
...
transaction_tracer.function_trace = common.utils:validate*
Expand Down Expand Up @@ -2594,7 +2594,7 @@ Here are browser monitoring settings available via the agent configuration file.
>
If you are generating HTML page responses and using the `Content-Type` of `application/xhtml+xml`, you can override the allowed content types to list both this content type and the default `text/html` by using:

```py
```ini
browser_monitoring.content_type = text/html application/xhtml+xml
```

Expand Down Expand Up @@ -4798,7 +4798,7 @@ To disable default instrumentation, provide a special `import-hook` section corr
>
Add the following to the configuration file:

```py
```ini
[import-hook:MySQLdb]
enabled = false
```
Expand Down
Expand Up @@ -24,9 +24,9 @@ To extend instrumentation to designated functions and class methods, add them to
id="dumdbm-example"
title="Using dumbdbm"
>
In this example, you use the Python **dumbdbm** module and want to instrument the time it took to open a database, and then to write that database back to a file. In this case you would use:
In this example, you use the Python **`dumbdbm`** module and want to instrument the time it took to open a database, and then to write that database back to a file. In this case you would use:

```
```ini
transaction_tracer.function_trace = dumbdbm:open
dumbdbm:_Database._commit
```
Expand All @@ -48,14 +48,14 @@ When wrapping functions by listing them in the agent configuration file, you can

When using the `transaction_tracer.function_trace` setting in the agent configuration file, the name of the function will be used in the metric name, with it being classified as a `Function`. If it is necessary to override what function name may be used in the metric name or classify it differently, then an alternate means of defining the function trace in the configuration file can be used. The equivalent for:

```
```ini
transaction_tracer.function_trace = dumbdbm:open
dumbdbm:_Database._commit
```

would be to create two new configuration sections in the agent configuration file, one for each function to be traced:

```
```ini
[function-trace:dumbdbm-1]
enabled = true
function = dumbdbm:open
Expand Down
Expand Up @@ -14,7 +14,7 @@ redirects:

## Syntax

```
```py
newrelic.agent.accept_distributed_trace_payload(payload, transport_type='HTTP')
```

Expand Down Expand Up @@ -66,8 +66,9 @@ This call is used to link transactions by parsing the distributed tracing payloa

<tr>
<td>
transport_type
\_string_
`transport_type`

_string_
</td>

<td>
Expand Down Expand Up @@ -98,7 +99,7 @@ When unsuccessful, returns `False`. Accepting a payload can fail for several rea

An example of using `accept_distributed_trace_payload` in a background task:

```
```py
@newrelic.agent.background_task()
def handle(request):
payload = request.headers.get('newrelic')
Expand All @@ -112,7 +113,7 @@ def handle(request):

An example of using `accept_distributed_trace_payload` and creating a [background task](/docs/agents/python-agent/supported-features/python-background-tasks) for each message:

```
```py
import newrelic.agent
newrelic.agent.initialize('newrelic.ini')
application = newrelic.agent.register_application(timeout=10.0)
Expand Down
Expand Up @@ -11,7 +11,7 @@ metaDescription: 'Python API: This call adds a custom attribute (key/value pair)

## Syntax

```
```py
newrelic.agent.add_custom_attribute(key, value)
```

Expand Down Expand Up @@ -59,7 +59,7 @@ Attributes may be found in APM if the transaction is associated with an error or
<td>
`value`

_string, integer, float, boolean_
_string_, _integer_, _float_, _boolean_
</td>

<td>
Expand All @@ -79,18 +79,18 @@ Returns `True` if attribute was added successfully. 

An example of adding custom attributes to a [background task](/docs/agents/python-agent/python-agent-api/background_task):

```
```py
@newrelic.agent.background_task()
def send_request():
response = requests.post('http://URL_path', headers=headers, data=data)
newrelic.agent.add_custom_attribute('url_path_status_code', response.status_code)
response = requests.post('http://URL_path', headers=headers, data=data)
newrelic.agent.add_custom_attribute('url_path_status_code', response.status_code)
```

### Using custom attributes to troubleshoot [#attribute-troubleshooting]

You can also use custom attributes to troubleshoot performance issues. For example, you might see occasional slow response times from a pool of memcache instances, but you don't know what instance is causing the problem. You might add an attribute to the transaction indicating the server, like so:

```
```py
# Set server_ip to be the current server processing the transaction

newrelic.agent.add_custom_attribute("memcache_query_frontend_lookup", server_ip)
Expand Down
Expand Up @@ -11,7 +11,7 @@ metaDescription: 'Python API: This call adds a custom attribute (key/value tuple

## Syntax

```
```py
newrelic.agent.add_custom_attributes(items)
```

Expand Down Expand Up @@ -51,7 +51,7 @@ Attributes may be found in APM if the transaction is associated with an error or
</td>

<td>
Required. Each item in the list must be a tuple, with the first element being a key, and the second its value. Each key is a string representing the name of an attribute, and each corresponding value is the value to add to the current transaction for this attribute. Values can be `int`, `float`, `string`, or `boolean`. Only the first 255 characters are retained for both keys and values.
Required. Each item in the list must be a `tuple`, with the first element being a _key_, and the second its _value_. Each key is a string representing the name of an attribute, and each corresponding value is the value to add to the current transaction for this attribute. Values can be `int`, `float`, `string`, or `boolean`. Only the first 255 characters are retained for both keys and values.
</td>
</tr>
</tbody>
Expand All @@ -67,7 +67,7 @@ Returns `True` if all attributes were added successfully.

An example of adding custom attributes to a [background task](/docs/agents/python-agent/python-agent-api/background_task):

```
```py
@newrelic.agent.background_task()
def send_request():
response = requests.get("http://example.com")
Expand All @@ -80,7 +80,7 @@ def send_request():

You can also use custom attributes to troubleshoot performance issues. For example, you might see occasional slow response times from a pool of memcache instances, but you don't know what instance is causing the problem. You might add an attribute to the transaction indicating the server, like so:

```
```py
# Set server_ip to be the current server processing the transaction
newrelic.agent.add_custom_attributes([
("memcache_query_frontend_lookup", "server_ip")
Expand Down
Expand Up @@ -13,7 +13,7 @@ redirects:

## Syntax

```
```py
newrelic.agent.add_custom_span_attribute(key, value)
```

Expand Down Expand Up @@ -61,7 +61,7 @@ Attributes may be found in Distributed Tracing or in APM if a transaction trace
<td>
`value`

_string, integer, float, boolean_
_string_, _integer_, _float_, _boolean_
</td>

<td>
Expand All @@ -81,18 +81,18 @@ Returns `True` if attribute was added successfully. 

An example of adding custom attributes to a [background task](/docs/agents/python-agent/python-agent-api/background_task):

```
```py
@newrelic.agent.background_task()
def send_request():
with newrelic.agent.FunctionTrace(name='Trace'):
newrelic.agent.add_custom_span_attribute('attribute', 'value')
with newrelic.agent.FunctionTrace(name='Trace'):
newrelic.agent.add_custom_span_attribute('attribute', 'value')
```

### Using custom span attribute to troubleshoot [#parameter-troubleshooting]

You can also use custom attributes to troubleshoot performance issues. For example, you might see occasional slow response times from a pool of memcache instances, but you don't know what instance is causing the problem. You might add an attribute to the span indicating the server, like so:

```
```py
# Set server_ip to be the current server processing the transaction

newrelic.agent.add_custom_span_attribute("memcache_query_frontend_lookup", server_ip)
Expand Down
Expand Up @@ -14,7 +14,7 @@ redirects:

## Syntax

```
```py
newrelic.agent.application(name=None)
```

Expand Down Expand Up @@ -70,7 +70,7 @@ Returns an application object. The object itself does not present any public API

To generate an application object, use:

```
```py
import newrelic.agent

app = newrelic.agent.application()
Expand Down
Expand Up @@ -74,7 +74,7 @@ Returns an application settings object. The object itself does not present any p

You might want to check the configuration settings to determine what custom instrumentation to implement. Here's an example of using an `if` statement with the app settings object:

```
```py
settings = newrelic.agent.application_settings()

if settings and settings.error_collector.enabled:
Expand All @@ -85,7 +85,7 @@ if settings and settings.error_collector.enabled:

If you are debugging or logging and require the global settings as a traditional Python dictionary object, you can pass the result into a `dict`. For example:

```
```py
settings_dict = dict(newrelic.agent.application_settings())

for name, value in settings_dict.items():
Expand Down

0 comments on commit 21d83b5

Please sign in to comment.