File tree 7 files changed +96
-2
lines changed
packages/opentelemetry-api
7 files changed +96
-2
lines changed Original file line number Diff line number Diff line change 4
4
"description" : " Public API for OpenTelemetry" ,
5
5
"main" : " build/src/index.js" ,
6
6
"types" : " build/src/index.d.ts" ,
7
+ "browser" : {
8
+ "./src/platform/index.ts" : " ./src/platform/browser/index.ts" ,
9
+ "./build/src/platform/index.js" : " ./build/src/platform/browser/index.js"
10
+ },
7
11
"repository" : " open-telemetry/opentelemetry-js" ,
8
12
"scripts" : {
9
13
"test" : " nyc ts-mocha -p tsconfig.json test/**/*.test.ts" ,
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import { ContextManager } from '@opentelemetry/context-base';
18
18
import { HttpTextPropagator } from '../context/propagation/HttpTextPropagator' ;
19
19
import { MeterProvider } from '../metrics/MeterProvider' ;
20
20
import { TracerProvider } from '../trace/tracer_provider' ;
21
+ import { _globalThis } from '../platform' ;
21
22
22
23
export const GLOBAL_CONTEXT_MANAGER_API_KEY = Symbol . for (
23
24
'io.opentelemetry.js.api.context'
@@ -31,14 +32,14 @@ export const GLOBAL_PROPAGATION_API_KEY = Symbol.for(
31
32
export const GLOBAL_TRACE_API_KEY = Symbol . for ( 'io.opentelemetry.js.api.trace' ) ;
32
33
33
34
type Get < T > = ( version : number ) => T ;
34
- type MyGlobals = Partial < {
35
+ type OtelGlobal = Partial < {
35
36
[ GLOBAL_CONTEXT_MANAGER_API_KEY ] : Get < ContextManager > ;
36
37
[ GLOBAL_METRICS_API_KEY ] : Get < MeterProvider > ;
37
38
[ GLOBAL_PROPAGATION_API_KEY ] : Get < HttpTextPropagator > ;
38
39
[ GLOBAL_TRACE_API_KEY ] : Get < TracerProvider > ;
39
40
} > ;
40
41
41
- export const _global = global as typeof global & MyGlobals ;
42
+ export const _global = _globalThis as OtelGlobal ;
42
43
43
44
/**
44
45
* Make a function which accepts a version integer and returns the instance of an API if the version
Original file line number Diff line number Diff line change
1
+ /*!
2
+ * Copyright 2020, 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
+ /** only globals that common to node and browsers are allowed */
18
+ // eslint-disable-next-line node/no-unsupported-features/es-builtins, no-undef
19
+ export const _globalThis = typeof globalThis === 'object' ? globalThis : window ;
Original file line number Diff line number Diff line change
1
+ /*!
2
+ * Copyright 2020, 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
+ export * from './globalThis' ;
Original file line number Diff line number Diff line change
1
+ /*!
2
+ * Copyright 2020, 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
+ export * from './node' ;
Original file line number Diff line number Diff line change
1
+ /*!
2
+ * Copyright 2020, 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
+ /** only globals that common to node and browsers are allowed */
18
+ // eslint-disable-next-line node/no-unsupported-features/es-builtins
19
+ export const _globalThis = typeof globalThis === 'object' ? globalThis : global ;
Original file line number Diff line number Diff line change
1
+ /*!
2
+ * Copyright 2020, 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
+ export * from './globalThis' ;
You can’t perform that action at this time.
0 commit comments