Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions autodynatrace/wrappers/pymongo/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def started(self, event):
tracer = sdk.trace_sql_database_request(db_info, "{}".format(operation))
self._tracer_dict[_get_tracer_dict_key(event)] = tracer
tracer.start()
logger.debug("Tracing Mongo call: {}({})@{}:{}".format(operation, db_name, host, port))
#logger.debug("Tracing Mongo call: {}@{}:{}".format(operation, db_name, host, port))

except Exception as e:
logger.debug("Error instrumenting MongoDB: {}".format(e))
Expand All @@ -42,7 +42,7 @@ def end(self, failed, event, message=""):
logger.debug("Got bad pymongo event: {}".format(event))
tracer.mark_failed("MongoDB Command", message)

logger.debug("Ending Mongo call: {}({})@{}:{}".format(event.command_name, event.database_name, event.connection_id[0], event.connection_id[1]))
#logger.debug("Ending Mongo call: {}({})@{}:{}".format(event.command_name, event.database_name, event.connection_id[0], event.connection_id[1]))
tracer.end()
self._tracer_dict.pop(_get_tracer_dict_key(event))

Expand Down
30 changes: 26 additions & 4 deletions autodynatrace/wrappers/urllib/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,27 @@ def dynatrace_putrequest(wrapped, instance, args, kwargs):
method, path = args[:2]
scheme = "https" if "HTTPS" in instance.__class__.__name__ else "http"
url = "{}://{}{}{}".format(
scheme, instance.host, ":{}".format(instance.port) if str(instance.port) not in ["80", "443"] else "", path
scheme,
instance.host,
":{}".format(instance.port)
if str(instance.port) not in ["80", "443"]
else "",
path,
)
tracer = sdk.trace_outgoing_web_request(url, method)
tracer.start()
setattr(instance, "__dynatrace_tracer", tracer)
ret = wrapped(*args, **kwargs)
tag = tracer.outgoing_dynatrace_string_tag
tag = tracer.outgoing_dynatrace_string_tag # outgoing_dynatrace_byte_tag

byte_tag = tracer.outgoing_dynatrace_byte_tag
decoded_tag = tracer.outgoing_dynatrace_string_tag.decode("utf-8")

logger.debug("Tracing urllib, url: '{}', Byte tag: '{}'".format(url, byte_tag))
logger.debug(
"Tracing urllib, url: '{}', Decoded tag: '{}'".format(url, decoded_tag)
)

logger.debug("Tracing urllib, url: '{}', tag: '{}'".format(url, tag))
instance.putheader("x-dynatrace", tag)
return ret
Expand All @@ -35,7 +49,15 @@ def dynatrace_getresponse(wrapped, instance, args, kwargs):

return response

setattr(httplib.HTTPConnection, "putrequest", wrapt.FunctionWrapper(httplib.HTTPConnection.putrequest, dynatrace_putrequest))
setattr(
httplib.HTTPConnection, "getresponse", wrapt.FunctionWrapper(httplib.HTTPConnection.getresponse, dynatrace_getresponse)
httplib.HTTPConnection,
"putrequest",
wrapt.FunctionWrapper(httplib.HTTPConnection.putrequest, dynatrace_putrequest),
)
setattr(
httplib.HTTPConnection,
"getresponse",
wrapt.FunctionWrapper(
httplib.HTTPConnection.getresponse, dynatrace_getresponse
),
)