Search code examples
reactjsloggingsumologic

Configure Sumo Logic RUM Tracing on the frontend in my React Application


As described in the title, I am looking to configure sumo logic to get RUM tracing from my react application (IE user clicks, errors, etc). How can I do this. Few things that I have looked into

  • open telemetry - this seemed to make the most sense but I wasn't able to get it working My implementation looked something like this
import { OTLPSpanExporter } from "@opentelemetry/exporter-otlp-http";
import { SimpleSpanProcessor } from "@opentelemetry/sdk-trace-base";
import { WebTracerProvider } from "@opentelemetry/sdk-trace-web";

const provider = new WebTracerProvider();

// Configure the Sumo Logic exporter
const exporter = new OTLPSpanExporter({
  endpoint: "SUMO_ENDPOINT",
  // Add any other exporter configuration options as needed
});

// Set the tracer provider for the OpenTelemetry API
trace.setGlobalTracerProvider(provider);
 export default class SumoLogger {
  install(logger: Logger): void {
    const defaultMethodFactory = logger.methodFactory;
    const tracer = initialize({
      collectionSourceUrl:
        "endpoint",
      serviceName: "name",
      deploymentEnvironment: "local",
      applicationName: "name",
      samplingProbability: 1,
      collectErrors: true,
    });
     if (method === "warn" || method === "error") {
          // message may be an error
          if (errorObject && errorObject instanceof Error) {
       
            tracer?.recordError(errorObject.message);

            return;
          }
    ``` but don't see any data in sumo logic

Solution

  • Here is a comprehensive tutorial: https://help.sumologic.com/docs/apm/real-user-monitoring/configure-data-collection/, which consists of two steps: