ObserveNow
...
Integrations
Applications
Javascript (Node.JS and Browser)
nodejs metrics instrumentation instrumenting your app please follow the steps outlined in the following documents node prom client https //github com/siimon/prom client example implementation https //codersociety com/blog/articles/nodejs application monitoring with prometheus and grafana setting the pod annotations once your application is emitting metrics, your pod in k8s will need to be annotated to enable the agent to scrape the metrics following are the relevant annotations prometheus io/scrape 'true' prometheus io/path '/data/metrics' # (if the metrics are served on a path other than /metrics) prometheus io/port '80' # (if the metrics are served on a port other than the container port) node js tracing instrumentation opentelemetry is the recommended approach to instrument for tracing please follow the instructions in the following document to instrument your node application opentelemetry node js instrumentation https //opentelemetry io/docs/instrumentation/js/getting started/nodejs/ when your tracing js file (from above) is created, make sure to edit the traceexporter to export using the zipkin exporter https //opentelemetry io/docs/instrumentation/js/exporters/#zipkin to this location \+ const { zipkinexporter } = require('@opentelemetry/exporter zipkin'); \ traceexporter new opentelemetry tracing consolespanexporter(), \+ traceexporter new zipkinexporter({ \+ servicename 'my cool app', \+ url 'http //otel collector devopsnow\ svc cluster local 9411', \+ }), the zipkin url above ( http //otel collector devopsnow\ svc cluster local 9411 ) is available on all your clusters to which you installed the opsverse agent this will allow the node app to emit spans which will be collected by the opentelemetry collector installed as part of the opsverse agent and forwarded to the tracing backend trace context (traceid, spanid and traceflags) injection into logs it is very simple to configure traceid, spanid, and trace flags data injection into user logs in javascript applications based on the logging framework that is in use, follow the below mentioned steps to print the trace id to the logs winston the following steps can be followed to to inject trace context with winston https //www npmjs com/package/winston logger with opentelemetry instrumentation https //www npmjs com/package/@opentelemetry/instrumentation winston step 1 install the following dependency npm install save @opentelemetry/instrumentation winston step 2 add the following block of code where opentelemetry js instrumentation is configured (usually tracing js file) const { winstoninstrumentation } = require('@opentelemetry/instrumentation winston'); registerinstrumentations({ instrumentations \[ new winstoninstrumentation(), // other instrumentations ], }); the examples below apply to opentelemetry js instrumentation version 0 23 0 or above more information available here https //github com/open telemetry/opentelemetry js contrib/tree/main/plugins/node/opentelemetry instrumentation winston bunyan the following steps can be followed to to inject trace context with bunyan https //www npmjs com/package/bunyan logger with opentelemetry instrumentation https //www npmjs com/package/@opentelemetry/instrumentation bunyan step 1 install the following dependency npm install save @opentelemetry/instrumentation bunyan step 2 add the following block of code where opentelemetry js instrumentation is configured (usually tracing js file) const { bunyaninstrumentation } = require('@opentelemetry/instrumentation bunyan'); registerinstrumentations({ instrumentations \[ new bunyaninstrumentation(), // other instrumentations ], }); pino the following steps can be followed to to inject trace context with pino https //www npmjs com/package/pino logger with opentelemetry instrumentation https //www npmjs com/package/@opentelemetry/instrumentation pino step 1 install the following dependency npm install save @opentelemetry/instrumentation pino step 2 add the following block of code where opentelemetry js instrumentation is configured (usually tracing js file) const { pinoinstrumentation } = require('@opentelemetry/instrumentation pino'); registerinstrumentations({ instrumentations \[ new pinoinstrumentation(), // other instrumentations ], }); custom logger in the case of custom loggers, the most important thing is to know how to obtain the traceid , spanid , and trace flag follow the steps below step 1 install the following dependency npm install save @opentelemetry/api step 2 extract the trace context ( traceid , spanid , and trace flag ) using the following snippet \# import the dependency which helps us to extract trace context const api = require('@opentelemetry/api'); \# get the current span let current span = api trace getspan(api context active()); \# obtain trace id, span id and trace flag let trace id = current span spancontext() traceid; let span id = current span spancontext() spanid; let trace flags = current span spancontext() traceflags; example usage console log(`sample log trace id ”${trace id}” span id ”${span id}” trace flags ”${trace flags}”`); browser tracing instrumentation opentelemetry is the recommended approach to instrument for tracing please follow the instructions in the following document to instrument your html/js browser application opentelemetry html and js instrumentation https //opentelemetry io/docs/instrumentation/js/getting started/browser/ to start emitting spans to your observability backend, your document load js file (from above) should look like the following to export in zipkin format to a tba trace proxy host import { consolespanexporter, simplespanprocessor } from '@opentelemetry/sdk trace base'; import { webtracerprovider } from '@opentelemetry/sdk trace web'; import { documentloadinstrumentation } from '@opentelemetry/instrumentation document load'; import { zonecontextmanager } from '@opentelemetry/context zone'; import { registerinstrumentations } from '@opentelemetry/instrumentation'; const provider = new webtracerprovider(); provider addspanprocessor(new simplespanprocessor(new consolespanexporter())); const { zipkinexporter } = require('@opentelemetry/exporter zipkin'); const { batchspanprocessor } = require("@opentelemetry/tracing"); // you can also define your custom headers which will be added automatically const options = { // the opentelemetry collector url 'http //\<jaeger collector proxy>', } const exporter = new zipkinexporter(options); provider addspanprocessor(new batchspanprocessor(new zipkinexporter(options))); provider register({ // changing default contextmanager to use zonecontextmanager supports asynchronous operations optional contextmanager new zonecontextmanager(), }); // registering instrumentations registerinstrumentations({ instrumentations \[ new documentloadinstrumentation(), ], }); this will allow your browser app to emit events to a proxy collector (which validates events are coming from your whitelisted urls) directly to your jaeger collector ( https //\<jaeger collector host>/api/v2/spans ) there are processors running on the collector that will generate the rum metrics