# withOtelAgent

- Module: [Aspire.Hosting.Java](/reference/api/typescript/aspire.hosting.java.md)
- Version: `17.0.0-preview.1.26567.5`
- Kind: `method`
- Source: [GitHub](https://github.com/microsoft/aspire/tree/2d325b13709752ba6d9a943635c5e2940a2530c0)

Runs the application with the OpenTelemetry Java agent so it exports traces, metrics, and logs to Aspire.

## Definition

```typescript
interface JavaAppResource {
  // ... omitted for brevity
  withOtelAgent(agentPath: string): JavaAppResource
}
```

## Parameters

- `agentPath` (`string`)

## Returns

[JavaAppResource](/reference/api/typescript/aspire.hosting.java/javaappresource.md) `builder`

## Applies to

- [JavaAppResource](/reference/api/typescript/aspire.hosting.java/javaappresource.md)
