Skip to content

Commit

Permalink
chore: add language identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
brnhensley committed May 29, 2023
1 parent 7cb7416 commit 2d015f8
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ redirects:

## Syntax

```
```py
newrelic.agent.background_task(application=None, name=None, group=None)
```

Expand All @@ -25,7 +25,7 @@ Used to instrument a background task or other non-web transaction.
This Python decorator can be used to instrument background tasks or other [non-web transactions](/docs/apm/transactions/intro-transactions/monitor-background-processes-other-non-web-transactions). This is typically used to instrument non-web activity like worker processes, job-based systems, and standalone scripts. Transactions marked as background tasks are displayed as non-web transactions in the APM UI and separated from web transactions.

<Callout variant="imporant">
If a function isn't already instrumented, you can use [function_trace()](/docs/apm/agents/python-agent/python-agent-api/functiontrace-python-agent-api) to create a function trace for that function within a background task. Or you can use the [config file](/docs/apm/agents/python-agent/custom-instrumentation/python-custom-instrumentation-config-file/#listing_functions) to instrument uninstrumented functions.
If a function isn't already instrumented, you can use [`function_trace()`](/docs/apm/agents/python-agent/python-agent-api/functiontrace-python-agent-api) to create a function trace for that function within a background task. Or you can use the [config file](/docs/apm/agents/python-agent/custom-instrumentation/python-custom-instrumentation-config-file/#listing_functions) to instrument uninstrumented functions.
</Callout>

If a function using the background task decorator is called within the context of a web transaction, then the web transaction is marked as a background task. The measurement of the time taken begins when the original web transaction starts.
Expand All @@ -42,11 +42,11 @@ For more on the differences between and uses of these function forms, see [Varia

### Decorator and context manager parameters [#main-params]

```
```py
newrelic.agent.background_task(application=None, name=None, group=None)
```

```
```py
newrelic.agent.BackgroundTask(application=None, name=None, group=None)
```

Expand Down Expand Up @@ -112,7 +112,7 @@ Parameters for these calls:

### Wrapper parameters: [#wrapper-params]

```
```py
newrelic.agent.BackgroundTaskWrapper(wrapped, application=None, name=None, group=None)
```

Expand Down Expand Up @@ -148,7 +148,7 @@ newrelic.agent.BackgroundTaskWrapper(wrapped, application=None, name=None, group

### Path-based parameters: [#path-based-params]

```
```py
newrelic.agent.wrap_background_task(module, object_path, application=None, name=None, group=None)
```

Expand Down Expand Up @@ -200,7 +200,7 @@ newrelic.agent.wrap_background_task(module, object_path, application=None, name=

Here's an example of using the `background_task` decorator:

```
```py
@newrelic.agent.background_task()
def task():
...
Expand All @@ -210,7 +210,7 @@ def task():

An example of using `BackgroundTask`:

```
```py
application = newrelic.agent.application()
name = newrelic.agent.callable_name(task)

Expand All @@ -220,7 +220,7 @@ with BackgroundTask(application, name):

Here's another example with more parameters:

```
```py
application = newrelic.agent.register_application(timeout=10.0)

def execute_task(task_name):
Expand All @@ -232,7 +232,7 @@ def execute_task(task_name):

An example of using the `BackgroundTaskWrapper`:

```
```py
task = newrelic.agent.BackgroundTaskWrapper(get_next_task())
result = task(*args, **kwargs)
```
Expand Down

0 comments on commit 2d015f8

Please sign in to comment.