Skip to content

Commit

Permalink
Merge branch 'main' into fix/mysql-test-script
Browse files Browse the repository at this point in the history
  • Loading branch information
pichlermarc committed Feb 28, 2024
2 parents 37f2126 + 44b2df0 commit a316da4
Show file tree
Hide file tree
Showing 97 changed files with 4,956 additions and 6,666 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ jobs:
- name: Unit tests (Delta)
if: ${{ !matrix.code-coverage }}
run: npm run test:ci:changed
- name: Build examples
run: npm run compile:examples
- name: Report Coverage
if: ${{ matrix.code-coverage && !cancelled()}}
uses: codecov/codecov-action@v3
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"detectors/node/opentelemetry-resource-detector-alibaba-cloud":"0.28.6","detectors/node/opentelemetry-resource-detector-aws":"1.3.6","detectors/node/opentelemetry-resource-detector-azure":"0.2.4","detectors/node/opentelemetry-resource-detector-container":"0.3.6","detectors/node/opentelemetry-resource-detector-gcp":"0.29.6","detectors/node/opentelemetry-resource-detector-github":"0.28.1","detectors/node/opentelemetry-resource-detector-instana":"0.6.0","metapackages/auto-instrumentations-node":"0.41.1","metapackages/auto-instrumentations-web":"0.36.0","packages/opentelemetry-host-metrics":"0.35.0","packages/opentelemetry-id-generator-aws-xray":"1.2.1","packages/opentelemetry-propagation-utils":"0.30.6","packages/opentelemetry-redis-common":"0.36.1","packages/opentelemetry-sampler-aws-xray":"0.34.0","packages/opentelemetry-sql-common":"0.40.0","packages/opentelemetry-test-utils":"0.36.0","plugins/node/instrumentation-amqplib":"0.34.0","plugins/node/instrumentation-cucumber":"0.3.0","plugins/node/instrumentation-dataloader":"0.6.0","plugins/node/instrumentation-fs":"0.9.0","plugins/node/instrumentation-lru-memoizer":"0.34.0","plugins/node/instrumentation-mongoose":"0.35.0","plugins/node/instrumentation-perf-hooks": "0.1.0","plugins/node/instrumentation-socket.io":"0.36.0","plugins/node/instrumentation-tedious":"0.7.0","plugins/node/opentelemetry-instrumentation-aws-lambda":"0.38.0","plugins/node/opentelemetry-instrumentation-aws-sdk":"0.38.1","plugins/node/opentelemetry-instrumentation-bunyan":"0.35.0","plugins/node/opentelemetry-instrumentation-bunyan/examples":"0.1.0","plugins/node/opentelemetry-instrumentation-cassandra":"0.35.0","plugins/node/opentelemetry-instrumentation-connect":"0.33.0","plugins/node/opentelemetry-instrumentation-dns":"0.33.0","plugins/node/opentelemetry-instrumentation-express":"0.35.0","plugins/node/opentelemetry-instrumentation-express/examples":"0.1.0","plugins/node/opentelemetry-instrumentation-fastify":"0.33.0","plugins/node/opentelemetry-instrumentation-generic-pool":"0.33.0","plugins/node/opentelemetry-instrumentation-graphql":"0.37.0","plugins/node/opentelemetry-instrumentation-hapi":"0.34.0","plugins/node/opentelemetry-instrumentation-ioredis":"0.37.0","plugins/node/opentelemetry-instrumentation-knex":"0.33.0","plugins/node/opentelemetry-instrumentation-koa":"0.37.0","plugins/node/opentelemetry-instrumentation-koa/examples":"0.1.0","plugins/node/opentelemetry-instrumentation-memcached":"0.33.0","plugins/node/opentelemetry-instrumentation-mongodb":"0.39.0","plugins/node/opentelemetry-instrumentation-mongodb/examples":"0.1.0","plugins/node/opentelemetry-instrumentation-mysql":"0.35.0","plugins/node/opentelemetry-instrumentation-mysql/examples":"0.1.0","plugins/node/opentelemetry-instrumentation-mysql2":"0.35.0","plugins/node/opentelemetry-instrumentation-nestjs-core":"0.34.0","plugins/node/opentelemetry-instrumentation-net":"0.33.0","plugins/node/opentelemetry-instrumentation-pg":"0.38.0","plugins/node/opentelemetry-instrumentation-pino":"0.35.0","plugins/node/opentelemetry-instrumentation-redis":"0.36.0","plugins/node/opentelemetry-instrumentation-redis/examples":"0.1.0","plugins/node/opentelemetry-instrumentation-redis-4":"0.36.0","plugins/node/opentelemetry-instrumentation-restify":"0.35.0","plugins/node/opentelemetry-instrumentation-router":"0.34.0","plugins/node/opentelemetry-instrumentation-winston":"0.34.0","plugins/web/opentelemetry-instrumentation-document-load":"0.35.0","plugins/web/opentelemetry-instrumentation-long-task":"0.35.0","plugins/web/opentelemetry-instrumentation-user-interaction":"0.35.0","plugins/web/opentelemetry-plugin-react-load":"0.30.0","propagators/opentelemetry-propagator-aws-xray":"1.3.1","propagators/opentelemetry-propagator-grpc-census-binary":"0.27.1","propagators/opentelemetry-propagator-instana":"0.3.1","propagators/opentelemetry-propagator-ot-trace":"0.27.1"}
{"detectors/node/opentelemetry-resource-detector-alibaba-cloud":"0.28.6","detectors/node/opentelemetry-resource-detector-aws":"1.3.6","detectors/node/opentelemetry-resource-detector-azure":"0.2.4","detectors/node/opentelemetry-resource-detector-container":"0.3.6","detectors/node/opentelemetry-resource-detector-gcp":"0.29.6","detectors/node/opentelemetry-resource-detector-github":"0.28.1","detectors/node/opentelemetry-resource-detector-instana":"0.6.0","metapackages/auto-instrumentations-node":"0.41.1","metapackages/auto-instrumentations-web":"0.36.0","packages/opentelemetry-host-metrics":"0.35.0","packages/opentelemetry-id-generator-aws-xray":"1.2.1","packages/opentelemetry-propagation-utils":"0.30.6","packages/opentelemetry-redis-common":"0.36.1","packages/opentelemetry-sql-common":"0.40.0","packages/opentelemetry-test-utils":"0.36.0","plugins/node/instrumentation-amqplib":"0.34.0","plugins/node/instrumentation-cucumber":"0.3.0","plugins/node/instrumentation-dataloader":"0.6.0","plugins/node/instrumentation-fs":"0.9.0","plugins/node/instrumentation-lru-memoizer":"0.34.0","plugins/node/instrumentation-mongoose":"0.35.0","plugins/node/instrumentation-perf-hooks": "0.1.0","plugins/node/instrumentation-socket.io":"0.36.0","plugins/node/instrumentation-tedious":"0.7.0","plugins/node/opentelemetry-instrumentation-aws-lambda":"0.38.0","plugins/node/opentelemetry-instrumentation-aws-sdk":"0.38.1","plugins/node/opentelemetry-instrumentation-bunyan":"0.35.0","plugins/node/opentelemetry-instrumentation-cassandra":"0.35.0","plugins/node/opentelemetry-instrumentation-connect":"0.33.0","plugins/node/opentelemetry-instrumentation-dns":"0.33.0","plugins/node/opentelemetry-instrumentation-express":"0.35.0","plugins/node/opentelemetry-instrumentation-fastify":"0.33.0","plugins/node/opentelemetry-instrumentation-generic-pool":"0.33.0","plugins/node/opentelemetry-instrumentation-graphql":"0.37.0","plugins/node/opentelemetry-instrumentation-hapi":"0.34.0","plugins/node/opentelemetry-instrumentation-ioredis":"0.37.0","plugins/node/opentelemetry-instrumentation-knex":"0.33.0","plugins/node/opentelemetry-instrumentation-koa":"0.37.0","plugins/node/opentelemetry-instrumentation-memcached":"0.33.0","plugins/node/opentelemetry-instrumentation-mongodb":"0.39.0","plugins/node/opentelemetry-instrumentation-mysql":"0.35.0","plugins/node/opentelemetry-instrumentation-mysql2":"0.35.0","plugins/node/opentelemetry-instrumentation-nestjs-core":"0.34.0","plugins/node/opentelemetry-instrumentation-net":"0.33.0","plugins/node/opentelemetry-instrumentation-pg":"0.38.0","plugins/node/opentelemetry-instrumentation-pino":"0.35.0","plugins/node/opentelemetry-instrumentation-redis":"0.36.0","plugins/node/opentelemetry-instrumentation-redis-4":"0.36.0","plugins/node/opentelemetry-instrumentation-restify":"0.35.0","plugins/node/opentelemetry-instrumentation-router":"0.34.0","plugins/node/opentelemetry-instrumentation-winston":"0.34.0","plugins/web/opentelemetry-instrumentation-document-load":"0.35.0","plugins/web/opentelemetry-instrumentation-long-task":"0.35.0","plugins/web/opentelemetry-instrumentation-user-interaction":"0.35.0","plugins/web/opentelemetry-plugin-react-load":"0.30.0","propagators/opentelemetry-propagator-aws-xray":"1.3.1","propagators/opentelemetry-propagator-grpc-census-binary":"0.27.1","propagators/opentelemetry-propagator-instana":"0.3.1","propagators/opentelemetry-propagator-ot-trace":"0.27.1"}
41 changes: 3 additions & 38 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,6 @@
# Instrumentation Examples

:warning: Note: We are working on migrating these examples to their respective package directories.
:warning: Some of these examples may be out of date. Compare the version of the `@opentelemetry/instrumentation-{module}` dependency in the example's "package.json" file to the latest published version of that dependency to know.

For instance, examples of using `express` instrumentation have moved from this directory to [plugins/node/opentelemetry-instrumentation-express](https://github.com/open-telemetry/opentelemetry-js/tree/main/plugins/node/opentelemetry-instrumentation-express).

## Instructions for Migrating an Example

* [ ] Move the files
* [ ] Choose an instrumentation package to migrate examples for.
* [ ] Move the examples from `./examples/[name]` to `./plugins/[node or web]]/opentelemetry-instrumentation-[name]/examples`.
* [ ] Update the `./plugins/[node or web]]/opentelemetry-instrumentation-[name]/README.md` and replace the path `examples/[name]` with the new path of the examples.
* [ ] Update the `package.json` in the examples folder
* [ ] Remove the `@opentelemetry/instrumentation-[name]` dependency.
* [ ] Install `typescript` and `ts-node` in the examples directory.
* [ ] Replace usage of `node` in scripts with `ts-node`.
* [ ] Add a script for compiling the code in scripts: `"compile": "tsc -p ."`
* [ ] Add a tsconfig.json file in the examples folder. (Example below)
* [ ] Update the code
* [ ] Change code to use a relative import of the library.
* [ ] Add types to the code
* [ ] Update the instrumentation package's `package.json`
* [ ] Add a script `"compile:examples": "cd examples && npm run compile",`.
* [ ] Test the updated code
* [ ] Test building the examples by running `npm run compile:examples`
* [ ] Test that the actual exapmle code runs as expected

Example tsconfig.json file:

```json
{
"extends": "../tsconfig.json",
"compilerOptions": {
"noEmit": true,
"rootDir": ".",
},
"include": [
"src/**/*.ts",
]
}
```
This directory holds a number of examples demonstrating using OpenTelemetry
instrumentation with a particular module.
1 change: 1 addition & 0 deletions examples/bunyan/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions examples/express/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
71 changes: 71 additions & 0 deletions examples/express/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Overview

OpenTelemetry Express 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.

This is a simple example that demonstrates tracing calls made to Express API. The example
shows key aspects of tracing such as

- Root Span (on Client)
- Child Span (on Client)
- Span Events
- Span Attributes

## Installation

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

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
npm run zipkin:server
```

Then run the client in a separate terminal:

```sh
npm run zipkin:client
```

After a short time, the generated traces should be available in the Zipkin UI.
Visit <http://localhost:9411/zipkin> and click the "RUN QUERY" button to view
recent traces, then click "SHOW" on a given trace.

<p align="center"><img src="./images/zipkin.jpg?raw=true"/></p>

### Jaeger

Run the server:

```sh
npm run jaeger:server
```

Then run the client in a separate terminal:

```sh
npm run jaeger:client
```

Visit the Jaeger UI at <http://localhost:16686/search>, select a service (e.g. "example-express-client"), click "Find Traces", then click on a trace to view it.

<p align="center"><img src="images/jaeger.jpg?raw=true"/></p>

## Useful links

- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
- For more information on OpenTelemetry for Node.js, visit: <https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-sdk-trace-node>

## LICENSE

Apache License 2.0
File renamed without changes
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@
"zipkin:client": "cross-env EXPORTER=zipkin ts-node src/client.ts",
"jaeger:server": "cross-env EXPORTER=jaeger ts-node src/server.ts",
"jaeger:client": "cross-env EXPORTER=jaeger ts-node src/client.ts",
"compile": "tsc -p .",
"setup": "cd ../../../../ && npm ci && cd plugins/node/opentelemetry-instrumentation-express && npm run compile && cd examples && npm run compile"
"compile": "tsc -p ."
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/open-telemetry/opentelemetry-js-contrib.git",
"directory": "plugins/node/opentelemetry-instrumentation-express"
"directory": "examples/express"
},
"keywords": [
"opentelemetry",
Expand All @@ -29,7 +28,7 @@
"bugs": {
"url": "https://github.com/open-telemetry/opentelemetry-js-contrib/issues"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-express/examples#readme",
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/examples/express#readme",
"dependencies": {
"@opentelemetry/api": "^1.3.0",
"@opentelemetry/exporter-jaeger": "^1.18.1",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../tsconfig.json",
"extends": "../../tsconfig.base",
"compilerOptions": {
"noEmit": true,
"rootDir": ".",
Expand Down
1 change: 1 addition & 0 deletions examples/koa/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Setup [Jaeger Tracing](https://www.jaegertracing.io/docs/latest/getting-started/

#### Zipkin UI

`zipkin:server` script should output the `traceid` in the terminal (e.g `traceid: 4815c3d576d930189725f1f1d1bdfcc6`).
The `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>)

