Skip to content

Commit 2b7b1cd

Browse files
committed
Merge remote-tracking branch 'origin/master' into renovate/all-minor-patch
2 parents b5cbb96 + b8afb04 commit 2b7b1cd

File tree

25 files changed

+459
-299
lines changed

25 files changed

+459
-299
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,15 @@ After adding the package, run `npm install` from the root of the project. This w
187187
- No “changes requested” reviews.
188188
- No unresolved conversations.
189189
- 3 approvals, including the approvals of at least 2 maintainers
190-
- A pull request opened by an approver may be merged with only 2 reviews.
190+
- A pull request opened by an approver may be merged with only the 2 maintainer reviews.
191191
- Small (simple typo, URL, update docs, or grammatical fix) or high-priority changes may be merged more quickly or with fewer reviewers at the discretion of the maintainers. This is typically indicated with the express label.
192192
- For plugins, exporters, and propagators approval of the original code module author is preferred but not required.
193193
- New or changed functionality is tested by unit tests.
194194
- New or changed functionality is documented.
195195
- Substantial changes should not be merged within 24 hours of opening in order to allow reviewers from all time zones to have a chance to review.
196196

197+
If all of the above requirements are met and there are no unresolved discussions, a pull request may be merged by either a maintainer or an approver.
198+
197199
### Generating API documentation
198200

