All Projects → apache → skywalking-client-js

apache / skywalking-client-js

Licence: Apache-2.0 license
Client-side JavaScript exception and tracing library for Apache SkyWalking APM.

Programming Languages

typescript
32286 projects
python
139335 projects - #7 most used programming language
javascript
184084 projects - #8 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to skywalking-client-js

Skywalking
APM, Application Performance Monitoring System
Stars: ✭ 18,341 (+10625.73%)
Mutual labels:  web-performance, apm, dapper, observability, distributed-tracing, skywalking
skywalking-rust
Apache SkyWalking Rust Agent
Stars: ✭ 25 (-85.38%)
Mutual labels:  apm, dapper, observability, distributed-tracing, skywalking
skywalking-python
The Python agent for Apache SkyWalking
Stars: ✭ 152 (-11.11%)
Mutual labels:  apm, dapper, observability, distributed-tracing, skywalking
skywalking-nodejs
The NodeJS agent for Apache SkyWalking
Stars: ✭ 81 (-52.63%)
Mutual labels:  apm, dapper, observability, distributed-tracing, skywalking
skywalking-kong
Kong agent for Apache SkyWalking
Stars: ✭ 17 (-90.06%)
Mutual labels:  apm, dapper, observability, distributed-tracing, skywalking
Skywalking Data Collect Protocol
Data Collect Protocols of Apache SkyWalking
Stars: ✭ 49 (-71.35%)
Mutual labels:  apm, dapper, observability, distributed-tracing
skywalking-swck
Apache SkyWalking Cloud on Kubernetes
Stars: ✭ 62 (-63.74%)
Mutual labels:  apm, observability, distributed-tracing, skywalking
Skywalking Rocketbot Ui
SkyWalking RocketBot UI
Stars: ✭ 658 (+284.8%)
Mutual labels:  apm, dapper, observability, distributed-tracing
Skywalking Kubernetes
Apache SkyWalking Kubernetes Deployment Helm Chart
Stars: ✭ 207 (+21.05%)
Mutual labels:  apm, dapper, observability, distributed-tracing
Skywalking Docker
SkyWalking Docker file archive for all official releases
Stars: ✭ 206 (+20.47%)
Mutual labels:  apm, dapper, observability, distributed-tracing
live-platform
Add breakpoints, logs, metrics, and spans to live production applications
Stars: ✭ 37 (-78.36%)
Mutual labels:  observability, distributed-tracing, skywalking
STAM
STAM, Streaming Topology Analysis Method
Stars: ✭ 26 (-84.8%)
Mutual labels:  apm, observability, skywalking
Skyapm Dotnet
The .NET/.NET Core instrument agent for Apache SkyWalking
Stars: ✭ 1,268 (+641.52%)
Mutual labels:  apm, observability, distributed-tracing
easeagent
An agent component for the Java system
Stars: ✭ 437 (+155.56%)
Mutual labels:  apm, observability, distributed-tracing
skywalking-query-protocol
Query Protocol for Apache SkyWalking in GraphQL format
Stars: ✭ 45 (-73.68%)
Mutual labels:  apm, observability, skywalking
gateway
A proxy to buffer and forward metrics, events, and traces.
Stars: ✭ 94 (-45.03%)
Mutual labels:  apm, observability, distributed-tracing
Signoz
Open source Observability Platform. 👉 SigNoz helps developers find issues in their deployed applications & solve them quickly
Stars: ✭ 738 (+331.58%)
Mutual labels:  apm, observability, distributed-tracing
skywalking-banyandb
An observability database aims to ingest, analyze and store Metrics, Tracing and Logging data.
Stars: ✭ 111 (-35.09%)
Mutual labels:  apm, observability, skywalking
Transmittable Thread Local
📌 TransmittableThreadLocal (TTL), the missing Java™ std lib(simple & 0-dependency) for framework/middleware, provide an enhanced InheritableThreadLocal that transmits values between threads even using thread pooling components.
Stars: ✭ 4,678 (+2635.67%)
Mutual labels:  apm, dapper, distributed-tracing
uptrace
Open source APM: OpenTelemetry traces, metrics, and logs
Stars: ✭ 1,187 (+594.15%)
Mutual labels:  apm, observability, distributed-tracing

Apache SkyWalking Client JS

Sky Walking logo

Apache SkyWalking Client-side JavaScript exception and tracing library.

  • Provide metrics and error collection to SkyWalking backend.
  • Lightweight
  • Make browser as a start of whole distributed tracing

NOTICE, SkyWalking Client JS 0.8.0 and later versions require SkyWalking v9.

Usage

Install

The skywalking-client-js runtime library is available at npm.

npm install skywalking-client-js --save

Quick Start

skywalking-client-js requires SkyWalking 8.2+

User could use register method to load and report data automatically.

import ClientMonitor from 'skywalking-client-js';
// Report collected data to `http:// + window.location.host + /browser/perfData` in default
ClientMonitor.register({
  # Use core/default/restPort in the OAP server.
  # If External Communication Channels are activated, `receiver-sharing-server/default/restPort`,
  # ref to https://skywalking.apache.org/docs/main/latest/en/setup/backend/backend-expose/
  collector: 'http://127.0.0.1:12800', 
  service: 'test-ui',
  pagePath: '/current/page/name',
  serviceVersion: 'v1.0.0',
});

