Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0149bcf
feat: initial implementation of restify instrumentation
rauno56 Apr 5, 2021
96f73e6
feat: create spans instead of altering parent spans
rauno56 Apr 6, 2021
4f920f5
feat: clean examples up
rauno56 Apr 6, 2021
92af233
feat: make exporter configurable like other examples
rauno56 Apr 7, 2021
3c37d7f
feat: implement disabling restify instrumentation
rauno56 Apr 8, 2021
32b8931
test: be more verbose in tests and check all spans
rauno56 Apr 8, 2021
ee64e4d
fix: remove the handlers from req, those events seem not to be fired
rauno56 Apr 8, 2021
b6c8318
refactor: export the instrumentation as default
rauno56 Apr 8, 2021
a46adb7
fix: thrown errors are generally not caught in restify
rauno56 Apr 8, 2021
5d67867
feat: enable the instrumentation for all versions after 4.0.0
rauno56 Apr 8, 2021
c4657df
docs: update docs and metadata in package.json and README.md files
rauno56 Apr 8, 2021
cbbdea0
style: fix linting errors
rauno56 Apr 9, 2021
c760527
style: make _moduleVersion optional
rauno56 Apr 12, 2021
4ca8036
feat: use more descriptive span name
rauno56 Apr 13, 2021
e9ab22e
feat: rename HTTP span
rauno56 Apr 13, 2021
0dc22aa
feat: remove creating additional span on the client side
rauno56 Apr 13, 2021
6c380a2
docs: remove TODO
rauno56 Apr 13, 2021
3b8072b
feat: update version
rauno56 Apr 13, 2021
fa55dab
test: test more verbose API
rauno56 Apr 13, 2021
ac8d41b
fix: update version
rauno56 Apr 14, 2021
520d54e
fix: update the example in README
rauno56 Apr 14, 2021
b5be54c
fix: reference @opentelemetry/instrumentation-http correctly
rauno56 Apr 14, 2021
14772ba
feat: remove lodash.once
rauno56 Apr 15, 2021
c8914d1
style: rename constants to be more verbose
rauno56 Apr 15, 2021
88f6052
feat: handle cases with promises
rauno56 Apr 15, 2021
df87efd
feat: support async and promise-returning handlers
rauno56 Apr 15, 2021
4b58434
style: use RestifyInstrumentation as the import name
rauno56 Apr 15, 2021
c4dee5c
feat: let the example be broken until the publish for consistency
rauno56 Apr 15, 2021
f8bcb5c
fix: remove lodash.once types
rauno56 Apr 15, 2021
fd906b1
Merge branch 'main' into feat/restify-instrumentation
vmarchaud Apr 15, 2021
f4f4b08
Merge branch 'main' into feat/restify-instrumentation
rauno56 Apr 16, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
docs: update docs and metadata in package.json and README.md files
  • Loading branch information
rauno56 committed Apr 15, 2021
commit c4657df111a6408b2771aab6c369eea49092fba8
74 changes: 19 additions & 55 deletions examples/restify/README.md
Original file line number Diff line number Diff line change
@@ -1,75 +1,39 @@
# Overview

OpenTelemetry HTTP Instrumentation allows the user to automatically collect trace data and export them to the backend of choice (we can use Zipkin or Jaeger for this example), to give observability to distributed systems.
OpenTelemetry Restify Instrumentation allows the user to automatically collect trace data and export them to the backend of choice (we can use Zipkin or Jaeger for this example). This example demonstrates tracing calls made to Restify API. All generated spans include following attributes:

This is a simple example that demonstrates tracing HTTP request from client to server. The example
shows key aspects of tracing such as
- `http.route`: resolved route;
- `restify.method`: server method used to register the handler. One of `use`, `pre`, `del`, `get`, `head`, `opts`, `post`, `put` or `patch`;
- `restify.type`: either `middleware` or `request_handler`;
- `restify.version`: `restify` version running.

- Root Span (on Client)
- Child Span (on Client)
- Child Span from a Remote Parent (on Server)
- SpanContext Propagation (from Client to Server)
- Span Events
- Span Attributes

## Installation

```sh
# from this directory
npm install
```
## Setup

