Skip to content

Conversation

@findingrish
Copy link
Contributor

No description provided.

@findingrish findingrish requested review from a team and kotharironak December 7, 2020 17:40
if (DbSemanticConventionUtils.isSqlTypeBackendForOtelFormat(attributeFieldMap)) {
Optional<String> sqlUrl = DbSemanticConventionUtils.getBackendURIForOtelFormat(attributeFieldMap);
sqlUrl.ifPresent(s -> eventBuilder.getSqlBuilder().setUrl(s));
if (sqlUrl.isPresent()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we use getSqlURI form DbSemanticsConvention?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That accepts Event object, we have an attribute map here. I can create one more method there. Should I?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it's a common code, and it's difficult to maintain.

@tim-mwangi
Copy link
Contributor

Some unit tests?

@codecov
Copy link

codecov bot commented Dec 14, 2020

Codecov Report

Merging #84 (5237866) into main (1e7ac57) will increase coverage by 0.31%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main      #84      +/-   ##
============================================
+ Coverage     68.68%   68.99%   +0.31%     
  Complexity      814      814              
============================================
  Files            83       83              
  Lines          3442     3441       -1     
  Branches        367      367              
============================================
+ Hits           2364     2374      +10     
+ Misses          933      922      -11     
  Partials        145      145              
Flag Coverage Δ Complexity Δ
unit 68.99% <100.00%> (+0.31%) 0.00 <2.00> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ Complexity Δ
...normalizer/fieldgenerators/SqlFieldsGenerator.java 100.00% <100.00%> (ø) 15.00 <2.00> (-1.00)
...race/core/rawspansgrouper/TraceEmitPunctuator.java 85.50% <0.00%> (+15.94%) 9.00% <0.00%> (+1.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 1e7ac57...5237866. Read the comment docs.

@findingrish findingrish changed the title Use db.connection_string for sql backend url Fallback to db.connection_string for sql backend url Dec 14, 2020
@kotharironak
Copy link
Contributor

@rish691 snyk scan is failing.

}
if (SpanAttributeUtils.containsAttributeKey(
event, OTelDbSemanticConventions.DB_CONNECTION_STRING.getValue())) {
String url = SpanAttributeUtils.getStringAttribute(
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we have to convert this String to URI object?

try {
new URI(URL)
} catch (Mulformed) {
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@JBAhire
Copy link
Member

JBAhire commented Dec 14, 2020

@rish691 snyk scan is failing.

I guess Buchi fixed it here: #87 (comment)

@findingrish findingrish merged commit 4a47807 into main Dec 14, 2020
@findingrish findingrish deleted the sql-url-fallback branch December 14, 2020 13:37
event, OTelDbSemanticConventions.DB_CONNECTION_STRING.getValue())) {
String url = SpanAttributeUtils.getStringAttribute(
event, OTelDbSemanticConventions.DB_CONNECTION_STRING.getValue());
if (!isValidURI(url)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, if you do isValirURI(url) { return Optional.of(url); } I think you can just keep the last return Optional.empty().

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, I will do it in a subsequent pr.

}

@Test
public void testGetSqlUrlForOtelFormat() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we need some test where the user/password are included in the URL. Not sure tif that is a thing among jdbc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean if username/pwd is present we should drop the url?

@jcchavezs
Copy link
Contributor

Late to the party @rish691 but left you a couple of comments.

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.

6 participants