open-telemetry / opentelemetry-java-instrumentation

OpenTelemetry auto-instrumentation and instrumentation libraries for Java
https://opentelemetry.io
Apache License 2.0
1.99k stars 868 forks source link

Auto-instrumentation for Rhino #10907

Closed agent-adam closed 7 months ago

agent-adam commented 8 months ago

Is your feature request related to a problem? Please describe.

I would like to suggest the addition of instrumentation support for the Rhino JavaScript engine. Rhino is a JavaScript engine written entirely in Java and is widely used in various Java applications to integrate JavaScript scripting capabilities. Adding instrumentation for Rhino would enable developers to gain insights into JavaScript execution within their Java applications, providing valuable tracing and monitoring data for applications using Rhino.

Describe the solution you'd like

There are key areas for Instrumentation of the library which I would like to add

Function Calls:

Classes: org.mozilla.javascript.Function, org.mozilla.javascript.IdFunctionObject Methods: Instrumenting the call() methods would allow you to create spans for each JavaScript function call, including built-in and user-defined functions.

Script Execution:

Classes: org.mozilla.javascript.Context, org.mozilla.javascript.Script Methods: The evaluateString, execute, and exec methods are critical for script execution. Instrumenting these methods helps in capturing the evaluation or execution of entire scripts or script fragments.

Optimization and Execution:

Class: org.mozilla.javascript.optimizer.OptRuntime Methods: Methods like callN, call1, call0 which are used during optimized execution. Instrumenting these can provide insights into function calls within optimized code.

Describe alternatives you've considered

There are other important places with the Rhino library that can be considered down the line

Additional context

I am happy to work on this issue and add this instrumentation

steverao commented 8 months ago

It looks like a good idea, @open-telemetry/java-instrumentation-approvers WDYT?

trask commented 8 months ago

hi @agent-adam! unfortunately we are struggling to keep up with reviewing new instrumentation PRs in this repo, and I'm not sure if this trend will get much better, and we generally give priority to instrumentations which implement the existing semantic conventions

if rhino instrumentation is something useful for you, you could implement it as a Java agent extension to get started, and still potentially contribute it to the https://github.com/open-telemetry/opentelemetry-java-contrib repository (we will need to find two component owners including yourself to maintain it over there)