[master] 78aff3e97 vsc: Control adjusted values with a 'r'aw argument

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Mon Jan 11 17:06:07 UTC 2021


commit 78aff3e977db1732584a98d7276204d4b97c862b
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Tue Dec 8 18:37:28 2020 +0100

    vsc: Control adjusted values with a 'r'aw argument

diff --git a/include/vapi/vsc.h b/include/vapi/vsc.h
index 5eaa85c41..fc6448911 100644
--- a/include/vapi/vsc.h
+++ b/include/vapi/vsc.h
@@ -69,6 +69,7 @@ struct VSC_point {
 	const char *sdesc;		/* short description		*/
 	const char *ldesc;		/* long description		*/
 	void *priv;			/* return val from VSC_new_f	*/
+	unsigned raw;			/* adjusted or raw value	*/
 };
 
 /*---------------------------------------------------------------------
@@ -118,6 +119,7 @@ int VSC_Arg(struct vsc *, char arg, const char *opt);
 	 *	'X' - field exclusion glob
 	 *	'R' - required field glob
 	 *	'f' - legacy field filter glob (deprecated)
+	 *	'r' - toggle raw gauges
 	 *
 	 * Return:
 	 *	-1 error, VSM_Error() returns diagnostic string
@@ -165,7 +167,7 @@ VSC_Value(const struct VSC_point * const pt)
 	uint64_t val;
 
 	val = *pt->ptr;
-	if (pt->semantics == 'g' && val > INT64_MAX)
+	if (!pt->raw && pt->semantics == 'g' && val > INT64_MAX)
 		val = 0;
 	return (val);
 }
diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c
index 05e3c11e2..ae597b0ca 100644
--- a/lib/libvarnishapi/vsc.c
+++ b/lib/libvarnishapi/vsc.c
@@ -98,6 +98,7 @@ struct vsc {
 	unsigned		magic;
 #define VSC_MAGIC		0x3373554a
 
+	unsigned		raw;
 	struct vsc_sf_head	sf_list;
 	VTAILQ_HEAD(,vsc_seg)	segs;
 
@@ -185,6 +186,7 @@ VSC_Arg(struct vsc *vsc, char arg, const char *opt)
 	case 'X': return (vsc_sf_arg(vsc, opt, VSC_SF_EXCLUDE));
 	case 'R': return (vsc_sf_arg(vsc, opt, VSC_SF_REQUIRE));
 	case 'f': return (vsc_f_arg(vsc, opt));
+	case 'r': vsc->raw = !vsc->raw; return (1);
 	default: return (0);
 	}
 }
@@ -299,6 +301,7 @@ vsc_fill_point(const struct vsc *vsc, const struct vsc_seg *seg,
 	AN(vt);
 
 	point->point.ptr = (volatile void*)(seg->body + atoi(vt->value));
+	point->point.raw = vsc->raw;
 }
 
 static void


More information about the varnish-commit mailing list