Skip to content

Commit

Permalink
Merge branch 'main' into actions
Browse files Browse the repository at this point in the history
  • Loading branch information
dyladan authored Jan 25, 2022
2 parents f36cb43 + 04f9edd commit b7bbe21
Show file tree
Hide file tree
Showing 63 changed files with 1,265 additions and 303 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,41 @@ jobs:
run: npm run test:browser
- name: Report Coverage
run: npm run codecov:browser
webworker-tests-stable:
runs-on: ubuntu-latest
container:
image: circleci/node:14-browsers
env:
NPM_CONFIG_UNSAFE_PERM: true
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Permission Setup
run: sudo chmod -R 777 /github /__w

- name: restore lerna
uses: actions/cache@v2
id: cache
with:
path: |
node_modules
*/*/node_modules
key: browser-tests-stable-${{ runner.os }}-${{ matrix.node_version }}-${{ hashFiles('**/package.json') }}

- name: Bootstrap
if: steps.cache.outputs.cache-hit != 'true'
run: |
npm install --ignore-scripts
npx lerna bootstrap --no-ci --hoist --nohoist='zone.js'
- name: Build 🔧
run: |
npm run compile
- name: Unit tests
run: npm run test:webworker
- name: Report Coverage
run: npm run codecov:webworker
node-tests-experimental:
strategy:
fail-fast: false
Expand Down Expand Up @@ -164,3 +199,42 @@ jobs:
- name: Report Coverage
working-directory: experimental
run: npm run codecov:browser
webworker-tests-experimental:
runs-on: ubuntu-latest
container:
image: circleci/node:14-browsers
env:
NPM_CONFIG_UNSAFE_PERM: true
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Permission Setup
run: sudo chmod -R 777 /github /__w

- name: restore lerna
uses: actions/cache@v2
id: cache
with:
path: |
experimental/node_modules
experimental/*/*/node_modules
key: browser-tests-experimental-${{ runner.os }}-${{ matrix.node_version }}-${{ hashFiles('**/package.json') }}

- name: Bootstrap
if: steps.cache.outputs.cache-hit != 'true'
working-directory: experimental
run: |
npm install --ignore-scripts
npx lerna bootstrap --no-ci --hoist --nohoist='zone.js'
- name: Build 🔧
working-directory: experimental
run: |
npm run compile
- name: Unit tests
working-directory: experimental
run: npm run test:webworker
- name: Report Coverage
working-directory: experimental
run: npm run codecov:webworker
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ If you are a library author looking to build OpenTelemetry into your library, pl
### Node Support

Automated tests are run using the latest release of each currently active version of Node.JS.
While Node.JS v8 is no longer supported by the Node.JS team, the latest version of Node.JS v8 is still included in our testing suite.
While Node.JS v8 and v10 are no longer supported by the Node.JS team, the latest versions of Node.JS v8 and v10 are still included in our testing suite.
Please note that versions of Node.JS v8 prior to `v8.5.0` will NOT work, because OpenTelemetry Node depends on the `perf_hooks` module introduced in `v8.5.0`

### Browser Support
Expand Down
21 changes: 21 additions & 0 deletions doc/web-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Web API Usages Guidance

The packages of OpenTelemetry that targeting web platforms should be compatible
with the following web environments:

