Skip to content

Commit b3da797

Browse files
author
Naseem
authored
Merge branch 'master' into ioredis-cleanup
2 parents aa571ca + 16d3515 commit b3da797

File tree

9 files changed

+31
-37
lines changed

9 files changed

+31
-37
lines changed

plugins/web/opentelemetry-plugin-document-load/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
"dependencies": {
7575
"@opentelemetry/api": "^0.10.1",
7676
"@opentelemetry/core": "^0.10.1",
77+
"@opentelemetry/semantic-conventions": "^0.10.1",
7778
"@opentelemetry/tracing": "^0.10.1",
7879
"@opentelemetry/web": "^0.10.1"
7980
}

plugins/web/opentelemetry-plugin-document-load/src/documentLoad.ts

+10-22
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ import {
2828
} from '@opentelemetry/core';
2929
import {
3030
addSpanNetworkEvent,
31+
addSpanNetworkEvents,
3132
hasKey,
3233
PerformanceEntries,
3334
PerformanceLegacy,
3435
PerformanceTimingNames as PTN,
3536
} from '@opentelemetry/web';
3637
import { AttributeNames } from './enums/AttributeNames';
3738
import { VERSION } from './version';
39+
import { HttpAttribute } from '@opentelemetry/semantic-conventions';
3840

3941
/**
4042
* This class represents a document load plugin
@@ -81,21 +83,6 @@ export class DocumentLoad extends BasePlugin<unknown> {
8183
}
8284
}
8385

84-
/**
85-
* Adds span network events
86-
* @param span
87-
* @param entries entries that contains performance information about resource
88-
*/
89-
private _addSpanNetworkEvents(span: Span, entries: PerformanceEntries) {
90-
addSpanNetworkEvent(span, PTN.DOMAIN_LOOKUP_START, entries);
91-
addSpanNetworkEvent(span, PTN.DOMAIN_LOOKUP_END, entries);
92-
addSpanNetworkEvent(span, PTN.CONNECT_START, entries);
93-
addSpanNetworkEvent(span, PTN.SECURE_CONNECTION_START, entries);
94-
addSpanNetworkEvent(span, PTN.CONNECT_END, entries);
95-
addSpanNetworkEvent(span, PTN.REQUEST_START, entries);
96-
addSpanNetworkEvent(span, PTN.RESPONSE_START, entries);
97-
}
98-
9986
/**
10087
* Collects information about performance and creates appropriate spans
10188
*/
@@ -123,14 +110,15 @@ export class DocumentLoad extends BasePlugin<unknown> {
123110
);
124111
if (fetchSpan) {
125112
this._tracer.withSpan(fetchSpan, () => {
126-
this._addSpanNetworkEvents(fetchSpan, entries);
113+
addSpanNetworkEvents(fetchSpan, entries);
127114
this._endSpan(fetchSpan, PTN.RESPONSE_END, entries);
128115
});
129116
}
130117
});
131118

132119
this._addResourcesSpans(rootSpan);
133120

