Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tag values are corrupted #453

Closed
tantra35 opened this issue Dec 15, 2022 · 2 comments
Closed

tag values are corrupted #453

tantra35 opened this issue Dec 15, 2022 · 2 comments

Comments

@tantra35
Copy link

if we will send metrics with follow tags values vmrange=8.799e-01...1.000e+00, tag value will be demaged as transformation to vmrange=8.799e-01.1.000e+00,

here 3 dots was replaced by one, as in this case transformation is wrong for tag value

@tantra35
Copy link
Author

tantra35 commented Dec 15, 2022

seems that follow patch solve problem, it's not ideal, but if it acceptable we can make a PR:

From eb6c7de1c66a8d357e0475cd19a5afd791650e29 Mon Sep 17 00:00:00 2001
From: tantra35 <ruslan.usifov@gmail.com>
Date: Thu, 15 Dec 2022 21:05:31 +0300
Subject: [PATCH] fix tag demage

---
 dispatcher.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/dispatcher.c b/dispatcher.c
index 4facd7f..4ba6012 100644
--- a/dispatcher.c
+++ b/dispatcher.c
@@ -1021,6 +1021,7 @@ dispatch_received_metrics(connection *conn, dispatcher *self)
 	firstspace = NULL;
 	lastnl = NULL;
 	search_tags = self->tags_supported;
+	char tagfound = 0;
 	for (p = conn->buf; p - conn->buf < conn->buflen; p++) {
 		if (*p == '\n' || *p == '\r') {
 			/* end of metric */
@@ -1086,12 +1087,19 @@ dispatch_received_metrics(connection *conn, dispatcher *self)
 				/* metric_path separator or space,
 				 * - duplicate elimination
 				 * - don't start with separator/space */
-				if (*(q - 1) != *p && (q - 1) != firstspace)
-					*q++ = *p;
+				if (tagfound == 0) {
+					if (*(q - 1) != *p && (q - 1) != firstspace)
+						*q++ = *p;
+				} else {
+					if ((q - 1) != firstspace) {
+						*q++ = *p;
+					}
+				}
 			}
 		} else if (search_tags && *p == ';') {
 			/* copy up to next space */
 			search_tags = 0;
+			tagfound = 1;
 			firstspace = q;
 			*q++ = *p;
 		} else if (
-- 
2.35.1.windows.2
 

@grobian
Copy link
Owner

grobian commented Dec 21, 2022

I've applied a different way (to avoid any modifications/changes), can you try? Thanks!

msaf1980 pushed a commit to msaf1980/carbon-c-relay that referenced this issue Feb 15, 2024


Closes: grobian#453
Signed-off-by: Fabian Groffen <grobian@gentoo.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants