Skip to content

Commit

Permalink
Merge branch 'main' into jamie.otlp-user-agent
Browse files Browse the repository at this point in the history
  • Loading branch information
pichlermarc authored May 15, 2023
2 parents 43b223f + 422a36a commit 5d6fcc4
Show file tree
Hide file tree
Showing 48 changed files with 530 additions and 106 deletions.
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use the latest and greatest features, and best practices.
| [grpc](grpc/) | gRPC Instrumentation to automatically collect trace data and export them to the backend of choice | Intermediate |
| [otlp-exporter-node](otlp-exporter-node/) | This example shows how to use `@opentelemetry/exporter-otlp-http` to instrument a simple Node.js application | Intermediate |
| [opentracing-shim](opentracing-shim/) | This is a simple example that demonstrates how existing OpenTracing instrumentation can be integrated with OpenTelemetry | Intermediate |
| [esm-http-ts](esm-http-ts/) | This is a simple example that demonstrates tracing HTTP request, with an app written in TypeScript and transpiled to ES Modules. | Intermediate |

Examples of experimental packages can be found at [experimental/examples](../experimental/examples).

Expand Down
25 changes: 25 additions & 0 deletions examples/esm-http-ts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Overview

This is a simple example that demonstrates tracing HTTP request, with an app written in TypeScript and transpiled to ES Modules.

## Installation

```sh
# from this directory
npm install
npm run build
npm start
```

In a separate terminal, `curl localhost:3000`.

See two spans in the console (one manual, one for http instrumentation)

## 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
43 changes: 43 additions & 0 deletions examples/esm-http-ts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { trace, DiagConsoleLogger, DiagLogLevel, diag } from '@opentelemetry/api';
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
import {
ConsoleSpanExporter,
SimpleSpanProcessor,
} from '@opentelemetry/sdk-trace-base';
import { Resource } from '@opentelemetry/resources';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import http from 'http';

diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);
const tracerProvider = new NodeTracerProvider({
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: 'esm-http-ts-example',
}),
});
const exporter = new ConsoleSpanExporter();
const processor = new SimpleSpanProcessor(exporter);
tracerProvider.addSpanProcessor(processor);
tracerProvider.register();

registerInstrumentations({
instrumentations: [new HttpInstrumentation()],
});

const hostname = '0.0.0.0';
const port = 3000;

const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
const tracer = trace.getTracer('esm-tracer');
tracer.startActiveSpan('manual', span => {
span.end();
});
res.end('Hello, World!\n');
});

