You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by yi...@apache.org on 2023/11/07 02:17:35 UTC

(skywalking-showcase) branch ai-endpoint-grouping updated: save

This is an automated email from the ASF dual-hosted git repository.

yihaochen pushed a commit to branch ai-endpoint-grouping
in repository https://gitbox.apache.org/repos/asf/skywalking-showcase.git


The following commit(s) were added to refs/heads/ai-endpoint-grouping by this push:
     new 1ffe4ea  save
1ffe4ea is described below

commit 1ffe4ea3e0a03785a9eda509cfbf307b8ffa4295
Author: Superskyyy (Back) <Su...@outlook.com>
AuthorDate: Mon Nov 6 21:17:29 2023 -0500

    save
---
 Makefile.in                                            |  2 ++
 deploy/platform/docker/docker-compose.agent.yaml       |  4 ++--
 deploy/platform/docker/docker-compose.ai-pipeline.yaml |  6 +++---
 docs/readme.md                                         |  4 +++-
 services/app/server/src/index.agentless.js             | 10 ++++++++++
 services/app/server/src/index.js                       | 11 +++++++----
 services/artists-service/Dockerfile                    |  2 +-
 services/artists-service/requirements.txt              |  2 +-
 services/load-gen/loadgen.py                           |  2 +-
 9 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 9ebb11b..f0ff50e 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -55,5 +55,7 @@ GRAFANA_IMAGE ?= grafana/grafana:9.5.2
 OTEL_COLLECTOR_IMAGE ?= otel/opentelemetry-collector
 OTEL_COLLECTOR_IMAGE_TAG ?= 0.72.0
 
+SW_R3_IMAGE ?= ghcr.io/
+SW_R3_IMAGE_TAG ?= pending 
 # ALL variables should be listed above ^^
 EXPORTED_VARS := $(filter-out <%,$(.VARIABLES))
diff --git a/deploy/platform/docker/docker-compose.agent.yaml b/deploy/platform/docker/docker-compose.agent.yaml
index 54702eb..3eea538 100644
--- a/deploy/platform/docker/docker-compose.agent.yaml
+++ b/deploy/platform/docker/docker-compose.agent.yaml
@@ -72,8 +72,8 @@ services:
       oap:
         condition: service_healthy
 
-  # Python agent
-  rcmd:
+  # Python agent + R3 URI Grouping demo
+  artists:
     image: ${HUB}/artists-service:${TAG}
     networks: [ sw ]
     environment:
diff --git a/deploy/platform/docker/docker-compose.ai-pipeline.yaml b/deploy/platform/docker/docker-compose.ai-pipeline.yaml
index 8726859..2ac00e3 100644
--- a/deploy/platform/docker/docker-compose.ai-pipeline.yaml
+++ b/deploy/platform/docker/docker-compose.ai-pipeline.yaml
@@ -18,17 +18,17 @@
 version: '2.1'
 
 services:
-  r3:
+  r3: # https://github.com/SkyAPM/R3 
     image: ${SW_R3_IMAGE}:${SW_R3_IMAGE_TAG}
     container_name: r3
     healthcheck:
       test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/17128" ]
-    networks:
-      - manual
+    networks: [ sw ]
     ports:
         - "17128:17128"
     depends_on:
       oap:
         condition: service_healthy
+
 networks:
   sw:
diff --git a/docs/readme.md b/docs/readme.md
index c6cda23..ff25920 100644
--- a/docs/readme.md
+++ b/docs/readme.md
@@ -12,13 +12,15 @@ graph LR;
   loadgen[load generator] --> ui("UI (React)") --> Traffic1("HTTP Request for backend serv") -->  apisix("APISIX as UI container")
  --> app("app server (NodeJS)") --> gateway("gateway (Spring)");
   ui("UI (React)") --> Traffic2("HTTP Request for UI codes") --> apisix("APISIX with  UI container")
