htrace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmcc...@apache.org
Subject incubator-htrace git commit: HTRACE-279. Fix issues where the HTracedSpanReceiver was using the wrong JSON serialization for spans and add validation to htraced REST ingest path (cmccabe)
Date Tue, 13 Oct 2015 23:08:48 GMT
Repository: incubator-htrace
Updated Branches:
  refs/heads/master c1e8cc5ac -> 157c20ae6


HTRACE-279. Fix issues where the HTracedSpanReceiver was using the wrong JSON serialization
for spans and add validation to htraced REST ingest path (cmccabe)


Project: http://git-wip-us.apache.org/repos/asf/incubator-htrace/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-htrace/commit/157c20ae
Tree: http://git-wip-us.apache.org/repos/asf/incubator-htrace/tree/157c20ae
Diff: http://git-wip-us.apache.org/repos/asf/incubator-htrace/diff/157c20ae

Branch: refs/heads/master
Commit: 157c20ae67a81cf03812a33daff7d8e35c97c354
Parents: c1e8cc5
Author: Colin Patrick Mccabe <cmccabe@cloudera.com>
Authored: Tue Oct 13 15:02:14 2015 -0700
Committer: Colin Patrick Mccabe <cmccabe@cloudera.com>
Committed: Tue Oct 13 16:05:18 2015 -0700

----------------------------------------------------------------------
 htrace-htraced/go/src/org/apache/htrace/htraced/rest.go       | 7 ++++++-
 .../main/java/org/apache/htrace/impl/RestBufferManager.java   | 6 +-----
 2 files changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/157c20ae/htrace-htraced/go/src/org/apache/htrace/htraced/rest.go
----------------------------------------------------------------------
diff --git a/htrace-htraced/go/src/org/apache/htrace/htraced/rest.go b/htrace-htraced/go/src/org/apache/htrace/htraced/rest.go
index cbfc508..c038e59 100644
--- a/htrace-htraced/go/src/org/apache/htrace/htraced/rest.go
+++ b/htrace-htraced/go/src/org/apache/htrace/htraced/rest.go
@@ -210,7 +210,12 @@ func (hand *writeSpansHandler) ServeHTTP(w http.ResponseWriter, req *http.Reques
 		if span.TracerId == "" {
 			span.TracerId = msg.DefaultTrid
 		}
-		hand.store.WriteSpan(span)
+		spanIdProblem := span.Id.FindProblem()
+		if spanIdProblem != "" {
+			hand.lg.Warnf(fmt.Sprintf("Invalid span ID: %s", spanIdProblem))
+		} else {
+			hand.store.WriteSpan(span)
+		}
 	}
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/157c20ae/htrace-htraced/src/main/java/org/apache/htrace/impl/RestBufferManager.java
----------------------------------------------------------------------
diff --git a/htrace-htraced/src/main/java/org/apache/htrace/impl/RestBufferManager.java b/htrace-htraced/src/main/java/org/apache/htrace/impl/RestBufferManager.java
index 2e1aa70..377d19f 100644
--- a/htrace-htraced/src/main/java/org/apache/htrace/impl/RestBufferManager.java
+++ b/htrace-htraced/src/main/java/org/apache/htrace/impl/RestBufferManager.java
@@ -26,8 +26,6 @@ import java.util.NoSuchElementException;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeoutException;
 
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectWriter;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -43,8 +41,6 @@ import org.eclipse.jetty.http.HttpStatus;
 
 class RestBufferManager implements BufferManager {
   private static final Log LOG = LogFactory.getLog(RestBufferManager.class);
-  private static ObjectMapper OBJECT_MAPPER = new ObjectMapper();
-  private static ObjectWriter JSON_WRITER = OBJECT_MAPPER.writer();
   private static final Charset UTF8 = Charset.forName("UTF-8");
   private static final byte COMMA_BYTE = (byte)0x2c;
   private static final int MAX_PREQUEL_LENGTH = 512;
@@ -133,7 +129,7 @@ class RestBufferManager implements BufferManager {
 
   @Override
   public void writeSpan(Span span) throws IOException {
-    byte[] spanJsonBytes = JSON_WRITER.writeValueAsBytes(span);
+    byte[] spanJsonBytes = span.toString().getBytes(UTF8);
     if ((spans.capacity() - spans.position()) < (spanJsonBytes.length + 1)) {
       // Make sure we have enough space for the span JSON and a comma.
       throw new IOException("Not enough space remaining in span buffer.");


Mime
View raw message