This repository was archived by the owner on Oct 3, 2023. It is now read-only.
File tree 4 files changed +29
-7
lines changed
4 files changed +29
-7
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file.
4
4
5
5
## Unreleased
6
6
7
+ - Add optional ` compressedSize ` and ` uncompressedSize ` params to ` Span.addMessageEvent `
7
8
8
9
## 0.0.9 - 2019-02-12
9
10
- Add Metrics API.
Original file line number Diff line number Diff line change @@ -209,18 +209,25 @@ export abstract class SpanBase implements types.Span {
209
209
* @param type The type of message event.
210
210
* @param id An identifier for the message event.
211
211
* @param timestamp A time in milliseconds. Defaults to Date.now()
212
+ * @param uncompressedSize The number of uncompressed bytes sent or received
213
+ * @param compressedSize The number of compressed bytes sent or received. If
214
+ * zero or undefined, assumed to be the same size as uncompressed.
212
215
*/
213
- addMessageEvent ( type : types . MessageEventType , id : string , timestamp = 0 ) {
216
+ addMessageEvent (
217
+ type : types . MessageEventType , id : string , timestamp = 0 ,
218
+ uncompressedSize ?: number , compressedSize ?: number ) {
214
219
if ( this . messageEvents . length >=
215
220
this . activeTraceParams . numberOfMessageEventsPerSpan ) {
216
221
this . messageEvents . shift ( ) ;
217
222
this . droppedMessageEventsCount ++ ;
218
223
}
219
224
220
225
this . messageEvents . push ( {
221
- 'type' : type ,
222
- 'id' : id ,
223
- 'timestamp' : timestamp ? timestamp : Date . now ( ) ,
226
+ type,
227
+ id,
228
+ timestamp : timestamp ? timestamp : Date . now ( ) ,
229
+ uncompressedSize,
230
+ compressedSize,
224
231
} as types . MessageEvent ) ;
225
232
}
226
233
Original file line number Diff line number Diff line change @@ -192,7 +192,13 @@ export interface MessageEvent {
192
192
timestamp : number ;
193
193
/** Indicates whether the message was sent or received. */
194
194
type : MessageEventType ;
195
- /** An identifier for the MessageEvent's message. */
195
+ /**
196
+ * An identifier for the MessageEvent's message. This should be a hexadecimal
197
+ * value that fits within 64-bits. Message event ids should start with 1 for
198
+ * both sent and received messages and increment by 1 for each message
199
+ * sent/received. See:
200
+ * https://github.com/census-instrumentation/opencensus-specs/blob/master/trace/gRPC.md#message-events
201
+ */
196
202
id : string ;
197
203
/** The number of uncompressed bytes sent or received. */
198
204
uncompressedSize ?: number ;
Original file line number Diff line number Diff line change @@ -21,7 +21,6 @@ import {CoreTracer} from '../src/trace/model/tracer';
21
21
import * as types from '../src/trace/model/types' ;
22
22
import { Annotation , Attributes , Link } from '../src/trace/model/types' ;
23
23
24
-
25
24
// TODO: we should evaluate a way to merge similar test cases between span and
26
25
// rootspan
27
26
@@ -304,9 +303,18 @@ describe('Span', () => {
304
303
span . start ( ) ;
305
304
306
305
span . addMessageEvent (
307
- types . MessageEventType . UNSPECIFIED , 'message_event_test_id' ) ;
306
+ types . MessageEventType . UNSPECIFIED , /* id */ '1' ,
307
+ /* timestamp */ 1550000000000 , /* uncompressedSize */ 55 ,
308
+ /** compressedSize */ 40 ) ;
308
309
309
310
assert . ok ( span . messageEvents . length > 0 ) ;
311
+ assert . deepEqual ( span . messageEvents , [ {
312
+ type : types . MessageEventType . UNSPECIFIED ,
313
+ id : '1' ,
314
+ timestamp : 1550000000000 ,
315
+ uncompressedSize : 55 ,
316
+ compressedSize : 40 ,
317
+ } ] ) ;
310
318
assert . equal ( span . droppedMessageEventsCount , 0 ) ;
311
319
assert . ok ( instanceOfLink ( span . messageEvents [ 0 ] ) ) ;
312
320
} ) ;
You can’t perform that action at this time.
0 commit comments