Parameters

The register method supports the following parameters.

Parameter Type Description Required Default Value
collector String In default, the collected data would be reported to current domain(/browser/perfData. Then, typically, we recommend you use a Gateway/proxy to redirect the data to the OAP(resthost:restport). If you set this, the data could be reported to another domain, NOTE the Cross-Origin Resource Sharing (CORS) issuse and solution. false -
service String project ID. true -
serviceVersion String project verison true -
pagePath String project path true -
jsErrors Boolean Support js errors monitoring false true
apiErrors Boolean Support API errors monitoring false true
resourceErrors Boolean Support resource errors monitoring false true
useFmp Boolean Collect FMP (first meaningful paint) data of the first screen false false
enableSPA Boolean Monitor the page hashchange event and report PV, which is suitable for single page application scenarios false false
autoTracePerf Boolean Support sending of performance data automatically. false true
vue Vue Support vue errors monitoring false undefined
traceSDKInternal Boolean Support tracing SDK internal RPC. false false
detailMode Boolean Support tracing http method and url as tags in spans. false true
noTraceOrigins (string | RegExp)[] Origin in the noTraceOrigins list will not be traced. false []
traceTimeInterval Number Support setting time interval to report segments. false 60000

Collect Metrics Manually

Use the setPerformance method to report metrics at the moment of page loaded or any other moment meaningful.

  1. Set the SDK configuration item autoTracePerf to false to turn off automatic reporting performance metrics and wait for manual triggering of escalation.
  2. Call ClientMonitor.setPerformance(object) method to report
  • Examples
import ClientMonitor from 'skywalking-client-js';

ClientMonitor.setPerformance({
  collector: 'http://127.0.0.1:12800',
  service: 'browser-app',
  serviceVersion: '1.0.0',
  pagePath: location.href,
  useFmp: true
});

Special scene

SPA Page

In spa (single page application) single page application, the page will be refreshed only once. The traditional method only reports PV once after the page loading, but cannot count the PV of each sub-page, and can't make other types of logs aggregate by sub-page.
The SDK provides two processing methods for spa pages:

  1. Enable spa automatic parsing
    This method is suitable for most single page application scenarios with URL hash as the route.
    In the initialized configuration item, set enableSPA to true, which will turn on the page's hashchange event listening (trigger re reporting PV), and use URL hash as the page field in other data reporting.
  2. Manual reporting
    This method can be used in all single page application scenarios. This method can be used if the first method is invalid.
    The SDK provides a set page method to manually update the page name when data is reported. When this method is called, the page PV will be re reported by default. For details, see setPerformance().
app.on('routeChange', function (next) {
  ClientMonitor.setPerformance({
    collector: 'http://127.0.0.1:12800',
    service: 'browser-app',
    serviceVersion: '1.0.0',
    pagePath: location.href,
    useFmp: true
  });
});   

Tracing range of data requests in the browser

Support tracking these(XMLHttpRequest and Fetch API) two modes of data requests. At the same time, Support tracking libraries and tools that base on XMLHttpRequest and fetch, such as Axios, SuperAgent, OpenApi and so on.

Catching errors in frames, including React, Angular, Vue.

// Angular
import { ErrorHandler } from '@angular/core';
import ClientMonitor from 'skywalking-client-js';
export class AppGlobalErrorhandler implements ErrorHandler {
  handleError(error) {
    ClientMonitor.reportFrameErrors({
      collector: 'http://127.0.0.1:12800',
      service: 'angular-demo',
      pagePath: '/app',
      serviceVersion: 'v1.0.0',
    }, error);
  }
}
@NgModule({
  ...
  providers: [{provide: ErrorHandler, useClass: AppGlobalErrorhandler}]
})
class AppModule {}
// React
class ErrorBoundary extends React.Component {
  constructor(props) {
    super(props);
    this.state = { hasError: false };
  }

  static getDerivedStateFromError(error) {
    // Update state so the next render will show the fallback UI.
    return { hasError: true };
  }

  componentDidCatch(error, errorInfo) {
    // You can also log the error to an error reporting service
    ClientMonitor.reportFrameErrors({
      collector: 'http://127.0.0.1:12800',
      service: 'react-demo',
      pagePath: '/app',
      serviceVersion: 'v1.0.0',
    }, error);
  }

  render() {
    if (this.state.hasError) {
      // You can render any custom fallback UI
      return <h1>Something went wrong.</h1>;
    }

    return this.props.children; 
  }
}
<ErrorBoundary>
  <MyWidget />
</ErrorBoundary>
// Vue
Vue.config.errorHandler = (error) => {
  ClientMonitor.reportFrameErrors({
    collector: 'http://127.0.0.1:12800',
    service: 'vue-demo',
    pagePath: '/app',
    serviceVersion: 'v1.0.0',
  }, error);
}

Demo project

Demo project provides instrumented web application with necessary environment, you could just simple use it to see the data SkyWalking collected and how SkyWalking visualizes on the UI. See more information, click here.

Contact Us

Release Guide

All committers should follow Release Guide to publish the official release.

License

Apache 2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].