199201
- `npm run docs` to generate API documentation. Generates the documentation in `packages/opentelemetry-api/docs/out`

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ Approvers ([@open-telemetry/js-approvers](https://github.com/orgs/open-telemetry
134134
- [Matthew Wear](https://github.com/mwear), LightStep
135135
- [Naseem K. Ullah](https://github.com/naseemkullah), Transit
136136
- [Chengzhong Wu](https://github.com/legendecas), Alibaba
137+
- [Gerhard Stöbich](https://github.com/Flarna), Dynatrace
137138

138139
*Find more about the approver role in [community repository](https://github.com/open-telemetry/community/blob/master/community-membership.md#approver).*
139140

packages/opentelemetry-api/src/api/propagation.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ export class PropagationAPI {
9696
return this._getGlobalPropagator().extract(context, carrier, getter);
9797
}
9898

99+
/**
100+
* Return a list of all fields which may be used by the propagator.
101+
*/
102+
public fields(): string[] {
103+
return this._getGlobalPropagator().fields();
104+
}
105+
99106
/** Remove the global propagator */
100107
public disable() {
101108
delete _global[GLOBAL_PROPAGATION_API_KEY];

packages/opentelemetry-api/src/context/propagation/TextMapPropagator.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ export interface TextMapPropagator<Carrier = any> {
6767

6868
/**
6969
* Return a list of all fields which may be used by the propagator.
70-
*
71-
* This list should be used to clear fields before calling inject if a carrier is
72-
* used more than once.
7370
*/
7471
fields(): string[];
7572
}

packages/opentelemetry-api/src/trace/ProxyTracer.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
import { Context } from '@opentelemetry/context-base';
1718
import { Span, SpanOptions, Tracer } from '..';
1819
import { NOOP_TRACER } from './NoopTracer';
1920
import { ProxyTracerProvider } from './ProxyTracerProvider';
@@ -31,8 +32,8 @@ export class ProxyTracer implements Tracer {
3132
public readonly version?: string
3233
) {}
3334

34-
startSpan(name: string, options?: SpanOptions): Span {
35-
return this._getTracer().startSpan(name, options);
35+
startSpan(name: string, options?: SpanOptions, context?: Context): Span {
36+
return this._getTracer().startSpan(name, options, context);
3637
}
3738

3839
/**

packages/opentelemetry-api/src/trace/SpanOptions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
import { TimeInput } from '../common/Time';
1718
import { Attributes } from './attributes';
1819
import { Link } from './link';
1920
import { SpanKind } from './span_kind';
@@ -35,7 +36,7 @@ export interface SpanOptions {
3536
links?: Link[];
3637

3738
/** A manually specified start time for the created `Span` object. */
38-
startTime?: number;
39+
startTime?: TimeInput;
3940

4041
/** The new span should be a root span. (Ignore parent from context). */
4142
root?: boolean;

packages/opentelemetry-api/test/api/api.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,13 @@ describe('API', () => {
150150
assert.strictEqual(data.carrier, carrier);
151151
assert.strictEqual(data.getter, getter);
152152
});
153+
154+
it('fields', () => {
155+
api.propagation.setGlobalPropagator(new TestTextMapPropagation());
156+
157+
const fields = api.propagation.fields();
158+
assert.deepStrictEqual(fields, ['TestField']);
159+
});
153160
});
154161
});
155162
});

packages/opentelemetry-api/test/proxy-implementations/proxy-tracer.test.ts

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,22 @@ import {
2626
Tracer,
2727
Span,
2828
NoopTracer,
29+
ROOT_CONTEXT,
30+
SpanOptions,
2931
} from '../../src';
3032

3133
describe('ProxyTracer', () => {
3234
let provider: ProxyTracerProvider;
35+
const sandbox = sinon.createSandbox();
3336

3437
beforeEach(() => {
3538
provider = new ProxyTracerProvider();
3639
});
3740

41+
afterEach(() => {
42+
sandbox.restore();
43+
});
44+
3845
describe('when no delegate is set', () => {
3946
it('should return proxy tracers', () => {
4047
const tracer = provider.getTracer('test');
@@ -61,7 +68,6 @@ describe('ProxyTracer', () => {
6168

6269
describe('when delegate is set before getTracer', () => {
6370
let delegate: TracerProvider;
64-
const sandbox = sinon.createSandbox();
6571
let getTracerStub: sinon.SinonStub;
6672

6773
beforeEach(() => {
@@ -72,10 +78,6 @@ describe('ProxyTracer', () => {
7278
provider.setDelegate(delegate);
7379
});
7480

75-
afterEach(() => {
76-
sandbox.restore();
77-
});
78-
7981
it('should return tracers directly from the delegate', () => {
8082
const tracer = provider.getTracer('test', 'v0');
8183

@@ -114,5 +116,25 @@ describe('ProxyTracer', () => {
114116

115117
assert.strictEqual(span, delegateSpan);
116118
});
119+
120+
it('should pass original arguments to DelegateTracer#startSpan', () => {
121+
const startSpanStub = sandbox.stub(delegateTracer, 'startSpan');
122+
123+
const name = 'name1';
124+
const options: SpanOptions = {};
125+
const ctx = ROOT_CONTEXT.setValue(Symbol('test'), 1);
126+
tracer.startSpan(name, options, ctx);
127+
128+
// Assert the proxy tracer has the full API of the NoopTracer
129+
assert.strictEqual(
130+
NoopTracer.prototype.startSpan.length,
131+
ProxyTracer.prototype.startSpan.length
132+
);
133+
assert.deepStrictEqual(Object.getOwnPropertyNames(NoopTracer.prototype), [
134+
'constructor',
135+
'startSpan',
136+
]);
137+
sandbox.assert.calledOnceWithExactly(startSpanStub, name, options, ctx);
138+
});
117139
});
118140
});

packages/opentelemetry-core/src/platform/browser/environment.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
import {
1818
DEFAULT_ENVIRONMENT,
1919
ENVIRONMENT,
20-
ENVIRONMENT_MAP,
20+
RAW_ENVIRONMENT,
2121
parseEnvironment,
2222
} from '../../utils/environment';
2323

2424
/**
2525
* Gets the environment variables
2626
*/
2727
export function getEnv(): Required<ENVIRONMENT> {
28-
const _window = window as typeof window & ENVIRONMENT_MAP;
28+
const _window = window as typeof window & RAW_ENVIRONMENT;
2929
const globalEnv = parseEnvironment(_window);
3030
return Object.assign({}, DEFAULT_ENVIRONMENT, globalEnv);
3131
}

packages/opentelemetry-core/src/platform/node/environment.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,24 @@
1414
* limitations under the License.
1515
*/
1616

17+
import * as os from 'os';
1718
import {
1819
DEFAULT_ENVIRONMENT,
1920
ENVIRONMENT,
20-
ENVIRONMENT_MAP,
21+
RAW_ENVIRONMENT,
2122
parseEnvironment,
2223
} from '../../utils/environment';
2324

2425
/**
2526
* Gets the environment variables
2627
*/
2728
export function getEnv(): Required<ENVIRONMENT> {
28-
const processEnv = parseEnvironment(process.env as ENVIRONMENT_MAP);
29-
return Object.assign({}, DEFAULT_ENVIRONMENT, processEnv);
29+
const processEnv = parseEnvironment(process.env as RAW_ENVIRONMENT);
30+
return Object.assign(
31+
{
32+
HOSTNAME: os.hostname(),
33+
},
34+
DEFAULT_ENVIRONMENT,
35+
processEnv
36+
);
3037
}

0 commit comments

Comments
 (0)