Merge pull request #10279 from overleaf/jpa-tracing-optimizations

[misc] do not load the tracing module unless enabled

GitOrigin-RevId: 8a3b9da3e9451e3060b852dd44e078c99cf43cfa
This commit is contained in:
Mathias Jakobsen 2022-11-03 12:46:06 +00:00 committed by Copybot
parent aac9e6616e
commit 50b346b4ed
5 changed files with 21 additions and 19 deletions

View file

@ -1,3 +1,10 @@
let tracer
function tracingEnabled() {
return process.env.GCP_OPENTELEMETRY || process.env.JAEGER_OPENTELEMETRY
}
function initialize(appName) {
const opentelemetry = require('@opentelemetry/sdk-node') const opentelemetry = require('@opentelemetry/sdk-node')
const { const {
getNodeAutoInstrumentations, getNodeAutoInstrumentations,
@ -15,13 +22,6 @@ const {
} = require('@opentelemetry/semantic-conventions') } = require('@opentelemetry/semantic-conventions')
const GCP = require('@google-cloud/opentelemetry-cloud-trace-exporter') const GCP = require('@google-cloud/opentelemetry-cloud-trace-exporter')
let tracer
function tracingEnabled() {
return process.env.GCP_OPENTELEMETRY || process.env.JAEGER_OPENTELEMETRY
}
function initialize(appName) {
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO) diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO)
const resource = new Resource({ const resource = new Resource({

View file

@ -115,6 +115,8 @@ block append meta
include ./editor/meta include ./editor/meta
block foot-scripts block foot-scripts
each file in (useOpenTelemetry ? entrypointScripts("tracing") : [])
script(type="text/javascript", nonce=scriptNonce, src=file)
script(type="text/javascript", nonce=scriptNonce, src=(wsUrl || '/socket.io') + '/socket.io.js') script(type="text/javascript", nonce=scriptNonce, src=(wsUrl || '/socket.io') + '/socket.io.js')
script(type="text/javascript", nonce=scriptNonce, src=mathJaxPath) script(type="text/javascript", nonce=scriptNonce, src=mathJaxPath)
each file in entrypointScripts("ide") each file in entrypointScripts("ide")

View file

@ -16,7 +16,6 @@
* DS207: Consider shorter variations of null checks * DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/ */
import '../tracing'
import App from './base' import App from './base'
import FileTreeManager from './ide/file-tree/FileTreeManager' import FileTreeManager from './ide/file-tree/FileTreeManager'
import LoadingManager from './ide/LoadingManager' import LoadingManager from './ide/LoadingManager'

View file

@ -7,7 +7,7 @@ import { ZoneContextManager } from '@opentelemetry/context-zone'
import { registerInstrumentations } from '@opentelemetry/instrumentation' import { registerInstrumentations } from '@opentelemetry/instrumentation'
import { getWebAutoInstrumentations } from '@opentelemetry/auto-instrumentations-web' import { getWebAutoInstrumentations } from '@opentelemetry/auto-instrumentations-web'
import getMeta from './js/utils/meta' import getMeta from './utils/meta'
if (getMeta('ol-useOpenTelemetry')) { if (getMeta('ol-useOpenTelemetry')) {
const resource = new Resource({ const resource = new Resource({

View file

@ -12,6 +12,7 @@ const PackageVersions = require('./app/src/infrastructure/PackageVersions')
// Generate a hash of entry points, including modules // Generate a hash of entry points, including modules
const entryPoints = { const entryPoints = {
tracing: './frontend/js/tracing.js',
main: './frontend/js/main.js', main: './frontend/js/main.js',
ide: './frontend/js/ide.js', ide: './frontend/js/ide.js',
'ide-detached': './frontend/js/ide-detached.js', 'ide-detached': './frontend/js/ide-detached.js',