Skip to content

Commit

Permalink
Merge branch 'main' into ot-shim-log-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dyladan authored Jun 30, 2021
2 parents 8cc0ddd + b09ee6f commit 6bd55df
Show file tree
Hide file tree
Showing 33 changed files with 456 additions and 325 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ jobs:
strategy:
fail-fast: false
matrix:
container: ["node:8", "node:10", "node:12", "node:14", "node:16"]
node_version: ["8", "10", "12", "14", "16"]
runs-on: ubuntu-latest
container:
image: ${{ matrix.container }}
env:
NPM_CONFIG_UNSAFE_PERM: true
steps:
- name: Checkout
uses: actions/checkout@v1

- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node_version }}

- name: restore lock files
uses: actions/cache@master # must use unreleased master to cache multiple paths
id: cache
Expand All @@ -33,12 +35,11 @@ jobs:
metapackages/*/package-lock.json
packages/*/package-lock.json
integration-tests/*/package-lock.json
key: ${{ runner.os }}-unit_test-${{ matrix.container }}-${{ hashFiles('**/package.json') }}
key: ${{ runner.os }}-unit_test-${{ matrix.node_version }}-${{ hashFiles('**/package.json') }}
- name: Install and Build (cache miss) 🔧
if: steps.cache.outputs.cache-hit != 'true'
run: |
npm install --ignore-scripts
chown -R 1001:121 "/github/home/.npm" # fix npm cache permissions for npm v7
npx lerna bootstrap --no-ci
npm run compile
Expand All @@ -53,7 +54,7 @@ jobs:
run: npm run test
- name: Report Coverage
run: npm run codecov
if: ${{ matrix.container == 'node:14' }}
if: ${{ matrix.node_version == '14' }}
browser-tests:
runs-on: ubuntu-latest
container:
Expand Down
9 changes: 7 additions & 2 deletions examples/basic-tracer-node/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
'use strict';

