-
Notifications
You must be signed in to change notification settings - Fork 302
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
[Instrumentation.EntityFrameworkCore] Fix db.statement tag for Devart Oracle #2466
base: main
Are you sure you want to change the base?
[Instrumentation.EntityFrameworkCore] Fix db.statement tag for Devart Oracle #2466
Conversation
if (command.GetType().FullName?.Contains("Devart.Data.Oracle") == true) | ||
{ | ||
string payloadString = payload?.ToString() ?? string.Empty; | ||
if ((payloadString.Contains("CommandType='Text'") && this.options.SetDbStatementForText) || | ||
(payloadString.Contains("CommandType='StoredProcedure'") && this.options.SetDbStatementForStoredProcedure)) | ||
{ | ||
string[] result = payloadString.Split(['\n'], 2); | ||
if (result.Length > 1) | ||
{ | ||
activity.AddTag(AttributeDbStatement, result[1]); | ||
} | ||
} | ||
} | ||
else if (this.commandTypeFetcher.Fetch(command) is CommandType commandType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is couple things you should consider here:
- Support both for emitting old and new attributes. See lese if statement for details:
if (this.options.SetDbStatementForStoredProcedure)
{
if (this.options.EmitOldAttributes)
{
activity.AddTag(AttributeDbStatement, commandText);
}
if (this.options.EmitNewAttributes)
{
activity.AddTag(AttributeDbQueryText, commandText);
}
}
- payloadString split, is it always '\n' or it can be vary based on the environment settings?
- Consider adding stub/mocked tests for this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
I was writing this code based on an older version (1.0.0-beta.10) that didn't have
this.options.EmitOldAttributes
andthis.options.EmitNewAttributes
. So, I will update the code structure to follow the convention of the switch statement. -
Updated the line as follows:
string[] result = payloadString.Split([Environment.NewLine], 2, StringSplitOptions.None);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I am unable to write mock tests because Devart requires a license in order to connect to Oracle database. 😞
src/OpenTelemetry.Instrumentation.EntityFrameworkCore/CHANGELOG.md
Outdated
Show resolved
Hide resolved
Co-authored-by: Piotr Kiełkowicz <[email protected]>
Fixes #2462
Changes
Added code to fix exception thrown when Devart Oracle is used (
this.commandTypeFetcher.Fetch(command)
).If Devart Oracle is used, the SQL statement will be extracted from the payload.
Merge requirement checklist
CHANGELOG.md
files updated for non-trivial changes