@@ -51,22 +51,22 @@ class Emitter(object):
5151 def __init__ (
5252 self ,
5353 endpoint : str ,
54- protocol : HttpProtocol = "http " ,
54+ protocol : HttpProtocol = "https " ,
5555 port : Optional [int ] = None ,
56- method : Method = "get " ,
56+ method : Method = "post " ,
5757 buffer_size : Optional [int ] = None ,
5858 on_success : Optional [SuccessCallback ] = None ,
5959 on_failure : Optional [FailureCallback ] = None ,
6060 byte_limit : Optional [int ] = None ,
6161 request_timeout : Optional [Union [float , Tuple [float , float ]]] = None ) -> None :
6262 """
63- :param endpoint: The collector URL. Don't include "http ://" - this is done automatically.
63+ :param endpoint: The collector URL. If protocol is not set in endpoint it will automatically set to "https ://" - this is done automatically.
6464 :type endpoint: string
65- :param protocol: The protocol to use - http or https. Defaults to http .
65+ :param protocol: The protocol to use - http or https. Defaults to https .
6666 :type protocol: protocol
6767 :param port: The collector port to connect to
6868 :type port: int | None
69- :param method: The HTTP request method
69+ :param method: The HTTP request method. Defaults to post.
7070 :type method: method
7171 :param buffer_size: The maximum number of queued events before the buffer is flushed. Default is 10.
7272 :type buffer_size: int | None
@@ -116,9 +116,9 @@ def __init__(
116116 @staticmethod
117117 def as_collector_uri (
118118 endpoint : str ,
119- protocol : HttpProtocol = "http " ,
119+ protocol : HttpProtocol = "https " ,
120120 port : Optional [int ] = None ,
121- method : Method = "get " ) -> str :
121+ method : Method = "post " ) -> str :
122122 """
123123 :param endpoint: The raw endpoint provided by the user
124124 :type endpoint: string
@@ -133,6 +133,11 @@ def as_collector_uri(
133133 if len (endpoint ) < 1 :
134134 raise ValueError ("No endpoint provided." )
135135
136+ if endpoint .split ("://" )[0 ] in PROTOCOLS :
137+ endpoint_arr = endpoint .split ("://" )
138+ protocol = endpoint_arr [0 ]
139+ endpoint = endpoint_arr [1 ]
140+
136141 if method == "get" :
137142 path = "/i"
138143 else :
@@ -148,7 +153,7 @@ def input(self, payload: PayloadDict) -> None:
148153 If the maximum size has been reached, flushes the buffer.
149154
150155 :param payload: The name-value pairs for the event
151- :type payload: dict(string:\*)
156+ :type payload: dict(string:\\ *)
152157 """
153158 with self .lock :
154159 if self .bytes_queued is not None :
@@ -207,7 +212,7 @@ def http_post(self, data: str) -> bool:
207212 def http_get (self , payload : PayloadDict ) -> bool :
208213 """
209214 :param payload: The event properties
210- :type payload: dict(string:\*)
215+ :type payload: dict(string:\\ *)
211216 """
212217 logger .info ("Sending GET request to %s..." % self .endpoint )
213218 logger .debug ("Payload: %s" % payload )
@@ -242,7 +247,7 @@ def is_good_status_code(status_code: int) -> bool:
242247 def send_events (self , evts : PayloadDictList ) -> None :
243248 """
244249 :param evts: Array of events to be sent
245- :type evts: list(dict(string:\*))
250+ :type evts: list(dict(string:\\ *))
246251 """
247252 if len (evts ) > 0 :
248253 logger .info ("Attempting to send %s events" % len (evts ))
@@ -307,7 +312,7 @@ def attach_sent_timestamp(events: PayloadDictList) -> None:
307312 as `stm` param
308313
309314 :param events: Array of events to be sent
310- :type events: list(dict(string:\*))
315+ :type events: list(dict(string:\\ *))
311316 :rtype: None
312317 """
313318 def update (e : PayloadDict ) -> None :
@@ -327,7 +332,7 @@ def __init__(
327332 endpoint : str ,
328333 protocol : HttpProtocol = "http" ,
329334 port : Optional [int ] = None ,
330- method : Method = "get " ,
335+ method : Method = "post " ,
331336 buffer_size : Optional [int ] = None ,
332337 on_success : Optional [SuccessCallback ] = None ,
333338 on_failure : Optional [FailureCallback ] = None ,
0 commit comments