diff --git a/CHANGELOG.md b/CHANGELOG.md index 651c54da10..cd6d6055d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/ ### :bug: (Bug Fix) +* fix: avoid grpc types dependency [#3551](https://github.com/open-telemetry/opentelemetry-js/pull/3551) @flarna * fix(otlp-proto-exporter-base): Match Accept header with Content-Type in the proto exporter [#3562](https://github.com/open-telemetry/opentelemetry-js/pull/3562) @scheler diff --git a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/clientUtils.ts b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/clientUtils.ts index 050eee24b1..8c98a10936 100644 --- a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/clientUtils.ts +++ b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/clientUtils.ts @@ -33,7 +33,7 @@ import { CALL_SPAN_ENDED } from './serverUtils'; import { EventEmitter } from 'events'; import { AttributeNames } from '../enums/AttributeNames'; import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; -import { metadataCaptureType } from '../types'; +import { metadataCaptureType } from '../internal-types'; import { GRPC_STATUS_CODE_OK } from '../status-code'; /** diff --git a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/index.ts b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/index.ts index 9147f455a0..2e5c833b19 100644 --- a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/index.ts +++ b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/index.ts @@ -20,7 +20,8 @@ import { isWrapped, } from '@opentelemetry/instrumentation'; import { InstrumentationBase } from '@opentelemetry/instrumentation'; -import { GrpcInstrumentationConfig, metadataCaptureType } from '../types'; +import { GrpcInstrumentationConfig } from '../types'; +import { metadataCaptureType } from '../internal-types'; import { ServerCallWithMeta, SendUnaryDataCallback, diff --git a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/clientUtils.ts b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/clientUtils.ts index 47de2ecf34..af56330a85 100644 --- a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/clientUtils.ts +++ b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/clientUtils.ts @@ -25,7 +25,7 @@ import { findIndex, } from '../utils'; import { AttributeNames } from '../enums/AttributeNames'; -import { metadataCaptureType } from '../types'; +import { metadataCaptureType } from '../internal-types'; import { GRPC_STATUS_CODE_OK } from '../status-code'; /** diff --git a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/index.ts b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/index.ts index 436e04ada4..4df381eb66 100644 --- a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/index.ts +++ b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/index.ts @@ -27,7 +27,8 @@ import { SendUnaryDataCallback, GrpcClientFunc, } from './types'; -import { GrpcInstrumentationConfig, metadataCaptureType } from '../types'; +import { GrpcInstrumentationConfig } from '../types'; +import { metadataCaptureType } from '../internal-types'; import { context, propagation, diff --git a/experimental/packages/opentelemetry-instrumentation-grpc/src/internal-types.ts b/experimental/packages/opentelemetry-instrumentation-grpc/src/internal-types.ts new file mode 100644 index 0000000000..d0052f7643 --- /dev/null +++ b/experimental/packages/opentelemetry-instrumentation-grpc/src/internal-types.ts @@ -0,0 +1,32 @@ +/* + * 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 { Span } from '@opentelemetry/api'; +import type * as grpcJsTypes from '@grpc/grpc-js'; +import type * as grpcTypes from 'grpc'; + +export type metadataCaptureType = { + client: { + captureRequestMetadata: ( + span: Span, + metadata: grpcJsTypes.Metadata | grpcTypes.Metadata + ) => void; + captureResponseMetadata: ( + span: Span, + metadata: grpcJsTypes.Metadata | grpcTypes.Metadata + ) => void; + }; +}; diff --git a/experimental/packages/opentelemetry-instrumentation-grpc/src/types.ts b/experimental/packages/opentelemetry-instrumentation-grpc/src/types.ts index 67940a48e0..dd08d8224b 100644 --- a/experimental/packages/opentelemetry-instrumentation-grpc/src/types.ts +++ b/experimental/packages/opentelemetry-instrumentation-grpc/src/types.ts @@ -15,9 +15,6 @@ */ import { InstrumentationConfig } from '@opentelemetry/instrumentation'; -import { Span } from '@opentelemetry/api'; -import type * as grpcJsTypes from '@grpc/grpc-js'; -import type * as grpcTypes from 'grpc'; export type IgnoreMatcher = string | RegExp | ((str: string) => boolean); @@ -34,16 +31,3 @@ export interface GrpcInstrumentationConfig extends InstrumentationConfig { }; }; } - -export type metadataCaptureType = { - client: { - captureRequestMetadata: ( - span: Span, - metadata: grpcJsTypes.Metadata | grpcTypes.Metadata - ) => void; - captureResponseMetadata: ( - span: Span, - metadata: grpcJsTypes.Metadata | grpcTypes.Metadata - ) => void; - }; -};