Skip to content

Commit

Permalink
Merge branch 'main' into fix/4130
Browse files Browse the repository at this point in the history
  • Loading branch information
pichlermarc authored Sep 15, 2023
2 parents e7dd685 + 30d1fca commit 3621750
Show file tree
Hide file tree
Showing 41 changed files with 818 additions and 46 deletions.
34 changes: 21 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,19 +141,27 @@ There may also be API packages for experimental signals in the experimental dire
All stable packages are released with the same version, and all experimental packages are released with the same version.
The below table describes which versions of each set of packages are expected to work together.

| API | Stable Packages | Experimental Packages |
| ----- | --------------- | --------------------- |
| 1.3.x | 1.9.x | 0.35.x |
| 1.3.x | 1.8.x | 0.34.x |
| 1.2.x | 1.7.x | 0.33.x |
| 1.2.x | 1.6.x | 0.32.x |
| 1.1.x | 1.5.x | 0.31.x |
| 1.1.x | 1.4.x | 0.30.x |
| 1.1.x | 1.3.x | 0.29.x |
| 1.1.x | 1.2.x | 0.29.x |
| 1.1.x | 1.1.x | 0.28.x |
| 1.0.x | 1.0.x | 0.27.x |
| 1.0.x | 1.0.x | 0.26.x |
| Stable Packages | Experimental Packages |
|-----------------------------------------------------------------|-----------------------|
| 1.17.x | 0.43.x |
| 1.16.x | 0.42.x |
| 1.15.x | 0.41.x |
| 1.14.x | 0.40.x |
| 1.13.x | 0.39.x |
| 1.12.x | 0.38.x |
| 1.11.x | 0.37.x |
| 1.10.x | 0.36.x |
| 1.9.x | 0.35.x |
| 1.8.x (this and later versions require API >=1.3.0 for metrics) | 0.34.x |
| 1.7.x | 0.33.x |
| 1.6.x | 0.32.x |
| 1.5.x | 0.31.x |
| 1.4.x | 0.30.x |
| 1.3.x | 0.29.x |
| 1.2.x | 0.29.x |
| 1.1.x | 0.28.x |
| 1.0.x | 0.27.x |
| 1.0.x (this and later versions require API >=1.0.0 for traces) | 0.26.x |

## Versioning

Expand Down
1 change: 1 addition & 0 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ All notable changes to experimental packages in this project will be documented
### :rocket: (Enhancement)

