Skip to content

Commit

Permalink
Merge branch 'main' into renovate/angular-monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
pichlermarc authored Dec 6, 2024
2 parents b3dda26 + de679ad commit c9ab1eb
Show file tree
Hide file tree
Showing 6 changed files with 227 additions and 26 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node: ["16"]
node: ["22"]
runs-on: ubuntu-latest
env:
NPM_CONFIG_UNSAFE_PERM: true
Expand All @@ -195,9 +195,6 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Update npm to a version that supports workspaces (v7 or later)
if: ${{ matrix.node < 16 }}
run: npm install -g npm@9 # npm@9 supports node >=14.17.0
- name: Install
run: npm ci
- name: Download Build Artifacts
Expand Down
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ Maintainers may override the decisions of component owners, but should only do s

### Becoming a Component Owner

To become a component owner, contributors MUST be a member of the OpenTelemetry GitHub organization.
To become a member, follow the steps in the [community guidelines for membership requirements](https://github.com/open-telemetry/community/blob/main/guides/contributor/membership.md#requirements).

To become a component owner, contributors SHOULD demonstrate prior knowledge of the instrumented package or the concepts therein.

Ways do to so may be by providing proof of:
Expand Down Expand Up @@ -177,6 +180,7 @@ If all these conditions are met, aspiring component owners are encouraged to sel
information provided on the issue - either approve or deny the ownership request. If the ownership request has been
approved, the new component owner opens a PR to add themselves to the list of owners ([.github/component_owners.yml](.github/component_owners.yml))
for that package.
@open-telemetry/javascript-maintainers will add the component owner to @open-telemetry/javascript-contrib-triagers.

## Component Lifecycle

Expand Down Expand Up @@ -306,6 +310,7 @@ When instrumentation cannot be included in a target package and there is good re
Note that new instrumentation needs at least two contributors assigned to it as code-owners. It is the responsibility
of the requesting party to reach out and find code-owners for the proposed instrumentation. The instrumentation request
needs to be accepted before any pull requests for the instrumentation can be considered for merging.
Review the guidelines for [Becoming a Component Owner](#becoming-a-component-owner).

Regardless of where instrumentation is hosted, it needs to be discoverable.
The [OpenTelemetry registry](https://opentelemetry.io/registry/) exists to ensure that instrumentation is discoverable.
Expand Down
42 changes: 38 additions & 4 deletions packages/opentelemetry-test-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,41 @@
* limitations under the License.
*/

export * from './resource-assertions';
export * from './test-fixtures';
export * from './test-utils';
export * from './instrumentations';
export {
assertCloudResource,
assertContainerResource,
assertEmptyResource,
assertHostResource,
assertK8sResource,
assertProcessResource,
assertServiceResource,
assertTelemetrySDKResource,
} from './resource-assertions';
export { OtlpSpanKind } from './otlp-types';
export {
createTestNodeSdk,
runTestFixture,
TestSpan,
RunTestFixtureOptions,
TestCollector,
} from './test-fixtures';
export {
assertPropagation,
assertSpan,
cleanUpDocker,
getPackageVersion,
initMeterProvider,
TimedEvent,
startDocker,
TestMetricReader,
} from './test-utils';
export {
getInstrumentation,
getTestMemoryExporter,
getTestSpans,
mochaHooks,
registerInstrumentationTesting,
registerInstrumentationTestingProvider,
resetMemoryExporter,
setTestMemoryExporter,
} from './instrumentations';
167 changes: 167 additions & 0 deletions packages/opentelemetry-test-utils/src/otlp-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
/*
* 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.
*/

export enum OtlpSpanKind {
UNSPECIFIED = 0,
INTERNAL = 1,
SERVER = 2,
CLIENT = 3,
PRODUCER = 4,
CONSUMER = 5,
}

/** Properties of a KeyValueList. */
interface IKeyValueList {
/** KeyValueList values */
values: IKeyValue[];
}

/** Properties of an ArrayValue. */
interface IArrayValue {
/** ArrayValue values */
values: IAnyValue[];
}

/** Properties of an AnyValue. */
interface IAnyValue {
/** AnyValue stringValue */
stringValue?: string | null;
/** AnyValue boolValue */
boolValue?: boolean | null;
/** AnyValue intValue */
intValue?: number | null;
/** AnyValue doubleValue */
doubleValue?: number | null;
/** AnyValue arrayValue */
arrayValue?: IArrayValue;
/** AnyValue kvlistValue */
kvlistValue?: IKeyValueList;
/** AnyValue bytesValue */
bytesValue?: Uint8Array;
}

/** Properties of a KeyValue. */
interface IKeyValue {
/** KeyValue key */
key: string;
/** KeyValue value */
value: IAnyValue;
}

/** Properties of an InstrumentationScope. */
export interface IInstrumentationScope {
/** InstrumentationScope name */
name: string;
/** InstrumentationScope version */
version?: string;
/** InstrumentationScope attributes */
attributes?: IKeyValue[];
/** InstrumentationScope droppedAttributesCount */
droppedAttributesCount?: number;
}

/** Properties of a Resource. */
export interface IResource {
/** Resource attributes */
attributes: IKeyValue[];
/** Resource droppedAttributesCount */
droppedAttributesCount: number;
}

interface LongBits {
low: number;
high: number;
}

type Fixed64 = LongBits | string | number;

/** Properties of an Event. */
interface IEvent {
/** Event timeUnixNano */
timeUnixNano: Fixed64;
/** Event name */
name: string;
/** Event attributes */
attributes: IKeyValue[];
/** Event droppedAttributesCount */
droppedAttributesCount: number;
}

/** Properties of a Link. */
interface ILink {
/** Link traceId */
traceId: string | Uint8Array;
/** Link spanId */
spanId: string | Uint8Array;
/** Link traceState */
traceState?: string;
/** Link attributes */
attributes: IKeyValue[];
/** Link droppedAttributesCount */
droppedAttributesCount: number;
}

/** Properties of a Status. */
interface IStatus {
/** Status message */
message?: string;
/** Status code */
code: EStatusCode;
}

/** StatusCode enum. */
const enum EStatusCode {
/** The default status. */
STATUS_CODE_UNSET = 0,
/** The Span has been evaluated by an Application developer or Operator to have completed successfully. */
STATUS_CODE_OK = 1,
/** The Span contains an error. */
STATUS_CODE_ERROR = 2,
}

/** Properties of a Span. */
export interface ISpan {
/** Span traceId */
traceId: string | Uint8Array;
/** Span spanId */
spanId: string | Uint8Array;
/** Span traceState */
traceState?: string | null;
/** Span parentSpanId */
parentSpanId?: string | Uint8Array;
/** Span name */
name: string;
/** Span kind */
kind: OtlpSpanKind;
/** Span startTimeUnixNano */
startTimeUnixNano: Fixed64;
/** Span endTimeUnixNano */
endTimeUnixNano: Fixed64;
/** Span attributes */
attributes: IKeyValue[];
/** Span droppedAttributesCount */
droppedAttributesCount: number;
/** Span events */
events: IEvent[];
/** Span droppedEventsCount */
droppedEventsCount: number;
/** Span links */
links: ILink[];
/** Span droppedLinksCount */
droppedLinksCount: number;
/** Span status */
status: IStatus;
}
19 changes: 4 additions & 15 deletions packages/opentelemetry-test-utils/src/test-fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,9 @@ import type { AddressInfo } from 'net';
import { URL } from 'url';
import { createGunzip } from 'zlib';

import {
IInstrumentationScope,
IResource,
ISpan,
} from '@opentelemetry/otlp-transformer';
import { NodeSDK, tracing } from '@opentelemetry/sdk-node';
import type { Instrumentation } from '@opentelemetry/instrumentation';
import { IInstrumentationScope, IResource, ISpan } from './otlp-types';

/**
* A utility for scripts that will be run with `runTestFixture()` to create an
Expand All @@ -55,15 +51,6 @@ export function createTestNodeSdk(opts: {
return sdk;
}

export enum OtlpSpanKind {
UNSPECIFIED = 0,
INTERNAL = 1,
SERVER = 2,
CLIENT = 3,
PRODUCER = 4,
CONSUMER = 5,
}

// TestSpan is an OTLP span plus references to `resource` and
// `instrumentationScope` that are shared between multiple spans in the
// protocol.
Expand Down Expand Up @@ -249,7 +236,7 @@ export async function runTestFixture(
const collector = new TestCollector();
await collector.start();

return new Promise(resolve => {
return new Promise((resolve, reject) => {
execFile(
process.execPath,
opts.argv,
Expand All @@ -274,6 +261,8 @@ export async function runTestFixture(
if (opts.checkCollector) {
await opts.checkCollector(collector);
}
} catch (err) {
reject(err);
} finally {
collector.close();
resolve();
Expand Down
15 changes: 12 additions & 3 deletions plugins/node/opentelemetry-instrumentation-hapi/test/hapi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -557,15 +557,24 @@ describe('Hapi Instrumentation - Core Tests', () => {
},
checkCollector: (collector: TestCollector) => {
const spans = collector.sortedSpans;
assert.strictEqual(spans.length, 2);
assert.strictEqual(spans[0].name, 'GET /route/{param}');

assert.strictEqual(spans.length, 3);

assert.strictEqual(spans[0].name, 'GET');
assert.strictEqual(
spans[0].instrumentationScope.name,
'@opentelemetry/instrumentation-http'
);
assert.strictEqual(spans[1].name, 'route - /route/{param}');

assert.strictEqual(spans[1].name, 'GET /route/{param}');
assert.strictEqual(
spans[1].instrumentationScope.name,
'@opentelemetry/instrumentation-http'
);

assert.strictEqual(spans[2].name, 'route - /route/{param}');
assert.strictEqual(
spans[2].instrumentationScope.name,
'@opentelemetry/instrumentation-hapi'
);
},
Expand Down

0 comments on commit c9ab1eb

Please sign in to comment.