Skip to content

Commit 3670071

Browse files
Flarnapichlermarcdyladan
authored
fix: avoid grpc types dependency (#3551)
* 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 <marc.pichler@dynatrace.com> Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>
1 parent b5ef0e4 commit 3670071

File tree

7 files changed

+39
-20
lines changed

7 files changed

+39
-20
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/
1313

1414
### :bug: (Bug Fix)
1515

16+
* fix: avoid grpc types dependency [#3551](https://github.com/open-telemetry/opentelemetry-js/pull/3551) @flarna
1617
* fix(otlp-proto-exporter-base): Match Accept header with Content-Type in the proto exporter
1718
[#3562](https://github.com/open-telemetry/opentelemetry-js/pull/3562) @scheler
1819

experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/clientUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { CALL_SPAN_ENDED } from './serverUtils';
3333
import { EventEmitter } from 'events';
3434
import { AttributeNames } from '../enums/AttributeNames';
3535
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
36-
import { metadataCaptureType } from '../types';
36+
import { metadataCaptureType } from '../internal-types';
3737
import { GRPC_STATUS_CODE_OK } from '../status-code';
3838

3939
/**

experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import {
2020
isWrapped,
2121
} from '@opentelemetry/instrumentation';
2222
import { InstrumentationBase } from '@opentelemetry/instrumentation';
23-
import { GrpcInstrumentationConfig, metadataCaptureType } from '../types';
23+
import { GrpcInstrumentationConfig } from '../types';
24+
import { metadataCaptureType } from '../internal-types';
2425
import {
2526
ServerCallWithMeta,
2627
SendUnaryDataCallback,

experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/clientUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
findIndex,
2626
} from '../utils';
2727
import { AttributeNames } from '../enums/AttributeNames';
28-
import { metadataCaptureType } from '../types';
28+
import { metadataCaptureType } from '../internal-types';
2929
import { GRPC_STATUS_CODE_OK } from '../status-code';
3030

3131
/**

experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ import {
2727
SendUnaryDataCallback,
2828
GrpcClientFunc,
2929
} from './types';
30-
import { GrpcInstrumentationConfig, metadataCaptureType } from '../types';
30+
import { GrpcInstrumentationConfig } from '../types';
31+
import { metadataCaptureType } from '../internal-types';
3132
import {
3233
context,
3334
propagation,
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { Span } from '@opentelemetry/api';
18+
import type * as grpcJsTypes from '@grpc/grpc-js';
19+
import type * as grpcTypes from 'grpc';
20+
21+
export type metadataCaptureType = {
22+
client: {
23+
captureRequestMetadata: (
24+
span: Span,
25+
metadata: grpcJsTypes.Metadata | grpcTypes.Metadata
26+
) => void;
27+
captureResponseMetadata: (
28+
span: Span,
29+
metadata: grpcJsTypes.Metadata | grpcTypes.Metadata
30+
) => void;
31+
};
32+
};

experimental/packages/opentelemetry-instrumentation-grpc/src/types.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
*/
1616

1717
import { InstrumentationConfig } from '@opentelemetry/instrumentation';
18-
import { Span } from '@opentelemetry/api';
19-
import type * as grpcJsTypes from '@grpc/grpc-js';
20-
import type * as grpcTypes from 'grpc';
2118

2219
export type IgnoreMatcher = string | RegExp | ((str: string) => boolean);
2320

@@ -34,16 +31,3 @@ export interface GrpcInstrumentationConfig extends InstrumentationConfig {
3431
};
3532
};
3633
}
37-
38-
export type metadataCaptureType = {
39-
client: {
40-
captureRequestMetadata: (
41-
span: Span,
42-
metadata: grpcJsTypes.Metadata | grpcTypes.Metadata
43-
) => void;
44-
captureResponseMetadata: (
45-
span: Span,
46-
metadata: grpcJsTypes.Metadata | grpcTypes.Metadata
47-
) => void;
48-
};
49-
};

0 commit comments

Comments
 (0)