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

Add Pulsar configuration to determine the collection of message contents #657

Closed
wants to merge 8 commits into from

Conversation

CommissarXia
Copy link
Contributor

@CommissarXia CommissarXia commented Dec 7, 2023

  • If this is non-trivial feature, paste the links/URLs to the design doc.

  • Update the documentation to include this new feature.

  • Tests(including UT, IT, E2E) are added to verify the new feature.

  • If it's UI related, attach the screenshots below.

  • Modify the unit test to verify that the feature works.

  • The configuration has been verified in practice.

  • If this pull request closes/resolves/fixes an existing issue, replace the issue number. Closes #.

  • Update the CHANGES log.

@wu-sheng
Copy link
Member

wu-sheng commented Dec 7, 2023

You should update pulsar test scenarios to cover the new parameters.

/**
* If set to true, the message contents of the Pulsar topic would be collected.
*/
public static boolean TRACE_MESSAGE_CONTENTS = true;
Copy link
Member

Choose a reason for hiding this comment

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

The default value should be false. The impact is clear for memory, network and database.

Copy link
Member

Choose a reason for hiding this comment

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

agent.config set to false is not enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I'll make some modifications and conduct unit testing. Thank you!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wu-sheng Shengge The relevant modifications have been submitted. Please check them when you have time. Thank you!

@@ -73,6 +75,9 @@ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allAr
Tags.MQ_BROKER.set(activeSpan, serviceUrl);
Tags.MQ_TOPIC.set(activeSpan, consumer.getTopic());
activeSpan.setPeer(serviceUrl);
if (Pulsar.TRACE_MESSAGE_CONTENTS) {
Tags.MQ_BODY.set(activeSpan, StringUtil.cut(new String(msg.getData()), Pulsar.MESSAGE_CONTENTS_MAX_LENGTH));
Copy link
Member

Choose a reason for hiding this comment

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

msg.getData() is a byte[]. Is here OK to use the default charset?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We used the default encoding for a long time without any issues, but we are using Java and are unsure if other languages can execute properly. This time, I added the UTF-8 character set and it ran normally in our environment

@wu-sheng
Copy link
Member

wu-sheng commented Dec 8, 2023

Please update this test, https://github.com/apache/skywalking-java/tree/main/test/plugin/scenarios/pulsar-scenario

Plugin test could run locally, https://skywalking.apache.org/docs/skywalking-java/v9.1.0/en/setup/service-agent/java-agent/plugin-test/

You should activate this new config and verify new tags.

@CommissarXia
Copy link
Contributor Author

There are some issues with the environment of my computer. I will submit it after I run it. Thanks!

@CommissarXia
Copy link
Contributor Author

This test (https://github.com/apache/skywalking-java/tree/main/test/plugin/scenarios/pulsar-scenario) has passed (Scenario[pulsar-scenario-2.2.1] passed!) in the local environment and has been submitted.

@@ -97,6 +99,7 @@ segmentItems:
- { key: transmission.latency, value: not blank }
- { key: mq.broker, value: not blank }
- { key: mq.topic, value: test }
- { key: mq.body, value: "1" }
Copy link
Member

Choose a reason for hiding this comment

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

This is how the message is built,

producer.newMessage().key("testKey").value(Integer.toString(1).getBytes()).property("TEST", "TEST").send();

But you only set 1 as body? Could you explain?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This 1 was set by the previous submitter, and I only tested the corresponding expected value based on this value. If need test message bodies in other formats, I can modify and resubmit them.

Copy link
Member

Choose a reason for hiding this comment

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

But there is not only value. There are a key and properties. aren't those message body too?

@wu-sheng
Copy link
Member

Could you explain what you changed?

Personally, I am frustrated about the communications between us. I have to read codes, understand codes, but you never relies words.

@CommissarXia
Copy link
Contributor Author

Actually, I only added a dynamic configuration item to dynamically collect the message contents of Pulsar. I changed "mq.body" to "mq.message_contents" and have already submitted it. This can more clearly reflect the content I added and the expected results.

@wu-sheng
Copy link
Member

My question is key/value, why is the key not collected?

@CommissarXia
Copy link
Contributor Author

The key is Pulsar's strategy for message routing, and its relationship with actual messages can be inclusive or independent. I just wanted to collect actual messages, so I didn't consider this key. Perhaps my consideration was a bit lacking.

@wu-sheng
Copy link
Member

Is there pulsar doc indicating key is not a part of message? I am doubt about that.

@wu-sheng
Copy link
Member

@tisonkun What is the message concept in the Pulsar?

@CommissarXia
Copy link
Contributor Author

Misunderstand my meaning, key must be passed together with the content of the message body, but the collection content I want to add does not take into account key, I will add it sometime today.

@CommissarXia
Copy link
Contributor Author

The messages in Pulsar include Value/data payload, Key, Properties, etc. My initial idea was just to collect Values.

@wu-sheng
Copy link
Member

That doesn't make sense from my understanding, unless this is from Pulsar officially.
If we declare collecting message, it should be the whole.

@CommissarXia
Copy link
Contributor Author

OK, it should be my lack of understanding. I'll readjust it again. I'm really sorry for wasting your time.

@wu-sheng
Copy link
Member

For next time, please write the proposal that you design first. It would help me align with you.

@CommissarXia
Copy link
Contributor Author

Ok, thank you very much!

@wu-sheng
Copy link
Member

Any update about this/

@CommissarXia
Copy link
Contributor Author

I was sick last week. I have time to deal with it this week.

@wu-sheng
Copy link
Member

Is this still on going?

@CommissarXia
Copy link
Contributor Author

Shengge, After careful consideration later, maybe this feature is not very necessary, and the demand for simply collecting message content is probably not too much, so I want to give up this pull request.
Shengge, do you have any opinions? Sorry for wasting your time.

@wu-sheng
Copy link
Member

wu-sheng commented Jan 2, 2024

Closing upon request.

@wu-sheng wu-sheng closed this Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants