-
-
Save manuel-delverme/1f0160a51d67d1fddd47cb10b574a963 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| from functools import wraps | |
| import arize_otel | |
| from arize_otel import Endpoints | |
| from opentelemetry import trace | |
| from opentelemetry.trace import NoOpTracer | |
| def delay_decorator(func): | |
| @wraps(func) | |
| def wrapper(*args, **kwargs): | |
| time.sleep(10) | |
| return func(*args, **kwargs) | |
| return wrapper | |
| arize_otel.register_otel( | |
| endpoints=Endpoints.ARIZE, | |
| space_key="bbbbbbbbbb", | |
| api_key="aaaaaaaaaa", | |
| model_id="cake", | |
| ) | |
| # Test 1: Normal operation | |
| t0 = time.time() | |
| tracer = trace.get_tracer("cake") | |
| with tracer.start_as_current_span("a") as span: | |
| with tracer.start_as_current_span("b") as span: | |
| time.sleep(1) | |
| print("Test 1-b Duration:", time.time() - t0) | |
| print("Test 1-a Duration:", time.time() - t0) | |
| # Test 2: Using NoOpTracer | |
| tracer = NoOpTracer() | |
| t0 = time.time() | |
| with tracer.start_as_current_span("a") as span: | |
| with tracer.start_as_current_span("b") as span: | |
| time.sleep(1) | |
| print("Test 2-b Duration:", time.time() - t0) | |
| print("Test 2-a Duration:", time.time() - t0) | |
| tracer = trace.get_tracer("cake") | |
| t0 = time.time() | |
| with tracer.start_as_current_span("a") as span: | |
| original_export = span._span_processor._span_processors[0].span_exporter._client.Export | |
| span._span_processor._span_processors[0].span_exporter._client.Export = delay_decorator(original_export) | |
| with tracer.start_as_current_span("b") as span: | |
| time.sleep(1) | |
| print("Test 3-b Duration:", time.time() - t0) | |
| print("Test 3-a Duration:", time.time() - t0) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Test 1-b Duration: 1.7479286193847656
Test 1-a Duration: 2.0280649662017822
Test 2-b Duration: 1.0003631114959717
Test 2-a Duration: 1.0003926753997803
Test 3-b Duration: 11.34163522720337
Test 3-a Duration: 21.62044596672058