Skip to content

Commit

Permalink
fix(api): add public 'fields' function to api.propagator (open-teleme…
Browse files Browse the repository at this point in the history
…try#1813)

* fix(api): add public 'fields' function to api.propagator

* chore: remove redundant comment

Co-authored-by: Daniel Dyla <[email protected]>
  • Loading branch information
blumamir and dyladan committed Feb 18, 2021
1 parent b365b94 commit baad68f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
7 changes: 7 additions & 0 deletions api/src/api/propagation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
3 changes: 0 additions & 3 deletions api/src/context/propagation/TextMapPropagator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ export interface TextMapPropagator<Carrier = any> {

/**
* 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[];
}
Expand Down
7 changes: 7 additions & 0 deletions api/test/api/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
});
});
});
});

0 comments on commit baad68f

Please sign in to comment.