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

Commit beb6d8e

Browse files
crdgonzalezcadraffensperger
authored andcommitted
Message events: use counters instead of hexdecimal value. Sync to v0.0.11 (#77)
1 parent 67e5bb8 commit beb6d8e

8 files changed

Lines changed: 16 additions & 16 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file.
55
## Unreleased
66

77
- Add support for object(`SpanOptions`) as an argument for `startChildSpan` function, similar to `startRootSpan`.
8+
- Please note that there is an API breaking change in methods `addMessageEvent()`. The field `id` is now number instead of string.
89

910
## 0.0.2 - 2019-04-29
1011

packages/opencensus-web-core/src/trace/model/span.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export class Span implements webTypes.Span {
186186
*/
187187
addMessageEvent(
188188
type: webTypes.MessageEventType,
189-
id: string,
189+
id: number,
190190
timestamp: number = performance.now(),
191191
uncompressedSize?: number,
192192
compressedSize?: number

packages/opencensus-web-core/test/test-span.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,12 @@ describe('Span', () => {
153153

154154
describe('addMessageEvent', () => {
155155
it('adds message event with specified timestamp', () => {
156-
span.addMessageEvent(MessageEventType.SENT, 'id22', /* timestamp */ 25);
156+
span.addMessageEvent(MessageEventType.SENT, 22, /* timestamp */ 25);
157157

158158
expect(span.messageEvents).toEqual([
159159
{
160160
type: MessageEventType.SENT,
161-
id: 'id22',
161+
id: 22,
162162
timestamp: 25,
163163
uncompressedSize: undefined,
164164
compressedSize: undefined,
@@ -168,12 +168,12 @@ describe('Span', () => {
168168

169169
it('defaults timestamp to performance.now', () => {
170170
spyOn(performance, 'now').and.returnValue(33);
171-
span.addMessageEvent(MessageEventType.RECEIVED, 'id23');
171+
span.addMessageEvent(MessageEventType.RECEIVED, 23);
172172

173173
expect(span.messageEvents).toEqual([
174174
{
175175
type: MessageEventType.RECEIVED,
176-
id: 'id23',
176+
id: 23,
177177
timestamp: 33,
178178
uncompressedSize: undefined,
179179
compressedSize: undefined,

packages/opencensus-web-exporter-ocagent/src/adapters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ function adaptMessageEvent(
114114
time: adaptTimestampNumber(messageEvent.timestamp),
115115
messageEvent: {
116116
// tslint:disable-next-line:ban Needed to parse hexadecimal.
117-
id: String(parseInt(messageEvent.id, 16)),
117+
id: messageEvent.id,
118118
type: messageEvent.type, // Enum values match proto values
119119
uncompressedSize: messageEvent.uncompressedSize,
120120
compressedSize: messageEvent.compressedSize,

packages/opencensus-web-exporter-ocagent/src/api-types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ export interface MessageEvent {
450450
* sequence ID for a streaming RPC. It is recommended to be unique within a
451451
* Span.
452452
*/
453-
id?: string;
453+
id?: string | number;
454454
/**
455455
* The number of uncompressed bytes sent or received.
456456
*/

packages/opencensus-web-exporter-ocagent/test/test-adapters.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ describe('Core to API Span adapters', () => {
137137
webSpan1.endPerfTime = 20.113;
138138
webSpan1.messageEvents = [
139139
{
140-
id: '1',
140+
id: 1,
141141
timestamp: 19.002,
142142
type: webCore.MessageEventType.SENT,
143143
uncompressedSize: 22,
@@ -209,7 +209,7 @@ describe('Core to API Span adapters', () => {
209209
{
210210
time: '2019-01-20T16:00:00.019002000Z',
211211
messageEvent: {
212-
id: '1',
212+
id: 1,
213213
type: API_MESSAGE_EVENT_TYPE_SENT,
214214
uncompressedSize: 22,
215215
compressedSize: 15,

packages/opencensus-web-types/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"scripts": {
88
"build": "npm run compile",
99
"clean": "rimraf build/*",
10-
"copytypes": "node scripts/copy-types.js '27de0b1e3422df31af936a0dba457728ff4bffc2' && npm run fix",
10+
"copytypes": "node scripts/copy-types.js 'v0.0.11' && npm run fix",
1111
"check": "gts check",
1212
"compile": "tsc -p .",
1313
"fix": "gts fix",

packages/opencensus-web-types/src/trace/model/types.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,12 @@ export interface MessageEvent {
192192
/** Indicates whether the message was sent or received. */
193193
type: MessageEventType;
194194
/**
195-
* An identifier for the MessageEvent's message. This should be a hexadecimal
196-
* value that fits within 64-bits. Message event ids should start with 1 for
195+
* An identifier for the MessageEvent's message that can be used to match
196+
* SENT and RECEIVED MessageEvents. Message event ids should start with 1 for
197197
* both sent and received messages and increment by 1 for each message
198-
* sent/received. See:
199-
* https://github.com/census-instrumentation/opencensus-specs/blob/master/trace/gRPC.md#message-events
198+
* sent/received.
200199
*/
201-
id: string;
200+
id: number;
202201
/** The number of uncompressed bytes sent or received. */
203202
uncompressedSize?: number;
204203
/**
@@ -441,7 +440,7 @@ export interface Span {
441440
*/
442441
addMessageEvent(
443442
type: MessageEventType,
444-
id: string,
443+
id: number,
445444
timestamp?: number,
446445
uncompressedSize?: number,
447446
compressedSize?: number

0 commit comments

Comments
 (0)