Skip to content

Commit

Permalink
fix: adjust based on comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Tamir David authored and Tamir David committed Oct 1, 2024
1 parent d591e1d commit bf7c8b2
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 26 deletions.
11 changes: 10 additions & 1 deletion tests/e2e/workload-lifecycle/01-assert-runtime-detected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ metadata:
spec:
runtimeDetails:
- containerName: python-alpine
envVars:
- name: PYTHONPATH
value: "/app:/var/odigos/python:/var/odigos/python/opentelemetry/instrumentation/auto_instrumentation"
language: python
runtimeVersion: 3.10.15
---
Expand All @@ -281,6 +284,9 @@ metadata:
spec:
runtimeDetails:
- containerName: python-latest-version
envVars:
- name: PYTHONPATH
value: "/var/odigos/python:/var/odigos/python/opentelemetry/instrumentation/auto_instrumentation"
language: python
runtimeVersion: 3.12.6
---
Expand All @@ -298,8 +304,11 @@ metadata:
spec:
runtimeDetails:
- containerName: python-min-version
envVars:
- name: PYTHONPATH
value: "/var/odigos/python:/var/odigos/python/opentelemetry/instrumentation/auto_instrumentation"
language: python
runtimeVersion: 3.8.20
runtimeVersion: 3.8.0
---
apiVersion: odigos.io/v1alpha1
kind: InstrumentedApplication
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/workload-lifecycle/01-generate-traffic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ spec:
curl -s --fail http://java-latest-version:3000
curl -s --fail http://java-old-version:3000
curl -s --fail http://python-alpine:8000/insert-random/
curl -s --fail http://python-latest-version:8000/insert-random/
curl -s --fail http://python-min-version:8000/insert-random/
curl -s --fail http://python-not-supported:8000/insert-random/
curl -s --fail http://python-alpine:3000/insert-random/
curl -s --fail http://python-latest-version:3000/insert-random/
curl -s --fail http://python-min-version:3000/insert-random/
curl -s --fail http://python-not-supported:3000/insert-random/
12 changes: 8 additions & 4 deletions tests/e2e/workload-lifecycle/01-install-test-apps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,8 @@ spec:
app: python-latest-version
ports:
- protocol: TCP
port: 8000
port: 3000
targetPort: 8000
---
kind: Deployment
apiVersion: apps/v1
Expand Down Expand Up @@ -616,7 +617,8 @@ spec:
app: python-alpine
ports:
- protocol: TCP
port: 8000
port: 3000
targetPort: 8000
---
kind: Deployment
apiVersion: apps/v1
Expand Down Expand Up @@ -663,7 +665,8 @@ spec:
app: python-not-supported
ports:
- protocol: TCP
port: 8000
port: 3000
targetPort: 8000
---
kind: Deployment
apiVersion: apps/v1
Expand Down Expand Up @@ -710,4 +713,5 @@ spec:
app: python-min-version
ports:
- protocol: TCP
port: 8000
port: 3000
targetPort: 8000
4 changes: 4 additions & 0 deletions tests/e2e/workload-lifecycle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,23 @@ This e2e test verify various scenarios related to the lifecycle of workloads in
### python-latest-version
- Runs on the latest Python version.
- The instrumentation device should be added, and the agent must load and report traces as expected.
- We ensure that odigos-opentelemetry-python does not conflict with or overwrite the application's dependencies.

### python-alpine
- Runs Python 3.10 on the Alpine Linux distribution.
- The instrumentation device should be added, and the agent must load and report traces as expected.
- We ensure that odigos-opentelemetry-python does not conflict with or overwrite the application's dependencies.
- The application utilizes the `PYTHONPATH` environment variable in the Kubernetes deployment manifest.

### python-minimum-supported-version
- Runs Python 3.8 (minimum supported version).
- The instrumentation device should be added, and the agent must load and report traces as expected.
- We ensure that odigos-opentelemetry-python does not conflict with or overwrite the application's dependencies.

### python-not-supported-version
- Runs Python 3.6.
- This version is not supported for instrumentation.
- We ensure that odigos-opentelemetry-python does not conflict with or overwrite the application's dependencies.

## CPP Workloads

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Dockerfile.python310-slim
FROM python

WORKDIR /app
COPY . /app

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Dockerfile.python38-slim
FROM python:3.8-slim
FROM python:3.8.0-slim
WORKDIR /app
COPY . /app

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
from .proto import example_pb2_legacy as example_pb2
else:
from .proto import example_pb2
import google.protobuf
# Assert python protobuf version is the same as pinned in the requirements.txt
if google.protobuf.__version__ != '5.28.2':
raise ImportError(f"Expected protobuf version 5.28.2, got {google.protobuf.__version__}")

logger = logging.getLogger()

Expand All @@ -25,46 +29,42 @@ async def async_greeting():
await asyncio.sleep(1)
return "Hello from async!"

# Create a view to insert a random row

def insert_random_row(request):
try:
# Uses some 3rd packages that conflict with odigosodigos-opentelemetry-python
# Uses some 3rd packages that conflict with odigos-opentelemetry-python
# These few lines wont have business logic, but just to try to reproduce the conflicts

### importlib_metadata
package_name = "Django"
metadata = importlib_metadata.metadata(package_name)
django_version = metadata['Version']
logger.info(f"Using Django version: {django_version}")

### packaging
# Version comparison using packaging
v1 = parse("3.1.4")
v2 = parse(django_version)
if v1 < v2:
version_comparison_result = f"v1 ({v1}) is older than Django version ({v2})"
else:
version_comparison_result = f"v1 ({v1}) is newer than Django version ({v2})"
logger.info(version_comparison_result)

### asgiref
greeting = async_to_sync(async_greeting)()
logger.info(f"Async greeting: {greeting}")

# Create a random name
random_name = f"RandomName{random.randint(1, 1000)}"

# Create a new entry in the database
new_entry = ExampleModel.objects.create(name=random_name)
new_entry = ExampleModel.objects.create(name=f"RandomName{random.randint(1, 1000)}")

# Create a Protobuf message
# google.protobuf
message = example_pb2.ExampleMessage(
name=new_entry.name,
id=new_entry.id,
created_at=str(new_entry.created_at)
)

# Serialize the message to binary format
serialized_message = message.SerializeToString()

# You can now store or send this serialized message
logger.info(f"Serialized protobuf message: {serialized_message}")

return HttpResponse(f"Inserted random row and serialized protobuf: {new_entry.name}")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Django
protobuf
protobuf==5.28.2
importlib_metadata
packaging
asgiref
Expand Down

0 comments on commit bf7c8b2

Please sign in to comment.