Skip to content

Commit

Permalink
fix(fb_custom_audience): add null fields logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ujjwal-ab committed Jun 1, 2023
1 parent eea417d commit 05e8b76
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/util/prometheus.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ class Prometheus {
try {
let metric = this.prometheusRegistry.getSingleMetric(appendPrefix(name));
if (!metric) {
logger.warn(`Prometheus: Summary metric ${name} not found in the registry. Creating a new one`);
logger.warn(
`Prometheus: Summary metric ${name} not found in the registry. Creating a new one`,
);
metric = this.newSummaryStat(name, '', Object.keys(tags));
}
metric.observe(tags, value);
Expand All @@ -104,7 +106,9 @@ class Prometheus {
try {
let metric = this.prometheusRegistry.getSingleMetric(appendPrefix(name));
if (!metric) {
logger.warn(`Prometheus: Timing metric ${name} not found in the registry. Creating a new one`);
logger.warn(
`Prometheus: Timing metric ${name} not found in the registry. Creating a new one`,
);
metric = this.newHistogramStat(name, '', Object.keys(tags));
}
metric.observe(tags, (new Date() - start) / 1000);
Expand All @@ -117,7 +121,9 @@ class Prometheus {
try {
let metric = this.prometheusRegistry.getSingleMetric(appendPrefix(name));
if (!metric) {
logger.warn(`Prometheus: Histogram metric ${name} not found in the registry. Creating a new one`);
logger.warn(
`Prometheus: Histogram metric ${name} not found in the registry. Creating a new one`,
);
metric = this.newHistogramStat(name, '', Object.keys(tags));
}
metric.observe(tags, value);
Expand All @@ -134,7 +140,9 @@ class Prometheus {
try {
let metric = this.prometheusRegistry.getSingleMetric(appendPrefix(name));
if (!metric) {
logger.warn(`Prometheus: Counter metric ${name} not found in the registry. Creating a new one`);
logger.warn(
`Prometheus: Counter metric ${name} not found in the registry. Creating a new one`,
);
metric = this.newCounterStat(name, '', Object.keys(tags));
}
metric.inc(tags, delta);
Expand All @@ -147,8 +155,10 @@ class Prometheus {
try {
let metric = this.prometheusRegistry.getSingleMetric(appendPrefix(name));
if (!metric) {
logger.warn(`Prometheus: Gauge metric ${name} not found in the registry. Creating a new one`);
metric = this.newGaugeStat(name, '', Object.keys(tags));
logger.warn(
`Prometheus: Gauge metric ${name} not found in the registry. Creating a new one`,
);
metric = this.newGaugeStat(name, '', Object.keys(tags));
}
metric.set(tags, value);
} catch (e) {
Expand Down Expand Up @@ -762,7 +772,7 @@ class Prometheus {
name: 'fb_custom_audience_event_having_all_null_field_values_for_a_user',
help: 'fbcustomaudience event having all null field values for a user',
type: 'counter',
labelNames: ['destinationId'],
labelNames: ['destinationId', 'nullFields'],
},
{
name: 'fb_custom_audience_event_having_all_null_field_values_for_all_users',
Expand Down
1 change: 1 addition & 0 deletions src/v0/destinations/fb_custom_audience/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ const prepareDataField = (
if (nullUserData) {
stats.increment('fb_custom_audience_event_having_all_null_field_values_for_a_user', {
destinationId,
nullFields: userSchema,
});
}

Expand Down

0 comments on commit 05e8b76

Please sign in to comment.