Skip to content

Commit

Permalink
datadog: fix test_memory_trace_client_test2.py
Browse files Browse the repository at this point in the history
  • Loading branch information
naisanzaa committed Apr 12, 2024
1 parent 4400120 commit a182fe8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
12 changes: 12 additions & 0 deletions automon/integrations/openTelemetryWrapper/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@ async def test(self):

return True

async def test2(self):
with self.config.tracer.start_as_current_span(name='rootSpan') as trace_root:
self.config.opentelemetry.trace.get_current_span('AAAAAAAA')

with self.config.tracer.start_as_current_span(name='childSpan') as trace_child:
self.config.opentelemetry.trace.get_current_span('AAAAAAAA')
self.config.opentelemetry.trace.get_current_span('BBBBBBBB')

self.config.opentelemetry.trace.get_current_span('BBBBBBBB')

return True

async def to_dict(self):
return [
json.loads(span.to_json())
Expand Down
1 change: 1 addition & 0 deletions automon/integrations/openTelemetryWrapper/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

class OpenTelemetryConfig(object):
def __init__(self):
self.opentelemetry = opentelemetry
self.provider = TracerProvider()
self.memory_processor = InMemorySpanExporter()
self.processor = SimpleSpanProcessor(self.memory_processor)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import unittest
import asyncio

from automon.integrations.openTelemetryWrapper import OpenTelemetryClient


class MyTestCase(unittest.TestCase):
client = OpenTelemetryClient()

def test_something(self):
self.assertTrue(asyncio.run(
self.client.test2()))

spans = asyncio.run(
self.client.get_finished_spans())

pass


if __name__ == '__main__':
unittest.main()

0 comments on commit a182fe8

Please sign in to comment.