Ejemplo n.º 1
0
 def test_local_component_structure(self):
     local_trace_observer = TraceLocalSpanObserver("test-service",
                                                   "test-component",
                                                   "test-host", self.span,
                                                   self.recorder)
     self.assertListEqual(
         local_trace_observer.binary_annotations,
         [
             {
                 "key": ANNOTATIONS["COMPONENT"],
                 "value": "baseplate",
                 "endpoint": {
                     "ipv4": "test-host",
                     "serviceName": "test-service"
                 },
             },
             {
                 "key": ANNOTATIONS["LOCAL_COMPONENT"],
                 "value": "test-component",
                 "endpoint": {
                     "ipv4": "test-host",
                     "serviceName": "test-service"
                 },
             },
         ],
     )
Ejemplo n.º 2
0
 def _register_local_mock(self, span):
     local_span_observer = TraceLocalSpanObserver('test-service',
                                                  'test-component',
                                                  'test-hostname', span,
                                                  NullRecorder())
     self.local_span_ids.append(span.id)
     self.local_span_observers.append(local_span_observer)
     span.register(local_span_observer)
Ejemplo n.º 3
0
 def test_local_component_structure(self):
     local_trace_observer = TraceLocalSpanObserver("test-service",
                                                   "test-component",
                                                   "test-host", self.span,
                                                   self.recorder)
     self.assertEqual(len(local_trace_observer.binary_annotations), 1)
     annotation = local_trace_observer.binary_annotations[0]
     self.assertEqual(annotation["key"], ANNOTATIONS["LOCAL_COMPONENT"])
     self.assertEqual(annotation["value"], "test-component")
Ejemplo n.º 4
0
 def test_init_local_component(self):
     local_trace_observer = TraceLocalSpanObserver(
         'test-service',
         'test-component',
         'test-host',
         self.span,
         self.recorder,
     )
     self.assertEqual(
         local_trace_observer.component_name,
         'test-component',
     )
Ejemplo n.º 5
0
 def test_serialize(self):
     local_trace_observer = TraceLocalSpanObserver("test-service",
                                                   "test-component",
                                                   "test-host", self.span,
                                                   self.recorder)
     local_trace_observer.on_start()
     local_trace_observer.on_finish(None)
     serialized_span = local_trace_observer._serialize()
     self.assertIsNotNone(serialized_span["duration"])
     self.assertEqual(serialized_span["name"], self.span.name)
     lc_annotation = serialized_span["binaryAnnotations"][0]
     self.assertEqual(lc_annotation["endpoint"]["serviceName"],
                      "test-service")
     self.assertEqual(lc_annotation["value"], "test-component")
Ejemplo n.º 6
0
 def test_serialize(self):
     local_trace_observer = TraceLocalSpanObserver("test-service",
                                                   "test-component",
                                                   "test-host", self.span,
                                                   self.recorder)
     local_trace_observer.on_start()
     local_trace_observer.on_finish(None)
     serialized_span = local_trace_observer._serialize()
     self.assertIsNotNone(serialized_span["duration"])
     self.assertEqual(serialized_span["name"], self.span.name)
     annotations = serialized_span["binaryAnnotations"]
     for annotation in annotations:
         self.assertTrue("key" in annotation)
         self.assertTrue("value" in annotation)
         self.assertTrue("endpoint" in annotation)
Ejemplo n.º 7
0
 def test_serialize(self):
     local_trace_observer = TraceLocalSpanObserver(
         'test-service',
         'test-component',
         'test-host',
         self.span,
         self.recorder,
     )
     local_trace_observer.on_start()
     local_trace_observer.on_finish(None)
     serialized_span = local_trace_observer._serialize()
     self.assertIsNotNone(serialized_span['duration'])
     self.assertEqual(serialized_span['name'], self.span.name)
     lc_annotation = serialized_span['binaryAnnotations'][0]
     self.assertEqual(lc_annotation['endpoint']['serviceName'], 'test-service')
     self.assertEqual(lc_annotation['value'], 'test-component')
Ejemplo n.º 8
0
 def test_local_component_structure(self):
     local_trace_observer = TraceLocalSpanObserver(
         'test-service',
         'test-component',
         'test-host',
         self.span,
         self.recorder,
     )
     self.assertEqual(
         len(local_trace_observer.binary_annotations),
         1,
     )
     annotation = local_trace_observer.binary_annotations[0]
     self.assertEqual(
         annotation['key'],
         ANNOTATIONS['LOCAL_COMPONENT'],
     )
     self.assertEqual(
         annotation['value'],
         'test-component',
     )
Ejemplo n.º 9
0
 def test_serialize(self):
     local_trace_observer = TraceLocalSpanObserver(
         'test-service',
         'test-component',
         'test-host',
         self.span,
         self.recorder,
     )
     local_trace_observer.on_start()
     local_trace_observer.on_finish(None)
     serialized_span = local_trace_observer._serialize()
     self.assertIsNotNone(serialized_span['duration'])
     self.assertEqual(serialized_span['name'], self.span.name)
     lc_annotation = serialized_span['binaryAnnotations'][0]
     self.assertEqual(lc_annotation['endpoint']['serviceName'], 'test-service')
     self.assertEqual(lc_annotation['value'], 'test-component')
Ejemplo n.º 10
0
 def test_init_local_component(self):
     local_trace_observer = TraceLocalSpanObserver("test-service",
                                                   "test-component",
                                                   "test-host", self.span,
                                                   self.recorder)
     self.assertEqual(local_trace_observer.component_name, "test-component")