Skip to content

Commit

Permalink
Adding RecordDatastoreSegment to .NET Agent API
Browse files Browse the repository at this point in the history
  • Loading branch information
chynesNR authored Oct 17, 2024
1 parent 5810fd5 commit 2a3aef1
Showing 1 changed file with 136 additions and 0 deletions.
136 changes: 136 additions & 0 deletions src/content/docs/apm/agents/net-agent/net-agent-api/net-agent-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,16 @@ The following list contains the different calls you can make with the API, inclu
Associates a user ID to the current transaction (see below for more details).
</td>
</tr>

<tr>
<td class="children-nowrap">
`RecordDatastoreSegment`
</td>

<td>
Allows an unsupported datastore to be instrumented (see below for more details).
</td>
</tr>
</tbody>
</table>

Expand Down Expand Up @@ -1104,6 +1114,132 @@ The following list contains the different calls you can make with the API, inclu
transaction.SetUserId("BobSmith123");
```
</Collapser>
<Collapser
id="RecordDatastoreSegment"
title="RecordDatastoreSegment"
>
### Syntax

```cs
SegmentWrapper? RecordDatastoreSegment(string vendor, string model, string operation, string? commandText = null, string? host = null, string? portPathOrID = null, string? databaseName = null)
```

Allows an unsupported datastore to be instrumented in the same way as the .NET agent automatically instruments its supported datastores.

This method requires .NET agent and .NET agent API [version 10.22.0](/docs/release-notes/agent-release-notes/net-release-notes/net-agent-10-22-0/) or higher.

### Parameters

<table>
<thead>
<tr>
<th>
Parameter
</th>

<th>
Description
</th>
</tr>
</thead>

<tbody>
<tr>
<td>
`vendor`

_string_
</td>

<td>
Datastore vendor name, such as MySQL, MSSQL, or MongoDB.
</td>
</tr>
<tr>
<td>
`model`

_string_
</td>

<td>
Table name, or similar identifier in a non-relational datastore.
</td>
</tr>
<tr>
<td>
`operation`

_string_
</td>

<td>
Operation being performed, such as "SELECT" or "UPDATE" for SQL databases.
</td>
</tr>
<tr>
<td>
`commandText`

_string?_
</td>

<td>
Optional. Query, or similar descriptor in a non-relational datastore.
</td>
</tr>
<tr>
<td>
`host`

_string?_
</td>

<td>
Optional. Server hosting the datastore.
</td>
</tr>
<tr>
<td>
`portPathOrID`

_string?_
</td>

<td>
Optional. Port, path, or other identifier, paired with the host to aid in identifying the datastore.
</td>
</tr>
<tr>
<td>
`databaseName`

_string?_
</td>

<td>
Optional. Datastore name or similar identifier.
</td>
</tr>
</tbody>
</table>

### Returns

IDisposable segment wrapper that both creates and ends the segment automatically.

### Example

```cs
var transaction = NewRelic.Api.Agent.NewRelic.GetAgent().CurrentTransaction;
using (transaction.RecordDatastoreSegment(vendor, model, operation,
commandText, host, portPathOrID, databaseName))
{
DatastoreWorker();
}
```

</Collapser>
</CollapserGroup>
</Collapser>

Expand Down

0 comments on commit 2a3aef1

Please sign in to comment.