- [Browsing Context](https://developer.mozilla.org/en-US/docs/Glossary/Browsing_context),
- [Web Worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Functions_and_classes_available_to_workers).

As such, the usage of Web API that depends on APIs like [`window`],
[`document`] and [`navigator`] is discouraged.

If the use of the browsing context API is necessary, like adding `onload`
listeners, an alternative code path for Web Worker environment should also be
supported.

It is an exception to above guidance if the package is instrumenting the
browsing context only.

[`window`]: https://developer.mozilla.org/en-US/docs/Web/API/window
[`document`]: https://developer.mozilla.org/en-US/docs/Web/API/Document
[`navigator]: https://developer.mozilla.org/en-US/docs/Web/API/Navigator
13 changes: 9 additions & 4 deletions examples/basic-tracer-node/docker/ot/collector-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,24 @@ receivers:
protocols:
grpc:
http:
cors_allowed_origins:
- http://*
- https://*
cors:
allowed_origins:
- http://*
- https://*

exporters:
jaeger:
endpoint: jaeger-all-in-one:14250
insecure: true
tls:
insecure: true

processors:
batch:

service:
telemetry:
logs:
level: "debug"
pipelines:
traces:
receivers: [otlp]
Expand Down
8 changes: 4 additions & 4 deletions examples/basic-tracer-node/docker/ot/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ services:

# Collector
otel-collector:
image: otel/opentelemetry-collector:0.27.0
command: ["--config=/conf/collector-config.yaml", "--log-level=DEBUG"]
image: otel/opentelemetry-collector-contrib:0.42.0
command: ["--config=/conf/collector-config.yaml"]
volumes:
- ./collector-config.yaml:/conf/collector-config.yaml
ports:
- "9464:9464"
- "4317:4317"
- "55681:55681"
- "4318:4318"
depends_on:
- jaeger-all-in-one

# Jaeger
jaeger-all-in-one:
image: jaegertracing/all-in-one:1.22.0
image: jaegertracing/all-in-one:1.30.0
ports:
- "16686:16686"
- "14268:14268"
Expand Down
10 changes: 7 additions & 3 deletions examples/otlp-exporter-node/docker/collector-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ receivers:
protocols:
grpc:
http:
cors_allowed_origins:
- http://*
- https://*
cors:
allowed_origins:
- http://*
- https://*

exporters:
zipkin:
Expand All @@ -17,6 +18,9 @@ processors:
batch:

service:
telemetry:
logs:
level: "debug"
pipelines:
traces:
receivers: [otlp]
Expand Down
8 changes: 4 additions & 4 deletions examples/otlp-exporter-node/docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ version: "3"
services:
# Collector
collector:
image: otel/opentelemetry-collector:0.25.0
# image: otel/opentelemetry-collector:latest
command: ["--config=/conf/collector-config.yaml", "--log-level=DEBUG"]
image: otel/opentelemetry-collector-contrib:0.42.0
# image: otel/opentelemetry-collector-contrib:latest
command: ["--config=/conf/collector-config.yaml"]
volumes:
- ./collector-config.yaml:/conf/collector-config.yaml
ports:
- "9464:9464"
- "4317:4317"
- "55681:55681"
- "4318:4318"
depends_on:
- zipkin-all-in-one

Expand Down
4 changes: 2 additions & 2 deletions examples/otlp-exporter-node/metrics.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const { DiagConsoleLogger, DiagLogLevel, diag } = require('@opentelemetry/api');
const { OTLPMetricExporter } = require('@opentelemetry/exporter-otlp-http');
const { OTLPMetricExporter } = require('@opentelemetry/exporter-metrics-otlp-http');
// const { OTLPMetricExporter } = require('@opentelemetry/exporter-otlp-grpc');
// const { OTLPMetricExporter } = require('@opentelemetry/exporter-otlp-proto');
const { MeterProvider } = require('@opentelemetry/sdk-metrics-base');
Expand All @@ -12,7 +12,7 @@ const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventi
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);

const metricExporter = new OTLPMetricExporter({
// url: 'http://localhost:55681/v1/metrics',
url: 'http://localhost:4318/v1/metrics',
});

const meter = new MeterProvider({
Expand Down
21 changes: 12 additions & 9 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.25.0",
"version": "0.27.0",
"description": "Example of using @opentelemetry/collector-exporter in Node.js",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -29,14 +29,17 @@
},
"dependencies": {
"@opentelemetry/api": "^1.0.2",
"@opentelemetry/core": "0.25.0",
"@opentelemetry/exporter-otlp-http": "0.25.0",
"@opentelemetry/exporter-otlp-grpc": "0.25.0",
"@opentelemetry/exporter-otlp-proto": "0.25.0",
"@opentelemetry/resources": "0.25.0",
"@opentelemetry/semantic-conventions": "0.25.0",
"@opentelemetry/sdk-metrics-base": "0.25.0",
"@opentelemetry/sdk-trace-base": "0.25.0"
"@opentelemetry/core": "1.0.1",
"@opentelemetry/exporter-trace-otlp-http": "0.27.0",
"@opentelemetry/exporter-metrics-otlp-http": "0.27.0",
"@opentelemetry/exporter-trace-otlp-grpc": "0.27.0",
"@opentelemetry/exporter-metrics-otlp-grpc": "0.27.0",
"@opentelemetry/exporter-trace-otlp-proto": "0.27.0",
"@opentelemetry/exporter-metrics-otlp-proto": "0.27.0",
"@opentelemetry/resources": "1.0.1",
"@opentelemetry/semantic-conventions": "1.0.1",
"@opentelemetry/sdk-metrics-base": "0.27.0",
"@opentelemetry/sdk-trace-base": "1.0.1"
},
"homepage": "https:/open-telemetry/opentelemetry-js#readme"
}
2 changes: 1 addition & 1 deletion examples/otlp-exporter-node/tracing.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const opentelemetry = require('@opentelemetry/api');
const { BasicTracerProvider, ConsoleSpanExporter, SimpleSpanProcessor } = require('@opentelemetry/sdk-trace-base');
const { OTLPTraceExporter } = require('@opentelemetry/exporter-otlp-http');
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-http');
const { Resource } = require('@opentelemetry/resources');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
// const { OTLPTraceExporter } = require('@opentelemetry/exporter-otlp-grpc');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,13 @@ import { Attributes } from './Metric';
* Interface that is being used in callback function for Observable Metric
*/
export interface ObservableResult {
/**
* Observe a measurement of the value associated with the given attributes.
*
* @param value The value to be observed.
* @param attributes The attributes associated with the value. If more than
* one values associated with the same attributes values, SDK may pick the
* last one or simply drop the entire observable result.
*/
observe(value: number, attributes?: Attributes): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The OTLPMetricExporter in Web expects the endpoint to end in `/v1/metrics`.
import { MeterProvider } from '@opentelemetry/sdk-metrics-base';
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http';
const collectorOptions = {
url: '<opentelemetry-collector-url>', // url is optional and can be omitted - default is http://localhost:55681/v1/metrics
url: '<opentelemetry-collector-url>', // url is optional and can be omitted - default is http://localhost:4318/v1/metrics
headers: {}, // an optional object containing custom headers to be sent with each request
concurrencyLimit: 1, // an optional limit on pending requests
};
Expand All @@ -49,7 +49,7 @@ counter.add(10, { 'key': 'value' });
const { MeterProvider } = require('@opentelemetry/sdk-metrics-base');
const { OTLPMetricExporter } = require('@opentelemetry/exporter-metrics-otlp-http');
const collectorOptions = {
url: '<opentelemetry-collector-url>', // url is optional and can be omitted - default is http://localhost:55681/v1/metrics
url: '<opentelemetry-collector-url>', // url is optional and can be omitted - default is http://localhost:4318/v1/metrics
concurrencyLimit: 1, // an optional limit on pending requests
};
const exporter = new OTLPMetricExporter(collectorOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { toOTLPExportMetricServiceRequest } from '../../transformMetrics';
import { getEnv, baggageUtils } from '@opentelemetry/core';

const DEFAULT_COLLECTOR_RESOURCE_PATH = '/v1/metrics';
const DEFAULT_COLLECTOR_URL=`http://localhost:55681${DEFAULT_COLLECTOR_RESOURCE_PATH}`;
const DEFAULT_COLLECTOR_URL=`http://localhost:4318${DEFAULT_COLLECTOR_RESOURCE_PATH}`;

/**
* Collector Metric Exporter for Web
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { toOTLPExportMetricServiceRequest } from '../../transformMetrics';
import { getEnv, baggageUtils } from '@opentelemetry/core';

const DEFAULT_COLLECTOR_RESOURCE_PATH = '/v1/metrics';
const DEFAULT_COLLECTOR_URL=`http://localhost:55681${DEFAULT_COLLECTOR_RESOURCE_PATH}`;
const DEFAULT_COLLECTOR_URL=`http://localhost:4318${DEFAULT_COLLECTOR_RESOURCE_PATH}`;

/**
* Collector Metric Exporter for Node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ describe('OTLPMetricExporter - node with json over http', () => {
setTimeout(() => {
assert.strictEqual(
collectorExporter['url'],
'http://localhost:55681/v1/metrics'
'http://localhost:4318/v1/metrics'
);
done();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ To see sample code and documentation for the traces exporter, visit the [Collect
const { MeterProvider } = require('@opentelemetry/sdk-metrics-base');
const { OTLPMetricExporter } = require('@opentelemetry/exporter-metrics-otlp-proto');
const collectorOptions = {
url: '<opentelemetry-collector-url>', // url is optional and can be omitted - default is http://localhost:55681/v1/metrics
url: '<opentelemetry-collector-url>', // url is optional and can be omitted - default is http://localhost:4318/v1/metrics
};
const exporter = new OTLPMetricExporter(collectorOptions);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { ServiceClientType, OTLPExporterNodeBase } from '@opentelemetry/exporter
import { getEnv, baggageUtils } from '@opentelemetry/core';

const DEFAULT_COLLECTOR_RESOURCE_PATH = '/v1/metrics';
const DEFAULT_COLLECTOR_URL=`http://localhost:55681${DEFAULT_COLLECTOR_RESOURCE_PATH}`;
const DEFAULT_COLLECTOR_URL=`http://localhost:4318${DEFAULT_COLLECTOR_RESOURCE_PATH}`;

/**
* OTLP Metric Exporter for Node with protobuf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,20 @@ Http instrumentation has few options available to choose from. You can set the f
| [`responseHook`](https:/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-http/src/types.ts#L95) | `HttpResponseCustomAttributeFunction` | Function for adding custom attributes before response is handled |
| [`startIncomingSpanHook`](https:/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-http/src/types.ts#L97) | `StartIncomingSpanCustomAttributeFunction` | Function for adding custom attributes before a span is started in incomingRequest |
| [`startOutgoingSpanHook`](https:/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-http/src/types.ts#L99) | `StartOutgoingSpanCustomAttributeFunction` | Function for adding custom attributes before a span is started in outgoingRequest |
| [`ignoreIncomingPaths`](https:/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-http/src/types.ts#L87) | `IgnoreMatcher[]` | Http instrumentation will not trace all incoming requests that match paths |
| [`ignoreOutgoingUrls`](https:/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-http/src/types.ts#L89) | `IgnoreMatcher[]` | Http instrumentation will not trace all outgoing requests that match urls |
| `ignoreIncomingRequestHook` | `IgnoreIncomingRequestFunction` | Http instrumentation will not trace all incoming requests that matched with custom function |
| `ignoreOutgoingRequestHook` | `IgnoreOutgoingRequestFunction` | Http instrumentation will not trace all outgoing requests that matched with custom function |
| [`serverName`](https:/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-http/src/types.ts#L101) | `string` | The primary server name of the matched virtual host. |
| [`requireParentforOutgoingSpans`](https:/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-http/src/types.ts#L103) | Boolean | Require that is a parent span to create new span for outgoing requests. |
| [`requireParentforIncomingSpans`](https:/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-http/src/types.ts#L105) | Boolean | Require that is a parent span to create new span for incoming requests. |
| [`headersToSpanAttributes`](https:/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-http/src/types.ts#L107) | `object` | List of case insensitive HTTP headers to convert to span attributes. Client (outgoing requests, incoming responses) and server (incoming requests, outgoing responses) headers will be converted to span attributes in the form of `http.{request\|response}.header.header_name`, e.g. `http.response.header.content_length` |

The following options are deprecated:

| Options | Type | Description |
| ------- | ---- | ----------- |
| `ignoreIncomingPaths` | `IgnoreMatcher[]` | Http instrumentation will not trace all incoming requests that match paths |
| `ignoreOutgoingUrls` | `IgnoreMatcher[]` | Http instrumentation will not trace all outgoing requests that match urls |

## Useful links

- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
Expand Down
Loading

0 comments on commit b7bbe21

Please sign in to comment.