> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/guardrails/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/guardrails/_mcp/server.

# nemoguardrails.http.instrumented

## Module Contents

### Classes

| Name                                                                                 | Description                                                    |
| ------------------------------------------------------------------------------------ | -------------------------------------------------------------- |
| [`InstrumentedHTTPClient`](#nemoguardrails-http-instrumented-InstrumentedHTTPClient) | Decorate an HTTP client with privacy-safe tracing and metrics. |

### Functions

| Name                                                                                 | Description                                                  |
| ------------------------------------------------------------------------------------ | ------------------------------------------------------------ |
| [`instrument_http_client`](#nemoguardrails-http-instrumented-instrument_http_client) | Return `client` decorated with the requested HTTP telemetry. |

### Data

[`__all__`](#nemoguardrails-http-instrumented-__all__)

### API

```python
class nemoguardrails.http.instrumented.InstrumentedHTTPClient(
    client: nemoguardrails.http.client.HTTPClient,
    tracer: opentelemetry.trace.Tracer | None,
    metrics_enabled: bool = False
)
```

Decorate an HTTP client with privacy-safe tracing and metrics.

The decorator preserves request behavior and client ownership. Wrapping an
existing `InstrumentedHTTPClient` is idempotent, and tracing and metrics
can be enabled independently.

**`_close_lock`** `= asyncio.Lock()`

---

**`wrapped_client`** `HTTPClient`

Return the underlying client for direct access or re-instrumentation.

---

```python
nemoguardrails.http.instrumented.InstrumentedHTTPClient.__new__(
    client: nemoguardrails.http.client.HTTPClient,
    args: typing.Any = (),
    kwargs: typing.Any = {}
)
```

Return an existing instrumented client without wrapping it again.

```python
nemoguardrails.http.instrumented.InstrumentedHTTPClient._with_wrapped_client(
    client: nemoguardrails.http.client.HTTPClient
) -> nemoguardrails.http.instrumented.InstrumentedHTTPClient
```

Apply the current instrumentation settings to another client.

```python
nemoguardrails.http.instrumented.InstrumentedHTTPClient.close() -> None
```

async

Close the wrapped client without taking ownership from its caller.

Repeated calls are safe. A failed or cancelled close remains retryable.

```python
nemoguardrails.http.instrumented.InstrumentedHTTPClient.request(
    method: str,
    url: str,
    headers: typing.Mapping[str, str] | None = None,
    params: typing.Mapping[str, typing.Any] | None = None,
    json: typing.Any = None,
    content: bytes | str | None = None,
    timeout: float | None = None
) -> nemoguardrails.http.types.HTTPResponse
```

async

Forward one request while recording privacy-safe HTTP telemetry.

Telemetry includes the method, sanitized URL, payload sizes, response
status, and retry count. Header, query, body, and credential values are
never recorded.

```python
nemoguardrails.http.instrumented.instrument_http_client(
    client: nemoguardrails.http.client.HTTPClient,
    tracer: opentelemetry.trace.Tracer | None = None,
    metrics_enabled: bool = False
) -> nemoguardrails.http.client.HTTPClient
```

Return `client` decorated with the requested HTTP telemetry.

The original client is returned when telemetry is disabled or the client is
already instrumented.

```python
nemoguardrails.http.instrumented.__all__ = ['InstrumentedHTTPClient', 'instrument_http_client']
```