[ 
https://issues.apache.org/jira/browse/PROTON-2487?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17519485#comment-17519485
 ] 

ASF GitHub Bot commented on PROTON-2487:
----------------------------------------

DreamPearl commented on code in PR #355:
URL: https://github.com/apache/qpid-proton/pull/355#discussion_r845962781


##########
cpp/examples/tracing_client.cpp:
##########
@@ -0,0 +1,108 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include <proton/connection.hpp>
+#include <proton/container.hpp>
+#include <proton/delivery.hpp>
+#include <proton/message.hpp>
+#include <proton/message_id.hpp>
+#include <proton/messaging_handler.hpp>
+#include <proton/receiver.hpp>
+#include <proton/receiver_options.hpp>
+#include <proton/sender.hpp>
+#include <proton/source_options.hpp>
+#include <proton/target.hpp>
+#include <proton/uuid.hpp>
+
+// Header file for tracing.
+#include <proton/tracing.hpp>
+
+#include <iostream>
+#include <string>
+
+struct client : public proton::messaging_handler {
+    std::string conn_url_;
+    std::string addr_;
+    std::string msg_;
+    proton::sender sender_;
+
+  public:
+    client(const std::string& u, const std::string& r, std::string& m) : 
conn_url_(u), addr_(r), msg_(m) {}
+
+    void on_container_start(proton::container& cont) override {
+        proton::connection conn = cont.connect(conn_url_);
+
+        sender_ = conn.open_sender(addr_);
+
+        proton::receiver_options opts{};
+        proton::source_options sopts{};
+
+        sopts.dynamic(true);
+        opts.source(sopts);
+
+        conn.open_receiver("", opts);
+    }
+
+    void on_sender_open(proton::sender& snd) override {
+        std::cout << "Opened sender for target address '" << 
snd.target().address() << "'\n";
+    }
+
+    void on_receiver_open(proton::receiver& rcv) override {
+        std::cout << "Opened dynamic receiver for responses\n";
+
+        proton::message request{msg_};
+        request.id(proton::message_id{proton::uuid::random()});
+        request.reply_to(rcv.source().address());
+
+        sender_.send(request);
+
+        std::cout << "Sent request '" << request.body() << "'\n";
+    }
+
+    void on_message(proton::delivery& d, proton::message& response) override {
+        std::cout << "Received response '" << response.body() << "'\n";
+
+        d.receiver().close();
+        d.connection().close();
+    }
+};
+
+int main(int argc, char** argv) {
+    try {
+        std::string conn_url = argc > 1 ? argv[1] : "//127.0.0.1:5672";
+        std::string addr = argc > 2 ? argv[2] : "examples";
+        std::string msg = argc > 3 ? argv[3] : "Hello tracing";
+
+        // The only thing that makes this example a tracing example.
+        proton::initOpentelemetryTracer(proton::jaeger);
+
+        client c(conn_url, addr, msg);
+
+        proton::container(c).run();
+
+        return 0;
+    } catch (const std::exception& e) {
+        std::cerr << e.what() << "\n";
+        return 1;

Review Comment:
   Will remove this in the next PR update. (Removed locally)





> [cpp] Implement distributed tracing
> -----------------------------------
>
>                 Key: PROTON-2487
>                 URL: https://issues.apache.org/jira/browse/PROTON-2487
>             Project: Qpid Proton
>          Issue Type: New Feature
>          Components: cpp-binding
>    Affects Versions: proton-c-0.37.0
>            Reporter: Rakhi Kumari
>            Assignee: Rakhi Kumari
>            Priority: Major
>             Fix For: proton-c-0.38.0
>
>
> Implement distributed tracing using opentelemetry.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to