Skip to content

Commit

Permalink
Merge branch 'main' into renovate/eslint-8.x
Browse files Browse the repository at this point in the history
  • Loading branch information
pichlermarc authored Jul 5, 2023
2 parents 02ccb63 + dccd906 commit 73d4cbd
Show file tree
Hide file tree
Showing 23 changed files with 219 additions and 221 deletions.
2 changes: 2 additions & 0 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ All notable changes to experimental packages in this project will be documented

### :house: (Internal)

* chore(instrumentation-grpc): Cleanup remnants of grpc-native support. [#3886](https://github.com/open-telemetry/opentelemetry-js/pull/3886) @llc1123

## 0.40.0

### :boom: Breaking Change
Expand Down
2 changes: 1 addition & 1 deletion experimental/packages/exporter-logs-otlp-grpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

**Note: This is an experimental package under active development. New releases may include breaking changes.**

This module provides an exporter for OTLP gRPC logs using protocol version `v0.18`.
This module provides a logs-exporter for OTLP (gRPC) using protocol version `v0.20.0`.

## Installation

Expand Down
2 changes: 1 addition & 1 deletion experimental/packages/exporter-logs-otlp-http/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

**Note: This is an experimental package under active development. New releases may include breaking changes.**

This module provides an exporter for OTLP (http/json) logs using protocol version `v0.18`.
This module provides a logs-exporter for OTLP (http/json) using protocol version `v0.20.0`.

## Installation

Expand Down
2 changes: 1 addition & 1 deletion experimental/packages/exporter-logs-otlp-proto/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

**Note: This is an experimental package under active development. New releases may include breaking changes.**

This module provides an exporter for OTLP (http/protobuf) logs using protocol version `v0.18`.
This module provides a logs-exporter for OTLP (http/protobuf) using protocol version `v0.20.0`.

## Installation

Expand Down
3 changes: 1 addition & 2 deletions experimental/packages/exporter-trace-otlp-grpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

**Note: This is an experimental package under active development. New releases may include breaking changes.**

This module provides exporter for node to be used with OTLP (`grpc`) compatible receivers.
Compatible with [opentelemetry-collector][opentelemetry-collector-url] versions `>=0.16 <=0.50`.
This module provides a trace-exporter for OTLP (gRPC) traces using protocol version `v0.20.0`.

## Installation

Expand Down
3 changes: 1 addition & 2 deletions experimental/packages/exporter-trace-otlp-http/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

**Note: This is an experimental package under active development. New releases may include breaking changes.**

This module provides exporter for web and node to be used with OTLP (`http/json`) compatible receivers.
Compatible with [opentelemetry-collector][opentelemetry-collector-url] versions `>=0.48 <=0.50`.
This module provides a trace-exporter for OTLP (http/json) using protocol version `v0.20.0`.

## Installation

Expand Down
3 changes: 1 addition & 2 deletions experimental/packages/exporter-trace-otlp-proto/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

**Note: This is an experimental package under active development. New releases may include breaking changes.**

This module provides exporter for node to be used with OTLP (`http/protobuf`) compatible receivers.
Compatible with [opentelemetry-collector][opentelemetry-collector-url] versions `>=0.32 <=0.50`.
This module provides a trace-exporter for OTLP (http/protobuf) using protocol version `v0.20.0`.

## Installation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

**Note: This is an experimental package under active development. New releases may include breaking changes.**

This module provides exporter for node to be used with OTLP (`grpc`) compatible receivers.
Compatible with [opentelemetry-collector][opentelemetry-collector-url] versions `>=0.16 <=0.53`.
This module provides a metrics-exporter for OTLP (gRPC) using protocol version `v0.20.0`.

## Installation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

**Note: This is an experimental package under active development. New releases may include breaking changes.**

This module provides exporter for web and node to be used with OTLP (`http/json`) compatible receivers.
Compatible with [opentelemetry-collector][opentelemetry-collector-url] versions `>=0.52 <=0.53`.
This module provides a metrics-exporter for OTLP (http/json) using protocol version `v0.20.0`.

## Installation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

**Note: This is an experimental package under active development. New releases may include breaking changes.**

This module provides exporter for node to be used with OTLP (`http/protobuf`) compatible receivers.
Compatible with [opentelemetry-collector][opentelemetry-collector-url] versions `>=0.32 <=0.53`.
This module provides a metrics-exporter for OTLP (http/protobuf) using protocol version `v0.20.0`.

## Installation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"cross-var": "1.1.0",
"lerna": "7.1.1",
"mocha": "10.2.0",
"node-pre-gyp": "0.17.0",
"nyc": "15.1.0",
"semver": "7.5.3",
"sinon": "15.1.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,32 @@
* limitations under the License.
*/

import { GrpcJsInstrumentation } from './';
import type { GrpcClientFunc, SendUnaryDataCallback } from './types';
import {
Span,
SpanStatusCode,
SpanStatus,
propagation,
context,
} from '@opentelemetry/api';
import type { EventEmitter } from 'events';
import type { Span, SpanStatus } from '@opentelemetry/api';
import type { Client, Metadata, ServiceError } from '@grpc/grpc-js';
import type * as grpcJs from '@grpc/grpc-js';
import type { GrpcJsInstrumentation } from './';
import type { GrpcClientFunc, SendUnaryDataCallback } from './types';
import type { metadataCaptureType } from '../internal-types';

import { SpanStatusCode, propagation, context } from '@opentelemetry/api';
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
import { CALL_SPAN_ENDED } from './serverUtils';
import { AttributeNames } from '../enums/AttributeNames';
import { GRPC_STATUS_CODE_OK } from '../status-code';
import {
_grpcStatusCodeToSpanStatus,
_grpcStatusCodeToOpenTelemetryStatusCode,
_methodIsIgnored,
} from '../utils';
import { CALL_SPAN_ENDED } from './serverUtils';
import { EventEmitter } from 'events';
import { AttributeNames } from '../enums/AttributeNames';
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
import { metadataCaptureType } from '../internal-types';
import { GRPC_STATUS_CODE_OK } from '../status-code';

/**
* Parse a package method list and return a list of methods to patch
* with both possible casings e.g. "TestMethod" & "testMethod"
*/
export function getMethodsToWrap(
this: GrpcJsInstrumentation,
client: typeof grpcJs.Client,
client: typeof Client,
methods: { [key: string]: { originalName?: string } }
): string[] {
const methodList: string[] = [];
Expand Down Expand Up @@ -74,8 +71,8 @@ export function makeGrpcClientRemoteCall(
metadataCapture: metadataCaptureType,
original: GrpcClientFunc,
args: unknown[],
metadata: grpcJs.Metadata,
self: grpcJs.Client
metadata: Metadata,
self: Client
): (span: Span) => EventEmitter {
/**
* Patches a callback so that the current span for this trace is also ended
Expand All @@ -86,7 +83,7 @@ export function makeGrpcClientRemoteCall(
callback: SendUnaryDataCallback<ResponseType>
) {
const wrappedFn: SendUnaryDataCallback<ResponseType> = (
err: grpcJs.ServiceError | null,
err: ServiceError | null,
res?: ResponseType
) => {
if (err) {
Expand Down Expand Up @@ -145,7 +142,7 @@ export function makeGrpcClientRemoteCall(
}
};
context.bind(context.active(), call);
call.on('error', (err: grpcJs.ServiceError) => {
call.on('error', (err: ServiceError) => {
if (call[CALL_SPAN_ENDED]) {
return;
}
Expand Down Expand Up @@ -185,22 +182,22 @@ export function makeGrpcClientRemoteCall(
*/
export function getMetadata(
this: GrpcJsInstrumentation,
grpcClient: typeof grpcJs,
original: GrpcClientFunc,
args: Array<unknown | grpcJs.Metadata>
): grpcJs.Metadata {
let metadata: grpcJs.Metadata;
grpcClient: typeof grpcJs,
args: Array<unknown | Metadata>
): Metadata {
let metadata: Metadata;

// This finds an instance of Metadata among the arguments.
// A possible issue that could occur is if the 'options' parameter from
// the user contains an '_internal_repr' as well as a 'getMap' function,
// but this is an extremely rare case.
let metadataIndex = args.findIndex((arg: unknown | grpcJs.Metadata) => {
let metadataIndex = args.findIndex((arg: unknown | Metadata) => {
return (
arg &&
typeof arg === 'object' &&
(arg as grpcJs.Metadata)['internalRepr'] && // changed from _internal_repr in grpc --> @grpc/grpc-js https://github.com/grpc/grpc-node/blob/95289edcaf36979cccf12797cc27335da8d01f03/packages/grpc-js/src/metadata.ts#L88
typeof (arg as grpcJs.Metadata).getMap === 'function'
(arg as Metadata)['internalRepr'] && // changed from _internal_repr in grpc --> @grpc/grpc-js https://github.com/grpc/grpc-node/blob/95289edcaf36979cccf12797cc27335da8d01f03/packages/grpc-js/src/metadata.ts#L88
typeof (arg as Metadata).getMap === 'function'
);
});
if (metadataIndex === -1) {
Expand All @@ -214,7 +211,7 @@ export function getMetadata(
}
args.splice(metadataIndex, 0, metadata);
} else {
metadata = args[metadataIndex] as grpcJs.Metadata;
metadata = args[metadataIndex] as Metadata;
}
return metadata;
}
Expand All @@ -224,7 +221,7 @@ export function getMetadata(
* grpc receiver
* @param metadata
*/
export function setSpanContext(metadata: grpcJs.Metadata): void {
export function setSpanContext(metadata: Metadata): void {
propagation.inject(context.active(), metadata, {
set: (meta, k, v) => meta.set(k, v),
});
Expand Down
Loading

0 comments on commit 73d4cbd

Please sign in to comment.