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

Addition of Stats Exporter for Microsoft Azure #795

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
6ac04b5
Created skeleton of Azure Monitor Exporter project.
jwlongnc Feb 10, 2020
5cf602c
Changed inheritance of AzureStatsExporter.
jwlongnc Feb 12, 2020
12bcf3f
Documented and organized the exporter skeleton.
jwlongnc Feb 12, 2020
9b92b52
Began implementing the expoter.
jwlongnc Feb 12, 2020
59a2e95
Added Application Insights SDK.
jwlongnc Feb 14, 2020
2317ac2
Refined options.
jwlongnc Feb 14, 2020
281fa91
Added a TODO to the onRecord() function.
jwlongnc Feb 14, 2020
961e5e6
Improved documentation.
jwlongnc Feb 14, 2020
b65c8d6
Added some information log statements.
jwlongnc Feb 17, 2020
166ea99
added onRecord functionality. Not sure if it works yet, but its built…
Feb 17, 2020
e039d6a
Started working on export()
jwlongnc Feb 19, 2020
f195568
Merge branch 'stats-exporter' of https://github.ncsu.edu/engr-csc-sdc…
jwlongnc Feb 19, 2020
6cb9b93
Switched import statements to export statements.
jwlongnc Feb 19, 2020
7932d63
Comments from code review.
jwlongnc Feb 24, 2020
167b506
Added google typescript tools to the module
jwlongnc Feb 24, 2020
df8ed77
Started a test file
jwlongnc Feb 24, 2020
2fd32fa
Whitespace changes from linting
jwlongnc Feb 24, 2020
38d3f73
Renamed period variable to specify ms
jwlongnc Feb 24, 2020
b6de712
Merge branch 'stats-exporter' of https://github.ncsu.edu/engr-csc-sdc…
jwlongnc Feb 24, 2020
fa8d543
Added code coverage tracking
jwlongnc Feb 26, 2020
8b18488
Added linting and compiler rules.
jwlongnc Feb 26, 2020
d5816dd
Fixed a linting issue
jwlongnc Feb 26, 2020
1c7b168
Moved location of test file
jwlongnc Feb 26, 2020
7d33fdb
Fixed linting issue
jwlongnc Feb 26, 2020
3758039
Linting issues fixed. Better error handling.
jwlongnc Feb 26, 2020
6d670b3
Added mocha chai and basic tests.
jwlongnc Feb 26, 2020
ac2d1db
Added a mock logger and new describes
jwlongnc Feb 26, 2020
0121327
Added tests to verify proper construction
jwlongnc Feb 28, 2020
1dd8609
Fixed improper error logging
jwlongnc Feb 28, 2020
d79872d
Changed require statement to import
jwlongnc Feb 28, 2020
70e1202
Single-Value Stats Export Test
tonyniverth Feb 28, 2020
9dd6e70
Style fixes
jwlongnc Feb 28, 2020
4a520c6
Merge branch 'stats-exporter' of https://github.ncsu.edu/engr-csc-sdc…
jwlongnc Feb 28, 2020
b4c601d
Reorganized tests.
jwlongnc Mar 2, 2020
5b1a1c2
Changed syntax for importing Azure SDK
jwlongnc Mar 2, 2020
c5dbc19
Updated exporter to use ConsoleLogger
jwlongnc Mar 2, 2020
4090472
Moved test input to exist with repl test file
jwlongnc Mar 2, 2020
7f5505d
Style changes, removal of unecessary comments
jwlongnc Mar 2, 2020
08a8b6b
Refactored construction tests
jwlongnc Mar 2, 2020
f615552
Consolidated error messages
jwlongnc Mar 2, 2020
3ba3e88
Removing initial repl. Added blackbox script.
jwlongnc Mar 4, 2020
43fd74e
Testing coverage
tonyniverth Mar 4, 2020
f14665a
Merge branch 'stats-exporter' of https://github.ncsu.edu/engr-csc-sdc…
tonyniverth Mar 4, 2020
f237d8f
Greatly simplified exporter and tests.
jwlongnc Mar 6, 2020
aa0dce6
Comment to help remember a resource.
jwlongnc Mar 6, 2020
cc6dec7
Merge branch 'stats-exporter' of https://github.ncsu.edu/engr-csc-sdc…
jwlongnc Mar 6, 2020
573749b
Added an additional test
jwlongnc Mar 25, 2020
5065315
Merge branch 'stats-exporter' of https://github.ncsu.edu/engr-csc-sdc…
jwlongnc Mar 25, 2020
7197507
azure-trace init
tonyniverth Mar 27, 2020
3dbdddd
Planned aggregation algorithm.
jwlongnc Mar 27, 2020
67e0233
Merge branch 'stats-exporter' of https://github.ncsu.edu/engr-csc-sdc…
jwlongnc Mar 27, 2020
04dd205
Import IllegalOptionsError
jwlongnc Apr 2, 2020
fb74e5e
Isolate aggregation logic into a function
jwlongnc Apr 2, 2020
ecddd05
Functionalize the test.
jwlongnc Apr 2, 2020
2312a45
Generate several batches of numbers to export.
jwlongnc Apr 2, 2020
fdfbfab
Testing started on Trace Exporter
jwlongnc Apr 2, 2020
d548ca8
Merge branch 'stats-exporter' of https://github.ncsu.edu/engr-csc-sdc…
tonyniverth Apr 3, 2020
5079ef3
Fixed imports
jwlongnc Apr 6, 2020
1a5ea7a
Added debugging log statements
jwlongnc Apr 6, 2020
f48a504
Added dependencies
jwlongnc Apr 7, 2020
d06e641
Merge branch 'stats-exporter' of https://github.ncsu.edu/engr-csc-sdc…
jwlongnc Apr 7, 2020
f87dde3
Changed method of aggregation
jwlongnc Apr 8, 2020
fa6732a
Added todo
jwlongnc Apr 11, 2020
feedcc1
Started adding tests for batch functionality.
jimmy-long Apr 17, 2020
b22f46c
Merge branch 'master' of https://github.com/jimmy-long/opencensus-nod…
jimmy-long Apr 17, 2020
1ff13b5
Removed unecessary dependency
jimmy-long May 1, 2020
0249ea3
Version bump
jimmy-long May 1, 2020
449aee6
Added license header
jimmy-long May 1, 2020
c02be23
Moved type definitions to their own file
jimmy-long May 1, 2020
bc1ebd8
Including changes from Tony
jimmy-long May 1, 2020
f110577
Added test from Tony @ahnivert
jimmy-long May 1, 2020
1ee9376
Added blackbox test from Tony. Removed key
jimmy-long May 1, 2020
46a7631
Removed instrumentation keys
jimmy-long May 1, 2020
0f9033a
Refactored imports
jimmy-long May 1, 2020
467268e
Formatting
jimmy-long May 1, 2020
01fa6ae
JSDoc comments
jimmy-long May 1, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/opencensus-exporter-azure/.nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"nyc": {
"all": true,
"include": [
"test/**/*.ts"
]
}
}
65 changes: 65 additions & 0 deletions packages/opencensus-exporter-azure/bbtest/batch_blackbox.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* Copyright 2020 OpenCensus Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

