Skip to content

Commit

Permalink
fix: avoid grpc types dependency (#3551)
Browse files Browse the repository at this point in the history
* fix: avoid grpc types dependency

Avoid a dependency to grpc types by moving the into a internal-types.ts file.

* Update CHANGELOG.md

Co-authored-by: Marc Pichler <[email protected]>
Co-authored-by: Daniel Dyla <[email protected]>
  • Loading branch information
3 people authored Jan 25, 2023
1 parent b5ef0e4 commit 3670071
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;
};
};

0 comments on commit 3670071

Please sign in to comment.