Mirror of https://github.com/roostorg/coop github.com/roostorg/coop
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 3a75984654db888a95d657c181e4e2a1c3a46b2d 53 lines 1.7 kB view raw
1import { getWebAutoInstrumentations } from '@opentelemetry/auto-instrumentations-web'; 2import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'; 3import { registerInstrumentations } from '@opentelemetry/instrumentation'; 4import { AWSXRayPropagator } from '@opentelemetry/propagator-aws-xray'; 5import { Resource } from '@opentelemetry/resources'; 6import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base'; 7import { WebTracerProvider } from '@opentelemetry/sdk-trace-web'; 8import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions'; 9 10const FrontendTracer = async () => { 11 const { ZoneContextManager } = await import('@opentelemetry/context-zone'); 12 13 const provider = new WebTracerProvider({ 14 resource: new Resource({ 15 [ATTR_SERVICE_NAME]: 'coop-ui', 16 }), 17 }); 18 19 provider.addSpanProcessor( 20 new BatchSpanProcessor( 21 new OTLPTraceExporter({ 22 url: import.meta.env.VITE_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, 23 }), 24 ), 25 ); 26 27 const contextManager = new ZoneContextManager(); 28 29 provider.register({ 30 contextManager, 31 propagator: new AWSXRayPropagator(), 32 }); 33 34 registerInstrumentations({ 35 tracerProvider: provider, 36 instrumentations: [ 37 getWebAutoInstrumentations({ 38 '@opentelemetry/instrumentation-fetch': { 39 propagateTraceHeaderCorsUrls: /.*/, 40 clearTimingResources: true, 41 applyCustomAttributesOnSpan(span, request, _result) { 42 span.setAttribute( 43 'http.request.body', 44 request.body?.toString() ?? '', 45 ); 46 }, 47 }, 48 }), 49 ], 50 }); 51}; 52 53export default FrontendTracer;