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 5b58c04 draft
5b58c04 is described below
commit 5b58c046359cadab9756d68160bb1f651b24cd8d
Author: Superskyyy <[email protected]>
AuthorDate: Tue Jun 27 23:47:37 2023 -0400
draft
---
deploy/platform/docker/docker-compose.agent.yaml | 16 ++++++
.../docker/docker-compose.ai-pipeline.yaml | 64 ++++++++++++----------
services/app/server/src/index.js | 6 ++
.../.dockerignore} | 14 +----
.../Dockerfile | 2 +-
.../Dockerfile.agentless | 2 +-
.../Dockerfile => artists-service/Makefile} | 18 +++---
services/artists-service/requirements.txt | 2 +
services/artists-service/src/app.py | 17 ++++++
.../src/main/resources/application.yaml | 4 ++
services/load-gen/loadgen.py | 4 +-
services/recommendation-service/Dockerfile | 4 +-
.../recommendation-service/Dockerfile.agentless | 2 +-
13 files changed, 100 insertions(+), 55 deletions(-)
diff --git a/deploy/platform/docker/docker-compose.agent.yaml
b/deploy/platform/docker/docker-compose.agent.yaml
index 43d2122..54702eb 100644
--- a/deploy/platform/docker/docker-compose.agent.yaml
+++ b/deploy/platform/docker/docker-compose.agent.yaml
@@ -72,6 +72,22 @@ services:
oap:
condition: service_healthy
+ # Python agent
+ rcmd:
+ image: ${HUB}/artists-service:${TAG}
+ networks: [ sw ]
+ environment:
+ SW_AGENT_NAME: artists
+ SW_AGENT_COLLECTOR_BACKEND_SERVICES: ${BACKEND_SERVICE}:11800
+ healthcheck:
+ test: [ "CMD-SHELL", "curl http://localhost/health" ]
+ interval: 30s
+ timeout: 10s
+ retries: 3
+ depends_on:
+ oap:
+ condition: service_healthy
+
# NodeJS backend agent
app:
image: ${HUB}/app:${TAG}
diff --git a/services/recommendation-service/Dockerfile
b/deploy/platform/docker/docker-compose.ai-pipeline.yaml
similarity index 67%
copy from services/recommendation-service/Dockerfile
copy to deploy/platform/docker/docker-compose.ai-pipeline.yaml
index 40f36fa..8726859 100644
--- a/services/recommendation-service/Dockerfile
+++ b/deploy/platform/docker/docker-compose.ai-pipeline.yaml
@@ -1,30 +1,34 @@
-# 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.
-#
-
-# @feature: python-agent;
-FROM apache/skywalking-python:0.7.0-grpc-py3.9
-
-WORKDIR /workspace
-
-COPY requirements.txt .
-
-RUN pip install -r requirements.txt
-
-COPY src .
-
-CMD python app.py
+# 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.
+#
+version: '2.1'
+
+services:
+ 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
+ ports:
+ - "17128:17128"
+ depends_on:
+ oap:
+ condition: service_healthy
+networks:
+ sw:
diff --git a/services/app/server/src/index.js b/services/app/server/src/index.js
index da920ea..7dce82f 100644
--- a/services/app/server/src/index.js
+++ b/services/app/server/src/index.js
@@ -37,6 +37,12 @@ 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
+ const artist = Math.random().toString(36).substring(7);
+ const postid = 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}`);
res.json({
top: top.data,
diff --git a/services/recommendation-service/Dockerfile.agentless
b/services/artists-service/.dockerignore
similarity index 86%
copy from services/recommendation-service/Dockerfile.agentless
copy to services/artists-service/.dockerignore
index 0ed70ef..83abcf1 100644
--- a/services/recommendation-service/Dockerfile.agentless
+++ b/services/artists-service/.dockerignore
@@ -15,15 +15,5 @@
# specific language governing permissions and limitations
# under the License.
#
-
-FROM python:3
-
-WORKDIR /workspace
-
-COPY requirements.txt .
-
-RUN pip install -r requirements.txt
-
-COPY src .
-
-CMD python app.py
+venv
+.venv
diff --git a/services/recommendation-service/Dockerfile
b/services/artists-service/Dockerfile
similarity index 95%
copy from services/recommendation-service/Dockerfile
copy to services/artists-service/Dockerfile
index 40f36fa..cdcdb1a 100644
--- a/services/recommendation-service/Dockerfile
+++ b/services/artists-service/Dockerfile
@@ -17,7 +17,7 @@
#
# @feature: python-agent;
-FROM apache/skywalking-python:0.7.0-grpc-py3.9
+FROM skywalking-python:1.0.1-grpc-py3.10-slim
WORKDIR /workspace
diff --git a/services/recommendation-service/Dockerfile.agentless
b/services/artists-service/Dockerfile.agentless
similarity index 97%
copy from services/recommendation-service/Dockerfile.agentless
copy to services/artists-service/Dockerfile.agentless
index 0ed70ef..1e585b5 100644
--- a/services/recommendation-service/Dockerfile.agentless
+++ b/services/artists-service/Dockerfile.agentless
@@ -16,7 +16,7 @@
# under the License.
#
-FROM python:3
+FROM python:3.10-slim
WORKDIR /workspace
diff --git a/services/recommendation-service/Dockerfile
b/services/artists-service/Makefile
similarity index 67%
copy from services/recommendation-service/Dockerfile
copy to services/artists-service/Makefile
index 40f36fa..503a316 100644
--- a/services/recommendation-service/Dockerfile
+++ b/services/artists-service/Makefile
@@ -16,15 +16,19 @@
# under the License.
#
-# @feature: python-agent;
-FROM apache/skywalking-python:0.7.0-grpc-py3.9
+include ../../Makefile.in
-WORKDIR /workspace
+.PHONY: build
+build:
-COPY requirements.txt .
+.PHONY: docker docker.build docker.push
-RUN pip install -r requirements.txt
+docker: docker.build
-COPY src .
+docker.build:
+ docker build . -t $(HUB)/artists-service:$(TAG)
+ docker build . -t $(HUB)/artists-service:$(TAG)-agentless -f
Dockerfile.agentless
-CMD python app.py
+docker.push: docker.build
+ docker push $(HUB)/artists-service:$(TAG)
+ docker push $(HUB)/artists-service:$(TAG)-agentless
diff --git a/services/artists-service/requirements.txt
b/services/artists-service/requirements.txt
new file mode 100644
index 0000000..c01e1d1
--- /dev/null
+++ b/services/artists-service/requirements.txt
@@ -0,0 +1,2 @@
+fastapi==0.98.0
+faker==18.11.2
\ No newline at end of file
diff --git a/services/artists-service/src/app.py
b/services/artists-service/src/app.py
new file mode 100644
index 0000000..38c6220
--- /dev/null
+++ b/services/artists-service/src/app.py
@@ -0,0 +1,17 @@
+from fastapi import FastAPI
+from faker import Faker
+
+app = FastAPI()
+fake = Faker()
+
[email protected]("/api/v{apiVersion}/artists/{artist}/moments/{postid}/comments/{commentid}")
+async def handle_request(apiVersion: int, artist: str, postid: int, commentid:
int):
+
+ comment_details = {
+ "commentId": commentid,
+ "commentBody": fake.sentence(),
+ "likes": fake.random_int(min=0, max=99999),
+ "userId": fake.random_number(digits=6)
+ }
+
+ return comment_details
diff --git a/services/gateway-service/src/main/resources/application.yaml
b/services/gateway-service/src/main/resources/application.yaml
index 2b728d8..fd677b2 100644
--- a/services/gateway-service/src/main/resources/application.yaml
+++ b/services/gateway-service/src/main/resources/application.yaml
@@ -31,3 +31,7 @@ spring:
uri: http://rcmd
predicates:
- Path=/rcmd/**
+ - id: artists-service
+ uri: http://artists
+ predicates:
+ - Path=/api/v*/artists/**
diff --git a/services/load-gen/loadgen.py b/services/load-gen/loadgen.py
index 23bfee8..0753d99 100644
--- a/services/load-gen/loadgen.py
+++ b/services/load-gen/loadgen.py
@@ -18,6 +18,7 @@
import os
import time
import traceback
+import random
from selenium import webdriver
from selenium.webdriver.firefox.options import Options as FirefoxOptions
@@ -36,4 +37,5 @@ while True:
except Exception:
traceback.print_exc()
finally:
- time.sleep(10)
+ # Introduces a bit randomness to the demo
+ time.sleep(random.randint(5, 15))
diff --git a/services/recommendation-service/Dockerfile
b/services/recommendation-service/Dockerfile
index 40f36fa..1ee9bcd 100644
--- a/services/recommendation-service/Dockerfile
+++ b/services/recommendation-service/Dockerfile
@@ -17,7 +17,7 @@
#
# @feature: python-agent;
-FROM apache/skywalking-python:0.7.0-grpc-py3.9
+FROM skywalking-python:1.0.1-grpc-py3.10-slim
WORKDIR /workspace
@@ -27,4 +27,4 @@ RUN pip install -r requirements.txt
COPY src .
-CMD python app.py
+CMD python app.py
\ No newline at end of file
diff --git a/services/recommendation-service/Dockerfile.agentless
b/services/recommendation-service/Dockerfile.agentless
index 0ed70ef..1e585b5 100644
--- a/services/recommendation-service/Dockerfile.agentless
+++ b/services/recommendation-service/Dockerfile.agentless
@@ -16,7 +16,7 @@
# under the License.
#
-FROM python:3
+FROM python:3.10-slim
WORKDIR /workspace