Sprkl Docs
SupportSprkl websiteJoin Sprkl betaJoin Sprkl for CI
0.0.66
0.0.66
  • What is Sprkl?
  • Getting started
    • Install Sprkl
    • Instrument your code
      • Bare metal
      • Docker
      • Kubernetes
    • Start with a sample project with Docker Compose
  • Features
    • Instrumentation
      • Frontend tracing - NEW!
      • Selenium tracing - NEW!
    • Dashboard
      • Personal vs. Global
      • Code Block Reference
    • Code markups
    • System Graph
    • Jaeger tracing
    • Jest integration
    • Detect runtime security vulnerabilities in your code
  • Integrations and supported stack
  • Concepts
    • Analysis
  • FAQ
  • Support
  • Sprkl for GitHub Actions
    • Overview
    • Setup
    • Pulling Sprkl data to your IDE for further debugging
  • Troubleshooting
Powered by GitBook
On this page
  • Configuration
  • Webpack
  • Rollup
  • Transpiler configuration Options
  • Other
  1. Features
  2. Instrumentation

Frontend tracing - NEW!

PreviousInstrumentationNextSelenium tracing - NEW!

Last updated 2 years ago

Frontend instrumentation is in its early stages. If you encounter any issues .

Configuration is required.

Sprkl frontend instrumentation provides function-level instrumentation to every code change. The frontend trace will show you every click and HTTP request made, connecting it to the related source code, and propagating the context to your backend.

Sprkl and OpenTelemetry instrumentation can be enabled on the frontend by doing the following:

Configuration

Webpack

  1. Install the Webpack loader:

npm install --save-dev @sprkl/obs-webpack-loader
  1. Configure Webpack

Webpack configuration is also available for:

const sprklOptions = {}
module.exports = {
  module: {
    rules: [
      {
        use: [
          { loader: '@sprkl/obs-webpack-loader', options: sprklOptions},
        ],
      },
    ],
  },
};

Rollup

  1. Install the Rollup plugin:

npm install --save-dev @sprkl/obs-rollup-plugin
  1. Configure Rollup

Rollup configuration is also available for:

import sprkl from '@sprkl/obs-rollup-plugin'
const sprklOptions = {}
export default (async () => ({
  plugins: [sprkl(sprklOptions)],
}))();

Transpiler configuration Options

export type Options = {
  /**
   When enabled, the modes in which sprkl operates.
   Mode is either 'development' or 'production'.
   In rollup mode is 'development' when using watch mode, otherwise 'production'.
   @default [development]
  */
  modes?: Mode[];
  /**
    The target determines the type of transformation.
    @default 'web'
  */
  target?: Target;
  /**
    Sprkl configuration path.
    @default ${homedir()}/.sprkl/cli.json
  */
  config?: string;
  /**
    Enables running a command each time the server restarts, useful in 'development' mode.
    The main purpose is the use `sprkl apply` each restart so the code will be instrumented automatically.
  */
  exec?: {
    /**
      @default false
    */
    enabled?: boolean;
    /**
      Determines which mode to execute the given script.
      @default development
    */
    mode?: Mode;
    /**
      Execution script to run every time server is loaded.
      @default sprkl apply
   */
    script?: string;
    /**
      @default The current root directory
    */
    workingDirectory?: string;
  };
};

Other

This instrumentation tries to transform the javascript/ HTML files that are being served from that server. Since there are many implementations of frontend web servers, the code-level Sprkl instrumentation may not work, but OpenTelemetry instrumentation should work in any case.

Note that enabling the web server instrumentation with the webpack loader or rollup plugin can cause issues due to collision, so to be on the safe side prefer the Webpack loader or Rollup plugin.

Enable Sprkl web server instrumentation with the flag:

# Short form
sprkl --web-server=true -- <YOUR COMMAND>

# Long form
sprkl --opentelemetry.instrumentations.web-server.enabled=true -- <YOUR COMMAND>

# Disable with
sprkl --opentelemetry.instrumentations.web-server.enabled=false -- <YOUR COMMAND>

# Kubernetes
# To enable web server instrumentation in Kubernetes deploy the operator with the flag enabled.
sprkl --web-server=true k8s apply

Or add in the configuration file at ~/.sprkl/cli.json:

// filepath: ~/.sprkl/cli.json

{
  //...
  "opentelemetry": {
    "instrumentations": {
      "web-server": {
        "enabled": true
      },
    },
  },
  //...
}

with the Sprkl CLI in any environment.

- either or .

These options are used both for the and the

For any other tooling or servers (like ), we provide Web server instrumentation, although this method is less preferred and is unstable.

Instrument your web server code
Next.js
Webpack Dev Server
Vite
Remix
Webpack
Rollup
Transpiler plugin
Webpack loader
Rollup plugin.
contact support
User click on checkout trace