const AS = require('../build/src/azure-stats');
const OC = require('@opencensus/core');

function exportSingleMetric() {
// Construct and register an AzureStatsExporter with the OpenCensus library.
const exporter = new AS.AzureStatsExporter({
instrumentationKey: 'xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
logger: new OC.logger.ConsoleLogger(process.argv[2] || 'info'),
periodInMillis: 15000,
exportMode: AS.ExportMode.BATCH,
aggregationMethod: AS.AggregationMethod.AVERAGE
});
OC.globalStats.registerExporter(exporter);

// Create a dummy metric.
const mDummy2 = OC.globalStats.createMeasureInt64('test/dummy2', OC.MeasureUnit.UNIT, 'This variable has absolutely no meaning.');
const dumbTagKey = { name: 'dumb' };

const view = OC.globalStats.createView(
'dummy/view2',
mDummy2,
OC.AggregationType.SUM,
[dumbTagKey],
'An average of the dummy measure.'
);
OC.globalStats.registerView(view);

// Create the tag map so we can set values for our dummy tags.
const tags = new OC.TagMap();

// Set a value for each.
tags.set(dumbTagKey, { value: 'dumb' });

// Loop through an arbitrary amount of numbers, and record them as 'metrics'.
setInterval(() => {
let randomCap = Math.floor(Math.random() * 901) + 100;
let randomFloor = Math.floor(Math.random() * randomCap);
for (let i = 0; i < 100; i++) {
let randomNum = Math.floor(Math.random() * (randomCap + 1)) + randomFloor;
OC.globalStats.record([{
measure: mDummy2,
value: randomNum
}], tags);
}
}, 6000);

}

exportSingleMetric();
73 changes: 73 additions & 0 deletions packages/opencensus-exporter-azure/bbtest/blackbox-trace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
* Copyright 2020 OpenCensus Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// Import Core OpenCensus and our Azure Exporter module.
const OpenCensus = require('@opencensus/core');
const tracing = require('@opencensus/nodejs');
const AzureTrace = require('../build/src/azure-trace');
const ApplicationInsights = require('applicationinsights');

// Start the global tracing object
const tracer = tracing.start({samplingRate: 1}).tracer;

