mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-30 04:05:25 -05:00
50b346b4ed
[misc] do not load the tracing module unless enabled GitOrigin-RevId: 8a3b9da3e9451e3060b852dd44e078c99cf43cfa
37 lines
1.3 KiB
JavaScript
37 lines
1.3 KiB
JavaScript
import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base'
|
|
import { Resource } from '@opentelemetry/resources'
|
|
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'
|
|
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http/build/esnext'
|
|
import { WebTracerProvider } from '@opentelemetry/sdk-trace-web'
|
|
import { ZoneContextManager } from '@opentelemetry/context-zone'
|
|
import { registerInstrumentations } from '@opentelemetry/instrumentation'
|
|
import { getWebAutoInstrumentations } from '@opentelemetry/auto-instrumentations-web'
|
|
|
|
import getMeta from './utils/meta'
|
|
|
|
if (getMeta('ol-useOpenTelemetry')) {
|
|
const resource = new Resource({
|
|
[SemanticResourceAttributes.SERVICE_NAME]: 'frontend',
|
|
[SemanticResourceAttributes.SERVICE_NAMESPACE]: 'Overleaf',
|
|
})
|
|
|
|
const provider = new WebTracerProvider({ resource })
|
|
|
|
provider.addSpanProcessor(
|
|
new SimpleSpanProcessor(
|
|
new OTLPTraceExporter({
|
|
url: `https://${window.location.hostname}/otlp/v1/traces`,
|
|
})
|
|
)
|
|
)
|
|
|
|
provider.register({
|
|
// Changing default contextManager to use ZoneContextManager - supports asynchronous operations - optional
|
|
contextManager: new ZoneContextManager(),
|
|
})
|
|
|
|
// Registering instrumentations
|
|
registerInstrumentations({
|
|
instrumentations: [getWebAutoInstrumentations()],
|
|
})
|
|
}
|