3.16.1 • Published 12 days ago

@midwayjs/otel v3.16.1

Weekly downloads
-
License
MIT
Repository
github
Last release
12 days ago

midwayjs open-telemetry module

PRs Welcome

this is a sub package for midway.

Install

$ npm install --save @opentelemetry/api
$ npm install --save @opentelemetry/sdk-node
$ npm install --save @opentelemetry/auto-instrumentations-node

Install component if you want decorator support.

$ npm i @midwayjs/otel@3 --save

Enable open-telemetry

open-telemetry must be loaded at the first of user code.

you can add at bootstrap.js.

const process = require('process');
const { NodeSDK, node, resources } = require('@opentelemetry/sdk-node');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { Bootstrap } = require('@midwayjs/bootstrap');

// configure the SDK to export telemetry data to the console
// enable all auto-instrumentations from the meta package
const traceExporter = new node.ConsoleSpanExporter();
const sdk = new NodeSDK({
  resource: new resources.Resource({
    [SemanticResourceAttributes.SERVICE_NAME]: 'my-service',
  }),
  traceExporter,
  instrumentations: [getNodeAutoInstrumentations()]
});

// initialize the SDK and register with the OpenTelemetry API
// this enables the API to record telemetry
sdk.start()

// gracefully shut down the SDK on process exit
process.on('SIGTERM', () => {
  sdk.shutdown()
    .then(() => console.log('Tracing terminated'))
    .catch((error) => console.log('Error terminating tracing', error))
    .finally(() => process.exit(0));
});

Bootstrap
  .configure(/**/)
  .run();

You can find more information at opentelemetry-js

Decorator Support

Enable component first.

import { Configuration } from '@midwayjs/core';
import * as koa from '@midwayjs/koa';
import * as otel from '@midwayjs/otel';

@Configuration({
  imports: [
    koa,
    otel
  ]
})
export class MainConfiguration {
}

Otel component add a @Trace decorator for method.

export class UserService {

  @Trace('user.get')
  async getUser() {
    // ...
  }
}

it will create a new span in current trace.

License

MIT

3.16.1

12 days ago

3.16.0

15 days ago

3.15.11

26 days ago

3.15.10

1 month ago

3.15.8

1 month ago

3.15.6

2 months ago

3.15.2

2 months ago

3.15.1

3 months ago

3.15.0

3 months ago

3.14.12

3 months ago

3.14.11

3 months ago

3.14.9

4 months ago

3.14.7

4 months ago

3.14.4

4 months ago

3.14.3

4 months ago

3.14.0

4 months ago

3.13.9

5 months ago

3.13.8

5 months ago

3.13.7

5 months ago

3.13.6

5 months ago

3.13.5

6 months ago

3.13.4

6 months ago

3.13.3

6 months ago

3.12.1

9 months ago

3.12.0

9 months ago

3.12.10

7 months ago

3.12.3

9 months ago

3.12.2

9 months ago

3.12.7

7 months ago

3.12.8

7 months ago

3.13.0

6 months ago

3.11.12

11 months ago

3.11.15

10 months ago

3.11.9

12 months ago

3.11.11

11 months ago

3.11.10

12 months ago

3.10.15

1 year ago

3.11.4

1 year ago

3.11.3

1 year ago

3.11.6

1 year ago

3.11.5

1 year ago

3.11.0

1 year ago

3.11.1

1 year ago

3.10.10

1 year ago

3.10.13

1 year ago

3.10.11

1 year ago

3.10.1

1 year ago

3.10.0

1 year ago

3.10.3

1 year ago

3.10.5

1 year ago

3.10.4

1 year ago

3.10.7

1 year ago

3.10.6

1 year ago

3.10.9

1 year ago

3.9.9

1 year ago

3.9.0

1 year ago

3.8.0

2 years ago

3.7.3

2 years ago

3.7.1

2 years ago

3.7.0

2 years ago

3.6.0

2 years ago

3.5.3

2 years ago

3.5.1

2 years ago

3.5.0

2 years ago

3.4.13

2 years ago

3.4.0-beta.7

2 years ago

3.4.0-beta.6

2 years ago

3.4.0-beta.11

2 years ago

3.4.0-beta.5

2 years ago

3.4.0-beta.12

2 years ago

3.4.0-beta.4

2 years ago

3.4.0-beta.10

2 years ago

3.4.0-beta.9

2 years ago

3.4.0-beta.8

2 years ago

3.4.7

2 years ago

3.4.6

2 years ago

3.4.0-beta.3

2 years ago

3.4.0-beta.2

2 years ago

3.4.0-beta.1

2 years ago

3.4.9

2 years ago

3.4.0

2 years ago

3.4.4

2 years ago

3.4.3

2 years ago

3.4.1

2 years ago

3.4.10

2 years ago

3.4.11

2 years ago

3.4.12

2 years ago

3.3.6

2 years ago

3.3.1

2 years ago

3.2.2

2 years ago

3.3.0

2 years ago

3.2.1

2 years ago

3.2.0

2 years ago

3.3.5

2 years ago

3.3.4

2 years ago

3.1.6

2 years ago

3.3.2

2 years ago

3.1.7-alpha.0

2 years ago

3.1.5

2 years ago

3.1.2

2 years ago

3.0.0

2 years ago