-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement support for infinite tracing payload compression and batchi…
…ng. Payloads being sent to trace observers will be compressed with `gzip` compression by default and will attempt to send batches of up to 100 spans by default. This replaces the existing default of no compression and no batching. The data is still streaming over HTTP/2 using gRPC but utilizing compression and batching to significantly reduce payload sizes and bytes over the wire, resulting in lower network transfer costs.
- Loading branch information
Showing
18 changed files
with
678 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.newrelic; | ||
|
||
import com.newrelic.trace.v1.V1; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
/** | ||
* Shared interface between batching and non-batching trace observer implementations | ||
*/ | ||
public interface Observer { | ||
|
||
/** | ||
* Sends a single span to the observer | ||
*/ | ||
void onNext(V1.Span span); | ||
|
||
/** | ||
* Sends a batch of spans to the observer. | ||
*/ | ||
void onNext(V1.SpanBatch spanBatch); | ||
|
||
/** | ||
* Whether the observer is in a ready state to accept spans | ||
*/ | ||
boolean isReady(); | ||
|
||
/** | ||
* Cancel the connection to the observer | ||
*/ | ||
void cancel(@Nullable String message, @Nullable Throwable cause); | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
infinite-tracing/src/main/java/com/newrelic/SpanBatchObserver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.newrelic; | ||
|
||
import com.newrelic.trace.v1.V1; | ||
import io.grpc.stub.ClientCallStreamObserver; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
public class SpanBatchObserver implements Observer { | ||
|
||
private final ClientCallStreamObserver<V1.SpanBatch> observer; | ||
|
||
public SpanBatchObserver(ClientCallStreamObserver<V1.SpanBatch> observer) { | ||
this.observer = observer; | ||
} | ||
|
||
@Override | ||
public void onNext(V1.Span span) { | ||
// This should only be used by the SpanObserver | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public void onNext(V1.SpanBatch spanBatch) { | ||
observer.onNext(spanBatch); | ||
} | ||
|
||
@Override | ||
public boolean isReady() { | ||
return observer.isReady(); | ||
} | ||
|
||
@Override | ||
public void cancel(@Nullable String message, @Nullable Throwable cause) { | ||
observer.cancel(message, cause); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.