예제 #1
0
 def test_trace_init_custom_ids_generator(self, mock_iter_entry_points):
     mock_iter_entry_points.configure_mock(return_value=[
         IterEntryPoint("custom_ids_generator", CustomIdsGenerator)
     ])
     Configuration._reset()
     ids_generator_name = _get_ids_generator()
     ids_generator = _import_ids_generator(ids_generator_name)
     _init_tracing({}, ids_generator)
     provider = self.set_provider_mock.call_args[0][0]
     self.assertIsInstance(provider.ids_generator, CustomIdsGenerator)
예제 #2
0
    def test_trace_init_default(self):
        environ["OTEL_SERVICE_NAME"] = "my-test-service"
        Configuration._reset()
        _init_tracing({"zipkin": Exporter}, RandomIdsGenerator)

        self.assertEqual(self.set_provider_mock.call_count, 1)
        provider = self.set_provider_mock.call_args[0][0]
        self.assertIsInstance(provider, Provider)
        self.assertIsInstance(provider.ids_generator, RandomIdsGenerator)
        self.assertIsInstance(provider.processor, Processor)
        self.assertIsInstance(provider.processor.exporter, Exporter)
        self.assertEqual(provider.processor.exporter.service_name,
                         "my-test-service")
예제 #3
0
    def test_trace_init_otlp(self):
        environ["OTEL_SERVICE_NAME"] = "my-otlp-test-service"
        Configuration._reset()
        _init_tracing({"otlp": OTLPExporter}, RandomIdsGenerator)

        self.assertEqual(self.set_provider_mock.call_count, 1)
        provider = self.set_provider_mock.call_args[0][0]
        self.assertIsInstance(provider, Provider)
        self.assertIsInstance(provider.ids_generator, RandomIdsGenerator)
        self.assertIsInstance(provider.processor, Processor)
        self.assertIsInstance(provider.processor.exporter, OTLPExporter)
        self.assertIsInstance(provider.resource, Resource)
        self.assertEqual(
            provider.resource.attributes.get("service.name"),
            "my-otlp-test-service",
        )
        del environ["OTEL_SERVICE_NAME"]