From e0818eb9ede838d08a6e3d75547ba23185d24f10 Mon Sep 17 00:00:00 2001 From: alrex Date: Tue, 4 May 2021 14:24:49 -0700 Subject: [PATCH] remove lstrace example (#72) --- .github/workflows/update-containers.yml | 1 - README.md | 1 - config/integration.yml | 3 - docker-compose.yml | 37 ---------- python/lstrace/Dockerfile.client | 4 -- python/lstrace/Dockerfile.server | 5 -- python/lstrace/client.py | 36 ---------- python/lstrace/common.py | 19 ------ python/lstrace/server.py | 89 ------------------------- python/opentelemetry/common.py | 9 +-- 10 files changed, 1 insertion(+), 203 deletions(-) delete mode 100644 python/lstrace/Dockerfile.client delete mode 100644 python/lstrace/Dockerfile.server delete mode 100755 python/lstrace/client.py delete mode 100644 python/lstrace/common.py delete mode 100755 python/lstrace/server.py diff --git a/.github/workflows/update-containers.yml b/.github/workflows/update-containers.yml index 19183814..fa053db9 100644 --- a/.github/workflows/update-containers.yml +++ b/.github/workflows/update-containers.yml @@ -14,7 +14,6 @@ jobs: 'go-opentracing-server', 'go-opentracing-client', 'go-opentelemetry-server', 'go-opentelemetry-client', 'go-launcher-server', 'go-launcher-client', - 'py-lstrace-client', 'py-lstrace-server', 'py-collector-client', 'py-collector-server', 'py-opentelemetry-client', 'py-opentelemetry-server', 'py-launcher-client', 'py-launcher-server', diff --git a/README.md b/README.md index 6020986c..3f0da321 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,6 @@ The following client/server applications use different mechanism for sending dat | go-opentracing | client/server example instrumented via lightstep-tracer-go | | go-opentelemetry | client/server example instrumented via OpenTelemetry and the OTLP exporter | | go-launcher | client/server example instrumented via OpenTelemetry and the Launcher for configuration | -| py-lstrace | client/server example instrumented via ls-trace-py | | py-collector | client/server example instrumented via OpenTelemetry and the OTLP exporter combined with the OpenTelemetry Collector | | py-opentelemetry | client/server example instrumented via OpenTelemetry and the OTLP exporter | | py-launcher | client/server example instrumented via OpenTelemetry and the Launcher for configuration | diff --git a/config/integration.yml b/config/integration.yml index 5fc5f6d3..9305f665 100644 --- a/config/integration.yml +++ b/config/integration.yml @@ -2,7 +2,6 @@ clients: - go-opentracing-client - go-opentelemetry-client - go-launcher-client -- py-lstrace-client - py-collector-client - py-opentelemetry-client - py-launcher-client @@ -17,7 +16,6 @@ endpoints: - http://go-opentracing-server:8081/ping - http://go-opentelemetry-server:8081/ping - http://go-launcher-server:8081/ping -- http://py-lstrace-server:5000/ping - http://py-collector-server:5000/ping - http://py-opentelemetry-server:5000/ping - http://py-launcher-server:5000/ping @@ -34,7 +32,6 @@ services: - go-opentracing-server - go-opentelemetry-server - go-launcher-server -- py-lstrace-server - py-collector-server - py-opentelemetry-server - py-launcher-server diff --git a/docker-compose.yml b/docker-compose.yml index d504a564..5428e371 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -94,42 +94,6 @@ services: ############################### ####### Python examples ####### ############################### - py-lstrace-client: - container_name: py-lstrace-client - image: ghcr.io/lightstep/opentelemetry-examples:py-lstrace-client - build: - context: ./python/lstrace - dockerfile: Dockerfile.client - networks: - - demo - depends_on: - - py-lstrace-server - env_file: - - .env - environment: - - LS_SERVICE_NAME=py-lstrace-client - - LS_SERVICE_VERSION=1.2.1 - - DESTINATION_URL=http://py-lstrace-server:5000/ping - stop_grace_period: 1s - py-lstrace-server: - container_name: py-lstrace-server - image: ghcr.io/lightstep/opentelemetry-examples:py-lstrace-server - build: - context: ./python/lstrace - dockerfile: Dockerfile.server - networks: - - demo - depends_on: - - redis - - postgres - - mysql - - mongo - env_file: - - .env - environment: - - LS_SERVICE_NAME=py-lstrace-server - - LS_SERVICE_VERSION=0.2.2 - stop_grace_period: 1s py-collector-client: container_name: py-collector-client image: ghcr.io/lightstep/opentelemetry-examples:py-collector-client @@ -532,7 +496,6 @@ services: - py-opentelemetry-server - py-launcher-server - py-opentracing-server - - py-lstrace-server - js-lstrace-server - js-launcher-server - js-ot-shim-server diff --git a/python/lstrace/Dockerfile.client b/python/lstrace/Dockerfile.client deleted file mode 100644 index 77f141e7..00000000 --- a/python/lstrace/Dockerfile.client +++ /dev/null @@ -1,4 +0,0 @@ -FROM python:3.7 -RUN pip install ls-trace -ADD *.py /app/ -CMD ["ls-trace-run", "/usr/local/bin/python", "/app/client.py"] diff --git a/python/lstrace/Dockerfile.server b/python/lstrace/Dockerfile.server deleted file mode 100644 index b90c6e21..00000000 --- a/python/lstrace/Dockerfile.server +++ /dev/null @@ -1,5 +0,0 @@ -FROM python:3.7 -RUN pip install flask redis pymongo sqlalchemy -RUN pip install ls-trace -ADD *.py /app/ -CMD ["ls-trace-run", "/usr/local/bin/python", "/app/server.py"] diff --git a/python/lstrace/client.py b/python/lstrace/client.py deleted file mode 100755 index 9c6e9a83..00000000 --- a/python/lstrace/client.py +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env python -# -# example code to test ls-trace-py -# -# usage: -# LS_ACCESS_TOKEN=${SECRET_TOKEN} \ -# LS_SERVICE_NAME=demo-python \ -# LS_SERVICE_VERSION=0.0.8 \ -# ls-trace-run python client.py - -import os -import time - -from ddtrace import tracer -import requests - -from common import get_tracer - -get_tracer() - - -def send_requests(url): - with tracer.trace("client operation"): - try: - res = requests.get(url) - print(f"Request to {url}, got {len(res.content)} bytes") - except Exception as e: - print(f"Request to {url} failed {e}") - pass - - -if __name__ == "__main__": - target = os.getenv("DESTINATION_URL", "http://localhost:8081/ping") - while True: - send_requests(target) - time.sleep(5) diff --git a/python/lstrace/common.py b/python/lstrace/common.py deleted file mode 100644 index b5adc8d4..00000000 --- a/python/lstrace/common.py +++ /dev/null @@ -1,19 +0,0 @@ -import os - -from ddtrace import tracer -from ddtrace.propagation.b3 import B3HTTPPropagator - - -def get_ls_tracer(): - tracer.configure(http_propagator=B3HTTPPropagator, settings={}) - tracer.set_tags( - { - "lightstep.service_name": os.getenv("LS_SERVICE_NAME"), - "service.version": os.getenv("LS_SERVICE_VERSION"), - "lightstep.access_token": os.getenv("LS_ACCESS_TOKEN"), - } - ) - - -def get_tracer(): - return get_ls_tracer() diff --git a/python/lstrace/server.py b/python/lstrace/server.py deleted file mode 100755 index 20272688..00000000 --- a/python/lstrace/server.py +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/env python -import random -import string -import flask - -from ddtrace import tracer -import redis -from pymongo import MongoClient -from sqlalchemy import Column, ForeignKey, Integer, String, create_engine -from sqlalchemy.ext.declarative import declarative_base -from sqlalchemy.orm import relationship - -from common import get_tracer - -get_tracer() - -app = flask.Flask(__name__) - -Base = declarative_base() - - -class Person(Base): - __tablename__ = "person" - # Here we define columns for the table person - # Notice that each column is also a normal Python instance attribute. - id = Column(Integer, primary_key=True) - name = Column(String(250), nullable=False) - - -class Address(Base): - __tablename__ = "address" - # Here we define columns for the table address. - # Notice that each column is also a normal Python instance attribute. - id = Column(Integer, primary_key=True) - street_name = Column(String(250)) - street_number = Column(String(250)) - post_code = Column(String(250), nullable=False) - person_id = Column(Integer, ForeignKey("person.id")) - person = relationship(Person) - - -def _random_string(length): - """Generate a random string of fixed length """ - letters = string.ascii_lowercase - return "".join(random.choice(letters) for i in range(int(length))) - - -@app.route("/ping") -def ping(): - length = random.randint(1, 1024) - redis_integration(length) - pymongo_integration(length) - sqlalchemy_integration(length) - return _random_string(length) - - -@app.route("/redis/") -def redis_integration(length): - with tracer.trace("server redis operation"): - r = redis.Redis(host="redis", port=6379) - r.mset({"length": _random_string(length)}) - return str(r.get("length")) - - -@app.route("/pymongo/") -def pymongo_integration(length): - with tracer.trace("server pymongo operation"): - client = MongoClient("mongo", 27017, serverSelectionTimeoutMS=2000) - db = client["opentelemetry-tests"] - collection = db["tests"] - collection.find_one() - return _random_string(length) - - -@app.route("/sqlalchemy/") -def sqlalchemy_integration(length): - with tracer.trace("server sqlalchemy operation"): - # Create an engine that stores data in the local directory's - # sqlalchemy_example.db file. - engine = create_engine("sqlite:///sqlalchemy_example.db") - - # Create all tables in the engine. This is equivalent to "Create Table" - # statements in raw SQL. - Base.metadata.create_all(engine) - return str(_random_string(length)) - - -if __name__ == "__main__": - app.run(host="0.0.0.0") diff --git a/python/opentelemetry/common.py b/python/opentelemetry/common.py index 8664c566..a54da143 100644 --- a/python/opentelemetry/common.py +++ b/python/opentelemetry/common.py @@ -1,6 +1,5 @@ import os -import grpc from opentelemetry import trace from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter from opentelemetry.propagate import set_global_textmap @@ -16,14 +15,8 @@ def get_otlp_exporter(): ) -def get_otel_tracer(): - - set_global_textmap(CompositeHTTPPropagator([B3Format()])) +def get_tracer(): span_exporter = get_otlp_exporter() trace.get_tracer_provider().add_span_processor(BatchSpanProcessor(span_exporter)) return trace.get_tracer(__name__) - - -def get_tracer(): - return get_otel_tracer()