Update test framework: fix run_tests.py to support all test files, add auto-import-check for test files

This commit is contained in:
qiaoxinjiu
2026-05-09 15:11:30 +08:00
parent eb053a347f
commit eaba8328da
21739 changed files with 2236758 additions and 719 deletions

201
node_modules/@opentelemetry/propagator-b3/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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
http://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.

131
node_modules/@opentelemetry/propagator-b3/README.md generated vendored Normal file
View File

@@ -0,0 +1,131 @@
# OpenTelemetry Propagator B3
[![NPM Published Version][npm-img]][npm-url]
[![Apache License][license-image]][license-image]
The OpenTelemetry b3 propagator package provides multiple propagator
implementations for systems using the b3 context format. See the
[b3 specification][b3-spec] for complete details.
## B3 Formats
Single-Header Format:
```bash
b3: {TraceId}-{SpanId}-{SamplingState}-{ParentSpanId}
```
Multi-Header Format:
```bash
X-B3-TraceId: {TraceId}
X-B3-SpanId: {SpanId}
X-B3-ParentSpanId: {ParentSpanId}
X-B3-Sampled: {SamplingState}
```
- {TraceId}
- Required
- Encoded as 32 or 16 lower-hex characters
- 16 character traceIds will be converted to 32 characters by left-padding
with 0s to conform with the [OpenTelemetry specification][otel-spec-id-format]
- {SpanId}
- Required
- Encoded as 16 lower-hex characters
- {ParentSpanId}
- Optional
- Used to support the Zipkin functionality where the client and server spans
that make up an HTTP request share the same id
- Not propagated by this library
- {SamplingState} - Single-header
- Optional
- Valid values
- 1 - Accept
- 0 - Deny
- d - Debug
- Absent - Defer sampling decision
- {SamplingState} - Multi-header
- Optional
- Valid values
- 1 - Accept
- 0 - Deny
- {Flags} - Multi-header
- Optional
- Debug is encoded as `X-B3-Flags`: 1. Absent or any other value can be ignored. Debug implies an accept decision, so don't also send the `X-B3-Sampled` header.
## B3 Propagation
The default `B3Propagator` implements b3 propagation according to the
[OpenTelemetry specification][otel-b3-requirements]. It extracts b3 context
from multi and single header encodings and injects context using the
single-header b3 encoding by default. The inject encoding can be changed to
multi-header via configuration. See the examples below.
### B3 Single-Header Configuration
```javascript
const api = require('@opentelemetry/api');
const { B3Propagator } = require('@opentelemetry/propagator-b3');
api.propagation.setGlobalPropagator(new B3Propagator());
```
### B3 Multi-Header Configuration
```javascript
const api = require('@opentelemetry/api');
const { B3Propagator, B3InjectEncoding } = require('@opentelemetry/propagator-b3');
api.propagation.setGlobalPropagator(
new B3Propagator({ injectEncoding: B3InjectEncoding.MULTI_HEADER })
);
```
### B3 Single and Multi-Header Configuration
The B3Propagator always extracts both the single and multi-header b3 encodings.
If you need to inject both encodings this can accomplished using a composite
propagator.
```javascript
const api = require('@opentelemetry/api');
const { CompositePropagator } = require('@opentelemetry/core');
const { B3Propagator, B3InjectEncoding } = require('@opentelemetry/propagator-b3');
api.propagation.setGlobalPropagator(
new CompositePropagator({
propagators: [
new B3Propagator(),
new B3Propagator({ injectEncoding: B3InjectEncoding.MULTI_HEADER }),
],
})
);
```
## Useful links
- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
- For more about OpenTelemetry JavaScript: <https://github.com/open-telemetry/opentelemetry-js>
- For help or feedback on this project, join us in [GitHub Discussions][discussions-url]
## License
Apache 2.0 - See [LICENSE][license-url] for more information.
[discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions
[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/master/LICENSE
[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
[npm-url]: https://www.npmjs.com/package/@opentelemetry/propagator-b3
[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fpropagator-b3.svg
[b3-spec]: https://github.com/openzipkin/b3-propagation
[otel-b3-requirements]: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/context/api-propagators.md#b3-requirements
[otel-spec-id-format]: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/api.md#retrieving-the-traceid-and-spanid

View File

@@ -0,0 +1,11 @@
import { Context, TextMapGetter, TextMapPropagator, TextMapSetter } from '@opentelemetry/api';
/**
* Propagator for the B3 multiple-header HTTP format.
* Based on: https://github.com/openzipkin/b3-propagation
*/
export declare class B3MultiPropagator implements TextMapPropagator {
inject(context: Context, carrier: unknown, setter: TextMapSetter): void;
extract(context: Context, carrier: unknown, getter: TextMapGetter): Context;
fields(): string[];
}
//# sourceMappingURL=B3MultiPropagator.d.ts.map

View File

@@ -0,0 +1,117 @@
/*
* 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 { isSpanContextValid, isValidSpanId, isValidTraceId, trace, TraceFlags, } from '@opentelemetry/api';
import { isTracingSuppressed } from '@opentelemetry/core';
import { B3_DEBUG_FLAG_KEY } from './common';
import { X_B3_FLAGS, X_B3_PARENT_SPAN_ID, X_B3_SAMPLED, X_B3_SPAN_ID, X_B3_TRACE_ID, } from './constants';
const VALID_SAMPLED_VALUES = new Set([true, 'true', 'True', '1', 1]);
const VALID_UNSAMPLED_VALUES = new Set([false, 'false', 'False', '0', 0]);
function isValidSampledValue(sampled) {
return sampled === TraceFlags.SAMPLED || sampled === TraceFlags.NONE;
}
function parseHeader(header) {
return Array.isArray(header) ? header[0] : header;
}
function getHeaderValue(carrier, getter, key) {
const header = getter.get(carrier, key);
return parseHeader(header);
}
function getTraceId(carrier, getter) {
const traceId = getHeaderValue(carrier, getter, X_B3_TRACE_ID);
if (typeof traceId === 'string') {
return traceId.padStart(32, '0');
}
return '';
}
function getSpanId(carrier, getter) {
const spanId = getHeaderValue(carrier, getter, X_B3_SPAN_ID);
if (typeof spanId === 'string') {
return spanId;
}
return '';
}
function getDebug(carrier, getter) {
const debug = getHeaderValue(carrier, getter, X_B3_FLAGS);
return debug === '1' ? '1' : undefined;
}
function getTraceFlags(carrier, getter) {
const traceFlags = getHeaderValue(carrier, getter, X_B3_SAMPLED);
const debug = getDebug(carrier, getter);
if (debug === '1' || VALID_SAMPLED_VALUES.has(traceFlags)) {
return TraceFlags.SAMPLED;
}
if (traceFlags === undefined || VALID_UNSAMPLED_VALUES.has(traceFlags)) {
return TraceFlags.NONE;
}
// This indicates to isValidSampledValue that this is not valid
return;
}
/**
* Propagator for the B3 multiple-header HTTP format.
* Based on: https://github.com/openzipkin/b3-propagation
*/
export class B3MultiPropagator {
inject(context, carrier, setter) {
const spanContext = trace.getSpanContext(context);
if (!spanContext ||
!isSpanContextValid(spanContext) ||
isTracingSuppressed(context))
return;
const debug = context.getValue(B3_DEBUG_FLAG_KEY);
setter.set(carrier, X_B3_TRACE_ID, spanContext.traceId);
setter.set(carrier, X_B3_SPAN_ID, spanContext.spanId);
// According to the B3 spec, if the debug flag is set,
// the sampled flag shouldn't be propagated as well.
if (debug === '1') {
setter.set(carrier, X_B3_FLAGS, debug);
}
else if (spanContext.traceFlags !== undefined) {
// We set the header only if there is an existing sampling decision.
// Otherwise we will omit it => Absent.
setter.set(carrier, X_B3_SAMPLED, (TraceFlags.SAMPLED & spanContext.traceFlags) === TraceFlags.SAMPLED
? '1'
: '0');
}
}
extract(context, carrier, getter) {
const traceId = getTraceId(carrier, getter);
const spanId = getSpanId(carrier, getter);
const traceFlags = getTraceFlags(carrier, getter);
const debug = getDebug(carrier, getter);
if (isValidTraceId(traceId) &&
isValidSpanId(spanId) &&
isValidSampledValue(traceFlags)) {
context = context.setValue(B3_DEBUG_FLAG_KEY, debug);
return trace.setSpanContext(context, {
traceId,
spanId,
isRemote: true,
traceFlags,
});
}
return context;
}
fields() {
return [
X_B3_TRACE_ID,
X_B3_SPAN_ID,
X_B3_FLAGS,
X_B3_SAMPLED,
X_B3_PARENT_SPAN_ID,
];
}
}
//# sourceMappingURL=B3MultiPropagator.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,20 @@
import { Context, TextMapGetter, TextMapPropagator, TextMapSetter } from '@opentelemetry/api';
import { B3PropagatorConfig } from './types';
/**
* Propagator that extracts B3 context in both single and multi-header variants,
* with configurable injection format defaulting to B3 single-header. Due to
* the asymmetry in injection and extraction formats this is not suitable to
* be implemented as a composite propagator.
* Based on: https://github.com/openzipkin/b3-propagation
*/
export declare class B3Propagator implements TextMapPropagator {
private readonly _b3MultiPropagator;
private readonly _b3SinglePropagator;
private readonly _inject;
readonly _fields: string[];
constructor(config?: B3PropagatorConfig);
inject(context: Context, carrier: unknown, setter: TextMapSetter): void;
extract(context: Context, carrier: unknown, getter: TextMapGetter): Context;
fields(): string[];
}
//# sourceMappingURL=B3Propagator.d.ts.map

View File

@@ -0,0 +1,63 @@
/*
* 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 { isTracingSuppressed } from '@opentelemetry/core';
import { B3MultiPropagator } from './B3MultiPropagator';
import { B3SinglePropagator } from './B3SinglePropagator';
import { B3_CONTEXT_HEADER } from './constants';
import { B3InjectEncoding } from './types';
/**
* Propagator that extracts B3 context in both single and multi-header variants,
* with configurable injection format defaulting to B3 single-header. Due to
* the asymmetry in injection and extraction formats this is not suitable to
* be implemented as a composite propagator.
* Based on: https://github.com/openzipkin/b3-propagation
*/
export class B3Propagator {
_b3MultiPropagator = new B3MultiPropagator();
_b3SinglePropagator = new B3SinglePropagator();
_inject;
_fields;
constructor(config = {}) {
if (config.injectEncoding === B3InjectEncoding.MULTI_HEADER) {
this._inject = this._b3MultiPropagator.inject;
this._fields = this._b3MultiPropagator.fields();
}
else {
this._inject = this._b3SinglePropagator.inject;
this._fields = this._b3SinglePropagator.fields();
}
}
inject(context, carrier, setter) {
if (isTracingSuppressed(context)) {
return;
}
this._inject(context, carrier, setter);
}
extract(context, carrier, getter) {
const header = getter.get(carrier, B3_CONTEXT_HEADER);
const b3Context = Array.isArray(header) ? header[0] : header;
if (b3Context) {
return this._b3SinglePropagator.extract(context, carrier, getter);
}
else {
return this._b3MultiPropagator.extract(context, carrier, getter);
}
}
fields() {
return this._fields;
}
}
//# sourceMappingURL=B3Propagator.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"B3Propagator.js","sourceRoot":"","sources":["../../src/B3Propagator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAQH,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAsB,MAAM,SAAS,CAAC;AAE/D;;;;;;GAMG;AACH,MAAM,OAAO,YAAY;IACN,kBAAkB,GACjC,IAAI,iBAAiB,EAAE,CAAC;IACT,mBAAmB,GAClC,IAAI,kBAAkB,EAAE,CAAC;IACV,OAAO,CAId;IACM,OAAO,CAAW;IAElC,YAAY,SAA6B,EAAE;QACzC,IAAI,MAAM,CAAC,cAAc,KAAK,gBAAgB,CAAC,YAAY,EAAE;YAC3D,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC;YAC9C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,CAAC;SACjD;aAAM;YACL,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC;YAC/C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE,CAAC;SAClD;IACH,CAAC;IAED,MAAM,CAAC,OAAgB,EAAE,OAAgB,EAAE,MAAqB;QAC9D,IAAI,mBAAmB,CAAC,OAAO,CAAC,EAAE;YAChC,OAAO;SACR;QACD,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,CAAC,OAAgB,EAAE,OAAgB,EAAE,MAAqB;QAC/D,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;QACtD,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAE7D,IAAI,SAAS,EAAE;YACb,OAAO,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;SACnE;aAAM;YACL,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;SAClE;IACH,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n Context,\n TextMapGetter,\n TextMapPropagator,\n TextMapSetter,\n} from '@opentelemetry/api';\nimport { isTracingSuppressed } from '@opentelemetry/core';\nimport { B3MultiPropagator } from './B3MultiPropagator';\nimport { B3SinglePropagator } from './B3SinglePropagator';\nimport { B3_CONTEXT_HEADER } from './constants';\nimport { B3InjectEncoding, B3PropagatorConfig } from './types';\n\n/**\n * Propagator that extracts B3 context in both single and multi-header variants,\n * with configurable injection format defaulting to B3 single-header. Due to\n * the asymmetry in injection and extraction formats this is not suitable to\n * be implemented as a composite propagator.\n * Based on: https://github.com/openzipkin/b3-propagation\n */\nexport class B3Propagator implements TextMapPropagator {\n private readonly _b3MultiPropagator: B3MultiPropagator =\n new B3MultiPropagator();\n private readonly _b3SinglePropagator: B3SinglePropagator =\n new B3SinglePropagator();\n private readonly _inject: (\n context: Context,\n carrier: unknown,\n setter: TextMapSetter\n ) => void;\n public readonly _fields: string[];\n\n constructor(config: B3PropagatorConfig = {}) {\n if (config.injectEncoding === B3InjectEncoding.MULTI_HEADER) {\n this._inject = this._b3MultiPropagator.inject;\n this._fields = this._b3MultiPropagator.fields();\n } else {\n this._inject = this._b3SinglePropagator.inject;\n this._fields = this._b3SinglePropagator.fields();\n }\n }\n\n inject(context: Context, carrier: unknown, setter: TextMapSetter): void {\n if (isTracingSuppressed(context)) {\n return;\n }\n this._inject(context, carrier, setter);\n }\n\n extract(context: Context, carrier: unknown, getter: TextMapGetter): Context {\n const header = getter.get(carrier, B3_CONTEXT_HEADER);\n const b3Context = Array.isArray(header) ? header[0] : header;\n\n if (b3Context) {\n return this._b3SinglePropagator.extract(context, carrier, getter);\n } else {\n return this._b3MultiPropagator.extract(context, carrier, getter);\n }\n }\n\n fields(): string[] {\n return this._fields;\n }\n}\n"]}

View File

@@ -0,0 +1,11 @@
import { Context, TextMapGetter, TextMapPropagator, TextMapSetter } from '@opentelemetry/api';
/**
* Propagator for the B3 single-header HTTP format.
* Based on: https://github.com/openzipkin/b3-propagation
*/
export declare class B3SinglePropagator implements TextMapPropagator {
inject(context: Context, carrier: unknown, setter: TextMapSetter): void;
extract(context: Context, carrier: unknown, getter: TextMapGetter): Context;
fields(): string[];
}
//# sourceMappingURL=B3SinglePropagator.d.ts.map

View File

@@ -0,0 +1,75 @@
/*
* 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 { isSpanContextValid, isValidSpanId, isValidTraceId, trace, TraceFlags, } from '@opentelemetry/api';
import { isTracingSuppressed } from '@opentelemetry/core';
import { B3_DEBUG_FLAG_KEY } from './common';
import { B3_CONTEXT_HEADER } from './constants';
const B3_CONTEXT_REGEX = /((?:[0-9a-f]{16}){1,2})-([0-9a-f]{16})(?:-([01d](?![0-9a-f])))?(?:-([0-9a-f]{16}))?/;
const PADDING = '0'.repeat(16);
const SAMPLED_VALUES = new Set(['d', '1']);
const DEBUG_STATE = 'd';
function convertToTraceId128(traceId) {
return traceId.length === 32 ? traceId : `${PADDING}${traceId}`;
}
function convertToTraceFlags(samplingState) {
if (samplingState && SAMPLED_VALUES.has(samplingState)) {
return TraceFlags.SAMPLED;
}
return TraceFlags.NONE;
}
/**
* Propagator for the B3 single-header HTTP format.
* Based on: https://github.com/openzipkin/b3-propagation
*/
export class B3SinglePropagator {
inject(context, carrier, setter) {
const spanContext = trace.getSpanContext(context);
if (!spanContext ||
!isSpanContextValid(spanContext) ||
isTracingSuppressed(context))
return;
const samplingState = context.getValue(B3_DEBUG_FLAG_KEY) || spanContext.traceFlags & 0x1;
const value = `${spanContext.traceId}-${spanContext.spanId}-${samplingState}`;
setter.set(carrier, B3_CONTEXT_HEADER, value);
}
extract(context, carrier, getter) {
const header = getter.get(carrier, B3_CONTEXT_HEADER);
const b3Context = Array.isArray(header) ? header[0] : header;
if (typeof b3Context !== 'string')
return context;
const match = b3Context.match(B3_CONTEXT_REGEX);
if (!match)
return context;
const [, extractedTraceId, spanId, samplingState] = match;
const traceId = convertToTraceId128(extractedTraceId);
if (!isValidTraceId(traceId) || !isValidSpanId(spanId))
return context;
const traceFlags = convertToTraceFlags(samplingState);
if (samplingState === DEBUG_STATE) {
context = context.setValue(B3_DEBUG_FLAG_KEY, samplingState);
}
return trace.setSpanContext(context, {
traceId,
spanId,
isRemote: true,
traceFlags,
});
}
fields() {
return [B3_CONTEXT_HEADER];
}
}
//# sourceMappingURL=B3SinglePropagator.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
/** shared context for storing an extracted b3 debug flag */
export declare const B3_DEBUG_FLAG_KEY: symbol;
//# sourceMappingURL=common.d.ts.map

View File

@@ -0,0 +1,19 @@
/*
* 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 { createContextKey } from '@opentelemetry/api';
/** shared context for storing an extracted b3 debug flag */
export const B3_DEBUG_FLAG_KEY = createContextKey('OpenTelemetry Context Key B3 Debug Flag');
//# sourceMappingURL=common.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/common.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,4DAA4D;AAC5D,MAAM,CAAC,MAAM,iBAAiB,GAAG,gBAAgB,CAC/C,yCAAyC,CAC1C,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createContextKey } from '@opentelemetry/api';\n\n/** shared context for storing an extracted b3 debug flag */\nexport const B3_DEBUG_FLAG_KEY = createContextKey(\n 'OpenTelemetry Context Key B3 Debug Flag'\n);\n"]}

View File

@@ -0,0 +1,8 @@
/** B3 single-header key */
export declare const B3_CONTEXT_HEADER = "b3";
export declare const X_B3_TRACE_ID = "x-b3-traceid";
export declare const X_B3_SPAN_ID = "x-b3-spanid";
export declare const X_B3_SAMPLED = "x-b3-sampled";
export declare const X_B3_PARENT_SPAN_ID = "x-b3-parentspanid";
export declare const X_B3_FLAGS = "x-b3-flags";
//# sourceMappingURL=constants.d.ts.map

View File

@@ -0,0 +1,24 @@
/*
* 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.
*/
/** B3 single-header key */
export const B3_CONTEXT_HEADER = 'b3';
/* b3 multi-header keys */
export const X_B3_TRACE_ID = 'x-b3-traceid';
export const X_B3_SPAN_ID = 'x-b3-spanid';
export const X_B3_SAMPLED = 'x-b3-sampled';
export const X_B3_PARENT_SPAN_ID = 'x-b3-parentspanid';
export const X_B3_FLAGS = 'x-b3-flags';
//# sourceMappingURL=constants.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,2BAA2B;AAC3B,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAEtC,0BAA0B;AAC1B,MAAM,CAAC,MAAM,aAAa,GAAG,cAAc,CAAC;AAC5C,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC;AAC1C,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAC3C,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AACvD,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** B3 single-header key */\nexport const B3_CONTEXT_HEADER = 'b3';\n\n/* b3 multi-header keys */\nexport const X_B3_TRACE_ID = 'x-b3-traceid';\nexport const X_B3_SPAN_ID = 'x-b3-spanid';\nexport const X_B3_SAMPLED = 'x-b3-sampled';\nexport const X_B3_PARENT_SPAN_ID = 'x-b3-parentspanid';\nexport const X_B3_FLAGS = 'x-b3-flags';\n"]}

View File

@@ -0,0 +1,4 @@
export { B3Propagator } from './B3Propagator';
export { B3_CONTEXT_HEADER, X_B3_FLAGS, X_B3_PARENT_SPAN_ID, X_B3_SAMPLED, X_B3_SPAN_ID, X_B3_TRACE_ID, } from './constants';
export { B3InjectEncoding, B3PropagatorConfig } from './types';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1,19 @@
/*
* 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.
*/
export { B3Propagator } from './B3Propagator';
export { B3_CONTEXT_HEADER, X_B3_FLAGS, X_B3_PARENT_SPAN_ID, X_B3_SAMPLED, X_B3_SPAN_ID, X_B3_TRACE_ID, } from './constants';
export { B3InjectEncoding } from './types';
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAsB,MAAM,SAAS,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { B3Propagator } from './B3Propagator';\nexport {\n B3_CONTEXT_HEADER,\n X_B3_FLAGS,\n X_B3_PARENT_SPAN_ID,\n X_B3_SAMPLED,\n X_B3_SPAN_ID,\n X_B3_TRACE_ID,\n} from './constants';\nexport { B3InjectEncoding, B3PropagatorConfig } from './types';\n"]}

View File

@@ -0,0 +1,10 @@
/** Enumeration of B3 inject encodings */
export declare enum B3InjectEncoding {
SINGLE_HEADER = 0,
MULTI_HEADER = 1
}
/** Configuration for the B3Propagator */
export interface B3PropagatorConfig {
injectEncoding?: B3InjectEncoding;
}
//# sourceMappingURL=types.d.ts.map

View File

@@ -0,0 +1,22 @@
/*
* 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.
*/
/** Enumeration of B3 inject encodings */
export var B3InjectEncoding;
(function (B3InjectEncoding) {
B3InjectEncoding[B3InjectEncoding["SINGLE_HEADER"] = 0] = "SINGLE_HEADER";
B3InjectEncoding[B3InjectEncoding["MULTI_HEADER"] = 1] = "MULTI_HEADER";
})(B3InjectEncoding || (B3InjectEncoding = {}));
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,yCAAyC;AACzC,MAAM,CAAN,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,yEAAa,CAAA;IACb,uEAAY,CAAA;AACd,CAAC,EAHW,gBAAgB,KAAhB,gBAAgB,QAG3B","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** Enumeration of B3 inject encodings */\nexport enum B3InjectEncoding {\n SINGLE_HEADER,\n MULTI_HEADER,\n}\n\n/** Configuration for the B3Propagator */\nexport interface B3PropagatorConfig {\n injectEncoding?: B3InjectEncoding;\n}\n"]}

View File

@@ -0,0 +1,2 @@
export declare const VERSION = "2.0.0";
//# sourceMappingURL=version.d.ts.map

View File

@@ -0,0 +1,18 @@
/*
* 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.
*/
// this is autogenerated file, see scripts/version-update.js
export const VERSION = '2.0.0';
//# sourceMappingURL=version.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '2.0.0';\n"]}

View File

@@ -0,0 +1,11 @@
import { Context, TextMapGetter, TextMapPropagator, TextMapSetter } from '@opentelemetry/api';
/**
* Propagator for the B3 multiple-header HTTP format.
* Based on: https://github.com/openzipkin/b3-propagation
*/
export declare class B3MultiPropagator implements TextMapPropagator {
inject(context: Context, carrier: unknown, setter: TextMapSetter): void;
extract(context: Context, carrier: unknown, getter: TextMapGetter): Context;
fields(): string[];
}
//# sourceMappingURL=B3MultiPropagator.d.ts.map

View File

@@ -0,0 +1,117 @@
/*
* 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 { isSpanContextValid, isValidSpanId, isValidTraceId, trace, TraceFlags, } from '@opentelemetry/api';
import { isTracingSuppressed } from '@opentelemetry/core';
import { B3_DEBUG_FLAG_KEY } from './common';
import { X_B3_FLAGS, X_B3_PARENT_SPAN_ID, X_B3_SAMPLED, X_B3_SPAN_ID, X_B3_TRACE_ID, } from './constants';
const VALID_SAMPLED_VALUES = new Set([true, 'true', 'True', '1', 1]);
const VALID_UNSAMPLED_VALUES = new Set([false, 'false', 'False', '0', 0]);
function isValidSampledValue(sampled) {
return sampled === TraceFlags.SAMPLED || sampled === TraceFlags.NONE;
}
function parseHeader(header) {
return Array.isArray(header) ? header[0] : header;
}
function getHeaderValue(carrier, getter, key) {
const header = getter.get(carrier, key);
return parseHeader(header);
}
function getTraceId(carrier, getter) {
const traceId = getHeaderValue(carrier, getter, X_B3_TRACE_ID);
if (typeof traceId === 'string') {
return traceId.padStart(32, '0');
}
return '';
}
function getSpanId(carrier, getter) {
const spanId = getHeaderValue(carrier, getter, X_B3_SPAN_ID);
if (typeof spanId === 'string') {
return spanId;
}
return '';
}
function getDebug(carrier, getter) {
const debug = getHeaderValue(carrier, getter, X_B3_FLAGS);
return debug === '1' ? '1' : undefined;
}
function getTraceFlags(carrier, getter) {
const traceFlags = getHeaderValue(carrier, getter, X_B3_SAMPLED);
const debug = getDebug(carrier, getter);
if (debug === '1' || VALID_SAMPLED_VALUES.has(traceFlags)) {
return TraceFlags.SAMPLED;
}
if (traceFlags === undefined || VALID_UNSAMPLED_VALUES.has(traceFlags)) {
return TraceFlags.NONE;
}
// This indicates to isValidSampledValue that this is not valid
return;
}
/**
* Propagator for the B3 multiple-header HTTP format.
* Based on: https://github.com/openzipkin/b3-propagation
*/
export class B3MultiPropagator {
inject(context, carrier, setter) {
const spanContext = trace.getSpanContext(context);
if (!spanContext ||
!isSpanContextValid(spanContext) ||
isTracingSuppressed(context))
return;
const debug = context.getValue(B3_DEBUG_FLAG_KEY);
setter.set(carrier, X_B3_TRACE_ID, spanContext.traceId);
setter.set(carrier, X_B3_SPAN_ID, spanContext.spanId);
// According to the B3 spec, if the debug flag is set,
// the sampled flag shouldn't be propagated as well.
if (debug === '1') {
setter.set(carrier, X_B3_FLAGS, debug);
}
else if (spanContext.traceFlags !== undefined) {
// We set the header only if there is an existing sampling decision.
// Otherwise we will omit it => Absent.
setter.set(carrier, X_B3_SAMPLED, (TraceFlags.SAMPLED & spanContext.traceFlags) === TraceFlags.SAMPLED
? '1'
: '0');
}
}
extract(context, carrier, getter) {
const traceId = getTraceId(carrier, getter);
const spanId = getSpanId(carrier, getter);
const traceFlags = getTraceFlags(carrier, getter);
const debug = getDebug(carrier, getter);
if (isValidTraceId(traceId) &&
isValidSpanId(spanId) &&
isValidSampledValue(traceFlags)) {
context = context.setValue(B3_DEBUG_FLAG_KEY, debug);
return trace.setSpanContext(context, {
traceId,
spanId,
isRemote: true,
traceFlags,
});
}
return context;
}
fields() {
return [
X_B3_TRACE_ID,
X_B3_SPAN_ID,
X_B3_FLAGS,
X_B3_SAMPLED,
X_B3_PARENT_SPAN_ID,
];
}
}
//# sourceMappingURL=B3MultiPropagator.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,20 @@
import { Context, TextMapGetter, TextMapPropagator, TextMapSetter } from '@opentelemetry/api';
import { B3PropagatorConfig } from './types';
/**
* Propagator that extracts B3 context in both single and multi-header variants,
* with configurable injection format defaulting to B3 single-header. Due to
* the asymmetry in injection and extraction formats this is not suitable to
* be implemented as a composite propagator.
* Based on: https://github.com/openzipkin/b3-propagation
*/
export declare class B3Propagator implements TextMapPropagator {
private readonly _b3MultiPropagator;
private readonly _b3SinglePropagator;
private readonly _inject;
readonly _fields: string[];
constructor(config?: B3PropagatorConfig);
inject(context: Context, carrier: unknown, setter: TextMapSetter): void;
extract(context: Context, carrier: unknown, getter: TextMapGetter): Context;
fields(): string[];
}
//# sourceMappingURL=B3Propagator.d.ts.map

View File

@@ -0,0 +1,63 @@
/*
* 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 { isTracingSuppressed } from '@opentelemetry/core';
import { B3MultiPropagator } from './B3MultiPropagator';
import { B3SinglePropagator } from './B3SinglePropagator';
import { B3_CONTEXT_HEADER } from './constants';
import { B3InjectEncoding } from './types';
/**
* Propagator that extracts B3 context in both single and multi-header variants,
* with configurable injection format defaulting to B3 single-header. Due to
* the asymmetry in injection and extraction formats this is not suitable to
* be implemented as a composite propagator.
* Based on: https://github.com/openzipkin/b3-propagation
*/
export class B3Propagator {
_b3MultiPropagator = new B3MultiPropagator();
_b3SinglePropagator = new B3SinglePropagator();
_inject;
_fields;
constructor(config = {}) {
if (config.injectEncoding === B3InjectEncoding.MULTI_HEADER) {
this._inject = this._b3MultiPropagator.inject;
this._fields = this._b3MultiPropagator.fields();
}
else {
this._inject = this._b3SinglePropagator.inject;
this._fields = this._b3SinglePropagator.fields();
}
}
inject(context, carrier, setter) {
if (isTracingSuppressed(context)) {
return;
}
this._inject(context, carrier, setter);
}
extract(context, carrier, getter) {
const header = getter.get(carrier, B3_CONTEXT_HEADER);
const b3Context = Array.isArray(header) ? header[0] : header;
if (b3Context) {
return this._b3SinglePropagator.extract(context, carrier, getter);
}
else {
return this._b3MultiPropagator.extract(context, carrier, getter);
}
}
fields() {
return this._fields;
}
}
//# sourceMappingURL=B3Propagator.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"B3Propagator.js","sourceRoot":"","sources":["../../src/B3Propagator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAQH,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAsB,MAAM,SAAS,CAAC;AAE/D;;;;;;GAMG;AACH,MAAM,OAAO,YAAY;IACN,kBAAkB,GACjC,IAAI,iBAAiB,EAAE,CAAC;IACT,mBAAmB,GAClC,IAAI,kBAAkB,EAAE,CAAC;IACV,OAAO,CAId;IACM,OAAO,CAAW;IAElC,YAAY,SAA6B,EAAE;QACzC,IAAI,MAAM,CAAC,cAAc,KAAK,gBAAgB,CAAC,YAAY,EAAE;YAC3D,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC;YAC9C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,CAAC;SACjD;aAAM;YACL,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC;YAC/C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE,CAAC;SAClD;IACH,CAAC;IAED,MAAM,CAAC,OAAgB,EAAE,OAAgB,EAAE,MAAqB;QAC9D,IAAI,mBAAmB,CAAC,OAAO,CAAC,EAAE;YAChC,OAAO;SACR;QACD,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,CAAC,OAAgB,EAAE,OAAgB,EAAE,MAAqB;QAC/D,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;QACtD,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAE7D,IAAI,SAAS,EAAE;YACb,OAAO,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;SACnE;aAAM;YACL,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;SAClE;IACH,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n Context,\n TextMapGetter,\n TextMapPropagator,\n TextMapSetter,\n} from '@opentelemetry/api';\nimport { isTracingSuppressed } from '@opentelemetry/core';\nimport { B3MultiPropagator } from './B3MultiPropagator';\nimport { B3SinglePropagator } from './B3SinglePropagator';\nimport { B3_CONTEXT_HEADER } from './constants';\nimport { B3InjectEncoding, B3PropagatorConfig } from './types';\n\n/**\n * Propagator that extracts B3 context in both single and multi-header variants,\n * with configurable injection format defaulting to B3 single-header. Due to\n * the asymmetry in injection and extraction formats this is not suitable to\n * be implemented as a composite propagator.\n * Based on: https://github.com/openzipkin/b3-propagation\n */\nexport class B3Propagator implements TextMapPropagator {\n private readonly _b3MultiPropagator: B3MultiPropagator =\n new B3MultiPropagator();\n private readonly _b3SinglePropagator: B3SinglePropagator =\n new B3SinglePropagator();\n private readonly _inject: (\n context: Context,\n carrier: unknown,\n setter: TextMapSetter\n ) => void;\n public readonly _fields: string[];\n\n constructor(config: B3PropagatorConfig = {}) {\n if (config.injectEncoding === B3InjectEncoding.MULTI_HEADER) {\n this._inject = this._b3MultiPropagator.inject;\n this._fields = this._b3MultiPropagator.fields();\n } else {\n this._inject = this._b3SinglePropagator.inject;\n this._fields = this._b3SinglePropagator.fields();\n }\n }\n\n inject(context: Context, carrier: unknown, setter: TextMapSetter): void {\n if (isTracingSuppressed(context)) {\n return;\n }\n this._inject(context, carrier, setter);\n }\n\n extract(context: Context, carrier: unknown, getter: TextMapGetter): Context {\n const header = getter.get(carrier, B3_CONTEXT_HEADER);\n const b3Context = Array.isArray(header) ? header[0] : header;\n\n if (b3Context) {\n return this._b3SinglePropagator.extract(context, carrier, getter);\n } else {\n return this._b3MultiPropagator.extract(context, carrier, getter);\n }\n }\n\n fields(): string[] {\n return this._fields;\n }\n}\n"]}

View File

@@ -0,0 +1,11 @@
import { Context, TextMapGetter, TextMapPropagator, TextMapSetter } from '@opentelemetry/api';
/**
* Propagator for the B3 single-header HTTP format.
* Based on: https://github.com/openzipkin/b3-propagation
*/
export declare class B3SinglePropagator implements TextMapPropagator {
inject(context: Context, carrier: unknown, setter: TextMapSetter): void;
extract(context: Context, carrier: unknown, getter: TextMapGetter): Context;
fields(): string[];
}
//# sourceMappingURL=B3SinglePropagator.d.ts.map

View File

@@ -0,0 +1,75 @@
/*
* 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 { isSpanContextValid, isValidSpanId, isValidTraceId, trace, TraceFlags, } from '@opentelemetry/api';
import { isTracingSuppressed } from '@opentelemetry/core';
import { B3_DEBUG_FLAG_KEY } from './common';
import { B3_CONTEXT_HEADER } from './constants';
const B3_CONTEXT_REGEX = /((?:[0-9a-f]{16}){1,2})-([0-9a-f]{16})(?:-([01d](?![0-9a-f])))?(?:-([0-9a-f]{16}))?/;
const PADDING = '0'.repeat(16);
const SAMPLED_VALUES = new Set(['d', '1']);
const DEBUG_STATE = 'd';
function convertToTraceId128(traceId) {
return traceId.length === 32 ? traceId : `${PADDING}${traceId}`;
}
function convertToTraceFlags(samplingState) {
if (samplingState && SAMPLED_VALUES.has(samplingState)) {
return TraceFlags.SAMPLED;
}
return TraceFlags.NONE;
}
/**
* Propagator for the B3 single-header HTTP format.
* Based on: https://github.com/openzipkin/b3-propagation
*/
export class B3SinglePropagator {
inject(context, carrier, setter) {
const spanContext = trace.getSpanContext(context);
if (!spanContext ||
!isSpanContextValid(spanContext) ||
isTracingSuppressed(context))
return;
const samplingState = context.getValue(B3_DEBUG_FLAG_KEY) || spanContext.traceFlags & 0x1;
const value = `${spanContext.traceId}-${spanContext.spanId}-${samplingState}`;
setter.set(carrier, B3_CONTEXT_HEADER, value);
}
extract(context, carrier, getter) {
const header = getter.get(carrier, B3_CONTEXT_HEADER);
const b3Context = Array.isArray(header) ? header[0] : header;
if (typeof b3Context !== 'string')
return context;
const match = b3Context.match(B3_CONTEXT_REGEX);
if (!match)
return context;
const [, extractedTraceId, spanId, samplingState] = match;
const traceId = convertToTraceId128(extractedTraceId);
if (!isValidTraceId(traceId) || !isValidSpanId(spanId))
return context;
const traceFlags = convertToTraceFlags(samplingState);
if (samplingState === DEBUG_STATE) {
context = context.setValue(B3_DEBUG_FLAG_KEY, samplingState);
}
return trace.setSpanContext(context, {
traceId,
spanId,
isRemote: true,
traceFlags,
});
}
fields() {
return [B3_CONTEXT_HEADER];
}
}
//# sourceMappingURL=B3SinglePropagator.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
/** shared context for storing an extracted b3 debug flag */
export declare const B3_DEBUG_FLAG_KEY: symbol;
//# sourceMappingURL=common.d.ts.map

View File

@@ -0,0 +1,19 @@
/*
* 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 { createContextKey } from '@opentelemetry/api';
/** shared context for storing an extracted b3 debug flag */
export const B3_DEBUG_FLAG_KEY = createContextKey('OpenTelemetry Context Key B3 Debug Flag');
//# sourceMappingURL=common.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/common.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,4DAA4D;AAC5D,MAAM,CAAC,MAAM,iBAAiB,GAAG,gBAAgB,CAC/C,yCAAyC,CAC1C,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createContextKey } from '@opentelemetry/api';\n\n/** shared context for storing an extracted b3 debug flag */\nexport const B3_DEBUG_FLAG_KEY = createContextKey(\n 'OpenTelemetry Context Key B3 Debug Flag'\n);\n"]}

View File

@@ -0,0 +1,8 @@
/** B3 single-header key */
export declare const B3_CONTEXT_HEADER = "b3";
export declare const X_B3_TRACE_ID = "x-b3-traceid";
export declare const X_B3_SPAN_ID = "x-b3-spanid";
export declare const X_B3_SAMPLED = "x-b3-sampled";
export declare const X_B3_PARENT_SPAN_ID = "x-b3-parentspanid";
export declare const X_B3_FLAGS = "x-b3-flags";
//# sourceMappingURL=constants.d.ts.map

View File

@@ -0,0 +1,24 @@
/*
* 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.
*/
/** B3 single-header key */
export const B3_CONTEXT_HEADER = 'b3';
/* b3 multi-header keys */
export const X_B3_TRACE_ID = 'x-b3-traceid';
export const X_B3_SPAN_ID = 'x-b3-spanid';
export const X_B3_SAMPLED = 'x-b3-sampled';
export const X_B3_PARENT_SPAN_ID = 'x-b3-parentspanid';
export const X_B3_FLAGS = 'x-b3-flags';
//# sourceMappingURL=constants.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,2BAA2B;AAC3B,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAEtC,0BAA0B;AAC1B,MAAM,CAAC,MAAM,aAAa,GAAG,cAAc,CAAC;AAC5C,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC;AAC1C,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAC3C,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AACvD,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** B3 single-header key */\nexport const B3_CONTEXT_HEADER = 'b3';\n\n/* b3 multi-header keys */\nexport const X_B3_TRACE_ID = 'x-b3-traceid';\nexport const X_B3_SPAN_ID = 'x-b3-spanid';\nexport const X_B3_SAMPLED = 'x-b3-sampled';\nexport const X_B3_PARENT_SPAN_ID = 'x-b3-parentspanid';\nexport const X_B3_FLAGS = 'x-b3-flags';\n"]}

View File

@@ -0,0 +1,4 @@
export { B3Propagator } from './B3Propagator';
export { B3_CONTEXT_HEADER, X_B3_FLAGS, X_B3_PARENT_SPAN_ID, X_B3_SAMPLED, X_B3_SPAN_ID, X_B3_TRACE_ID, } from './constants';
export { B3InjectEncoding, B3PropagatorConfig } from './types';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1,19 @@
/*
* 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.
*/
export { B3Propagator } from './B3Propagator';
export { B3_CONTEXT_HEADER, X_B3_FLAGS, X_B3_PARENT_SPAN_ID, X_B3_SAMPLED, X_B3_SPAN_ID, X_B3_TRACE_ID, } from './constants';
export { B3InjectEncoding } from './types';
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAsB,MAAM,SAAS,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { B3Propagator } from './B3Propagator';\nexport {\n B3_CONTEXT_HEADER,\n X_B3_FLAGS,\n X_B3_PARENT_SPAN_ID,\n X_B3_SAMPLED,\n X_B3_SPAN_ID,\n X_B3_TRACE_ID,\n} from './constants';\nexport { B3InjectEncoding, B3PropagatorConfig } from './types';\n"]}

View File

@@ -0,0 +1,10 @@
/** Enumeration of B3 inject encodings */
export declare enum B3InjectEncoding {
SINGLE_HEADER = 0,
MULTI_HEADER = 1
}
/** Configuration for the B3Propagator */
export interface B3PropagatorConfig {
injectEncoding?: B3InjectEncoding;
}
//# sourceMappingURL=types.d.ts.map

View File

@@ -0,0 +1,22 @@
/*
* 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.
*/
/** Enumeration of B3 inject encodings */
export var B3InjectEncoding;
(function (B3InjectEncoding) {
B3InjectEncoding[B3InjectEncoding["SINGLE_HEADER"] = 0] = "SINGLE_HEADER";
B3InjectEncoding[B3InjectEncoding["MULTI_HEADER"] = 1] = "MULTI_HEADER";
})(B3InjectEncoding || (B3InjectEncoding = {}));
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,yCAAyC;AACzC,MAAM,CAAN,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,yEAAa,CAAA;IACb,uEAAY,CAAA;AACd,CAAC,EAHW,gBAAgB,KAAhB,gBAAgB,QAG3B","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** Enumeration of B3 inject encodings */\nexport enum B3InjectEncoding {\n SINGLE_HEADER,\n MULTI_HEADER,\n}\n\n/** Configuration for the B3Propagator */\nexport interface B3PropagatorConfig {\n injectEncoding?: B3InjectEncoding;\n}\n"]}

View File

@@ -0,0 +1,2 @@
export declare const VERSION = "2.0.0";
//# sourceMappingURL=version.d.ts.map

View File

@@ -0,0 +1,18 @@
/*
* 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.
*/
// this is autogenerated file, see scripts/version-update.js
export const VERSION = '2.0.0';
//# sourceMappingURL=version.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '2.0.0';\n"]}

View File

@@ -0,0 +1,11 @@
import { Context, TextMapGetter, TextMapPropagator, TextMapSetter } from '@opentelemetry/api';
/**
* Propagator for the B3 multiple-header HTTP format.
* Based on: https://github.com/openzipkin/b3-propagation
*/
export declare class B3MultiPropagator implements TextMapPropagator {
inject(context: Context, carrier: unknown, setter: TextMapSetter): void;
extract(context: Context, carrier: unknown, getter: TextMapGetter): Context;
fields(): string[];
}
//# sourceMappingURL=B3MultiPropagator.d.ts.map

View File

@@ -0,0 +1,121 @@
"use strict";
/*
* 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.B3MultiPropagator = void 0;
const api_1 = require("@opentelemetry/api");
const core_1 = require("@opentelemetry/core");
const common_1 = require("./common");
const constants_1 = require("./constants");
const VALID_SAMPLED_VALUES = new Set([true, 'true', 'True', '1', 1]);
const VALID_UNSAMPLED_VALUES = new Set([false, 'false', 'False', '0', 0]);
function isValidSampledValue(sampled) {
return sampled === api_1.TraceFlags.SAMPLED || sampled === api_1.TraceFlags.NONE;
}
function parseHeader(header) {
return Array.isArray(header) ? header[0] : header;
}
function getHeaderValue(carrier, getter, key) {
const header = getter.get(carrier, key);
return parseHeader(header);
}
function getTraceId(carrier, getter) {
const traceId = getHeaderValue(carrier, getter, constants_1.X_B3_TRACE_ID);
if (typeof traceId === 'string') {
return traceId.padStart(32, '0');
}
return '';
}
function getSpanId(carrier, getter) {
const spanId = getHeaderValue(carrier, getter, constants_1.X_B3_SPAN_ID);
if (typeof spanId === 'string') {
return spanId;
}
return '';
}
function getDebug(carrier, getter) {
const debug = getHeaderValue(carrier, getter, constants_1.X_B3_FLAGS);
return debug === '1' ? '1' : undefined;
}
function getTraceFlags(carrier, getter) {
const traceFlags = getHeaderValue(carrier, getter, constants_1.X_B3_SAMPLED);
const debug = getDebug(carrier, getter);
if (debug === '1' || VALID_SAMPLED_VALUES.has(traceFlags)) {
return api_1.TraceFlags.SAMPLED;
}
if (traceFlags === undefined || VALID_UNSAMPLED_VALUES.has(traceFlags)) {
return api_1.TraceFlags.NONE;
}
// This indicates to isValidSampledValue that this is not valid
return;
}
/**
* Propagator for the B3 multiple-header HTTP format.
* Based on: https://github.com/openzipkin/b3-propagation
*/
class B3MultiPropagator {
inject(context, carrier, setter) {
const spanContext = api_1.trace.getSpanContext(context);
if (!spanContext ||
!(0, api_1.isSpanContextValid)(spanContext) ||
(0, core_1.isTracingSuppressed)(context))
return;
const debug = context.getValue(common_1.B3_DEBUG_FLAG_KEY);
setter.set(carrier, constants_1.X_B3_TRACE_ID, spanContext.traceId);
setter.set(carrier, constants_1.X_B3_SPAN_ID, spanContext.spanId);
// According to the B3 spec, if the debug flag is set,
// the sampled flag shouldn't be propagated as well.
if (debug === '1') {
setter.set(carrier, constants_1.X_B3_FLAGS, debug);
}
else if (spanContext.traceFlags !== undefined) {
// We set the header only if there is an existing sampling decision.
// Otherwise we will omit it => Absent.
setter.set(carrier, constants_1.X_B3_SAMPLED, (api_1.TraceFlags.SAMPLED & spanContext.traceFlags) === api_1.TraceFlags.SAMPLED
? '1'
: '0');
}
}
extract(context, carrier, getter) {
const traceId = getTraceId(carrier, getter);
const spanId = getSpanId(carrier, getter);
const traceFlags = getTraceFlags(carrier, getter);
const debug = getDebug(carrier, getter);
if ((0, api_1.isValidTraceId)(traceId) &&
(0, api_1.isValidSpanId)(spanId) &&
isValidSampledValue(traceFlags)) {
context = context.setValue(common_1.B3_DEBUG_FLAG_KEY, debug);
return api_1.trace.setSpanContext(context, {
traceId,
spanId,
isRemote: true,
traceFlags,
});
}
return context;
}
fields() {
return [
constants_1.X_B3_TRACE_ID,
constants_1.X_B3_SPAN_ID,
constants_1.X_B3_FLAGS,
constants_1.X_B3_SAMPLED,
constants_1.X_B3_PARENT_SPAN_ID,
];
}
}
exports.B3MultiPropagator = B3MultiPropagator;
//# sourceMappingURL=B3MultiPropagator.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,20 @@
import { Context, TextMapGetter, TextMapPropagator, TextMapSetter } from '@opentelemetry/api';
import { B3PropagatorConfig } from './types';
/**
* Propagator that extracts B3 context in both single and multi-header variants,
* with configurable injection format defaulting to B3 single-header. Due to
* the asymmetry in injection and extraction formats this is not suitable to
* be implemented as a composite propagator.
* Based on: https://github.com/openzipkin/b3-propagation
*/
export declare class B3Propagator implements TextMapPropagator {
private readonly _b3MultiPropagator;
private readonly _b3SinglePropagator;
private readonly _inject;
readonly _fields: string[];
constructor(config?: B3PropagatorConfig);
inject(context: Context, carrier: unknown, setter: TextMapSetter): void;
extract(context: Context, carrier: unknown, getter: TextMapGetter): Context;
fields(): string[];
}
//# sourceMappingURL=B3Propagator.d.ts.map

View File

@@ -0,0 +1,67 @@
"use strict";
/*
* 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.B3Propagator = void 0;
const core_1 = require("@opentelemetry/core");
const B3MultiPropagator_1 = require("./B3MultiPropagator");
const B3SinglePropagator_1 = require("./B3SinglePropagator");
const constants_1 = require("./constants");
const types_1 = require("./types");
/**
* Propagator that extracts B3 context in both single and multi-header variants,
* with configurable injection format defaulting to B3 single-header. Due to
* the asymmetry in injection and extraction formats this is not suitable to
* be implemented as a composite propagator.
* Based on: https://github.com/openzipkin/b3-propagation
*/
class B3Propagator {
_b3MultiPropagator = new B3MultiPropagator_1.B3MultiPropagator();
_b3SinglePropagator = new B3SinglePropagator_1.B3SinglePropagator();
_inject;
_fields;
constructor(config = {}) {
if (config.injectEncoding === types_1.B3InjectEncoding.MULTI_HEADER) {
this._inject = this._b3MultiPropagator.inject;
this._fields = this._b3MultiPropagator.fields();
}
else {
this._inject = this._b3SinglePropagator.inject;
this._fields = this._b3SinglePropagator.fields();
}
}
inject(context, carrier, setter) {
if ((0, core_1.isTracingSuppressed)(context)) {
return;
}
this._inject(context, carrier, setter);
}
extract(context, carrier, getter) {
const header = getter.get(carrier, constants_1.B3_CONTEXT_HEADER);
const b3Context = Array.isArray(header) ? header[0] : header;
if (b3Context) {
return this._b3SinglePropagator.extract(context, carrier, getter);
}
else {
return this._b3MultiPropagator.extract(context, carrier, getter);
}
}
fields() {
return this._fields;
}
}
exports.B3Propagator = B3Propagator;
//# sourceMappingURL=B3Propagator.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"B3Propagator.js","sourceRoot":"","sources":["../../src/B3Propagator.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAQH,8CAA0D;AAC1D,2DAAwD;AACxD,6DAA0D;AAC1D,2CAAgD;AAChD,mCAA+D;AAE/D;;;;;;GAMG;AACH,MAAa,YAAY;IACN,kBAAkB,GACjC,IAAI,qCAAiB,EAAE,CAAC;IACT,mBAAmB,GAClC,IAAI,uCAAkB,EAAE,CAAC;IACV,OAAO,CAId;IACM,OAAO,CAAW;IAElC,YAAY,SAA6B,EAAE;QACzC,IAAI,MAAM,CAAC,cAAc,KAAK,wBAAgB,CAAC,YAAY,EAAE;YAC3D,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC;YAC9C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,CAAC;SACjD;aAAM;YACL,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC;YAC/C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE,CAAC;SAClD;IACH,CAAC;IAED,MAAM,CAAC,OAAgB,EAAE,OAAgB,EAAE,MAAqB;QAC9D,IAAI,IAAA,0BAAmB,EAAC,OAAO,CAAC,EAAE;YAChC,OAAO;SACR;QACD,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,CAAC,OAAgB,EAAE,OAAgB,EAAE,MAAqB;QAC/D,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,6BAAiB,CAAC,CAAC;QACtD,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAE7D,IAAI,SAAS,EAAE;YACb,OAAO,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;SACnE;aAAM;YACL,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;SAClE;IACH,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AA3CD,oCA2CC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n Context,\n TextMapGetter,\n TextMapPropagator,\n TextMapSetter,\n} from '@opentelemetry/api';\nimport { isTracingSuppressed } from '@opentelemetry/core';\nimport { B3MultiPropagator } from './B3MultiPropagator';\nimport { B3SinglePropagator } from './B3SinglePropagator';\nimport { B3_CONTEXT_HEADER } from './constants';\nimport { B3InjectEncoding, B3PropagatorConfig } from './types';\n\n/**\n * Propagator that extracts B3 context in both single and multi-header variants,\n * with configurable injection format defaulting to B3 single-header. Due to\n * the asymmetry in injection and extraction formats this is not suitable to\n * be implemented as a composite propagator.\n * Based on: https://github.com/openzipkin/b3-propagation\n */\nexport class B3Propagator implements TextMapPropagator {\n private readonly _b3MultiPropagator: B3MultiPropagator =\n new B3MultiPropagator();\n private readonly _b3SinglePropagator: B3SinglePropagator =\n new B3SinglePropagator();\n private readonly _inject: (\n context: Context,\n carrier: unknown,\n setter: TextMapSetter\n ) => void;\n public readonly _fields: string[];\n\n constructor(config: B3PropagatorConfig = {}) {\n if (config.injectEncoding === B3InjectEncoding.MULTI_HEADER) {\n this._inject = this._b3MultiPropagator.inject;\n this._fields = this._b3MultiPropagator.fields();\n } else {\n this._inject = this._b3SinglePropagator.inject;\n this._fields = this._b3SinglePropagator.fields();\n }\n }\n\n inject(context: Context, carrier: unknown, setter: TextMapSetter): void {\n if (isTracingSuppressed(context)) {\n return;\n }\n this._inject(context, carrier, setter);\n }\n\n extract(context: Context, carrier: unknown, getter: TextMapGetter): Context {\n const header = getter.get(carrier, B3_CONTEXT_HEADER);\n const b3Context = Array.isArray(header) ? header[0] : header;\n\n if (b3Context) {\n return this._b3SinglePropagator.extract(context, carrier, getter);\n } else {\n return this._b3MultiPropagator.extract(context, carrier, getter);\n }\n }\n\n fields(): string[] {\n return this._fields;\n }\n}\n"]}

View File

@@ -0,0 +1,11 @@
import { Context, TextMapGetter, TextMapPropagator, TextMapSetter } from '@opentelemetry/api';
/**
* Propagator for the B3 single-header HTTP format.
* Based on: https://github.com/openzipkin/b3-propagation
*/
export declare class B3SinglePropagator implements TextMapPropagator {
inject(context: Context, carrier: unknown, setter: TextMapSetter): void;
extract(context: Context, carrier: unknown, getter: TextMapGetter): Context;
fields(): string[];
}
//# sourceMappingURL=B3SinglePropagator.d.ts.map

View File

@@ -0,0 +1,79 @@
"use strict";
/*
* 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.B3SinglePropagator = void 0;
const api_1 = require("@opentelemetry/api");
const core_1 = require("@opentelemetry/core");
const common_1 = require("./common");
const constants_1 = require("./constants");
const B3_CONTEXT_REGEX = /((?:[0-9a-f]{16}){1,2})-([0-9a-f]{16})(?:-([01d](?![0-9a-f])))?(?:-([0-9a-f]{16}))?/;
const PADDING = '0'.repeat(16);
const SAMPLED_VALUES = new Set(['d', '1']);
const DEBUG_STATE = 'd';
function convertToTraceId128(traceId) {
return traceId.length === 32 ? traceId : `${PADDING}${traceId}`;
}
function convertToTraceFlags(samplingState) {
if (samplingState && SAMPLED_VALUES.has(samplingState)) {
return api_1.TraceFlags.SAMPLED;
}
return api_1.TraceFlags.NONE;
}
/**
* Propagator for the B3 single-header HTTP format.
* Based on: https://github.com/openzipkin/b3-propagation
*/
class B3SinglePropagator {
inject(context, carrier, setter) {
const spanContext = api_1.trace.getSpanContext(context);
if (!spanContext ||
!(0, api_1.isSpanContextValid)(spanContext) ||
(0, core_1.isTracingSuppressed)(context))
return;
const samplingState = context.getValue(common_1.B3_DEBUG_FLAG_KEY) || spanContext.traceFlags & 0x1;
const value = `${spanContext.traceId}-${spanContext.spanId}-${samplingState}`;
setter.set(carrier, constants_1.B3_CONTEXT_HEADER, value);
}
extract(context, carrier, getter) {
const header = getter.get(carrier, constants_1.B3_CONTEXT_HEADER);
const b3Context = Array.isArray(header) ? header[0] : header;
if (typeof b3Context !== 'string')
return context;
const match = b3Context.match(B3_CONTEXT_REGEX);
if (!match)
return context;
const [, extractedTraceId, spanId, samplingState] = match;
const traceId = convertToTraceId128(extractedTraceId);
if (!(0, api_1.isValidTraceId)(traceId) || !(0, api_1.isValidSpanId)(spanId))
return context;
const traceFlags = convertToTraceFlags(samplingState);
if (samplingState === DEBUG_STATE) {
context = context.setValue(common_1.B3_DEBUG_FLAG_KEY, samplingState);
}
return api_1.trace.setSpanContext(context, {
traceId,
spanId,
isRemote: true,
traceFlags,
});
}
fields() {
return [constants_1.B3_CONTEXT_HEADER];
}
}
exports.B3SinglePropagator = B3SinglePropagator;
//# sourceMappingURL=B3SinglePropagator.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
/** shared context for storing an extracted b3 debug flag */
export declare const B3_DEBUG_FLAG_KEY: symbol;
//# sourceMappingURL=common.d.ts.map

View File

@@ -0,0 +1,22 @@
"use strict";
/*
* 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.B3_DEBUG_FLAG_KEY = void 0;
const api_1 = require("@opentelemetry/api");
/** shared context for storing an extracted b3 debug flag */
exports.B3_DEBUG_FLAG_KEY = (0, api_1.createContextKey)('OpenTelemetry Context Key B3 Debug Flag');
//# sourceMappingURL=common.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/common.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAAsD;AAEtD,4DAA4D;AAC/C,QAAA,iBAAiB,GAAG,IAAA,sBAAgB,EAC/C,yCAAyC,CAC1C,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createContextKey } from '@opentelemetry/api';\n\n/** shared context for storing an extracted b3 debug flag */\nexport const B3_DEBUG_FLAG_KEY = createContextKey(\n 'OpenTelemetry Context Key B3 Debug Flag'\n);\n"]}

View File

@@ -0,0 +1,8 @@
/** B3 single-header key */
export declare const B3_CONTEXT_HEADER = "b3";
export declare const X_B3_TRACE_ID = "x-b3-traceid";
export declare const X_B3_SPAN_ID = "x-b3-spanid";
export declare const X_B3_SAMPLED = "x-b3-sampled";
export declare const X_B3_PARENT_SPAN_ID = "x-b3-parentspanid";
export declare const X_B3_FLAGS = "x-b3-flags";
//# sourceMappingURL=constants.d.ts.map

View File

@@ -0,0 +1,27 @@
"use strict";
/*
* 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.X_B3_FLAGS = exports.X_B3_PARENT_SPAN_ID = exports.X_B3_SAMPLED = exports.X_B3_SPAN_ID = exports.X_B3_TRACE_ID = exports.B3_CONTEXT_HEADER = void 0;
/** B3 single-header key */
exports.B3_CONTEXT_HEADER = 'b3';
/* b3 multi-header keys */
exports.X_B3_TRACE_ID = 'x-b3-traceid';
exports.X_B3_SPAN_ID = 'x-b3-spanid';
exports.X_B3_SAMPLED = 'x-b3-sampled';
exports.X_B3_PARENT_SPAN_ID = 'x-b3-parentspanid';
exports.X_B3_FLAGS = 'x-b3-flags';
//# sourceMappingURL=constants.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,2BAA2B;AACd,QAAA,iBAAiB,GAAG,IAAI,CAAC;AAEtC,0BAA0B;AACb,QAAA,aAAa,GAAG,cAAc,CAAC;AAC/B,QAAA,YAAY,GAAG,aAAa,CAAC;AAC7B,QAAA,YAAY,GAAG,cAAc,CAAC;AAC9B,QAAA,mBAAmB,GAAG,mBAAmB,CAAC;AAC1C,QAAA,UAAU,GAAG,YAAY,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** B3 single-header key */\nexport const B3_CONTEXT_HEADER = 'b3';\n\n/* b3 multi-header keys */\nexport const X_B3_TRACE_ID = 'x-b3-traceid';\nexport const X_B3_SPAN_ID = 'x-b3-spanid';\nexport const X_B3_SAMPLED = 'x-b3-sampled';\nexport const X_B3_PARENT_SPAN_ID = 'x-b3-parentspanid';\nexport const X_B3_FLAGS = 'x-b3-flags';\n"]}

View File

@@ -0,0 +1,4 @@
export { B3Propagator } from './B3Propagator';
export { B3_CONTEXT_HEADER, X_B3_FLAGS, X_B3_PARENT_SPAN_ID, X_B3_SAMPLED, X_B3_SPAN_ID, X_B3_TRACE_ID, } from './constants';
export { B3InjectEncoding, B3PropagatorConfig } from './types';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1,30 @@
"use strict";
/*
* 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.B3InjectEncoding = exports.X_B3_TRACE_ID = exports.X_B3_SPAN_ID = exports.X_B3_SAMPLED = exports.X_B3_PARENT_SPAN_ID = exports.X_B3_FLAGS = exports.B3_CONTEXT_HEADER = exports.B3Propagator = void 0;
var B3Propagator_1 = require("./B3Propagator");
Object.defineProperty(exports, "B3Propagator", { enumerable: true, get: function () { return B3Propagator_1.B3Propagator; } });
var constants_1 = require("./constants");
Object.defineProperty(exports, "B3_CONTEXT_HEADER", { enumerable: true, get: function () { return constants_1.B3_CONTEXT_HEADER; } });
Object.defineProperty(exports, "X_B3_FLAGS", { enumerable: true, get: function () { return constants_1.X_B3_FLAGS; } });
Object.defineProperty(exports, "X_B3_PARENT_SPAN_ID", { enumerable: true, get: function () { return constants_1.X_B3_PARENT_SPAN_ID; } });
Object.defineProperty(exports, "X_B3_SAMPLED", { enumerable: true, get: function () { return constants_1.X_B3_SAMPLED; } });
Object.defineProperty(exports, "X_B3_SPAN_ID", { enumerable: true, get: function () { return constants_1.X_B3_SPAN_ID; } });
Object.defineProperty(exports, "X_B3_TRACE_ID", { enumerable: true, get: function () { return constants_1.X_B3_TRACE_ID; } });
var types_1 = require("./types");
Object.defineProperty(exports, "B3InjectEncoding", { enumerable: true, get: function () { return types_1.B3InjectEncoding; } });
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,yCAOqB;AANnB,8GAAA,iBAAiB,OAAA;AACjB,uGAAA,UAAU,OAAA;AACV,gHAAA,mBAAmB,OAAA;AACnB,yGAAA,YAAY,OAAA;AACZ,yGAAA,YAAY,OAAA;AACZ,0GAAA,aAAa,OAAA;AAEf,iCAA+D;AAAtD,yGAAA,gBAAgB,OAAA","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { B3Propagator } from './B3Propagator';\nexport {\n B3_CONTEXT_HEADER,\n X_B3_FLAGS,\n X_B3_PARENT_SPAN_ID,\n X_B3_SAMPLED,\n X_B3_SPAN_ID,\n X_B3_TRACE_ID,\n} from './constants';\nexport { B3InjectEncoding, B3PropagatorConfig } from './types';\n"]}

View File

@@ -0,0 +1,10 @@
/** Enumeration of B3 inject encodings */
export declare enum B3InjectEncoding {
SINGLE_HEADER = 0,
MULTI_HEADER = 1
}
/** Configuration for the B3Propagator */
export interface B3PropagatorConfig {
injectEncoding?: B3InjectEncoding;
}
//# sourceMappingURL=types.d.ts.map

View File

@@ -0,0 +1,25 @@
"use strict";
/*
* 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.B3InjectEncoding = void 0;
/** Enumeration of B3 inject encodings */
var B3InjectEncoding;
(function (B3InjectEncoding) {
B3InjectEncoding[B3InjectEncoding["SINGLE_HEADER"] = 0] = "SINGLE_HEADER";
B3InjectEncoding[B3InjectEncoding["MULTI_HEADER"] = 1] = "MULTI_HEADER";
})(B3InjectEncoding = exports.B3InjectEncoding || (exports.B3InjectEncoding = {}));
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,yCAAyC;AACzC,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,yEAAa,CAAA;IACb,uEAAY,CAAA;AACd,CAAC,EAHW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAG3B","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** Enumeration of B3 inject encodings */\nexport enum B3InjectEncoding {\n SINGLE_HEADER,\n MULTI_HEADER,\n}\n\n/** Configuration for the B3Propagator */\nexport interface B3PropagatorConfig {\n injectEncoding?: B3InjectEncoding;\n}\n"]}

View File

@@ -0,0 +1,2 @@
export declare const VERSION = "2.0.0";
//# sourceMappingURL=version.d.ts.map

View File

@@ -0,0 +1,21 @@
"use strict";
/*
* 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.VERSION = void 0;
// this is autogenerated file, see scripts/version-update.js
exports.VERSION = '2.0.0';
//# sourceMappingURL=version.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,OAAO,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '2.0.0';\n"]}

73
node_modules/@opentelemetry/propagator-b3/package.json generated vendored Normal file
View File

@@ -0,0 +1,73 @@
{
"name": "@opentelemetry/propagator-b3",
"version": "2.0.0",
"description": "OpenTelemetry B3 propagator provides context propagation for systems that are using the B3 header format",
"main": "build/src/index.js",
"module": "build/esm/index.js",
"esnext": "build/esnext/index.js",
"types": "build/src/index.d.ts",
"repository": "open-telemetry/opentelemetry-js",
"scripts": {
"prepublishOnly": "npm run compile",
"compile": "tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
"clean": "tsc --build --clean tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
"test": "nyc mocha test/**/*.test.ts",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"version": "node ../../scripts/version-update.js",
"watch": "tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
"precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies",
"prewatch": "npm run precompile",
"peer-api-check": "node ../../scripts/peer-api-check.js",
"align-api-deps": "node ../../scripts/align-api-deps.js"
},
"keywords": [
"opentelemetry",
"nodejs",
"tracing",
"profiling",
"monitoring",
"b3"
],
"author": "OpenTelemetry Authors",
"license": "Apache-2.0",
"engines": {
"node": "^18.19.0 || >=20.6.0"
},
"files": [
"build/esm/**/*.js",
"build/esm/**/*.js.map",
"build/esm/**/*.d.ts",
"build/esnext/**/*.js",
"build/esnext/**/*.js.map",
"build/esnext/**/*.d.ts",
"build/src/**/*.js",
"build/src/**/*.js.map",
"build/src/**/*.d.ts",
"LICENSE",
"README.md"
],
"publishConfig": {
"access": "public"
},
"dependencies": {
"@opentelemetry/core": "2.0.0"
},
"peerDependencies": {
"@opentelemetry/api": ">=1.0.0 <1.10.0"
},
"devDependencies": {
"@opentelemetry/api": ">=1.0.0 <1.10.0",
"@types/mocha": "10.0.10",
"@types/node": "18.6.5",
"cross-var": "1.1.0",
"lerna": "6.6.2",
"mocha": "11.1.0",
"nyc": "17.1.0",
"ts-loader": "9.5.2",
"typescript": "5.0.4"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-propagator-b3",
"sideEffects": false,
"gitHead": "7fde94081ed141c7d61db269b77d5765887a9665"
}