* feat: update PeriodicExportingMetricReader and PrometheusExporter to accept optional metric producers [#4077](https://github.com/open-telemetry/opentelemetry-js/pull/4077) @aabmass
* feat(opencensus-shim): implement OpenCensus metric producer [#4066](https://github.com/open-telemetry/opentelemetry-js/pull/4066) @aabmass

### :bug: (Bug Fix)

Expand Down
2 changes: 1 addition & 1 deletion experimental/packages/exporter-logs-otlp-grpc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"access": "public"
},
"devDependencies": {
"@babel/core": "7.22.17",
"@babel/core": "7.22.19",
"@grpc/proto-loader": "^0.7.3",
"@opentelemetry/api": "1.6.0",
"@opentelemetry/api-logs": "0.43.0",
Expand Down
2 changes: 1 addition & 1 deletion experimental/packages/exporter-logs-otlp-http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
],
"sideEffects": false,
"devDependencies": {
"@babel/core": "7.22.17",
"@babel/core": "7.22.19",
"@opentelemetry/api": "1.6.0",
"@opentelemetry/resources": "1.17.0",
"@types/mocha": "10.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"access": "public"
},
"devDependencies": {
"@babel/core": "7.22.17",
"@babel/core": "7.22.19",
"@opentelemetry/api": "1.6.0",
"@types/mocha": "10.0.1",
"@types/node": "18.6.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"access": "public"
},
"devDependencies": {
"@babel/core": "7.22.17",
"@babel/core": "7.22.19",
"@grpc/proto-loader": "^0.7.3",
"@opentelemetry/api": "1.6.0",
"@opentelemetry/otlp-exporter-base": "0.43.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"access": "public"
},
"devDependencies": {
"@babel/core": "7.22.17",
"@babel/core": "7.22.19",
"@opentelemetry/api": "1.6.0",
"@types/mocha": "10.0.1",
"@types/node": "18.6.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"access": "public"
},
"devDependencies": {
"@babel/core": "7.22.17",
"@babel/core": "7.22.19",
"@opentelemetry/api": "1.6.0",
"@types/mocha": "10.0.1",
"@types/node": "18.6.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"access": "public"
},
"devDependencies": {
"@babel/core": "7.22.17",
"@babel/core": "7.22.19",
"@opentelemetry/api": "1.6.0",
"@types/mocha": "10.0.1",
"@types/node": "18.6.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"access": "public"
},
"devDependencies": {
"@babel/core": "7.22.17",
"@babel/core": "7.22.19",
"@grpc/proto-loader": "^0.7.3",
"@opentelemetry/api": "1.6.0",
"@types/mocha": "10.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"access": "public"
},
"devDependencies": {
"@babel/core": "7.22.17",
"@babel/core": "7.22.19",
"@opentelemetry/api": "1.6.0",
"@types/mocha": "10.0.1",
"@types/node": "18.6.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"access": "public"
},
"devDependencies": {
"@babel/core": "7.22.17",
"@babel/core": "7.22.19",
"@opentelemetry/api": "1.6.0",
"@types/mocha": "10.0.1",
"@types/node": "18.6.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"access": "public"
},
"devDependencies": {
"@babel/core": "7.22.17",
"@babel/core": "7.22.19",
"@opentelemetry/api": "1.6.0",
"@opentelemetry/context-zone": "1.17.0",
"@opentelemetry/propagator-b3": "1.17.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"@protobuf-ts/runtime-rpc": "2.9.1",
"@types/mocha": "10.0.1",
"@types/node": "18.6.5",
"@types/semver": "7.5.1",
"@types/semver": "7.5.2",
"@types/sinon": "10.0.16",
"codecov": "3.8.3",
"cross-var": "1.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@types/mocha": "10.0.1",
"@types/node": "18.6.5",
"@types/request-promise-native": "1.0.18",
"@types/semver": "7.5.1",
"@types/semver": "7.5.2",
"@types/sinon": "10.0.16",
"@types/superagent": "4.1.18",
"axios": "1.5.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"access": "public"
},
"devDependencies": {
"@babel/core": "7.22.17",
"@babel/core": "7.22.19",
"@opentelemetry/api": "1.6.0",
"@opentelemetry/context-zone": "1.17.0",
"@opentelemetry/propagator-b3": "1.17.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@
"@opentelemetry/api": "^1.3.0"
},
"devDependencies": {
"@babel/core": "7.22.17",
"@babel/core": "7.22.19",
"@opentelemetry/api": "1.6.0",
"@opentelemetry/sdk-metrics": "1.17.0",
"@types/mocha": "10.0.1",
"@types/node": "18.6.5",
"@types/semver": "7.5.1",
"@types/semver": "7.5.2",
"@types/sinon": "10.0.16",
"@types/webpack-env": "1.16.3",
"babel-loader": "8.3.0",
Expand Down
2 changes: 1 addition & 1 deletion experimental/packages/opentelemetry-sdk-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"@opentelemetry/exporter-jaeger": "1.17.0",
"@types/mocha": "10.0.1",
"@types/node": "18.6.5",
"@types/semver": "7.5.1",
"@types/semver": "7.5.2",
"@types/sinon": "10.0.16",
"codecov": "3.8.3",
"cross-var": "1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion experimental/packages/otlp-exporter-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"@opentelemetry/core": "1.17.0"
},
"devDependencies": {
"@babel/core": "7.22.17",
"@babel/core": "7.22.19",
"@opentelemetry/api": "1.6.0",
"@types/mocha": "10.0.1",
"@types/node": "18.6.5",
Expand Down
2 changes: 1 addition & 1 deletion experimental/packages/otlp-grpc-exporter-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"access": "public"
},
"devDependencies": {
"@babel/core": "7.22.17",
"@babel/core": "7.22.19",
"@opentelemetry/api": "1.6.0",
"@opentelemetry/otlp-transformer": "0.43.0",
"@opentelemetry/resources": "1.17.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"access": "public"
},
"devDependencies": {
"@babel/core": "7.22.17",
"@babel/core": "7.22.19",
"@opentelemetry/api": "1.6.0",
"@types/mocha": "10.0.1",
"@types/node": "18.6.5",
Expand Down
2 changes: 1 addition & 1 deletion experimental/packages/sdk-logs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"@opentelemetry/api-logs": ">=0.39.1"
},
"devDependencies": {
"@babel/core": "7.22.17",
"@babel/core": "7.22.19",
"@opentelemetry/api": ">=1.4.0 <1.7.0",
"@opentelemetry/api-logs": "0.43.0",
"@types/mocha": "10.0.1",
Expand Down
2 changes: 2 additions & 0 deletions experimental/packages/shim-opencensus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
},
"dependencies": {
"@opentelemetry/core": "1.17.0",
"@opentelemetry/resources": "1.17.0",
"@opentelemetry/sdk-metrics": "1.17.0",
"require-in-the-middle": "^7.1.1",
"semver": "^7.5.2"
},
Expand Down
104 changes: 104 additions & 0 deletions experimental/packages/shim-opencensus/src/OpenCensusMetricProducer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* Copyright 2018, OpenCensus Authors
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import * as oc from '@opencensus/core';
import { Resource } from '@opentelemetry/resources';
import {
CollectionResult,
MetricData,
MetricProducer,
ScopeMetrics,
} from '@opentelemetry/sdk-metrics';
import { mapOcMetric } from './metric-transform';
import { VERSION } from './version';

const SCOPE = {
name: '@opentelemetry/shim-opencensus',
version: VERSION,
} as const;

interface OpenCensusMetricProducerOptions {
/**
* An instance of OpenCensus MetricProducerManager. If not provided,
* `oc.Metrics.getMetricProducerManager()` will be used.
*/
openCensusMetricProducerManager?: oc.MetricProducerManager;
}

/**
* A {@link MetricProducer} which collects metrics from OpenCensus. Provide an instance to your
* {@link MetricReader} when you create it to include all OpenCensus metrics in the collection
* result:
*
* @example
* ```
* const meterProvider = new MeterProvider();
* const reader = new PeriodicExportingMetricReader({
* metricProducers: [new OpenCensusMetricProducer()],
* exporter: exporter,
* });
* meterProvider.addMetricReader(reader);
* ```
*/
export class OpenCensusMetricProducer implements MetricProducer {
private _openCensusMetricProducerManager: oc.MetricProducerManager;

constructor(options?: OpenCensusMetricProducerOptions) {
this._openCensusMetricProducerManager =
options?.openCensusMetricProducerManager ??
oc.Metrics.getMetricProducerManager();
}

async collect(): Promise<CollectionResult> {
const metrics = await this._collectOpenCensus();
const scopeMetrics: ScopeMetrics[] =
metrics.length === 0
? []
: [
{
scope: SCOPE,
metrics,
},
];

return {
errors: [],
resourceMetrics: {
// Resource is ignored by the SDK, it just uses the SDK's resource
resource: Resource.EMPTY,
scopeMetrics,
},
};
}

private async _collectOpenCensus(): Promise<MetricData[]> {
const metrics: MetricData[] = [];

// The use of oc.Metrics.getMetricProducerManager() was adapted from
// https://github.com/census-instrumentation/opencensus-node/blob/d46c8891b15783803d724b717db9a8c22cb73d6a/packages/opencensus-exporter-stackdriver/src/stackdriver-monitoring.ts#L122
for (const metricProducer of this._openCensusMetricProducerManager.getAllMetricProducer()) {
for (const metric of metricProducer.getMetrics()) {
const metricData = mapOcMetric(metric);
if (metricData !== null) {
metrics.push(metricData);
}
}
}

return metrics;
}
}
2 changes: 1 addition & 1 deletion experimental/packages/shim-opencensus/src/ShimSpan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import * as oc from '@opencensus/core';
import { ShimTracer } from './ShimTracer';
import { AttributeValue, Span, SpanStatusCode, diag } from '@opentelemetry/api';
import { mapMessageEvent, reverseMapSpanContext } from './transform';
import { mapMessageEvent, reverseMapSpanContext } from './trace-transform';

// Copied from
// https://github.com/census-instrumentation/opencensus-node/blob/v0.1.0/packages/opencensus-core/src/trace/model/span.ts#L61
Expand Down
2 changes: 1 addition & 1 deletion experimental/packages/shim-opencensus/src/ShimTracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
Tracer,
} from '@opentelemetry/api';
import { DEFAULT_SPAN_NAME, ShimSpan } from './ShimSpan';
import { mapSpanContext, mapSpanKind } from './transform';
import { mapSpanContext, mapSpanKind } from './trace-transform';
import { shimPropagation } from './propagation';

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
Expand Down
1 change: 1 addition & 0 deletions experimental/packages/shim-opencensus/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
*/

export { ShimTracer } from './ShimTracer';
export { OpenCensusMetricProducer } from './OpenCensusMetricProducer';
export { installShim, uninstallShim } from './shim';
Loading

0 comments on commit 3621750

Please sign in to comment.