<p align="center"><img src="./images/zipkin.jpg?raw=true"/></p>
Expand All @@ -64,7 +64,7 @@ Go to Zipkin with your browser <http://localhost:9411/zipkin/traces/(your-trace-

#### Jaeger UI

`jaeger:server` script should output the `traceid` in the terminal (e.g `traceid: 4815c3d576d930189725f1f1d1bdfcc6`).
The `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.jpg?raw=true"/></p>
Expand Down
File renamed without changes
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"private": true,
"version": "0.1.0",
"description": "Example of Koa and @koa/router integration with OpenTelemetry",
"main": "index.js",
"scripts": {
"zipkin:server": "cross-env EXPORTER=zipkin ts-node src/server.ts",
"zipkin:client": "cross-env EXPORTER=zipkin ts-node src/client.ts",
Expand All @@ -13,7 +12,8 @@
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/open-telemetry/opentelemetry-js-contrib.git"
"url": "git+ssh://git@github.com/open-telemetry/opentelemetry-js-contrib.git",
"directory": "examples/koa"
},
"keywords": [
"opentelemetry",
Expand Down Expand Up @@ -42,7 +42,7 @@
"axios": "^1.6.0",
"koa": "^2.13.0"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib#readme",
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/examples/koa#readme",
"devDependencies": {
"cross-env": "^7.0.0",
"ts-node": "^10.6.0",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../tsconfig.json",
"extends": "../../tsconfig.base",
"compilerOptions": {
"noEmit": true,
"rootDir": ".",
Expand Down
1 change: 1 addition & 0 deletions examples/mongodb/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Setup [Jaeger Tracing](https://www.jaegertracing.io/docs/latest/getting-started/

### Zipkin

- Start MongoDB server via docker
- Start MongoDB server in docker

```sh
# from this directory
Expand All @@ -46,8 +46,9 @@ Setup [Jaeger Tracing](https://www.jaegertracing.io/docs/latest/getting-started/

#### Zipkin UI

`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>)
After a short time, the generated traces should be available in the Zipkin UI.
Visit <http://localhost:9411/zipkin> and click the "RUN QUERY" button to view
recent traces, then click "SHOW" on a given trace.

<p align="center"><img src="./images/zipkin.png?raw=true"/></p>

Expand Down Expand Up @@ -76,8 +77,7 @@ Go to Zipkin with your browser <http://localhost:9411/zipkin/traces/(your-trace-

#### Jaeger UI

`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>)
Visit the Jaeger UI at <http://localhost:16686/search>, select a service (e.g. "example-express-client"), click "Find Traces", then click on a trace to view it.

