File tree Expand file tree Collapse file tree 3 files changed +40
-2
lines changed
packages/instrumentation-redis Expand file tree Collapse file tree 3 files changed +40
-2
lines changed Original file line number Diff line number Diff line change 1919 "prepublishOnly" : " npm run compile" ,
2020 "tdd" : " npm run test -- --watch-extensions ts --watch" ,
2121 "test-v2-v3" : " nyc --no-clean mocha --require '@opentelemetry/contrib-test-utils' 'test/v2-v3/*.test.ts'" ,
22- "test" : " nyc --no-clean mocha --require '@opentelemetry/contrib-test-utils' 'test/v4-v5/*.test.ts'" ,
22+ "test" : " nyc --no-clean mocha --require '@opentelemetry/contrib-test-utils' 'test/v4-v5/*.test.ts' 'test/*.test.ts' " ,
2323 "test:debug" : " cross-env RUN_REDIS_TESTS=true mocha --inspect-brk --no-timeouts 'test/**/*.test.ts'" ,
2424 "test:with-services-env" : " cross-env NODE_OPTIONS='-r dotenv/config' DOTENV_CONFIG_PATH=../../test/test-services.env npm test" ,
2525 "test-all-versions" : " tav" ,
Original file line number Diff line number Diff line change 1313 * See the License for the specific language governing permissions and
1414 * limitations under the License.
1515 */
16- import { InstrumentationBase } from '@opentelemetry/instrumentation' ;
16+ import {
17+ InstrumentationBase ,
18+ InstrumentationModuleDefinition ,
19+ } from '@opentelemetry/instrumentation' ;
1720import { RedisInstrumentationConfig } from './types' ;
1821/** @knipignore */
1922import { PACKAGE_NAME , PACKAGE_VERSION } from './version' ;
@@ -56,6 +59,15 @@ export class RedisInstrumentation extends InstrumentationBase<RedisInstrumentati
5659
5760 override init ( ) { }
5861
62+ // Return underlying modules, as consumers (like https://github.com/DrewCorlin/opentelemetry-node-bundler-plugins) may
63+ // expect them to be populated without knowing that this module wraps 2 instrumentations
64+ override getModuleDefinitions ( ) : InstrumentationModuleDefinition [ ] {
65+ return [
66+ ...this . instrumentationV2_V3 . getModuleDefinitions ( ) ,
67+ ...this . instrumentationV4_V5 . getModuleDefinitions ( ) ,
68+ ] ;
69+ }
70+
5971 override setTracerProvider ( tracerProvider : TracerProvider ) {
6072 super . setTracerProvider ( tracerProvider ) ;
6173 if ( ! this . initialized ) {
Original file line number Diff line number Diff line change 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 { RedisInstrumentation } from '../src' ;
18+ import * as assert from 'assert' ;
19+
20+ describe ( 'redis' , ( ) => {
21+ it ( 'Returns module definitions of sub-instrumentations' , ( ) => {
22+ const instrumentation = new RedisInstrumentation ( ) ;
23+ const moduleDefinitions = instrumentation . getModuleDefinitions ( ) ;
24+ assert . ok ( moduleDefinitions . length >= 1 ) ;
25+ } ) ;
26+ } ) ;
You can’t perform that action at this time.
0 commit comments