Setup [Zipkin Tracing](https://zipkin.io/pages/quickstart.html)
or
Setup [Jaeger Tracing](https://www.jaegertracing.io/docs/latest/getting-started/#all-in-one)

## Run the Application

### Zipkin

- Run the server

```sh
# from this directory
npm run zipkin:server
```

- Run the client
First install the dependencies:

```sh
# from this directory
npm run zipkin:client
```

#### Zipkin UI
```sh
npm install
```

`zipkin:server` script should output the `traceid` in the terminal (e.g `traceid: 4815c3d576d930189725f1f1d1bdfcc6`).
Go to Zipkin with your browser <http://localhost:9411/zipkin/traces/(your-trace-id)> (e.g <http://localhost:9411/zipkin/traces/4815c3d576d930189725f1f1d1bdfcc6)>
### Zipkin

<p align="center"><img src="./images/zipkin-ui.png?raw=true"/></p>
```sh
npm run zipkin:server # Run the server
npm run zipkin:client # Run the client in a separate terminal
```

### Jaeger

- Run the server

```sh
# from this directory
npm run jaeger:server
```

- Run the client

```sh
# from this directory
npm run jaeger:client
```

#### Jaeger UI

`jaeger:server` script should output the `traceid` in the terminal (e.g `traceid: 4815c3d576d930189725f1f1d1bdfcc6`).
Go to Jaeger with your browser <http://localhost:16686/trace/(your-trace-id)> (e.g <http://localhost:16686/trace/4815c3d576d930189725f1f1d1bdfcc6)>

<p align="center"><img src="images/jaeger-ui.png?raw=true"/></p>
```sh
npm run jaeger:server # Run the server
npm run jaeger:client # Run the client in a separate terminal
```

## Useful links

Expand Down
2 changes: 1 addition & 1 deletion examples/restify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "restify-example",
"private": true,
"version": "0.18.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: 0.15.0 in core we have 0.18.x

Copy link
Member

@vmarchaud vmarchaud Apr 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version in examples are not kept in sync in this repo, i think it would be better to do it with lerna instead

EDit: #428

"description": "Example of HTTP integration with OpenTelemetry",
"description": "Example of restify integration with OpenTelemetry",
"main": "index.js",
"scripts": {
"zipkin:server": "cross-env EXPORTER=zipkin node ./server.js",
Expand Down
44 changes: 12 additions & 32 deletions plugins/node/opentelemetry-instrumentation-restify/README.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,35 @@
# OpenTelemetry Express Instrumentation for Node.js
# OpenTelemetry Restify Instrumentation for Node.js

[![Gitter chat][gitter-image]][gitter-url]
[![dependencies][dependencies-image]][dependencies-url]
[![devDependencies][devDependencies-image]][devDependencies-url]
[![Apache License][license-image]][license-image]

This module provides automatic instrumentation for [`express`](https://github.com/expressjs/express).
This module provides automatic instrumentation for [`restify`](https://github.com/restify/node-restify) and allows the user to automatically collect trace data and export them to their backend of choice.

For automatic instrumentation see the
[@opentelemetry/node](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-node) package.

## Installation

```bash
npm install --save @opentelemetry/instrumentation-express
npm install --save @opentelemetry/instrumentation-restify
```
### Supported Versions
- `^4.0.0`
- `>=4.0.0`

## Usage

OpenTelemetry Express Instrumentation allows the user to automatically collect trace data and export them to their backend of choice, to give observability to distributed systems.

To load a specific instrumentation (express in this case), specify it in the Node Tracer's configuration.
```js
const { NodeTracerProvider } = require('@opentelemetry/node');
const { ExpressInstrumentation } = require('@opentelemetry/instrumentation-express');
const RestifyInstrumentation = require('@opentelemetry/instrumentation-restify');

const provider = new NodeTracerProvider();
provider.register();
new ExpressInstrumentation();
new RestifyInstrumentation();
```

See [examples/express](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/examples/express) for a short example.

### Caveats

Because of the way express works, it's hard to correctly compute the time taken by asynchronous middlewares and request handlers. For this reason, the time you'll see reported for asynchronous middlewares and request handlers will only represent the synchronous execution time, and **not** any asynchronous work.

### Express Instrumentation Options

Express instrumentation has few options available to choose from. You can set the following:

| Options | Type | Description |
| ------- | ---- | ----------- |
| `ignoreLayers` | `IgnoreMatcher[]` | Express instrumentation will not trace all layers that match. |
| `ignoreLayersType`| `ExpressLayerType[]` | Express instrumentation will ignore the layers that match based on their type. |

For reference, here are the three different layer type:
- `router` is the name of `express.Router()`
- `middleware`
- `request_handler` is the name for anything thats not a router or a middleware.
See [examples/restify](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/examples/restify) for a short example.

## Useful links
- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
Expand All @@ -64,7 +44,7 @@ Apache 2.0 - See [LICENSE][license-url] for more information.
[gitter-url]: https://gitter.im/open-telemetry/opentelemetry-node?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/LICENSE
[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
[dependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib/status.svg?path=packages/opentelemetry-instrumentation-express
[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib?path=packages%2Fopentelemetry-instrumentation-express
[devDependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib/dev-status.svg?path=packages/opentelemetry-instrumentation-express
[devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib?path=packages%2Fopentelemetry-instrumentation-express&type=dev
[dependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib/status.svg?path=packages/opentelemetry-instrumentation-restify
[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib?path=packages%2Fopentelemetry-instrumentation-restify
[devDependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib/dev-status.svg?path=packages/opentelemetry-instrumentation-restify
[devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib?path=packages%2Fopentelemetry-instrumentation-restify&type=dev
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@opentelemetry/instrumentation-restify",
"version": "0.14.0",
"description": "OpenTelemetry express automatic instrumentation package.",
"description": "OpenTelemetry restify automatic instrumentation package",
"main": "build/src/index.js",
"types": "build/src/index.d.ts",
"repository": "open-telemetry/opentelemetry-js-contrib",
Expand All @@ -20,10 +20,9 @@
},
"keywords": [
"opentelemetry",
"express",
"restify",
"nodejs",
"tracing",
"profiling",
"instrumentation"
],
"author": "OpenTelemetry Authors",
Expand All @@ -45,7 +44,6 @@
"@opentelemetry/context-async-hooks": "0.18.0",
"@opentelemetry/node": "0.18.0",
"@opentelemetry/tracing": "0.18.0",
"@types/express": "4.17.7",
"@types/lodash.once": "^4.1.6",
"@types/mocha": "7.0.2",
"@types/node": "14.0.27",
Expand Down