Skip to content

Commit

Permalink
fix conflicts and bump api version
Browse files Browse the repository at this point in the history
  • Loading branch information
William Armiros committed Oct 28, 2021
2 parents 3e7daf4 + 357ec92 commit 2992e5c
Show file tree
Hide file tree
Showing 44 changed files with 125 additions and 113 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/peer-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ jobs:
- name: Install lerna
run: npm install -g lerna

- name: Install semver
run: npm install semver

- name: Check API dependency semantics (stable)
run: lerna exec --ignore propagation-validation-server "node ../../scripts/peer-api-check.js"

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ This is the JavaScript version of [OpenTelemetry](https://opentelemetry.io/), a

| API Version | Core version | Experimental Packages | Contrib Version |
| ----------- |--------------| --------------------- |-------------------------|
| 1.0.x | 1.x | 0.26.x | ------ |
| 1.0.x | 1.x | 0.26.x | 0.26.x |
| 1.0.x | 0.26.x | ----- | ------ |
| 1.0.x | 0.25.x | ----- | ------ |
| 1.0.x | 0.24.x | ----- | 0.24.x |
Expand Down
4 changes: 0 additions & 4 deletions experimental/packages/opentelemetry-api-metrics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@
"publishConfig": {
"access": "public"
},
"peerDependencies": {
"@opentelemetry/api": "^1.0.2"
},
"devDependencies": {
"@opentelemetry/api": "^1.0.2",
"@types/mocha": "8.2.3",
"@types/node": "14.17.11",
"@types/webpack-env": "1.16.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
},
"devDependencies": {
"@babel/core": "7.15.0",
"@opentelemetry/api": "^1.0.2",
"@opentelemetry/api": "^1.0.3",
"@opentelemetry/api-metrics": "0.26.0",
"@types/mocha": "8.2.3",
"@types/node": "14.17.11",
Expand All @@ -64,7 +64,7 @@
"typescript": "4.3.5"
},
"peerDependencies": {
"@opentelemetry/api": "^1.0.2"
"@opentelemetry/api": "^1.0.3"
},
"dependencies": {
"@grpc/grpc-js": "^1.3.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"access": "public"
},
"devDependencies": {
"@opentelemetry/api": "^1.0.2",
"@opentelemetry/api": "^1.0.3",
"@babel/core": "7.15.0",
"@types/mocha": "8.2.3",
"@types/node": "14.17.11",
Expand Down Expand Up @@ -83,7 +83,7 @@
"webpack-merge": "5.8.0"
},
"peerDependencies": {
"@opentelemetry/api": "^1.0.2"
"@opentelemetry/api": "^1.0.3"
},
"dependencies": {
"@opentelemetry/api-metrics": "0.26.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"access": "public"
},
"devDependencies": {
"@opentelemetry/api": "^1.0.2",
"@opentelemetry/api": "^1.0.3",
"@babel/core": "7.15.0",
"@opentelemetry/api-metrics": "0.26.0",
"@types/mocha": "8.2.3",
Expand All @@ -64,7 +64,7 @@
"typescript": "4.3.5"
},
"peerDependencies": {
"@opentelemetry/api": "^1.0.2"
"@opentelemetry/api": "^1.0.3"
},
"dependencies": {
"@grpc/proto-loader": "^0.6.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"access": "public"
},
"devDependencies": {
"@opentelemetry/api": "^1.0.2",
"@opentelemetry/api": "^1.0.3",
"@types/mocha": "8.2.3",
"@types/node": "14.17.11",
"@types/sinon": "10.0.2",
Expand All @@ -54,7 +54,7 @@
"typescript": "4.3.5"
},
"peerDependencies": {
"@opentelemetry/api": "^1.0.2"
"@opentelemetry/api": "^1.0.0"
},
"dependencies": {
"@opentelemetry/api-metrics": "0.26.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ export class PrometheusExporter implements MetricExporter {
typeof config.appendTimestamp === 'boolean'
? config.appendTimestamp
: PrometheusExporter.DEFAULT_OPTIONS.appendTimestamp;
this._server = createServer(this._requestHandler);
// unref to prevent prometheus exporter from holding the process open on exit
this._server = createServer(this._requestHandler).unref();
this._serializer = new PrometheusSerializer(
this._prefix,
this._appendTimestamp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ describe('PrometheusExporter', () => {
mockAggregator(HistogramAggregator);

afterEach(() => {
sinon.restore();
delete process.env.OTEL_EXPORTER_PROMETHEUS_HOST;
delete process.env.OTEL_EXPORTER_PROMETHEUS_PORT;
});
Expand Down Expand Up @@ -116,6 +117,16 @@ describe('PrometheusExporter', () => {
);
});

it('should unref the server to allow graceful termination', () => {
const mockServer = sinon.createStubInstance(http.Server);
const createStub = sinon.stub(http, 'createServer');
createStub.returns((mockServer as any) as http.Server);
const exporter = new PrometheusExporter({}, async () => {
await exporter.shutdown();
});
sinon.assert.calledOnce(mockServer.unref);
});

it('should listen on environmentally set host and port', () => {
process.env.OTEL_EXPORTER_PROMETHEUS_HOST = '127.0.0.1';
process.env.OTEL_EXPORTER_PROMETHEUS_PORT = '1234';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
},
"devDependencies": {
"@babel/core": "7.15.0",
"@opentelemetry/api": "^1.0.2",
"@opentelemetry/api": "^1.0.3",
"@types/mocha": "8.2.3",
"@types/node": "14.17.11",
"@types/sinon": "10.0.2",
Expand All @@ -63,7 +63,7 @@
"typescript": "4.3.5"
},
"peerDependencies": {
"@opentelemetry/api": "^1.0.2"
"@opentelemetry/api": "^1.0.0"
},
"dependencies": {
"@grpc/grpc-js": "^1.3.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
},
"devDependencies": {
"@babel/core": "7.15.0",
"@opentelemetry/api": "^1.0.2",
"@opentelemetry/api": "^1.0.3",
"@types/mocha": "8.2.3",
"@types/node": "14.17.11",
"@types/sinon": "10.0.2",
Expand All @@ -83,7 +83,7 @@
"webpack-merge": "5.8.0"
},
"peerDependencies": {
"@opentelemetry/api": "^1.0.2"
"@opentelemetry/api": "^1.0.0"
},
"dependencies": {
"@opentelemetry/core": "1.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
},
"devDependencies": {
"@babel/core": "7.15.0",
"@opentelemetry/api": "^1.0.2",
"@opentelemetry/api": "^1.0.3",
"@types/mocha": "8.2.3",
"@types/node": "14.17.11",
"@types/sinon": "10.0.2",
Expand All @@ -63,7 +63,7 @@
"typescript": "4.3.5"
},
"peerDependencies": {
"@opentelemetry/api": "^1.0.2"
"@opentelemetry/api": "^1.0.0"
},
"dependencies": {
"@grpc/proto-loader": "^0.6.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
},
"devDependencies": {
"@babel/core": "7.15.0",
"@opentelemetry/api": "^1.0.2",
"@opentelemetry/api": "^1.0.3",
"@opentelemetry/context-zone": "1.0.0",
"@opentelemetry/propagator-b3": "1.0.0",
"@opentelemetry/sdk-trace-base": "1.0.0",
Expand Down Expand Up @@ -78,7 +78,7 @@
"webpack-merge": "5.8.0"
},
"peerDependencies": {
"@opentelemetry/api": "^1.0.2"
"@opentelemetry/api": "^1.0.0"
},
"dependencies": {
"@opentelemetry/core": "1.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ export class FetchInstrumentation extends InstrumentationBase<
private _usedResources = new WeakSet<PerformanceResourceTiming>();
private _tasksCount = 0;

constructor(config: FetchInstrumentationConfig = {}) {
constructor(config?: FetchInstrumentationConfig) {
super(
'@opentelemetry/instrumentation-fetch',
VERSION,
Object.assign({}, config)
config
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"devDependencies": {
"@grpc/grpc-js": "1.3.7",
"@grpc/proto-loader": "0.6.4",
"@opentelemetry/api": "^1.0.2",
"@opentelemetry/api": "^1.0.3",
"@opentelemetry/context-async-hooks": "1.0.0",
"@opentelemetry/core": "1.0.0",
"@opentelemetry/sdk-trace-base": "1.0.0",
Expand All @@ -66,7 +66,7 @@
"typescript": "4.3.5"
},
"peerDependencies": {
"@opentelemetry/api": "^1.0.2"
"@opentelemetry/api": "^1.0.0"
},
"dependencies": {
"@opentelemetry/api-metrics": "0.26.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function getMethodsToWrap(

// For a method defined in .proto as "UnaryMethod"
Object.entries(methods).forEach(([name, { originalName }]) => {
if (!_methodIsIgnored(name, this._config.ignoreGrpcMethods)) {
if (!_methodIsIgnored(name, this.getConfig().ignoreGrpcMethods)) {
methodList.push(name); // adds camel case method name: "unaryMethod"
if (
originalName &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ import {
InstrumentationNodeModuleDefinition,
isWrapped,
} from '@opentelemetry/instrumentation';
import {
InstrumentationBase,
InstrumentationConfig,
} from '@opentelemetry/instrumentation';
import { InstrumentationBase } from '@opentelemetry/instrumentation';
import { GrpcInstrumentationConfig } from '../types';
import {
ServerCallWithMeta,
Expand Down Expand Up @@ -56,17 +53,11 @@ import { AttributeNames } from '../enums/AttributeNames';

export class GrpcJsInstrumentation extends InstrumentationBase {
constructor(
protected override _config: GrpcInstrumentationConfig & InstrumentationConfig = {},
name: string,
version: string
version: string,
config?: GrpcInstrumentationConfig,
) {
super(name, version, _config);
}

public override setConfig(
config: GrpcInstrumentationConfig & InstrumentationConfig = {}
) {
this._config = Object.assign({}, config);
super(name, version, config);
}

init() {
Expand Down Expand Up @@ -125,6 +116,10 @@ export class GrpcJsInstrumentation extends InstrumentationBase {
];
}

override getConfig(): GrpcInstrumentationConfig {
return super.getConfig();
}

/**
* Patch for grpc.Server.prototype.register(...) function. Provides auto-instrumentation for
* client_stream, server_stream, bidi, unary server handler calls.
Expand All @@ -134,7 +129,7 @@ export class GrpcJsInstrumentation extends InstrumentationBase {
) => ServerRegisterFunction {
const instrumentation = this;
return (originalRegister: ServerRegisterFunction) => {
const config = this._config;
const config = this.getConfig();
instrumentation._diag.debug('patched gRPC server');
return function register<RequestType, ResponseType>(
this: grpcJs.Server,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
InstrumentationNodeModuleDefinition,
InstrumentationNodeModuleFile,
InstrumentationBase,
InstrumentationConfig,
isWrapped,
} from '@opentelemetry/instrumentation';
import {
Expand Down Expand Up @@ -55,17 +54,11 @@ export class GrpcNativeInstrumentation extends InstrumentationBase<
typeof grpcTypes
> {
constructor(
protected override _config: GrpcInstrumentationConfig & InstrumentationConfig = {},
name: string,
version: string
version: string,
config?: GrpcInstrumentationConfig
) {
super(name, version, _config);
}

public override setConfig(
config: GrpcInstrumentationConfig & InstrumentationConfig = {}
) {
this._config = Object.assign({}, config);
super(name, version, config);
}

init() {
Expand Down Expand Up @@ -107,6 +100,10 @@ export class GrpcNativeInstrumentation extends InstrumentationBase<
];
}

override getConfig(): GrpcInstrumentationConfig {
return super.getConfig();
}

private _getInternalPatchs() {
const onPatch = (
moduleExports: GrpcInternalClientTypes,
Expand Down Expand Up @@ -268,7 +265,7 @@ export class GrpcNativeInstrumentation extends InstrumentationBase<

// For a method defined in .proto as "UnaryMethod"
Object.entries(methods).forEach(([name, { originalName }]) => {
if (!_methodIsIgnored(name, this._config.ignoreGrpcMethods)) {
if (!_methodIsIgnored(name, this.getConfig().ignoreGrpcMethods)) {
methodList.push(name); // adds camel case method name: "unaryMethod"
if (
originalName &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,6 @@ export const shouldNotTraceServerCall = function (
const parsedName = name.split('/');
return _methodIsIgnored(
parsedName[parsedName.length - 1] || name,
this._config.ignoreGrpcMethods
this.getConfig().ignoreGrpcMethods
);
};
Loading

0 comments on commit 2992e5c

Please sign in to comment.