Skip to content

Commit

Permalink
Merge pull request #16 from pmcollins/refact-examples
Browse files Browse the repository at this point in the history
Minor refactor of examples scripts
  • Loading branch information
pmcollins authored Aug 28, 2024
2 parents 4681eb9 + ed288cf commit 7e7a666
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
14 changes: 3 additions & 11 deletions example_scripts/trace_loop_http.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import time

from opentelemetry import trace
from lib import trace_loop

SERVICE_NAME = "my-otel-test"
NUM_ADDS = 12

if __name__ == "__main__":
tracer = trace.get_tracer("my-tracer")
for i in range(NUM_ADDS):
with tracer.start_as_current_span("my-span"):
print(f"simple_loop.py: {i+1}/{NUM_ADDS}")
time.sleep(0.5)

trace_loop(NUM_ADDS)

# Since we're not inheriting from the OtelTest base class (to avoid depending on it) we make sure our class name
# contains "OtelTest".
Expand All @@ -32,8 +25,7 @@ def on_start(self):
return None

def on_stop(self, telemetry, stdout: str, stderr: str, returncode: int) -> None:
print(f"script completed with return code {returncode}")
print(f"telemetry: {telemetry}")
pass

def is_http(self):
return True
11 changes: 2 additions & 9 deletions example_scripts/trace_loop_splk_pypi.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import time

from opentelemetry import trace
from lib import trace_loop

SERVICE_NAME = "my-otel-test"
NUM_ADDS = 12

if __name__ == "__main__":
tracer = trace.get_tracer("my-tracer")
for i in range(NUM_ADDS):
with tracer.start_as_current_span("my-span"):
print(f"simple_loop.py: {i+1}/{NUM_ADDS}")
time.sleep(0.5)

trace_loop(NUM_ADDS)

class MyOtelTest:
def requirements(self):
Expand Down

0 comments on commit 7e7a666

Please sign in to comment.