<p align="center"><img src="images/jaeger-ui.png?raw=true"/></p>

Expand Down
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../tsconfig.json",
"extends": "../../tsconfig.base",
"compilerOptions": {
"noEmit": true,
"rootDir": ".",
Expand Down
1 change: 1 addition & 0 deletions examples/mysql/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This is a modification of the HTTP example that executes multiple parallel reque

## supported metrics

- Currently only `db.client.connections.usage` is supported, which denoted the number of idle/used connections.
- Currently only `db.client.connections.usage` is supported, which denotes the number of idle/used connections.

## Installation

Expand Down Expand Up @@ -49,7 +49,7 @@ In case you want to see also metrics:

#### Zipkin UI

`server` script should output the `traceid` in the terminal (e.g `traceid: 4815c3d576d930189725f1f1d1bdfcc6`).
The `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>)

<p align="center"><img src="./images/zipkin-ui.png?raw=true"/></p>
Expand All @@ -72,7 +72,7 @@ Go to Zipkin with your browser <http://localhost:9411/zipkin/traces/(your-trace-

#### Jaeger UI

`server` script should output the `traceid` in the terminal (e.g `traceid: 4815c3d576d930189725f1f1d1bdfcc6`).
The `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>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@opentelemetry/exporter-metrics-otlp-grpc": "^0.48.0",
"mysql": "^2.18.1"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js#readme",
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/examples/mysql#readme",
"devDependencies": {
"@types/mysql": "^2.15.21",
"cross-env": "^7.0.0",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function startServer(port: number | undefined) {
function handleRequest(request: any, response: any) {
const currentSpan = api.trace.getSpan(api.context.active())
// display traceid in the terminal
const traceId = currentSpan?.spanContext();
const traceId = currentSpan?.spanContext().traceId;
console.log(`traceid: ${traceId}`);
console.log(`Jaeger URL: http://localhost:16686/trace/${traceId}`);
console.log(`Zipkin URL: http://localhost:9411/zipkin/traces/${traceId}`);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../tsconfig.json",
"extends": "../../tsconfig.base",
"compilerOptions": {
"noEmit": true,
"rootDir": ".",
Expand Down
1 change: 1 addition & 0 deletions examples/redis/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
Loading

0 comments on commit a316da4

Please sign in to comment.