Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:Add a new API method to time currently unsupported datastore method calls. #2320

Merged
merged 1 commit into from Mar 8, 2024

Conversation

jaffinito
Copy link
Member

@jaffinito jaffinito commented Mar 8, 2024

Description

Adds a new public API for timing unsupported datastore calls called RecordDatastoreSegment, To support this, a new IDisposable type has been added to the API called SegmentWrapper that creates and ends segments. It has a private constructor and uses static methods to create segments, currently only Datastore segments, to allow it to be extended to other segment types in the future.

The RecordDatastoreSegment API call requires a vendor name, model, and operation since this are needed to make useful datastore segments. There are four optional parameters to capture more of the rest of data used to make sql traces. Not included were query parameters since that would require the other data to be in a very specific format that I don't think would be intuitive for out customers.

Includes unit tests for the added TransactionBridgeApi method and integration tests for the rest of the work.

API:

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

Example:

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

Author Checklist

  • Unit tests, Integration tests, and Unbounded tests completed
  • Performance testing completed with satisfactory results (if required)

Reviewer Checklist

  • Perform code review
  • Pull request was adequately tested (new/existing tests, performance tests)

Copy link
Member

@chynesNR chynesNR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@jaffinito jaffinito merged commit 81abc5c into main Mar 8, 2024
83 checks passed
@jaffinito jaffinito deleted the feature/record-datastore-segment-api branch March 8, 2024 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants