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

Messaging convention reviewed #1297

Merged
merged 18 commits into from
Oct 13, 2020
Merged

Conversation

iNikem
Copy link
Contributor

@iNikem iNikem commented Oct 1, 2020

Closes #983
Closes #1031

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

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

😅 I didn't get through everything, but have a couple of initial comments

Comment on lines 19 to 23
public enum Operation {
send,
receive,
process
}
Copy link
Member

Choose a reason for hiding this comment

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

Are these only used as string constants? If so string constants in JMSTracer seems more natural

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Having string input parameter allows for passing any string. In this case only these 3 values are allowed by convention.

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense 👍

Btw, the lowercase enum names are throwing me a bit, can we change to SEND("send")? I think that's more conventional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can I answer you "no"? :) The "convention" to have enum elements all in uppercase baffles me. Why should we wrap desired values (lowercase in this case as per spec) in identical uppercase strings? What benefit that brings?

Copy link
Member

Choose a reason for hiding this comment

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

The "convention" to have enum elements all in uppercase baffles me

Curious if you disagree that it is conventional for enums to be uppercase in Java? Or if you disagree that we should follow this convention?

The point of following convention is that it helps people reading the code. When I see Operation.send in code, it looks like direct non-constant field access, and takes me more time to understand than it's worth.

Also we document in CONTRIBUTING.md that we follow Google Java Style Guide so would suggest we lean on that for style / convention questions where possible.

Happy to accept @anuraaga as tie-breaker vote either way though 👍😄

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 find strange the notion "constants should be UPPERCASE in Java". But in general that is indeed, not important and we should just follow coding style.

But it is more important, IMO, when such coding style forces clumsier design. And I think that SEND("send") is clumsy.

instrumentation/jms-1.1/src/test/groovy/JMS1Test.groovy Outdated Show resolved Hide resolved
Copy link
Contributor

@anuraaga anuraaga left a comment

Choose a reason for hiding this comment

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

Generally LGTM

@iNikem
Copy link
Contributor Author

iNikem commented Oct 8, 2020

Closes #983

bogdandrutu pushed a commit to bogdandrutu/opentelemetry-auto-instr-java that referenced this pull request Oct 8, 2020
@iNikem
Copy link
Contributor Author

iNikem commented Oct 11, 2020

@trask I have filed open-telemetry/opentelemetry-specification#1085. It also contains my proposal, how parent-child relationship should be modelled for messaging spans.

@iNikem
Copy link
Contributor Author

iNikem commented Oct 11, 2020

@trask Updated parents as well. I mostly agreed with you, as you can probably see from my spec issue :)

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

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

👍

Last remaining comment is about the uppercase enums.

@iNikem
Copy link
Contributor Author

iNikem commented Oct 12, 2020

👍

Last remaining comment is about the uppercase enums.

Yeah, I still don't like the idea of wrapping actual values just to have uppercase names.

@trask
Copy link
Member

trask commented Oct 12, 2020

Yeah, I still don't like the idea of wrapping actual values just to have uppercase names.

It's not "just to have uppercase names". It's to make your code easier for other people to read.

When you go against a widely followed convention like this, you make your code harder for other people to read. E.g. when I was reviewing this PR and ran across the first reference, Operation.receive, I had to spend time understanding what that was, whereas Operation.RECEIVE would have immediately made sense (oh, a constant) and I could have just kept reading on.

@iNikem
Copy link
Contributor Author

iNikem commented Oct 12, 2020

Yeah, I still don't like the idea of wrapping actual values just to have uppercase names.

It's not "just to have uppercase names". It's to make your code easier for other people to read.

When you go against a widely followed convention like this, you make your code harder for other people to read. E.g. when I was reviewing this PR and ran across the first reference, Operation.receive, I had to spend time understanding what that was, whereas Operation.RECEIVE would have immediately made sense (oh, a constant) and I could have just kept reading on.

(grumpy) ok-ok, make sense :( will do

@iNikem
Copy link
Contributor Author

iNikem commented Oct 12, 2020

@trask No, I still don't like. You suggested to have SEND("send"). What will be name of that new field? I couldn't come up with a good option, whose usage would be natural.

And I don't like the idea of always doing Operation.SEND.name().toLowerCase(). Both overhead and it may break in some locales.

@iNikem
Copy link
Contributor Author

iNikem commented Oct 12, 2020

Also, do you have any suggestions, how to merge your packages changes into this? :)

@anuraaga
Copy link
Contributor

How about just using String constants instead of enum? A bit less typesafe but it's essentially what we do for semantic attributes. And actually, these constants should be in the SDK anyways :)

@anuraaga
Copy link
Contributor

Sent open-telemetry/opentelemetry-java#1783

@iNikem
Copy link
Contributor Author

iNikem commented Oct 12, 2020

Removed enum altogether, will replace with open-telemetry/opentelemetry-java#1783 after we switch to 0.10.0

@trask
Copy link
Member

trask commented Oct 12, 2020

@iNikem I will fix the conflicts later today since I caused them 😁

@iNikem iNikem merged commit f23ad29 into open-telemetry:master Oct 13, 2020
@iNikem iNikem deleted the messaging-convention branch October 13, 2020 06:17
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.

Some attributes from spec are missing for JMS Update message queue (PRODUCER/CONSUMER) span names
3 participants