Skip to content

Commit 992baaa

Browse files
authored
observability: add base for instrumentation + tests (#2097)
This change adds the scaffolding for instrumentation along with tests for the tracing mechanisms that'll be used to trace the entire package. Built from #2087 Updates #2079
1 parent 95d2151 commit 992baaa

File tree

8 files changed

+784
-434
lines changed

8 files changed

+784
-434
lines changed

observability-test/helper.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*!
2+
* Copyright 2024 Google LLC. All Rights Reserved.
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+
* http://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 {ContextManager, context} from '@opentelemetry/api';
18+
19+
/**
20+
* This utility exists as a test helper because mocha has builtin "context"
21+
* and referring to context causes type/value collision errors.
22+
*/
23+
export function setGlobalContextManager(manager: ContextManager) {
24+
context.setGlobalContextManager(manager);
25+
}
26+
27+
/**
28+
* This utility exists as a test helper because mocha has builtin "context"
29+
* and referring to context causes type/value collision errors.
30+
*/
31+
export function disableContextAndManager(manager: ContextManager) {
32+
manager.disable();
33+
context.disable();
34+
}

0 commit comments

Comments
 (0)