@dbit-xia/node-agent
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

node-agent

基于opentelemetry规范的nodejs收集模块, 将trace数据发送到otlp-grpc的服务端口

默认开启收集的模块

# HttpServer
# HttpClient
# myjdbc

Quick Start

开发说明

npm install 
npm run build:watch

发布说明

npm run build
npm publish

安装使用

npm install @dbit-xia/node-agent

Basic Usage

  • 将以下代码放到启动文件的最前面
const {getContext, tracing} = require('@dbit-xia/node-agent');
global.getContext = getContext;
const {tracer} = tracing('ec_service', {
    exporter: {
        otlp: {url: 'http://127.0.0.1:14317'}, //发送目标服务地址
        console: false //不在控制台输出链路信息
    },
    myJdbcConfig: { //配置myjdbc要排除收集的方法
        connection: {exclude: []}
    },
    propagator: {
        traceIdHeader: 'request-id' //用于http调用时,传递traceId的请求头
    }
});
global.tracer = tracer;

其它用法

获取当前上下文

const {getContext} = require('@dbit-xia/node-agent');

//获取上下文
getContext();

//获取上下文traceId
getContext().traceId

Readme

Keywords

none

Package Sidebar

Install

npm i @dbit-xia/node-agent

Weekly Downloads

0

Version

0.0.2

License

none

Unpacked Size

20.7 kB

Total Files

10

Last publish

Collaborators

  • sunshine_it
  • dbit
  • dbit-node