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

Adds enhanced metadata parsing for Oracle DBs #270

Merged
merged 7 commits into from
Mar 31, 2021

Conversation

willarmiros
Copy link
Contributor

Description of changes:
This change enables users of the X-Ray SDK and agent who query Oracle DBs to have more accurate metadata by directly parsing the DB connection URL. Much of the parsing logic is adapted from OpenTelemetry, and attributed as such.

Since we are likely not going to add this advanced support for other DB providers, I mostly special-cased the Oracle logic as opposed to the more generic approach that OTel takes for simplicity. I always preferred the info from parsing over the info from DatabaseMetaData where applicable.

This also fixes a more general issue with DB subsegment naming where we didn't do sufficient null-checking.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.


@Override
public int hashCode() {
return Objects.hashCode(sanitizedUrl);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this sufficient to only hash the sanitized URL? Originally I hashed all 4 fields, but checkStyle called me out for using hash instead of hashCode.

Copy link
Contributor

Choose a reason for hiding this comment

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

Did you use Objects.hash(sanitizedUrl, user, host, dbName) (varargs)? That's pretty weird. Maybe you can use IntelliJ to generate equals / hashcode so it just uses multiply / add directly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, Objects.hash() is actually what IntelliJ generate used by default.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can use "IntelliJ default" to get the multiply version

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ohhh I had never seen that before, thanks for the tip!


@Override
public int hashCode() {
return Objects.hashCode(sanitizedUrl);
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you use Objects.hash(sanitizedUrl, user, host, dbName) (varargs)? That's pretty weird. Maybe you can use IntelliJ to generate equals / hashcode so it just uses multiply / add directly


/**
* Class for parsing Oracle database connection URLs and extracting useful metadata.
* Adapted from the OpenTelemetry JdbcConnectionUrlParser class under the Apache 2.0 license.
Copy link
Contributor

Choose a reason for hiding this comment

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

For all the classes adapted, can you add a second copyright header with the copy from OTel?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, good callout.

@codecov-io
Copy link

Codecov Report

Merging #270 (81c9f5d) into master (4e23d22) will increase coverage by 0.56%.
The diff coverage is 83.21%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #270      +/-   ##
============================================
+ Coverage     58.83%   59.40%   +0.56%     
- Complexity     1169     1207      +38     
============================================
  Files           129      131       +2     
  Lines          4910     5040     +130     
  Branches        552      585      +33     
============================================
+ Hits           2889     2994     +105     
- Misses         1761     1773      +12     
- Partials        260      273      +13     
Impacted Files Coverage Δ Complexity Δ
...in/java/com/amazonaws/xray/sql/ConnectionInfo.java 61.76% <61.76%> (ø) 6.00 <6.00> (?)
.../amazonaws/xray/sql/OracleConnectionUrlParser.java 89.18% <89.18%> (ø) 21.00 <21.00> (?)
...in/java/com/amazonaws/xray/sql/SqlSubsegments.java 89.58% <91.42%> (+4.96%) 14.00 <13.00> (+11.00)
.../java/com/amazonaws/xray/entities/SegmentImpl.java 87.50% <0.00%> (-3.75%) 22.00% <0.00%> (ø%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4e23d22...81c9f5d. Read the comment docs.

@willarmiros willarmiros merged commit d242a93 into aws:master Mar 31, 2021
@willarmiros willarmiros deleted the oracle-i-guess branch March 31, 2021 17:24
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

3 participants