0

We are having an Electron application developed in react and using webpack.

We are trying to integrate OTel(https://opentelemetry.io/) with our Electron app and was following solution mentioned on Quick Start section on https://github.com/open-telemetry/opentelemetry-js

Since we have Electron application I am running it with command "electron --require ./tracing.js main.js"

When starting the app I see some traces logged on console, but we don't see it capturing any other trace after application is up like I was expecting a trace for accessing AWS service.

Trying to confirm if Electron / chrome extension supports Otel ...

dependencies added:

"@opentelemetry/api": "^1.4.1",
"@opentelemetry/auto-instrumentations-node": "^0.36.4",
"@opentelemetry/exporter-trace-otlp-http": "^0.36.1",
"@opentelemetry/sdk-node": "^0.36.1",

tracing.js

const opentelemetry = require("@opentelemetry/sdk-node");
const { Resource } = require('@opentelemetry/resources');
const { HttpInstrumentation } = require("@opentelemetry/instrumentation-http");
    
const ResourceAttributes = require("@opentelemetry/semantic-conventions");// const v4 = require("uuid");
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { ConsoleSpanExporter } = require('@opentelemetry/sdk-trace-base');
    
const {getNodeAutoInstrumentations,} = require("@opentelemetry/auto-instrumentations-node");
const {OTLPTraceExporter,} = require("@opentelemetry/exporter-trace-otlp-http");
    
const traceExporter = new ConsoleSpanExporter();
const sdk = new opentelemetry.NodeSDK({
    resource: new Resource({
        [SemanticResourceAttributes.SERVICE_NAME]: 'companion',
        [SemanticResourceAttributes.DEPLOYMENT_ENVIRONMENT]: process.env.NODE_ENV,
    }),
    traceExporter,
    instrumentations: [getNodeAutoInstrumentations(), HttpInstrumentation],
});

sdk.start();

Command to build and run

To build:

rimraf dist && cross-env NODE_ENV=development webpack --progress --color

To run:

> electron --require ./tracing.js ./dist/main.bundle.js
midnight-coding
  • 2,857
  • 2
  • 17
  • 27
  • It is very important that opentelemetry is loaded _before_ anything that it needs to instrument. I'm not sure what the `electron` command is doing but it seems likely that it loads libraries. If it is loading `http` for example, that would interfere with our http instrumentation. – Danny Dyla Mar 29 '23 at 14:19

0 Answers0