server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
42 changes: 42 additions & 0 deletions examples/esm-http-ts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "esm-http-ts",
"private": true,
"version": "0.38.0",
"description": "Example of HTTP integration with OpenTelemetry using ESM and TypeScript",
"main": "build/index.js",
"type": "module",
"scripts": {
"build": "tsc --build",
"start": "node --experimental-loader=@opentelemetry/instrumentation/hook.mjs ./build/index.js"
},
"repository": {
"type": "git",
"url": "git+ssh://[email protected]/open-telemetry/opentelemetry-js.git"
},
"keywords": [
"opentelemetry",
"http",
"tracing",
"esm",
"typescript"
],
"engines": {
"node": ">=14"
},
"author": "OpenTelemetry Authors",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/open-telemetry/opentelemetry-js/issues"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/examples/",
"dependencies": {
"@opentelemetry/api": "1.4.0",
"@opentelemetry/exporter-trace-otlp-proto": "0.38.0",
"@opentelemetry/instrumentation": "0.38.0",
"@opentelemetry/instrumentation-http": "0.38.0",
"@opentelemetry/resources": "1.9.1",
"@opentelemetry/sdk-trace-base": "1.9.1",
"@opentelemetry/sdk-trace-node": "1.9.1",
"@opentelemetry/semantic-conventions": "1.9.1"
}
}
25 changes: 25 additions & 0 deletions examples/esm-http-ts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"compilerOptions": {
/* Language and Environment */
"target": "ES2020" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,

/* Modules */
"module": "ESNext" /* Specify what module code is generated. */,
"rootDir": "." /* Specify the root folder within your source files. */,
"moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */,
"resolveJsonModule": true /* Enable importing .json files. */,

/* Emit */
"outDir": "build" /* Specify an output folder for all emitted files. */,

/* Interop Constraints */
"allowSyntheticDefaultImports": true /* Allow 'import x from y' when a module doesn't have a default export. */,
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,

/* Completeness */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"include": ["**/*.ts", "**/*.js", "*.config.js"],
"exclude": ["node_modules"]
}
6 changes: 3 additions & 3 deletions examples/http/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "http-example",
"private": true,
"version": "0.39.0",
"version": "0.39.1",
"description": "Example of HTTP integration with OpenTelemetry",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -31,8 +31,8 @@
"@opentelemetry/api": "^1.3.0",
"@opentelemetry/exporter-jaeger": "1.13.0",
"@opentelemetry/exporter-zipkin": "1.13.0",
"@opentelemetry/instrumentation": "0.39.0",
"@opentelemetry/instrumentation-http": "0.39.0",
"@opentelemetry/instrumentation": "0.39.1",
"@opentelemetry/instrumentation-http": "0.39.1",
"@opentelemetry/resources": "1.13.0",
"@opentelemetry/sdk-trace-base": "1.13.0",
"@opentelemetry/sdk-trace-node": "1.13.0",
Expand Down
6 changes: 3 additions & 3 deletions examples/https/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "https-example",
"private": true,
"version": "0.39.0",
"version": "0.39.1",
"description": "Example of HTTPs integration with OpenTelemetry",
"main": "build/src/index.js",
"types": "build/src/index.d.ts",
Expand Down Expand Up @@ -35,8 +35,8 @@
"@opentelemetry/api": "^1.0.0",
"@opentelemetry/exporter-jaeger": "1.13.0",
"@opentelemetry/exporter-zipkin": "1.13.0",
"@opentelemetry/instrumentation": "0.39.0",
"@opentelemetry/instrumentation-http": "0.39.0",
"@opentelemetry/instrumentation": "0.39.1",
"@opentelemetry/instrumentation-http": "0.39.1",
"@opentelemetry/resources": "1.13.0",
"@opentelemetry/sdk-trace-base": "1.13.0",
"@opentelemetry/sdk-trace-node": "1.13.0",
Expand Down
14 changes: 7 additions & 7 deletions examples/opentelemetry-web/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "web-opentelemetry-example",
"private": true,
"version": "0.39.0",
"version": "0.39.1",
"description": "Example of using @opentelemetry/sdk-trace-web and @opentelemetry/sdk-metrics in browser",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -45,13 +45,13 @@
"@opentelemetry/api": "^1.3.0",
"@opentelemetry/context-zone": "1.13.0",
"@opentelemetry/core": "1.13.0",
"@opentelemetry/exporter-metrics-otlp-http": "0.39.0",
"@opentelemetry/exporter-trace-otlp-http": "0.39.0",
"@opentelemetry/exporter-trace-otlp-proto": "0.39.0",
"@opentelemetry/exporter-metrics-otlp-http": "0.39.1",
"@opentelemetry/exporter-trace-otlp-http": "0.39.1",
"@opentelemetry/exporter-trace-otlp-proto": "0.39.1",
"@opentelemetry/exporter-zipkin": "1.13.0",
"@opentelemetry/instrumentation": "0.39.0",
"@opentelemetry/instrumentation-fetch": "0.39.0",
"@opentelemetry/instrumentation-xml-http-request": "0.39.0",
"@opentelemetry/instrumentation": "0.39.1",
"@opentelemetry/instrumentation-fetch": "0.39.1",
"@opentelemetry/instrumentation-xml-http-request": "0.39.1",
"@opentelemetry/propagator-b3": "1.13.0",
"@opentelemetry/sdk-metrics": "1.13.0",
"@opentelemetry/sdk-trace-base": "1.13.0",
Expand Down
14 changes: 7 additions & 7 deletions examples/otlp-exporter-node/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "example-otlp-exporter-node",
"private": true,
"version": "0.39.0",
"version": "0.39.1",
"description": "Example of using @opentelemetry/collector-exporter in Node.js",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -30,12 +30,12 @@
"dependencies": {
"@opentelemetry/api": "^1.3.0",
"@opentelemetry/core": "1.13.0",
"@opentelemetry/exporter-metrics-otlp-grpc": "0.39.0",
"@opentelemetry/exporter-metrics-otlp-http": "0.39.0",
"@opentelemetry/exporter-metrics-otlp-proto": "0.39.0",
"@opentelemetry/exporter-trace-otlp-grpc": "0.39.0",
"@opentelemetry/exporter-trace-otlp-http": "0.39.0",
"@opentelemetry/exporter-trace-otlp-proto": "0.39.0",
"@opentelemetry/exporter-metrics-otlp-grpc": "0.39.1",
"@opentelemetry/exporter-metrics-otlp-http": "0.39.1",
"@opentelemetry/exporter-metrics-otlp-proto": "0.39.1",
"@opentelemetry/exporter-trace-otlp-grpc": "0.39.1",
"@opentelemetry/exporter-trace-otlp-http": "0.39.1",
"@opentelemetry/exporter-trace-otlp-proto": "0.39.1",
"@opentelemetry/resources": "1.13.0",
"@opentelemetry/sdk-metrics": "1.13.0",
"@opentelemetry/sdk-trace-base": "1.13.0",
Expand Down
10 changes: 8 additions & 2 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,20 @@ All notable changes to experimental packages in this project will be documented

### :rocket: (Enhancement)

### :bug: (Bug Fix)
* feat(instrumentation): add ESM support for instrumentation. [#3698](https://github.com/open-telemetry/opentelemetry-js/pull/3698) @JamieDanielson, @pkanal, @vmarchaud, @lizthegrey, @bengl

fix(otlp-transformer): move api-logs to dependencies [#3798](https://github.com/open-telemetry/opentelemetry-js/pull/3798) @pichlermarc
### :bug: (Bug Fix)

### :books: (Refine Doc)

### :house: (Internal)

## 0.39.1

### :bug: (Bug Fix)

* fix(otlp-transformer): move api-logs to dependencies [#3798](https://github.com/open-telemetry/opentelemetry-js/pull/3798) @pichlermarc

## 0.39.0

### :rocket: (Enhancement)
Expand Down
4 changes: 2 additions & 2 deletions experimental/backwards-compatability/node14/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "backcompat-node14",
"version": "0.39.0",
"version": "0.39.1",
"private": true,
"description": "Backwards compatability app for node 14 types and the OpenTelemetry Node.js SDK",
"main": "index.js",
Expand All @@ -9,7 +9,7 @@
"peer-api-check": "node ../../../scripts/peer-api-check.js"
},
"dependencies": {
"@opentelemetry/sdk-node": "0.39.0",
"@opentelemetry/sdk-node": "0.39.1",
"@opentelemetry/sdk-trace-base": "1.13.0"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions experimental/backwards-compatability/node16/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "backcompat-node16",
"version": "0.39.0",
"version": "0.39.1",
"private": true,
"description": "Backwards compatability app for node 16 types and the OpenTelemetry Node.js SDK",
"main": "index.js",
Expand All @@ -9,7 +9,7 @@
"peer-api-check": "node ../../../scripts/peer-api-check.js"
},
"dependencies": {
"@opentelemetry/sdk-node": "0.39.0",
"@opentelemetry/sdk-node": "0.39.1",
"@opentelemetry/sdk-trace-base": "1.13.0"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions experimental/examples/logs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
},
"dependencies": {
"@opentelemetry/api": "^1.4.1",
"@opentelemetry/api-logs": "0.39.0",
"@opentelemetry/sdk-logs": "0.39.0"
"@opentelemetry/api-logs": "0.39.1",
"@opentelemetry/sdk-logs": "0.39.1"
},
"devDependencies": {
"@types/node": "18.6.5",
Expand Down
4 changes: 2 additions & 2 deletions experimental/examples/prometheus/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prometheus-example",
"version": "0.39.0",
"version": "0.39.1",
"private": true,
"description": "Example of using @opentelemetry/sdk-metrics and @opentelemetry/exporter-prometheus",
"main": "index.js",
Expand All @@ -11,7 +11,7 @@
"license": "Apache-2.0",
"dependencies": {
"@opentelemetry/api": "^1.3.0",
"@opentelemetry/exporter-prometheus": "0.39.0",
"@opentelemetry/exporter-prometheus": "0.39.1",
"@opentelemetry/sdk-metrics": "1.13.0"
}
}
2 changes: 1 addition & 1 deletion experimental/packages/api-events/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentelemetry/api-events",
"version": "0.39.0",
"version": "0.39.1",
"description": "Public events API for OpenTelemetry",
"main": "build/src/index.js",
"module": "build/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion experimental/packages/api-logs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentelemetry/api-logs",
"version": "0.39.0",
"version": "0.39.1",
"description": "Public logs API for OpenTelemetry",
"main": "build/src/index.js",
"module": "build/esm/index.js",
Expand Down
12 changes: 6 additions & 6 deletions experimental/packages/exporter-logs-otlp-grpc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentelemetry/exporter-logs-otlp-grpc",
"version": "0.39.0",
"version": "0.39.1",
"description": "OpenTelemetry Collector Exporter allows user to send collected log records to the OpenTelemetry Collector",
"main": "build/src/index.js",
"types": "build/src/index.d.ts",
Expand Down Expand Up @@ -51,8 +51,8 @@
"@babel/core": "7.16.0",
"@grpc/proto-loader": "^0.7.3",
"@opentelemetry/api": "1.4.1",
"@opentelemetry/api-logs": "0.39.0",
"@opentelemetry/otlp-exporter-base": "0.39.0",
"@opentelemetry/api-logs": "0.39.1",
"@opentelemetry/otlp-exporter-base": "0.39.1",
"@opentelemetry/resources": "1.13.0",
"@types/mocha": "10.0.0",
"@types/node": "18.6.5",
Expand All @@ -72,9 +72,9 @@
"dependencies": {
"@grpc/grpc-js": "^1.7.1",
"@opentelemetry/core": "1.13.0",
"@opentelemetry/otlp-grpc-exporter-base": "0.39.0",
"@opentelemetry/otlp-transformer": "0.39.0",
"@opentelemetry/sdk-logs": "0.39.0"
"@opentelemetry/otlp-grpc-exporter-base": "0.39.1",
"@opentelemetry/otlp-transformer": "0.39.1",
"@opentelemetry/sdk-logs": "0.39.1"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/exporter-logs-otlp-grpc",
"sideEffects": false
Expand Down
Loading

0 comments on commit 5d6fcc4

Please sign in to comment.