const opentelemetry = require('@opentelemetry/api');
const { Resource } = require('@opentelemetry/resources');
const { ResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { BasicTracerProvider, ConsoleSpanExporter, SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { JaegerExporter } = require('@opentelemetry/exporter-jaeger');

const provider = new BasicTracerProvider();
const provider = new BasicTracerProvider({
resource: new Resource({
[ResourceAttributes.SERVICE_NAME]: 'basic-service',
}),
});

// Configure span processor to send spans to the exporter
const exporter = new JaegerExporter({
serviceName: 'basic-service',
endpoint: 'http://localhost:14268/api/traces',
});
provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
Expand Down
6 changes: 5 additions & 1 deletion examples/collector-exporter-node/metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@ const { CollectorMetricExporter } = require('@opentelemetry/exporter-collector')
// const { CollectorMetricExporter } = require('@opentelemetry/exporter-collector-grpc');
// const { CollectorMetricExporter } = require('@opentelemetry/exporter-collector-proto');
const { MeterProvider } = require('@opentelemetry/metrics');
const { Resource } = require('@opentelemetry/resources');
const { ResourceAttributes } = require('@opentelemetry/semantic-conventions');

// Optional and only needed to see the internal diagnostic logging (during development)
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);

const metricExporter = new CollectorMetricExporter({
serviceName: 'basic-metric-service',
// url: 'http://localhost:55681/v1/metrics',
});

const meter = new MeterProvider({
exporter: metricExporter,
interval: 1000,
resource: new Resource({
[ResourceAttributes.SERVICE_NAME]: 'basic-metric-service',
}),
}).getMeter('example-exporter-collector');

const requestCounter = meter.createCounter('requests', {
Expand Down
9 changes: 7 additions & 2 deletions examples/collector-exporter-node/tracing.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
const opentelemetry = require('@opentelemetry/api');
const { BasicTracerProvider, ConsoleSpanExporter, SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector');
const { Resource } = require('@opentelemetry/resources');
const { ResourceAttributes } = require('@opentelemetry/semantic-conventions');
// const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector-grpc');
// const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector-proto');

Expand All @@ -12,13 +14,16 @@ const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector');
// );

const exporter = new CollectorTraceExporter({
serviceName: 'basic-service',
// headers: {
// foo: 'bar'
// },
});

const provider = new BasicTracerProvider();
const provider = new BasicTracerProvider({
resource: new Resource({
[ResourceAttributes.SERVICE_NAME]: 'basic-service',
}),
});
provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
provider.register();
Expand Down
16 changes: 9 additions & 7 deletions examples/grpc-js/tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
const opentelemetry = require('@opentelemetry/api');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { NodeTracerProvider } = require('@opentelemetry/node');
const { Resource } = require('@opentelemetry/resources');
const { ResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { JaegerExporter } = require('@opentelemetry/exporter-jaeger');
const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin');
Expand All @@ -11,17 +13,17 @@ const { GrpcInstrumentation } = require('@opentelemetry/instrumentation-grpc');
const EXPORTER = process.env.EXPORTER || '';

module.exports = (serviceName) => {
const provider = new NodeTracerProvider();
const provider = new NodeTracerProvider({
resource: new Resource({
[ResourceAttributes.SERVICE_NAME]: serviceName,
}),
});

let exporter;
if (EXPORTER.toLowerCase().startsWith('z')) {
exporter = new ZipkinExporter({
serviceName,
});
exporter = new ZipkinExporter();
} else {
exporter = new JaegerExporter({
serviceName,
});
exporter = new JaegerExporter();
}

provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
Expand Down
16 changes: 9 additions & 7 deletions examples/grpc/tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
const opentelemetry = require('@opentelemetry/api');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { NodeTracerProvider } = require('@opentelemetry/node');
const { Resource } = require('@opentelemetry/resources');
const { ResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { JaegerExporter } = require('@opentelemetry/exporter-jaeger');
const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin');
Expand All @@ -11,17 +13,17 @@ const { GrpcInstrumentation } = require('@opentelemetry/instrumentation-grpc');
const EXPORTER = process.env.EXPORTER || '';

module.exports = (serviceName) => {
const provider = new NodeTracerProvider();
const provider = new NodeTracerProvider({
resource: new Resource({
[ResourceAttributes.SERVICE_NAME]: serviceName,
}),
});

let exporter;
if (EXPORTER.toLowerCase().startsWith('z')) {
exporter = new ZipkinExporter({
serviceName,
});
exporter = new ZipkinExporter();
} else {
exporter = new JaegerExporter({
serviceName,
});
exporter = new JaegerExporter();
}

provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
Expand Down
16 changes: 9 additions & 7 deletions examples/http/tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
const opentelemetry = require('@opentelemetry/api');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { NodeTracerProvider } = require('@opentelemetry/node');
const { Resource } = require('@opentelemetry/resources');
const { ResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { JaegerExporter } = require('@opentelemetry/exporter-jaeger');
const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin');
Expand All @@ -11,17 +13,17 @@ const { HttpInstrumentation } = require('@opentelemetry/instrumentation-http');
const EXPORTER = process.env.EXPORTER || '';

module.exports = (serviceName) => {
const provider = new NodeTracerProvider();
const provider = new NodeTracerProvider({
resource: new Resource({
[ResourceAttributes.SERVICE_NAME]: serviceName,
}),
});

let exporter;
if (EXPORTER.toLowerCase().startsWith('z')) {
exporter = new ZipkinExporter({
serviceName,
});
exporter = new ZipkinExporter();
} else {
exporter = new JaegerExporter({
serviceName,
});
exporter = new JaegerExporter();
}

provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
Expand Down
16 changes: 9 additions & 7 deletions examples/https/tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
const opentelemetry = require('@opentelemetry/api');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { NodeTracerProvider } = require('@opentelemetry/node');
const { Resource } = require('@opentelemetry/resources');
const { ResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { JaegerExporter } = require('@opentelemetry/exporter-jaeger');
const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin');
Expand All @@ -13,16 +15,16 @@ process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';

module.exports = (serviceName) => {
let exporter;
const provider = new NodeTracerProvider();
const provider = new NodeTracerProvider({
resource: new Resource({
[ResourceAttributes.SERVICE_NAME]: serviceName,
}),
});

if (EXPORTER.toLowerCase().startsWith('z')) {
exporter = new ZipkinExporter({
serviceName,
});
exporter = new ZipkinExporter();
} else {
exporter = new JaegerExporter({
serviceName,
});
exporter = new JaegerExporter();
}

provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
Expand Down
9 changes: 6 additions & 3 deletions examples/tracer-web/examples/metrics/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
const { DiagConsoleLogger, DiagLogLevel, diag } = require('@opentelemetry/api');
const { CollectorMetricExporter } = require('@opentelemetry/exporter-collector');
const { MeterProvider } = require('@opentelemetry/metrics');
const { Resource } = require('@opentelemetry/resources');
const { ResourceAttributes } = require('@opentelemetry/semantic-conventions');

// Optional and only needed to see the internal diagnostic logging (during development)
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);

const metricExporter = new CollectorMetricExporter({
serviceName: 'basic-metric-service',
});
const metricExporter = new CollectorMetricExporter();

let interval;
let meter;
Expand All @@ -25,6 +25,9 @@ function startMetrics() {
meter = new MeterProvider({
exporter: metricExporter,
interval: 1000,
resource: new Resource({
[ResourceAttributes.SERVICE_NAME]: 'basic-metric-service',
}),
}).getMeter('example-exporter-collector');

const requestCounter = meter.createCounter('requests', {
Expand Down
11 changes: 8 additions & 3 deletions getting-started/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ To create traces on NodeJS, you need `@opentelemetry/node`, `@opentelemetry/core

```sh
$ npm install \
@opentelemetry/core \
@opentelemetry/api \
@opentelemetry/node \
@opentelemetry/instrumentation-http \
@opentelemetry/instrumentation-express \
Expand Down Expand Up @@ -125,20 +125,25 @@ After you install these dependencies, initialize and register them. Modify `trac

const { diag, DiagConsoleLogger, DiagLogLevel } = require("@opentelemetry/api");
const { NodeTracerProvider } = require("@opentelemetry/node");
const { Resource } = require('@opentelemetry/resources');
const { ResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { SimpleSpanProcessor } = require("@opentelemetry/tracing");
const { ZipkinExporter } = require("@opentelemetry/exporter-zipkin");
const { registerInstrumentations } = require("@opentelemetry/instrumentation");
const { HttpInstrumentation } = require("@opentelemetry/instrumentation-http");
const { GrpcInstrumentation } = require("@opentelemetry/instrumentation-grpc");

const provider = new NodeTracerProvider();
const provider = new NodeTracerProvider({
resource: new Resource({
[ResourceAttributes.SERVICE_NAME]: "getting-started",
})
});

diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.ALL);

provider.addSpanProcessor(
new SimpleSpanProcessor(
new ZipkinExporter({
serviceName: "getting-started",
// If you are running your tracing backend on another host,
// you can point to it using the `url` parameter of the
// exporter config.
Expand Down
9 changes: 7 additions & 2 deletions getting-started/traced-example/tracing.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@

const { NodeTracerProvider } = require("@opentelemetry/node");
const { SimpleSpanProcessor } = require("@opentelemetry/tracing");
const { Resource } = require('@opentelemetry/resources');
const { ResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { ZipkinExporter } = require("@opentelemetry/exporter-zipkin");
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { ExpressInstrumentation } = require('@opentelemetry/instrumentation-express');
const { HttpInstrumentation } = require('@opentelemetry/instrumentation-http');

const provider = new NodeTracerProvider();
const provider = new NodeTracerProvider({
resource: new Resource({
[ResourceAttributes.SERVICE_NAME]: "getting-started",
})
});

provider.addSpanProcessor(
new SimpleSpanProcessor(
new ZipkinExporter({
serviceName: "getting-started"
// If you are running your tracing backend on another host,
// you can point to it using the `url` parameter of the
// exporter config.
Expand Down
4 changes: 3 additions & 1 deletion getting-started/ts-example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,16 @@ import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';

const provider: NodeTracerProvider = new NodeTracerProvider({
logLevel: LogLevel.ERROR,
resource: new Resource({
[ResourceAttributes.SERVICE_NAME]: 'getting-started',
}),
});

provider.addSpanProcessor(
new SimpleSpanProcessor(
new ZipkinExporter({
// For Jaeger, use the following line instead:
// new JaegerExporter({
serviceName: 'getting-started',
// If you are running your tracing backend on another host,
// you can point to it using the `url` parameter of the
// exporter config.
Expand Down
9 changes: 7 additions & 2 deletions getting-started/ts-example/traced-example/tracing.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { NodeTracerProvider } from '@opentelemetry/node';
const { Resource } = require('@opentelemetry/resources');
const { ResourceAttributes } = require('@opentelemetry/semantic-conventions');

import { SimpleSpanProcessor } from '@opentelemetry/tracing';
import { ZipkinExporter } from '@opentelemetry/exporter-zipkin';
Expand All @@ -9,13 +11,16 @@ const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { ExpressInstrumentation } = require('@opentelemetry/instrumentation-express');
const { HttpInstrumentation } = require('@opentelemetry/instrumentation-http');

const provider: NodeTracerProvider = new NodeTracerProvider();
const provider: NodeTracerProvider = new NodeTracerProvider({
resource: new Resource({
[ResourceAttributes.SERVICE_NAME]: 'getting-started',
}),
});
provider.addSpanProcessor(
new SimpleSpanProcessor(
new ZipkinExporter({
// For Jaeger, use the following line instead:
// new JaegerExporter({
serviceName: 'getting-started',
// If you are running your tracing backend on another host,
// you can point to it using the `url` parameter of the
// exporter config.
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-context-async-hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@types/mocha": "8.2.2",
"@types/node": "14.14.43",
"@types/shimmer": "1.0.1",
"codecov": "^3.8.2",
"codecov": "3.8.2",
"mocha": "7.2.0",
"nyc": "15.1.0",
"rimraf": "3.0.2",
Expand Down
Loading

0 comments on commit 6bd55df

Please sign in to comment.