Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Commit

Permalink
Update uncompressedSize and compressedSize for exporters (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
mayurkale22 committed Feb 18, 2019
1 parent 9d592e6 commit 0605a67
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 15 deletions.
7 changes: 6 additions & 1 deletion packages/opencensus-core/src/trace/model/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,13 @@ export interface Span {
* @param type The type of message event.
* @param id An identifier for the message event.
* @param timestamp A timestamp for this event.
* @param uncompressedSize The number of uncompressed bytes sent or received.
* @param compressedSize The number of compressed bytes sent or received. If
* zero or undefined, assumed to be the same size as uncompressed.
*/
addMessageEvent(type: MessageEventType, id: string, timestamp?: number): void;
addMessageEvent(
type: MessageEventType, id: string, timestamp?: number,
uncompressedSize?: number, compressedSize?: number): void;

/**
* Sets a status to the span.
Expand Down
4 changes: 3 additions & 1 deletion packages/opencensus-exporter-ocagent/src/adapters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,9 @@ const adaptTimeEvents =
messageEvent: {
// tslint:disable-next-line:ban Needed to parse hexadecimal.
id: parseInt(messageEvent.id, 16),
type: adaptMessageEventType(messageEvent.type)
type: adaptMessageEventType(messageEvent.type),
uncompressedSize: messageEvent.uncompressedSize || 0,
compressedSize: messageEvent.compressedSize || 0
}
});
});
Expand Down
7 changes: 4 additions & 3 deletions packages/opencensus-exporter-ocagent/test/test-ocagent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@ describe('OpenCensus Agent Exporter', () => {
// Message Event
const timeStamp = 123456789;
rootSpan.addMessageEvent(MessageEventType.SENT, 'aaaa', timeStamp);
rootSpan.addMessageEvent(MessageEventType.SENT, 'ffff', timeStamp);
rootSpan.addMessageEvent(
MessageEventType.SENT, 'ffff', timeStamp, 100, 12);
rootSpan.addMessageEvent(MessageEventType.RECEIVED, 'ffff', timeStamp);
// Use of `null` is to force a `TYPE_UNSPECIFIED` value
// tslint:disable-next-line:no-any
Expand Down Expand Up @@ -476,10 +477,10 @@ describe('OpenCensus Agent Exporter', () => {
},
{
messageEvent: {
compressedSize: '0',
compressedSize: '12',
id: '65535',
type: 'SENT',
uncompressedSize: '0'
uncompressedSize: '100'
},
time: {seconds: '123456', nanos: 789000000},
value: 'messageEvent'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ export function createTimeEvents(
time: new Date(messageEvent.timestamp).toISOString(),
messageEvent: {
id: messageEvent.id,
type: createMessageEventType(messageEvent.type)
type: createMessageEventType(messageEvent.type),
uncompressedSize: String(messageEvent.uncompressedSize || 0),
compressedSize: String(messageEvent.compressedSize || 0)
}
})));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,13 @@ describe('Stackdriver CloudTrace Exporter Utils', () => {
{description: 'my_annotation2', timestamp: ts, attributes: {}}
];
const messageEvents: coreTypes.MessageEvent[] = [
{id: 'aaaa', timestamp: ts, type: coreTypes.MessageEventType.SENT},
{
id: 'aaaa',
timestamp: ts,
type: coreTypes.MessageEventType.SENT,
compressedSize: 100,
uncompressedSize: 12
},
{id: 'ffff', timestamp: ts, type: coreTypes.MessageEventType.RECEIVED}, {
id: 'eeee',
timestamp: ts,
Expand Down Expand Up @@ -142,23 +148,21 @@ describe('Stackdriver CloudTrace Exporter Utils', () => {
},
{
messageEvent: {
compressedSize: '100',
id: 'aaaa',
type: 1,
uncompressedSize: '12'
},
time: '1970-01-02T10:17:36.789Z',
},
{
messageEvent: {
id: 'ffff',
type: 2,
},
messageEvent:
{compressedSize: '0', id: 'ffff', type: 2, uncompressedSize: '0'},
time: '1970-01-02T10:17:36.789Z',
},
{
messageEvent: {
id: 'eeee',
type: 0,
},
messageEvent:
{compressedSize: '0', id: 'eeee', type: 0, uncompressedSize: '0'},
time: '1970-01-02T10:17:36.789Z',
}
];
Expand Down

0 comments on commit 0605a67

Please sign in to comment.