-  gateway --> songs("songs (Spring)") & rcmd("recommendations (Python)");
+  gateway --> songs("songs (Spring)") & rcmd("recommendations (Python)") & artists("artists service (Python & R3 URI Grouping<sup>1</sup>)");
   songs --> activeMQ
   activeMQ --> songs
   rcmd --> songs;
   songs --> db("database (H2)");
 ```
 
+[1] URI Grouping is supported by **R3**, an algorithm that groups same RESTful URIs of different path parameters automatically. See the [R3 Project](https://github.com/SkyAPM/R3?tab=readme-ov-file#algorithm-uridrain) for details about the algorithm and its deployment methods. 
+
 ## Usage
 
 **Please run the showcase in a brand new test cluster, otherwise the undeploy process may delete
diff --git a/services/app/server/src/index.agentless.js b/services/app/server/src/index.agentless.js
index b880e7a..f67d67c 100644
--- a/services/app/server/src/index.agentless.js
+++ b/services/app/server/src/index.agentless.js
@@ -36,9 +36,19 @@ app.get('/homepage', async (req, res) => {
     const top = await axios.get(`http://${GATEWAY}/songs/top`, { headers });
     const rcmd = await axios.get(`http://${GATEWAY}/rcmd`, { headers });
 
+    // Retrival of a comment from some artist's timeline (moments), 
+    // this uri is intentionally made complex to showcase the R3 endpoint grouping algorithm
+    const apiVersion = Math.floor(Math.random() * 2) + 1;
+    const artist = Math.random().toString(36).substring(7);
+    const momentid = Math.floor(Math.random() * 1000);
+    const commentid = Math.floor(Math.random() * 1000);
+
+    const comment = await axios.get(`http://${GATEWAY}/api/v${apiVersion}/artists/${artist}/moments/${momentid}/comments/${commentid}`);
+
     res.json({
         top: top.data,
         rcmd: rcmd.data,
+        comment: comment.data
     });
 });
 
diff --git a/services/app/server/src/index.js b/services/app/server/src/index.js
index 7dce82f..480e61b 100644
--- a/services/app/server/src/index.js
+++ b/services/app/server/src/index.js
@@ -37,16 +37,19 @@ const app = express();
 app.get('/homepage', async (req, res) => {
     const top = await axios.get(`http://${GATEWAY}/songs/top`);
     const rcmd = await axios.get(`http://${GATEWAY}/rcmd`);
-    // Retrival of a comment from some artist's timeline, it is intentionally made complex to showcase the R3 endpoint grouping algorithm
+
+    // Retrival of a comment from some artist's timeline (moments), 
+    // this uri is intentionally made complex to showcase the R3 endpoint grouping algorithm
+    const apiVersion = Math.floor(Math.random() * 2) + 1;
     const artist = Math.random().toString(36).substring(7);
-    const postid = Math.floor(Math.random() * 1000);
+    const momentid = Math.floor(Math.random() * 1000);
     const commentid = Math.floor(Math.random() * 1000);
-    const apiVersion = Math.floor(Math.random() * 2) + 1;
-    const post = await axios.get(`http://${GATEWAY}/api/v${apiVersion}/artists/${artist}/moments/${postid}/comments/${commentid}`);
 
+    const comment = await axios.get(`http://${GATEWAY}/api/v${apiVersion}/artists/${artist}/moments/${momentid}/comments/${commentid}`);
     res.json({
         top: top.data,
         rcmd: rcmd.data,
+        comment: comment.data
     });
 });
 
diff --git a/services/artists-service/Dockerfile b/services/artists-service/Dockerfile
index cdcdb1a..2c2ad3d 100644
--- a/services/artists-service/Dockerfile
+++ b/services/artists-service/Dockerfile
@@ -17,7 +17,7 @@
 #
 
 # @feature: python-agent;
-FROM skywalking-python:1.0.1-grpc-py3.10-slim
+FROM skywalking-python:1.1.0-grpc-py3.10-slim
 
 WORKDIR /workspace
 
diff --git a/services/artists-service/requirements.txt b/services/artists-service/requirements.txt
index c01e1d1..9cfb55d 100644
--- a/services/artists-service/requirements.txt
+++ b/services/artists-service/requirements.txt
@@ -1,2 +1,2 @@
-fastapi==0.98.0
+fastapi==0.104.1
 faker==18.11.2
\ No newline at end of file
diff --git a/services/load-gen/loadgen.py b/services/load-gen/loadgen.py
index 0753d99..1dd83cb 100644
--- a/services/load-gen/loadgen.py
+++ b/services/load-gen/loadgen.py
@@ -37,5 +37,5 @@ while True:
     except Exception:
         traceback.print_exc()
     finally:
-        # Introduces a bit randomness to the demo
+        # Introduces some randomness to the demo
         time.sleep(random.randint(5, 15))