Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into metrics-ff/meter-sh…
Browse files Browse the repository at this point in the history
…ared-state

# Conflicts:
#	experimental/CHANGELOG.md
  • Loading branch information
legendecas committed Apr 8, 2022
2 parents cf796dd + 0213d82 commit 1aa3f98
Show file tree
Hide file tree
Showing 91 changed files with 1,474 additions and 1,416 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/peer-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Install lerna
run: npm install -g lerna

- name: Install semver
- name: Install semver
run: npm install semver

- name: Check API dependency semantics (stable)
Expand All @@ -27,4 +27,4 @@ jobs:

- name: Check API dependency semantics (experimental)
working-directory: experimental
run: lerna exec --ignore propagation-validation-server --ignore @opentelemetry/selenium-tests --ignore @opentelemetry/api-metrics-wip --ignore @opentelemetry/otlp-transformer "node ../../../scripts/peer-api-check.js"
run: lerna exec --ignore propagation-validation-server --ignore @opentelemetry/selenium-tests --ignore @opentelemetry/api-metrics --ignore @opentelemetry/otlp-transformer "node ../../../scripts/peer-api-check.js"
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[submodule "packages/exporter-trace-otlp-proto/protos"]
[submodule "experimental/packages/exporter-trace-otlp-proto/protos"]
path = experimental/packages/exporter-trace-otlp-proto/protos
url = https://github.com/open-telemetry/opentelemetry-proto.git
[submodule "packages/exporter-trace-otlp-grpc/protos"]
[submodule "experimental/packages/exporter-trace-otlp-grpc/protos"]
path = experimental/packages/exporter-trace-otlp-grpc/protos
url = https://github.com/open-telemetry/opentelemetry-proto.git
[submodule "experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/protos"]
Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ All notable changes to this project will be documented in this file.

### :books: (Refine Doc)

