Example #1
0
 def test_invalid_key_section5_length(self):
     self.assertRaises(
         ValueError,
         lambda: ConnectionStringParser(
             connection_string=
             "InstrumentationKey=234abcd-678-4efa-8abc-11234567890ab"),
     )
Example #2
0
 def test_invalid_key_suffix(self):
     self.assertRaises(
         ValueError,
         lambda: ConnectionStringParser(
             connection_string=
             "InstrumentationKey=1234abcd-5678-4efa-8abc-1234567890abtest"),
     )
Example #3
0
 def test_process_options_ikey_env_cs(self):
     os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING"] = (
         "Authorization=ikey;InstrumentationKey=" +
         self._valid_instrumentation_key)
     os.environ["APPINSIGHTS_INSTRUMENTATIONKEY"] = "101112"
     parser = ConnectionStringParser(connection_string=None)
     self.assertEqual(parser.instrumentation_key,
                      self._valid_instrumentation_key)
Example #4
0
    def __init__(self, **options):
        options = ExporterOptions(**options)
        parsed_connection_string = ConnectionStringParser(
            options.connection_string)

        self._instrumentation_key = parsed_connection_string.instrumentation_key
        self._timeout = 10.0  # networking timeout in seconds

        temp_suffix = self._instrumentation_key or ""
        default_storage_path = os.path.join(tempfile.gettempdir(),
                                            TEMPDIR_PREFIX + temp_suffix)
        retry_policy = RetryPolicy(timeout=self._timeout)
        self.client = AzureMonitorClient(parsed_connection_string.endpoint,
                                         retry_policy=retry_policy)
        self.storage = LocalFileStorage(
            path=default_storage_path,
            max_size=50 * 1024 * 1024,  # Maximum size in bytes.
            maintenance_period=60,  # Maintenance interval in seconds.
            retention_period=7 * 24 * 60 * 60,  # Retention period in seconds
        )
Example #5
0
 def test_invalid_key_empty(self):
     self.assertRaises(ValueError,
                       lambda: ConnectionStringParser(connection_string=""))
Example #6
0
 def test_parse_connection_string_suffix_no_location(self):
     parser = ConnectionStringParser(
         connection_string=
         "Authorization=ikey;EndpointSuffix=123;InstrumentationKey=" +
         self._valid_instrumentation_key, )
     self.assertEqual(parser.endpoint, "https://dc.123")
Example #7
0
 def test_parse_connection_string_invalid_auth(self):
     self.assertRaises(
         ValueError,
         lambda: ConnectionStringParser(connection_string=
                                        "Authorization=asd", ),
     )
Example #8
0
 def test_parse_connection_string_invalid(self):
     self.assertRaises(
         ValueError,
         lambda: ConnectionStringParser(connection_string="asd"))
Example #9
0
 def test_process_options_endpoint_default(self):
     parser = ConnectionStringParser(
         connection_string=self._valid_connection_string, )
     self.assertEqual(parser.endpoint,
                      "https://dc.services.visualstudio.com")
Example #10
0
 def test_process_options_endpoint_env_cs(self):
     os.environ[
         "APPLICATIONINSIGHTS_CONNECTION_STRING"] = "Authorization=ikey;IngestionEndpoint=456;InstrumentationKey=" + self._valid_instrumentation_key
     parser = ConnectionStringParser(connection_string=None, )
     self.assertEqual(parser.endpoint, "456")
Example #11
0
 def test_validate_connection_String(self):
     parser = ConnectionStringParser(
         connection_string=self._valid_connection_string)
     self.assertEqual(parser._connection_string,
                      self._valid_connection_string)
Example #12
0
 def test_process_options_ikey_env_ikey(self):
     os.environ[
         "APPINSIGHTS_INSTRUMENTATIONKEY"] = self._valid_instrumentation_key
     parser = ConnectionStringParser(connection_string=None)
     self.assertEqual(parser.instrumentation_key,
                      self._valid_instrumentation_key)