function doWork() {
for (let i = 0; i < 10; i++) {
const span = tracer.startChildSpan('doWork');
span.start();

for (let j = 0; j < 100000; j++);
span.addAnnotation('Invoking doWork');
for (let j = 0; j < 20000000; j++);
span.end();
}
}

function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}

async function exportSingleTrace() {
// Construct and register an AzureStatsExporter with the OpenCensus library.

const exporterOptions = {
instrumentationKey: 'xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
logger: new OpenCensus.logger.ConsoleLogger(process.argv[2] || 'info'),
maxBatchInterval: 1
};

const exporter = new AzureTrace.AzureTraceExporter(exporterOptions);
// OpenCensus.globalStats.registerExporter(exporter);

// Register the Azure trace exporter so that the global object will utilize
// the Azure exporter to push traces
tracer.registerSpanEventListener(exporter);

// Start an arbitrary root span
tracer.startRootSpan({ name: 'root-s01'}, rootSpan => {
// Do some arbitrary work, and create children spans while we are at it.
for(let i = 0; i < 10; i++) {
doWork();
}
// End the root span, triggering the publishing of it.
rootSpan.end();
});

// Pause execution of the script for 20 seconds, to allow the ExportBuffer that controls
// the publish() method within the Trace Exporter time to complete logging
await delay(20 * 1000);
}

exportSingleTrace();
104 changes: 104 additions & 0 deletions packages/opencensus-exporter-azure/bbtest/blackbox.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/**
* Copyright 2020 OpenCensus Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// Import Core OpenCensus and our Azure Exporter module.
const OpenCensus = require('@opencensus/core');
const AzureStats = require('../build/src/azure-stats');

function exportSingleMetrics() {
// Construct and register an AzureStatsExporter with the OpenCensus library.
const exporter = new AzureStats.AzureStatsExporter({
instrumentationKey: 'xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
logger: new OpenCensus.logger.ConsoleLogger(process.argv[2] || 'info')
});
OpenCensus.globalStats.registerExporter(exporter);

// Create a dummy metric.
const mDummy = OpenCensus.globalStats.createMeasureInt64('test/dummy', OpenCensus.MeasureUnit.UNIT, 'This variable has absolutely no meaning.');

// Create some dummy tags.
const dumbTagKey = { name: 'dumb' };
const dumberTagKey = { name: 'dumber' };
const evenDumberTagKey = { name: 'evenDumber' };
const dumbestTagKey = { name: 'dumbest' };

// Create some dummy views.
const sumView = OpenCensus.globalStats.createView(
'dummy/sumView',
mDummy,
OpenCensus.AggregationType.SUM,
[dumbTagKey],
'A sum of the dummy measure.'
);
OpenCensus.globalStats.registerView(sumView);

const distributionView = OpenCensus.globalStats.createView(
'dummy/distView',
mDummy,
OpenCensus.AggregationType.DISTRIBUTION,
[dumbTagKey, dumberTagKey],
'A distribution of the dummy measure.',
[0, 5, 10, 15, 20, 25, 30, 35, 40, 45]
);
OpenCensus.globalStats.registerView(distributionView);

const countView = OpenCensus.globalStats.createView(
'dummy/countView',
mDummy,
OpenCensus.AggregationType.COUNT,
[dumbTagKey, dumberTagKey, evenDumberTagKey],
'A count of the dummy measure.'
);
OpenCensus.globalStats.registerView(countView);

const lastValueView = OpenCensus.globalStats.createView(
'dummy/lastValueView',
mDummy,
OpenCensus.AggregationType.LAST_VALUE,
[dumbTagKey, dumberTagKey, evenDumberTagKey, dumbestTagKey],
'The last value of the dummy measure.'
);
OpenCensus.globalStats.registerView(lastValueView);

// Loop through an arbitrary amount of numbers, and record them as 'metrics'.
for (let i = 0; i < 42; i++) {
// Create the tag map so we can set values for our dummy tags.
const tags = new OpenCensus.TagMap();

// Set a value for each.
tags.set(dumbTagKey, { value: 'dumb' });
tags.set(dumberTagKey, { value: 'dumber' });
tags.set(evenDumberTagKey, { value: 'evenDumber' });
tags.set(dumbestTagKey, { value: 'dumbest' });

OpenCensus.globalStats.record([{
measure: mDummy,
value: i
}], tags);

// Do something special if i is greater than 30 so we have extra things to look for in
// AppInsights.
if (i > 30) {
tags.set(dumbTagKey, { value: 'dumb but over 30' });
OpenCensus.globalStats.record([{
measure: mDummy,
value: i
}], tags);
}
}
}

exportSingleMetrics();
Loading