* [#2860](https://github.com/open-telemetry/opentelemetry-js/pull/2860) docs(sdk): update earliest support node version ([@svetlanabrennan](https://github.com/svetlanabrennan))
* docs(sdk): update earliest support node version #2860 @svetlanabrennan

### :house: (Internal)

* [#2847](https://github.com/open-telemetry/opentelemetry-js/pull/2847) chore: require changelog entry to merge PR ([@dyladan](https://github.com/dyladan))
* chore: require changelog entry to merge PR #2847 @dyladan

## 1.1.1

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ If the change affects the overall project and not any individual package, it sho
Changelog entries should be in the following format:

```md
* [#{pull request number}](https://github.com/open-telemetry/opentelemetry-js/pull/{pull request number}) feat(subject): pull request title here ([@author](https://github.com/author))
* feat(subject): pull request title here #{pull request number} @{author github handle}
```

Subject should describe the area of the project that was changed as descriptively as is possible in a short space.
Expand Down
62 changes: 35 additions & 27 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,53 @@ All notable changes to experimental packages in this project will be documented

### :boom: Breaking Change

* [#2707](https://github.com/open-telemetry/opentelemetry-js/pull/2707) feat(sdk-metrics-base): update metric exporter interfaces ([@srikanthccv](https://github.com/srikanthccv))
* [#2687](https://github.com/open-telemetry/opentelemetry-js/pull/2687) feat(api-metrics): remove observable types ([@legendecas](https://github.com/legendecas))
* feat(sdk-metrics-base): update metric exporter interfaces #2707 @srikanthccv
* feat(api-metrics): remove observable types #2687 @legendecas
* fix(otlp-http-exporter): remove content length header #2879 @svetlanabrennan
* feat(experimental-packages): Update packages to latest SDK Version. #2871 @pichlermarc
* removed the -wip suffix from api-metrics and metrics-sdk-base.
* updated dependencies to stable packages to `1.1.1` for all "experimental" packages.
* updated Metrics Exporters to the latest Metrics SDK (`exporter-metrics-otlp-grpc`, `exporter-metrics-otlp-http`, `exporter-metrics-otlp-proto`)
* updated `opentelemetry-sdk-node` to the latest Metrics SDK.
* updated `otlp-transformer` to the latest Metrics SDK.
* updated all `instrumentation-*` packages to use local implementations of `parseUrl()` due to #2884

### :rocket: (Enhancement)

* [#2588](https://github.com/open-telemetry/opentelemetry-js/pull/2588) feat: spec compliant metric creation and sync instruments ([@dyladan](https://github.com/dyladan))
* [#2569](https://github.com/open-telemetry/opentelemetry-js/pull/2569) feat(api-metrics): async instruments spec compliance ([@legendecas](https://github.com/legendecas))
* [#2776](https://github.com/open-telemetry/opentelemetry-js/pull/2776) feat(sdk-metrics-base): add ValueType support for sync instruments ([@legendecas](https://github.com/legendecas))
* [#2686](https://github.com/open-telemetry/opentelemetry-js/pull/2686) feat(sdk-metrics-base): implement async instruments support ([@legendecas](https://github.com/legendecas))
* [#2666](https://github.com/open-telemetry/opentelemetry-js/pull/2666) feat(sdk-metrics-base): meter registration ([@legendecas](https://github.com/legendecas))
* [#2641](https://github.com/open-telemetry/opentelemetry-js/pull/2641) feat(sdk-metrics-base): bootstrap metrics exemplars ([@srikanthccv](https://github.com/srikanthccv))
* [#2634](https://github.com/open-telemetry/opentelemetry-js/pull/2634) feat(metrics-sdk): bootstrap aggregation support ([@legendecas](https://github.com/legendecas))
* [#2625](https://github.com/open-telemetry/opentelemetry-js/pull/2625) feat(metrics-sdk): bootstrap views api ([@legendecas](https://github.com/legendecas))
* [#2636](https://github.com/open-telemetry/opentelemetry-js/pull/2636) feat(sdk-metrics): bootstrap metric streams ([@legendecas](https://github.com/legendecas))
* [#2733](https://github.com/open-telemetry/opentelemetry-js/pull/2733) feat(views): add FilteringAttributesProcessor ([@pichlermarc](https://github.com/pichlermarc))
* [#2681](https://github.com/open-telemetry/opentelemetry-js/pull/2681) feat(metric-reader): add metric-reader ([@pichlermarc](https://github.com/pichlermarc))
* [#2725](https://github.com/open-telemetry/opentelemetry-js/pull/2725) feat(sdk-metrics-base): document and export basic APIs ([@legendecas](https://github.com/legendecas))
* [#2820](https://github.com/open-telemetry/opentelemetry-js/pull/2820) feat(views): Update addView() to disallow named views that select more than one instrument. ([@pichlermarc](https://github.com/pichlermarc))
* [#2829](https://github.com/open-telemetry/opentelemetry-js/pull/2829) feat(sdk-metrics-base): update exporting names ([@legendecas](https://github.com/legendecas))
* [#2813](https://github.com/open-telemetry/opentelemetry-js/pull/2813) Add grpc compression to trace-otlp-grpc exporter ([@svetlanabrennan](https://github.com/svetlanabrennan))
* [#2695](https://github.com/open-telemetry/opentelemetry-js/pull/2695) refactor: unifying shutdown once with BindOnceFuture ([@legendecas](https://github.com/legendecas))
* [#2824](https://github.com/open-telemetry/opentelemetry-js/pull/2824) feat(prometheus): update prometheus exporter with wip metrics sdk ([@legendecas](https://github.com/legendecas))
* [#2134](https://github.com/open-telemetry/opentelemetry-js/pull/2134) feat(instrumentation-xhr): add applyCustomAttributesOnSpan hook ([@mhennoch](https://github.com/mhennoch))
* [#2746](https://github.com/open-telemetry/opentelemetry-js/pull/2746) feat(proto): add @opentelemetry/otlp-transformer package with hand-rolled transformation ([@dyladan](https://github.com/dyladan))
* feat: spec compliant metric creation and sync instruments #2588 @dyladan
* feat(api-metrics): async instruments spec compliance #2569 @legendecas
* feat(sdk-metrics-base): add ValueType support for sync instruments #2776 @legendecas
* feat(sdk-metrics-base): implement async instruments support #2686 @legendecas
* feat(sdk-metrics-base): meter registration #2666 @legendecas
* feat(sdk-metrics-base): bootstrap metrics exemplars #2641 @srikanthccv
* feat(metrics-sdk): bootstrap aggregation support #2634 @legendecas
* feat(metrics-sdk): bootstrap views api #2625 @legendecas
* feat(sdk-metrics): bootstrap metric streams #2636 @legendecas
* feat(views): add FilteringAttributesProcessor #2733 @pichlermarc
* feat(metric-reader): add metric-reader #2681 @pichlermarc
* feat(sdk-metrics-base): document and export basic APIs #2725 @legendecas
* feat(views): Update addView() to disallow named views that select more than one instrument. #2820 @pichlermarc
* feat(sdk-metrics-base): update exporting names #2829 @legendecas
* Add grpc compression to trace-otlp-grpc exporter #2813 @svetlanabrennan
* refactor: unifying shutdown once with BindOnceFuture #2695 @legendecas
* feat(prometheus): update prometheus exporter with wip metrics sdk #2824 @legendecas
* feat(instrumentation-xhr): add applyCustomAttributesOnSpan hook #2134 @mhennoch
* feat(proto): add @opentelemetry/otlp-transformer package with hand-rolled transformation #2746 @dyladan

### :bug: (Bug Fix)

* [#2676](https://github.com/open-telemetry/opentelemetry-js/pull/2676) fix(sdk-metrics-base): remove aggregator.toMetricData dependency on AggregationTemporality ([@legendecas](https://github.com/legendecas))
* [#2859](https://github.com/open-telemetry/opentelemetry-js/pull/2859) fix(sdk-metrics-base): coerce histogram boundaries to be implicit Infinity ([@legendecas](https://github.com/legendecas))
* [#2789](https://github.com/open-telemetry/opentelemetry-js/pull/2789) fix(instrumentation-http): HTTP 400 status code should not set span status to error on servers ([@nordfjord](https://github.com/nordfjord))
* fix(sdk-metrics-base): remove aggregator.toMetricData dependency on AggregationTemporality #2676 @legendecas
* fix(sdk-metrics-base): coerce histogram boundaries to be implicit Infinity #2859 @legendecas
* fix(instrumentation-http): HTTP 400 status code should not set span status to error on servers #2789 @nordfjord

### :books: (Refine Doc)

* [#2658](https://github.com/open-telemetry/opentelemetry-js/pull/2658) Update metrics example ([@svetlanabrennan](https://github.com/svetlanabrennan))
* [#2712](https://github.com/open-telemetry/opentelemetry-js/pull/2712) docs(api-metrics): add notes on ObservableResult.observe ([@legendecas](https://github.com/legendecas))
* Update metrics example #2658 @svetlanabrennan
* docs(api-metrics): add notes on ObservableResult.observe #2712 @legendecas

### :house: (Internal)

* [#2835](https://github.com/open-telemetry/opentelemetry-js/pull/2835) chore: move trace exporters back to experimental ([@dyladan](https://github.com/dyladan))
* chore: move trace exporters back to experimental #2835 @dyladan
* refactor(sdk-metrics-base): meter shared states #2821 @legendecas

## v0.27.0
Expand Down
2 changes: 1 addition & 1 deletion experimental/backwards-compatability/node10/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"dependencies": {
"@opentelemetry/sdk-node": "0.27.0",
"@opentelemetry/sdk-trace-base": "1.0.1"
"@opentelemetry/sdk-trace-base": "1.1.1"
},
"devDependencies": {
"@types/node": "10.17.60",
Expand Down
2 changes: 1 addition & 1 deletion experimental/backwards-compatability/node12/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"dependencies": {
"@opentelemetry/sdk-node": "0.27.0",
"@opentelemetry/sdk-trace-base": "1.0.1"
"@opentelemetry/sdk-trace-base": "1.1.1"
},
"devDependencies": {
"@types/node": "12.20.37",
Expand Down
2 changes: 1 addition & 1 deletion experimental/backwards-compatability/node8/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"dependencies": {
"@opentelemetry/sdk-node": "0.27.0",
"@opentelemetry/sdk-trace-base": "1.0.1"
"@opentelemetry/sdk-trace-base": "1.1.1"
},
"devDependencies": {
"@types/node": "8.10.66",
Expand Down
4 changes: 2 additions & 2 deletions experimental/packages/exporter-trace-otlp-grpc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
},
"devDependencies": {
"@babel/core": "7.16.0",
"@opentelemetry/api": "^1.0.3",
"@opentelemetry/api": "^1.1.0",
"@types/mocha": "8.2.3",
"@types/node": "14.17.33",
"@types/sinon": "10.0.6",
Expand All @@ -64,7 +64,7 @@
"typescript": "4.4.4"
},
"peerDependencies": {
"@opentelemetry/api": "^1.0.3"
"@opentelemetry/api": "^1.1.0"
},
"dependencies": {
"@opentelemetry/core": "1.1.1",
Expand Down
4 changes: 2 additions & 2 deletions experimental/packages/exporter-trace-otlp-http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
},
"devDependencies": {
"@babel/core": "7.16.0",
"@opentelemetry/api": "^1.0.3",
"@opentelemetry/api": "^1.1.0",
"@types/mocha": "8.2.3",
"@types/node": "14.17.33",
"@types/sinon": "10.0.6",
Expand All @@ -89,7 +89,7 @@
"webpack-merge": "5.8.0"
},
"peerDependencies": {
"@opentelemetry/api": "^1.0.3"
"@opentelemetry/api": "^1.1.0"
},
"dependencies": {
"@opentelemetry/core": "1.1.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export function sendWithHttp<ExportItem, ServiceRequest>(
path: parsedUrl.pathname,
method: 'POST',
headers: {
'Content-Length': Buffer.byteLength(data),
'Content-Type': contentType,
...collector.headers,
},
Expand Down Expand Up @@ -96,9 +95,7 @@ export function sendWithHttp<ExportItem, ServiceRequest>(
break;
}
default:
req.write(data);
req.end();

req.end(data);
break;
}
}
Expand Down
4 changes: 2 additions & 2 deletions experimental/packages/exporter-trace-otlp-proto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
},
"devDependencies": {
"@babel/core": "7.16.0",
"@opentelemetry/api": "^1.0.3",
"@opentelemetry/api": "^1.1.0",
"@types/mocha": "8.2.3",
"@types/node": "14.17.33",
"@types/sinon": "10.0.6",
Expand All @@ -64,7 +64,7 @@
"typescript": "4.4.4"
},
"peerDependencies": {
"@opentelemetry/api": "^1.0.3"
"@opentelemetry/api": "^1.1.0"
},
"dependencies": {
"@opentelemetry/core": "1.1.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@opentelemetry/api-metrics-wip",
"name": "@opentelemetry/api-metrics",
"version": "0.27.0",
"private": true,
"description": "Public metrics API for OpenTelemetry",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@
"typescript": "4.4.4"
},
"peerDependencies": {
"@opentelemetry/api": "^1.0.3"
"@opentelemetry/api": "^1.1.0"
},
"dependencies": {
"@grpc/grpc-js": "^1.5.9",
"@grpc/proto-loader": "^0.6.9",
"@opentelemetry/core": "1.0.1",
"@opentelemetry/core": "1.1.1",
"@opentelemetry/exporter-metrics-otlp-http": "0.27.0",
"@opentelemetry/exporter-trace-otlp-grpc": "0.27.0",
"@opentelemetry/exporter-trace-otlp-http": "0.27.0",
"@opentelemetry/resources": "1.0.1",
"@opentelemetry/resources": "1.1.1",
"@opentelemetry/sdk-metrics-base": "0.27.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@
*/

import { otlpTypes } from '@opentelemetry/exporter-trace-otlp-http';
import { toOTLPExportMetricServiceRequest } from '@opentelemetry/exporter-metrics-otlp-http';
import { MetricRecord, MetricExporter } from '@opentelemetry/sdk-metrics-base';
import {
defaultExporterTemporality,
defaultOptions,
OTLPMetricExporterBase, OTLPMetricExporterOptions,
toOTLPExportMetricServiceRequest
} from '@opentelemetry/exporter-metrics-otlp-http';
import { AggregationTemporality, ResourceMetrics } from '@opentelemetry/sdk-metrics-base';
import {
OTLPExporterConfigNode,
OTLPExporterNodeBase,
Expand All @@ -28,52 +33,53 @@ import { Metadata } from '@grpc/grpc-js';

const DEFAULT_COLLECTOR_URL = 'localhost:4317';

/**
* OTLP Metric Exporter for Node
*/
export class OTLPMetricExporter
extends OTLPExporterNodeBase<
MetricRecord,
otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest
>
implements MetricExporter {
// Converts time to nanoseconds
protected readonly _startTime = new Date().getTime() * 1000000;

constructor(config: OTLPExporterConfigNode = {}) {
class OTLPMetricExporterProxy extends OTLPExporterNodeBase<ResourceMetrics,
otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest> {
protected readonly _aggregationTemporality: AggregationTemporality;

constructor(config: OTLPExporterConfigNode & OTLPMetricExporterOptions= defaultOptions) {
super(config);
const headers = baggageUtils.parseKeyPairsIntoRecord(getEnv().OTEL_EXPORTER_OTLP_METRICS_HEADERS);
this.metadata ||= new Metadata();
const headers = baggageUtils.parseKeyPairsIntoRecord(getEnv().OTEL_EXPORTER_OTLP_METRICS_HEADERS);
for (const [k, v] of Object.entries(headers)) {
this.metadata.set(k, v);
}
this._aggregationTemporality = config.aggregationTemporality ?? defaultExporterTemporality;
}

convert(
metrics: MetricRecord[]
): otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest {
return toOTLPExportMetricServiceRequest(
metrics,
this._startTime,
this
);
getServiceProtoPath(): string {
return 'opentelemetry/proto/collector/metrics/v1/metrics_service.proto';
}

getServiceClientType(): ServiceClientType {
return ServiceClientType.METRICS;
}

getDefaultUrl(config: OTLPExporterConfigNode): string {
return typeof config.url === 'string'
? validateAndNormalizeUrl(config.url)
: getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT.length > 0
? validateAndNormalizeUrl(getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT)
: getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0
? validateAndNormalizeUrl(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT)
: DEFAULT_COLLECTOR_URL;
? validateAndNormalizeUrl(getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT)
: getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0
? validateAndNormalizeUrl(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT)
: DEFAULT_COLLECTOR_URL;
}

getServiceClientType(): ServiceClientType {
return ServiceClientType.METRICS;
convert(metrics: ResourceMetrics[]): otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest {
return toOTLPExportMetricServiceRequest(
metrics[0],
this._aggregationTemporality,
this
);
}
}

getServiceProtoPath(): string {
return 'opentelemetry/proto/collector/metrics/v1/metrics_service.proto';
/**
* OTLP-gRPC metric exporter
*/
export class OTLPMetricExporter extends OTLPMetricExporterBase<OTLPMetricExporterProxy>{
constructor(config: OTLPExporterConfigNode & OTLPMetricExporterOptions = defaultOptions) {
super(new OTLPMetricExporterProxy(config), config);
}
}
Loading

0 comments on commit 1aa3f98

Please sign in to comment.