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

Commit 2f04eaf

Browse files
Rename globals prefix from ocw to oc (#56)
1 parent 59d2fc3 commit 2f04eaf

7 files changed

Lines changed: 19 additions & 19 deletions

File tree

examples/initial_load/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ <h1>OpenCensus Web Hello World!</h1>
2323

2424
<script>
2525
traceparent = "{{.Traceparent}}";
26-
ocwAgent = "http://{{.AgentHostAndPort}}";
26+
ocAgent = "http://{{.AgentHostAndPort}}";
2727
</script>
2828
<script src="{{.OcwScriptEndpoint}}/initial-load-all.js" async></script>
2929
<footer>

packages/opencensus-web-all/src/export-initial-load.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ const TRACE_ENDPOINT = '/v1/trace';
3535

3636
/**
3737
* Waits until after the document `load` event fires, and then uses the
38-
* `window.ocwAgent` setting to configure an OpenCensus agent exporter and
38+
* `window.ocAgent` setting to configure an OpenCensus agent exporter and
3939
* export the spans for the initial page load.
4040
*/
4141
export function exportRootSpanAfterLoadEvent() {
42-
if (!windowWithOcwGlobals.ocwAgent) {
42+
if (!windowWithOcwGlobals.ocAgent) {
4343
console.log('Not configured to export page load spans.');
4444
return;
4545
}
4646

4747
tracing.registerExporter(new OCAgentExporter(
48-
{agentEndpoint: `${windowWithOcwGlobals.ocwAgent}${TRACE_ENDPOINT}`}));
48+
{agentEndpoint: `${windowWithOcwGlobals.ocAgent}${TRACE_ENDPOINT}`}));
4949

5050
if (document.readyState === 'complete') {
5151
exportInitialLoadSpans();

packages/opencensus-web-all/src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export declare interface WindowWithOcwGlobals extends WindowWithLongTasks {
2222
* HTTP root URL of the agent endpoint to write traces to.
2323
* Example 'https://my-oc-agent-deployment.com:55678'
2424
*/
25-
ocwAgent?: string;
25+
ocAgent?: string;
2626
/**
2727
* For the initial page load, web browsers do not send any custom headers,
2828
* which means that the server will not receive trace context headers.
@@ -46,5 +46,5 @@ export declare interface WindowWithOcwGlobals extends WindowWithLongTasks {
4646
* exports it can be in different JS bundles. This enables deferring loading
4747
* the export code until it is needed.
4848
*/
49-
ocwLt?: PerformanceLongTaskTiming[];
49+
ocLt?: PerformanceLongTaskTiming[];
5050
}

packages/opencensus-web-all/test/test-export-initial-load.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ describe('exportRootSpanAfterLoadEvent', () => {
4646
spyOn(XMLHttpRequest.prototype, 'open');
4747
sendSpy = spyOn(XMLHttpRequest.prototype, 'send');
4848
spyOn(XMLHttpRequest.prototype, 'setRequestHeader');
49-
realOcwAgent = windowWithOcwGlobals.ocwAgent;
49+
realOcwAgent = windowWithOcwGlobals.ocAgent;
5050
realTraceparent = windowWithOcwGlobals.traceparent;
5151
});
5252
afterEach(() => {
5353
jasmine.clock().uninstall();
54-
windowWithOcwGlobals.ocwAgent = realOcwAgent;
54+
windowWithOcwGlobals.ocAgent = realOcwAgent;
5555
windowWithOcwGlobals.traceparent = realTraceparent;
5656
});
5757

5858
it('exports spans to agent if agent is configured', () => {
59-
windowWithOcwGlobals.ocwAgent = 'http://agent';
59+
windowWithOcwGlobals.ocAgent = 'http://agent';
6060
windowWithOcwGlobals.traceparent = undefined;
6161

6262
exportRootSpanAfterLoadEvent();
@@ -68,7 +68,7 @@ describe('exportRootSpanAfterLoadEvent', () => {
6868
});
6969

7070
it('does not export if agent not configured', () => {
71-
windowWithOcwGlobals.ocwAgent = undefined;
71+
windowWithOcwGlobals.ocAgent = undefined;
7272
windowWithOcwGlobals.traceparent = undefined;
7373

7474
exportRootSpanAfterLoadEvent();
@@ -79,7 +79,7 @@ describe('exportRootSpanAfterLoadEvent', () => {
7979
});
8080

8181
it('uses trace and span ID from window.traceparent if specified', () => {
82-
windowWithOcwGlobals.ocwAgent = 'http://agent';
82+
windowWithOcwGlobals.ocAgent = 'http://agent';
8383
const traceId = '0af7651916cd43dd8448eb211c80319c';
8484
const spanId = 'b7ad6b7169203331';
8585
windowWithOcwGlobals.traceparent = `00-${traceId}-${spanId}-01`;
@@ -97,7 +97,7 @@ describe('exportRootSpanAfterLoadEvent', () => {
9797
});
9898

9999
it('does not export spans if traceparent sampling hint not set', () => {
100-
windowWithOcwGlobals.ocwAgent = 'http://agent';
100+
windowWithOcwGlobals.ocAgent = 'http://agent';
101101
windowWithOcwGlobals.traceparent =
102102
'00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-00';
103103

packages/opencensus-web-instrumentation-perf/src/long-tasks-recorder.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import {PerformanceLongTaskTiming, PerformanceObserverEntryList, WindowWithLongTasks} from './perf-types';
1818

19-
/** Cast `window` to be access the `ocwLt` field for long task timings. */
19+
/** Cast `window` to be access the `ocLt` field for long task timings. */
2020
const windowWithLongTasks = window as WindowWithLongTasks;
2121

2222
/**
@@ -30,12 +30,12 @@ export function recordLongTasks() {
3030
new windowWithLongTasks.PerformanceObserver(onLongTasks);
3131
longTaskObserver.observe({entryTypes: ['longtask']});
3232
}
33-
windowWithLongTasks.ocwLt = [];
33+
windowWithLongTasks.ocLt = [];
3434
}
3535

3636
function onLongTasks(entryList: PerformanceObserverEntryList) {
3737
// These must be PerformanceLongTaskTiming objects because we only observe
3838
// 'longtask' above.
39-
windowWithLongTasks.ocwLt!.push(
39+
windowWithLongTasks.ocLt!.push(
4040
...(entryList.getEntries() as PerformanceLongTaskTiming[]));
4141
}

packages/opencensus-web-instrumentation-perf/src/perf-grouper.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import {PerformanceLongTaskTiming, PerformanceNavigationTimingExtended, PerformancePaintTiming, PerformanceResourceTimingExtended, WindowWithLongTasks} from './perf-types';
1818

19-
/** Cast `window` to be access the `ocwLt` field for long task timings. */
19+
/** Cast `window` to be access the `ocLt` field for long task timings. */
2020
const windowWithLongTasks = window as WindowWithLongTasks;
2121

2222
/** Represent all collected performance timings grouped by type. */
@@ -39,7 +39,7 @@ export function getPerfEntries(): GroupedPerfEntries {
3939

4040
const perf = window.performance;
4141

42-
const longTaskTimings = windowWithLongTasks.ocwLt;
42+
const longTaskTimings = windowWithLongTasks.ocLt;
4343

4444
const entries: GroupedPerfEntries = {
4545
resourceTimings: perf.getEntriesByType('resource') as
@@ -60,7 +60,7 @@ export function getPerfEntries(): GroupedPerfEntries {
6060
/** Clears resource timings, marks, measures and stored long task timings. */
6161
export function clearPerfEntries() {
6262
if (!window.performance) return;
63-
windowWithLongTasks.ocwLt = [];
63+
windowWithLongTasks.ocLt = [];
6464
performance.clearResourceTimings();
6565
performance.clearMarks();
6666
performance.clearMeasures();

packages/opencensus-web-instrumentation-perf/src/perf-types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,5 +162,5 @@ export declare interface PerformanceLongTaskTiming extends PerformanceEntry {
162162
/** Type for the `window` object with a field to track LongTask timings. */
163163
export declare interface WindowWithLongTasks extends Window {
164164
readonly PerformanceObserver?: PerformanceObserver;
165-
ocwLt?: PerformanceLongTaskTiming[];
165+
ocLt?: PerformanceLongTaskTiming[];
166166
}

0 commit comments

Comments
 (0)