Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
*/
const port = process.env.PORT || 3000
const upstream_uri = process.env.UPSTREAM_URI || 'http://worldclockapi.com/api/json/utc/now'
const service_name = process.env.SERVICE_NAME || 'opencensus-test-1-v1'
const express = require('express')
const app = express()
const request = require('request-promise-native')
// Start of OpenCensus setup ----------------------------------------------------------------------------
const opencensus = require('@opencensus/core')
const tracing = require('@opencensus/nodejs')
const propagation = require('@opencensus/propagation-b3')
const b3 = new propagation.B3Format()
// Set up jaeger
const jaeger = require('@opencensus/exporter-jaeger')
const jaeger_host = process.env.JAEGER_HOST || 'localhost'
const jaeger_port = process.env.JAEGER_PORT || '6832'
const exporter = new jaeger.JaegerTraceExporter({
host: jaeger_host,
port: jaeger_port,
serviceName: service_name,
});
tracing.start({
propagation: b3,
samplingRate: 1.0,
jaegerExporter.sender = new HTTPSender({
...jaegerOptions,
endpoint: process.env.JAEGER_COLLECTOR_ENDPOINT,
});
jaegerExporter.sender.setProcess(jaegerExporter.process);
}
}
tracing.start({
samplingRate: 1,
plugins: {
http: '@opencensus/instrumentation-http',
},
stats: globalStats,
exporter: jaegerExporter,
propagation: jaegerExporter ? new B3Format() : null,
});
(async function main() {
for (;;) {
try {
await sequelize.authenticate();
break;
} catch (error) {
logger.error('cannot connect to database', error);
await new Promise(res => setTimeout(res, 2000));
}
}
await runMigrations();
app.listen(port, '', err => {
if (err) {
logger.error(err.toString());
https://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 port = process.env.PORT || 3000
const upstream_uri = process.env.UPSTREAM_URI || 'http://worldclockapi.com/api/json/utc/now'
const service_name = process.env.SERVICE_NAME || 'opencensus-test-1-v1'
const tracing = require('@opencensus/nodejs');
const propagation = require('@opencensus/propagation-b3');
const b3 = new propagation.B3Format();
tracing.start({
propagation: b3,
samplingRate: 1.0
});
const express = require('express')
const app = express()
const request = require('request-promise-native')
app.get('/', async(req, res) => {
const begin = Date.now()
let up
try {
up = await request({
config: { detailedCommands: config.tracing.detailedDatabasesCalls }
},
'vue-server-renderer': {
module: resolve(__dirname, '../census/plugins/vue'),
config: {}
}
}
if (this.options.createSpanWithNet === true) {
plugins['net'] = {
module: resolve(__dirname, '../census/plugins/net')
}
}
this.tracer = tracer.start({
exporter: this.exporter,
plugins,
propagation: new B3Format(),
samplingRate: this.options.samplingRate || 0.5,
logLevel: this.isDebugEnabled() ? 4 : 1
})
Configuration.configureModule({
census_tracing: true
})
}