Skip to content

Attempt to properly parse out instance name from JDBC url#866

Merged
tylerbenson merged 7 commits intomasterfrom
tyler/jdbc-instance
Jun 13, 2019
Merged

Attempt to properly parse out instance name from JDBC url#866
tylerbenson merged 7 commits intomasterfrom
tyler/jdbc-instance

Conversation

@tylerbenson
Copy link
Contributor

@tylerbenson tylerbenson commented Jun 6, 2019

Unfortunately implementations are INCREDIBLY inconsistent on the matter so parsing is pretty complicated.

Updates #606

Unfortunately implementations are INCREDIBLY inconsistent on the matter.  Oracle implementation is still pending since it’s really complicated.
@tylerbenson tylerbenson added the inst: others All other instrumentations label Jun 6, 2019
@labbati labbati marked this pull request as ready for review June 6, 2019 16:59
@labbati labbati requested a review from a team as a code owner June 6, 2019 16:59
@labbati labbati added the tag: do not merge Do not merge changes label Jun 7, 2019
@tylerbenson tylerbenson force-pushed the tyler/jdbc-instance branch from 536b7ad to 1a5a706 Compare June 11, 2019 00:19
@tylerbenson tylerbenson removed the tag: do not merge Do not merge changes label Jun 11, 2019
Copy link
Member

@labbati labbati left a comment

Choose a reason for hiding this comment

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

@tylerbenson awesome work. I included a first round of CR and ideas. I would love to hear your thoughts about them

import java.util.regex.Pattern;

/**
* Structured as an enum instead of a class hierarchy to allow iterating through the parsers
Copy link
Member

Choose a reason for hiding this comment

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

The number of cases that we covered with this code is impressive. Very great job.

Let me add a comment here that applies to the approach in general, not to any specific parser.

From the functional standpoint I have nothing against it. I see your point (you are not required to remember adding a class/instance to a list) but I honestly think that this approach decreases readability to a certain degree. Now, I don't expect the number of DBs to explode over time, but we are already to the point where GH collapse 'large files' by default 😄.

So in the end I would probably fallback to defining an interface JDBCInfoParser or the liked and having N concrete parsers implementing it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I'd prefer to leave it as is if that's ok...

Copy link
Member

Choose a reason for hiding this comment

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

Yeah no problem with that. Worst case we can extract at a later time if we decide it is growing too much.

final int typeLoc = jdbcUrl.indexOf(':');

if (typeLoc < 1) {
// Invalid format: `jdbc:` or `jdbc::`
Copy link
Member

Choose a reason for hiding this comment

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

Did not know that jdbc:: was a valid format. BTW in this case is not tested and I don't think that code around can handle it, because indexOf returns the first occurence and below you are doing jdbcUrl.substring(0, typeLoc);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think jdbc: or jdbc:: is valid. I added a test to verify behavior.


final String baseType = jdbcUrl.substring(0, typeLoc);

final DBInfo.Builder parsedProps = DEFAULT.toBuilder().type(baseType);
Copy link
Member

Choose a reason for hiding this comment

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

How do you see moving the part from final int typeLoc = jdbcUrl.indexOf(':'); to here into a separate method parseDatabaseType()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to avoid extracting too many methods for various things that are either very context sensitive or only used once. Is this important to you?

Copy link
Member

Choose a reason for hiding this comment

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

Nevermind, is just that in this part I was having hard times figuring 'what' we were doing without going into 'how' we were doing it.

Copy link
Member

@labbati labbati left a comment

Choose a reason for hiding this comment

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

Thanks for your answers. I am fine with the changes and I really appreciated the extensive testing in this PR.

@tylerbenson tylerbenson added this to the 0.30.0 milestone Jun 13, 2019
@tylerbenson tylerbenson merged commit ec3b586 into master Jun 13, 2019
@tylerbenson tylerbenson deleted the tyler/jdbc-instance branch June 13, 2019 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

inst: others All other instrumentations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants