npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@jufab/opentelemetry-angular-webpack-interceptor

v0.11.0

Published

@jufab/opentelemetry-angular-webpack-interceptor is an Angular Library to deploy [OpenTelemetry](https://opentelemetry.io/) with Zipkin Exporter and use custom webpack in your Angular application

Downloads

288

Readme

OpenTelemetry Angular Webpack Interceptor

@jufab/opentelemetry-angular-webpack-interceptor is an Angular Library to deploy OpenTelemetry with Zipkin Exporter and use custom webpack in your Angular application

This library uses opentelemetry-js package and @jufab/opentelemetry-angular-interceptor

Only works for Angular >= 9.0.0

More info : https://jufab.github.io/opentelemetry-angular-webpack-interceptor/

npm version codecov

Table of contents

Getting started

Installation

With npm :

npm install @jufab/opentelemetry-angular-webpack-interceptor @jufab/opentelemetry-angular-interceptor @opentelemetry/web @opentelemetry/exporter-collector @opentelemetry/exporter-zipkin

And you need custom-webpack

More information about installation here

Configuration

Use the "OpenTelemetryWebpackConfig" interface to configure this extra feature (use "OpenTelemetryConfig" for the common config)

export interface OpenTelemetryWebpackConfig {
  zipkinConfig?: ZipkinCollectorConfig;
}

Example global Configuration

From the example-app

  openTelemetryConfig: {
    commonConfig: {
      console: true, // Display trace on console
      production: false, // Send Trace with BatchSpanProcessor (true) or SimpleSpanProcessor (false)
      serviceName: 'example-app', // Service name send in trace
      probabilitySampler: '0.7', // Samples a configurable percentage of traces, string value between '0' to '1'
    },
  },
  openTelemetryWebpackConfig: {
    zipkinConfig: {
      url: 'http://localhost:9411/api/v2/spans' // Default value: http://localhost:9411/api/v2/spans
    },
  },
  ...

Common Configuration

  • console: (boolean) Display trace on console if true
  • production: (boolean)Send trace via BatchSpanProcessor (Async) or SimpleSpanProcessor (Sync) : It's recommend to use BatchSpanProcessor on Production.
  • serviceName: (string) Service name in your trace
  • probabilitySampler: a value between 0 and 1

Zipkin Collector Configuration

  • url: (string) url of zipkin collector (default : http://localhost:9411/api/v2/spans)

Angular Module

To insert OpentelemetryInterceptorWebpackModule, you can add in your application module (generally app.module.ts)

import { NgModule } from '@angular/core';
...
import { OpenTelemetryInterceptorModule } from '@jufab/opentelemetry-angular-interceptor';
import { environment } from '../environments/environment';
...

@NgModule({
  declarations: [AppComponent, ...],
  imports: [
    ...
    // Insert module OpenTelemetryInterceptorModule with configuration, HttpClientModule is used for interceptor
    OpenTelemetryInterceptorModule.forRoot(environment.openTelemetryConfig),
    // Extra configuration for OpentelemetryInterceptorWebpackModule
    OpentelemetryInterceptorWebpackModule.forRoot(environment.openTelemetryWebpackConfig),
    // Propagator (here, composite propagator)
    CompositePropagatorModule,
    // Zipkin exporter
    ZipkinExporterModule,
    ...
  ],
  ...
})
export class AppModule {}

How it works

Example

This project have an "example-app" as Angular application example.

projects/example-app

You can see how configure and insert this module.

You can althought test opentelemetry-angular-webpack-interceptor with this application.

Run

To start this Example application, run command :

npm start

and open the application at http://localhost:4200

[Optional] Result in OpenTelemtery-collector

If you want to see the result in a collector *, there's a docker-compose available in this project.

You can start it with this command :

docker-compose -f projects/example-app/collector/docker-compose.yaml up -d

Go to the zipkin application (http://localhost:9412) to see result.

More info about the collector here : https://github.com/open-telemetry/opentelemetry-collector

* without an Agent or a Collector you can see an error in your browser about sending a "trace".

Troubleshoot

Angular 10 Warning

WARNING in /Users/julien/Documents/git/angular/opentelemetry-angular-interceptor-webpack/node_modules/@opentelemetry/api/build/src/index.js depends on '@opentelemetry/context-base'. CommonJS or AMD dependencies can cause optimization bailouts.

Add to your angular.json

"options": {
  "allowedCommonJsDependencies": [
    "@opentelemetry/context-base"
  ],