121+
addSpanNetworkEvent(rootSpan, PTN.FETCH_START, entries);
134122
addSpanNetworkEvent(rootSpan, PTN.UNLOAD_EVENT_START, entries);
135123
addSpanNetworkEvent(rootSpan, PTN.UNLOAD_EVENT_END, entries);
136124
addSpanNetworkEvent(rootSpan, PTN.DOM_INTERACTIVE, entries);
@@ -142,6 +130,7 @@ export class DocumentLoad extends BasePlugin<unknown> {
142130
addSpanNetworkEvent(rootSpan, PTN.DOM_CONTENT_LOADED_EVENT_END, entries);
143131
addSpanNetworkEvent(rootSpan, PTN.DOM_COMPLETE, entries);
144132
addSpanNetworkEvent(rootSpan, PTN.LOAD_EVENT_START, entries);
133+
addSpanNetworkEvent(rootSpan, PTN.LOAD_EVENT_END, entries);
145134

146135
this._endSpan(rootSpan, PTN.LOAD_EVENT_END, entries);
147136
});
@@ -161,7 +150,6 @@ export class DocumentLoad extends BasePlugin<unknown> {
161150
// span can be undefined when entries are missing the certain performance - the span will not be created
162151
if (span) {
163152
if (hasKey(entries, performanceName)) {
164-
addSpanNetworkEvent(span, performanceName, entries);
165153
span.end(entries[performanceName]);
166154
} else {
167155
// just end span
@@ -184,7 +172,7 @@ export class DocumentLoad extends BasePlugin<unknown> {
184172
keys.forEach((key: string) => {
185173
if (hasKey(performanceNavigationTiming, key)) {
186174
const value = performanceNavigationTiming[key];
187-
if (typeof value === 'number' && value > 0) {
175+
if (typeof value === 'number' && value >= 0) {
188176
entries[key] = value;
189177
}
190178
}
@@ -198,7 +186,7 @@ export class DocumentLoad extends BasePlugin<unknown> {
198186
keys.forEach((key: string) => {
199187
if (hasKey(performanceTiming, key)) {
200188
const value = performanceTiming[key];
201-
if (typeof value === 'number' && value > 0) {
189+
if (typeof value === 'number' && value >= 0) {
202190
entries[key] = value;
203191
}
204192
}
@@ -218,13 +206,14 @@ export class DocumentLoad extends BasePlugin<unknown> {
218206
spanOptions: SpanOptions = {}
219207
) {
220208
const span = this._startSpan(
221-
resource.name,
209+
AttributeNames.RESOURCE_FETCH,
222210
PTN.FETCH_START,
223211
resource,
224212
spanOptions
225213
);
226214
if (span) {
227-
this._addSpanNetworkEvents(span, resource);
215+
span.setAttribute(HttpAttribute.HTTP_URL, resource.name);
216+
addSpanNetworkEvents(span, resource);
228217
this._endSpan(span, PTN.RESPONSE_END, resource);
229218
}
230219
}
@@ -257,7 +246,6 @@ export class DocumentLoad extends BasePlugin<unknown> {
257246
)
258247
);
259248
span.setAttribute(AttributeNames.COMPONENT, this.component);
260-
addSpanNetworkEvent(span, performanceName, entries);
261249
return span;
262250
}
263251
return undefined;

plugins/web/opentelemetry-plugin-document-load/src/enums/AttributeNames.ts

+1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ export enum AttributeNames {
1818
COMPONENT = 'component',
1919
DOCUMENT_LOAD = 'documentLoad',
2020
DOCUMENT_FETCH = 'documentFetch',
21+
RESOURCE_FETCH = 'resourceFetch',
2122
}

plugins/web/opentelemetry-plugin-document-load/test/documentLoad.test.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import * as assert from 'assert';
4040
import * as sinon from 'sinon';
4141
import { ExportResult } from '@opentelemetry/core';
4242
import { DocumentLoad } from '../src';
43+
import { HttpAttribute } from '@opentelemetry/semantic-conventions';
4344

4445
export class DummyExporter implements SpanExporter {
4546
export(
@@ -325,6 +326,11 @@ describe('DocumentLoad Plugin', () => {
325326
const fsEvents = fetchSpan.events;
326327

327328
assert.strictEqual(rootSpan.name, 'documentFetch');
329+
assert.ok(
330+
(rootSpan.attributes[
331+
HttpAttribute.HTTP_RESPONSE_CONTENT_LENGTH
332+
] as number) > 0
333+
);
328334
assert.strictEqual(fetchSpan.name, 'documentLoad');
329335
ensureNetworkEventsExists(rsEvents);
330336

@@ -418,11 +424,11 @@ describe('DocumentLoad Plugin', () => {
418424
const srEvents2 = spanResource2.events;
419425

420426
assert.strictEqual(
421-
spanResource1.name,
427+
spanResource1.attributes[HttpAttribute.HTTP_URL],
422428
'http://localhost:8090/bundle.js'
423429
);
424430
assert.strictEqual(
425-
spanResource2.name,
431+
spanResource2.attributes[HttpAttribute.HTTP_URL],
426432
'http://localhost:8090/sockjs-node/info?t=1572620894466'
427433
);
428434

@@ -454,7 +460,7 @@ describe('DocumentLoad Plugin', () => {
454460
const srEvents1 = spanResource1.events;
455461

456462
assert.strictEqual(
457-
spanResource1.name,
463+
spanResource1.attributes[HttpAttribute.HTTP_URL],
458464
'http://localhost:8090/bundle.js'
459465
);
460466

propagators/opentelemetry-propagator-grpc-census-binary/package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
"access": "public"
4343
},
4444
"devDependencies": {
45-
"@opentelemetry/context-base": "0.10.2",
4645
"@types/mocha": "7.0.2",
4746
"@types/node": "14.0.27",
4847
"codecov": "3.7.2",
@@ -59,7 +58,7 @@
5958
"typescript": "3.9.7"
6059
},
6160
"dependencies": {
62-
"@opentelemetry/api": "^0.10.2",
63-
"@opentelemetry/core": "^0.10.2"
61+
"@opentelemetry/api": "^0.11.0",
62+
"@opentelemetry/core": "^0.11.0"
6463
}
6564
}

propagators/opentelemetry-propagator-grpc-census-binary/src/GrpcCensusPropagator.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import {
1818
Context,
1919
GetterFunction,
20-
HttpTextPropagator,
20+
TextMapPropagator,
2121
SetterFunction,
2222
} from '@opentelemetry/api';
2323
import {
@@ -53,11 +53,11 @@ function isValidSpanId(spanId: string): boolean {
5353

5454
/**
5555
* Propagator for the grpc-trace-bin header used by OpenCensus for
56-
* gRPC. Acts as a bridge between the HttpTextPropagator interface and
56+
* gRPC. Acts as a bridge between the TextMapPropagator interface and
5757
* the binary encoding/decoding that happens in the supporting
5858
* BinaryTraceContext class.
5959
*/
60-
export class GrpcCensusPropagator implements HttpTextPropagator {
60+
export class GrpcCensusPropagator implements TextMapPropagator {
6161
/**
6262
* Injects trace propagation context into the carrier after encoding
6363
* in binary format

propagators/opentelemetry-propagator-grpc-census-binary/test/GrpcCensusPropagator.test.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
*/
1616

1717
import * as assert from 'assert';
18-
import { SpanContext, TraceFlags } from '@opentelemetry/api';
19-
import { Context } from '@opentelemetry/context-base';
18+
import { SpanContext, TraceFlags, Context } from '@opentelemetry/api';
2019
import {
2120
getExtractedSpanContext,
2221
setExtractedSpanContext,

propagators/opentelemetry-propagator-jaeger/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"webpack": "4.43.0"
7171
},
7272
"dependencies": {
73-
"@opentelemetry/api": "^0.10.1",
74-
"@opentelemetry/core": "^0.10.1"
73+
"@opentelemetry/api": "^0.11.0",
74+
"@opentelemetry/core": "^0.11.0"
7575
}
7676
}

propagators/opentelemetry-propagator-jaeger/src/JaegerHttpTracePropagator.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import {
1818
Context,
19-
HttpTextPropagator,
19+
TextMapPropagator,
2020
SpanContext,
2121
TraceFlags,
2222
SetterFunction,
@@ -44,7 +44,7 @@ export const UBER_TRACE_ID_HEADER = 'uber-trace-id';
4444
* One byte bitmap, as two hex digits.
4545
* Inspired by jaeger-client-node project.
4646
*/
47-
export class JaegerHttpTracePropagator implements HttpTextPropagator {
47+
export class JaegerHttpTracePropagator implements TextMapPropagator {
4848
private readonly _jaegerTraceHeader: string;
4949

5050
/**

0 commit comments

Comments
 (0)