better logging and metrics
This commit is contained in:
parent
c5769378cf
commit
ba8eb7a3f5
|
@ -33,6 +33,7 @@
|
||||||
.. moduleauthor:: Harm Weites <harm@weites.com>
|
.. moduleauthor:: Harm Weites <harm@weites.com>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
from acme.errors import ClientError
|
from acme.errors import ClientError
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
|
|
||||||
|
@ -420,6 +421,8 @@ class S3DestinationPlugin(ExportDestinationPlugin):
|
||||||
"""
|
"""
|
||||||
current_app.logger.debug("S3 destination plugin is started for HTTP-01 challenge")
|
current_app.logger.debug("S3 destination plugin is started for HTTP-01 challenge")
|
||||||
|
|
||||||
|
function = f"{__name__}.{sys._getframe().f_code.co_name}"
|
||||||
|
|
||||||
account_number = self.get_option("accountNumber", options)
|
account_number = self.get_option("accountNumber", options)
|
||||||
bucket_name = self.get_option("bucket", options)
|
bucket_name = self.get_option("bucket", options)
|
||||||
prefix = self.get_option("prefix", options)
|
prefix = self.get_option("prefix", options)
|
||||||
|
@ -428,12 +431,24 @@ class S3DestinationPlugin(ExportDestinationPlugin):
|
||||||
if not prefix.endswith("/"):
|
if not prefix.endswith("/"):
|
||||||
prefix + "/"
|
prefix + "/"
|
||||||
|
|
||||||
s3.put(bucket_name=bucket_name,
|
res = s3.put(bucket_name=bucket_name,
|
||||||
region_name=region,
|
region_name=region,
|
||||||
prefix=prefix + filename,
|
prefix=prefix + filename,
|
||||||
data=token,
|
data=token,
|
||||||
encrypt=False,
|
encrypt=False,
|
||||||
account_number=account_number)
|
account_number=account_number)
|
||||||
|
res = "Success" if res else "Failure"
|
||||||
|
log_data = {
|
||||||
|
"function": function,
|
||||||
|
"message": "check if any valid certificate is revoked",
|
||||||
|
"result": res,
|
||||||
|
"bucket_name": bucket_name,
|
||||||
|
"filename": filename
|
||||||
|
}
|
||||||
|
current_app.logger.info(log_data)
|
||||||
|
metrics.send(f"{function}", "counter", 1, metric_tags={"result": res,
|
||||||
|
"bucket_name": bucket_name,
|
||||||
|
"filename": filename})
|
||||||
|
|
||||||
|
|
||||||
class SNSNotificationPlugin(ExpirationNotificationPlugin):
|
class SNSNotificationPlugin(ExpirationNotificationPlugin):
|
||||||
|
|
Loading…
Reference in New Issue