diff --git a/api/src/api/propagation.ts b/api/src/api/propagation.ts index a07b88b94d2..b99dada22a1 100644 --- a/api/src/api/propagation.ts +++ b/api/src/api/propagation.ts @@ -96,6 +96,13 @@ export class PropagationAPI { return this._getGlobalPropagator().extract(context, carrier, getter); } + /** + * Return a list of all fields which may be used by the propagator. + */ + public fields(): string[] { + return this._getGlobalPropagator().fields(); + } + /** Remove the global propagator */ public disable() { delete _global[GLOBAL_PROPAGATION_API_KEY]; diff --git a/api/src/context/propagation/TextMapPropagator.ts b/api/src/context/propagation/TextMapPropagator.ts index 59f2d39f8ad..b659a9704de 100644 --- a/api/src/context/propagation/TextMapPropagator.ts +++ b/api/src/context/propagation/TextMapPropagator.ts @@ -67,9 +67,6 @@ export interface TextMapPropagator { /** * Return a list of all fields which may be used by the propagator. - * - * This list should be used to clear fields before calling inject if a carrier is - * used more than once. */ fields(): string[]; } diff --git a/api/test/api/api.test.ts b/api/test/api/api.test.ts index 01aaf32df65..cc02a460f8f 100644 --- a/api/test/api/api.test.ts +++ b/api/test/api/api.test.ts @@ -150,6 +150,13 @@ describe('API', () => { assert.strictEqual(data.carrier, carrier); assert.strictEqual(data.getter, getter); }); + + it('fields', () => { + api.propagation.setGlobalPropagator(new TestTextMapPropagation()); + + const fields = api.propagation.fields(); + assert.deepStrictEqual(fields, ['TestField']); + }); }); }); });