Skip to content

Commit

Permalink
feat: Fix certSuccess (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
mamari90 authored Feb 8, 2024
1 parent 268a11b commit 7d3f064
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 83 deletions.
26 changes: 13 additions & 13 deletions src/statics.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = {

/**
* checks if the given data is null or is the string "null"
* @param {*} data
* @param {*} data
* @returns boolean
*/
function isNull(data){
Expand All @@ -26,10 +26,10 @@ function isNull(data){

/**
* adds the keys defined in keyList found in checkResult to the baseData object
*
* @param {object} baseData
* @param {object} checkResult
* @param {list(string)} keyList
*
* @param {object} baseData
* @param {object} checkResult
* @param {list(string)} keyList
* @returns a copy of base data, enriched
*/
function enrichData(baseData, checkResult, keyList){
Expand All @@ -46,7 +46,7 @@ function enrichData(baseData, checkResult, keyList){

/**
* parses the certificate response and populates the related metrics in the metric context
* @param {metricContext} metricContext
* @param {metricContext} metricContext
* @returns an async function that receives the certResponse and returns the enriched metric context
*/
function certResponseElaborator(metricContext){
Expand All @@ -55,7 +55,7 @@ function certResponseElaborator(metricContext){
let validTo = new Date(certResponse.valid_to);
const millisToExpiration = validTo - Date.now();
metricContext.certMetrics['success'] = millisToExpiration > 604800000; //7 days in millis
metricContext.certMetrics['certSuccess'] = millisToExpiration > 604800000
metricContext.certMetrics['certSuccess'] = millisToExpiration > 604800000 ? 1 : 0
metricContext.certMetrics['targetExpireInDays'] = Math.floor(millisToExpiration / 86400000); //convert in days
metricContext.certMetrics['targetExpirationTimestamp'] = validTo.getTime();
metricContext.certMetrics['runLocation'] = `${metricContext.monitoringConfiguration.type}-cert`
Expand All @@ -66,7 +66,7 @@ function certResponseElaborator(metricContext){

/**
* parses the error received from the certificate request and populates the related metric
* @param {metricContext} metricContext
* @param {metricContext} metricContext
* @returns an async function that receives an error and returns the enriched metric context
*/
function certErrorElaborator(metricContext){
Expand All @@ -82,7 +82,7 @@ function certErrorElaborator(metricContext){

/**
* parses the api response and populates the related metric in the metric context
* @param {metric context} metricContext
* @param {metric context} metricContext
* @returns an async function that receives a response and returns the enriched metric context
*/
function apiResponseElaborator(metricContext){
Expand All @@ -108,7 +108,7 @@ function apiResponseElaborator(metricContext){

/**
* parses the error received from the api request and populates the related metric
* @param {metricContext} metricContext
* @param {metricContext} metricContext
* @returns an async function that receives an error and returns the enriched metric context
*/
function apiErrorElaborator(metricContext){
Expand All @@ -130,7 +130,7 @@ function apiErrorElaborator(metricContext){

/**
* parses a string containing the tls version and returns the version as a number
* @param {string} versionString
* @param {string} versionString
* @returns the number representing the tls version
*/
function extractTlsVersion(versionString){
Expand All @@ -149,7 +149,7 @@ function extractTlsVersion(versionString){
/**
* creates the http request based on the given monitoring configuration
* built for axios client
* @param {monitoringConfiguration} monitoringConfiguration
* @param {monitoringConfiguration} monitoringConfiguration
* @returns http request configuration
*/
function buildRequest(monitoringConfiguration){
Expand All @@ -175,7 +175,7 @@ function buildRequest(monitoringConfiguration){

/**
* creates the basic metric objects used to track availability and events in app insight
* @param {monitoringConfiguration} monitoringConfiguration
* @param {monitoringConfiguration} monitoringConfiguration
* @returns object containing 'telemetry' and 'event' base data
*/
function initMetricObjects(monitoringConfiguration){
Expand Down
Loading

0 comments on commit 7d3f064

Please sign in to comment.