Skip to content

Commit

Permalink
Merge branch 'main' into fix-oltp-grpc-exporter-readme
Browse files Browse the repository at this point in the history
  • Loading branch information
legendecas authored Feb 8, 2022
2 parents 5089cc0 + 31380ac commit 6f223f5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/opentelemetry-core/src/utils/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const ENVIRONMENT_NUMBERS_KEYS = [
'OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT',
'OTEL_SPAN_EVENT_COUNT_LIMIT',
'OTEL_SPAN_LINK_COUNT_LIMIT',
'OTEL_EXPORTER_JAEGER_AGENT_PORT',
] as const;

type ENVIRONMENT_NUMBERS = {
Expand Down Expand Up @@ -109,6 +110,7 @@ export const DEFAULT_ENVIRONMENT: Required<ENVIRONMENT> = {
OTEL_BSP_MAX_QUEUE_SIZE: 2048,
OTEL_BSP_SCHEDULE_DELAY: 5000,
OTEL_EXPORTER_JAEGER_AGENT_HOST: '',
OTEL_EXPORTER_JAEGER_AGENT_PORT: 6832,
OTEL_EXPORTER_JAEGER_ENDPOINT: '',
OTEL_EXPORTER_JAEGER_PASSWORD: '',
OTEL_EXPORTER_JAEGER_USER: '',
Expand Down
2 changes: 2 additions & 0 deletions packages/opentelemetry-core/test/utils/environment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ describe('environment', () => {
OTEL_BSP_MAX_EXPORT_BATCH_SIZE: 40,
OTEL_BSP_SCHEDULE_DELAY: 50,
OTEL_EXPORTER_JAEGER_AGENT_HOST: 'host.domain.com',
OTEL_EXPORTER_JAEGER_AGENT_PORT: 1234,
OTEL_EXPORTER_JAEGER_ENDPOINT: 'https://example.com/endpoint',
OTEL_EXPORTER_JAEGER_PASSWORD: 'secret',
OTEL_EXPORTER_JAEGER_USER: 'whoami',
Expand Down Expand Up @@ -112,6 +113,7 @@ describe('environment', () => {
env.OTEL_EXPORTER_JAEGER_AGENT_HOST,
'host.domain.com'
);
assert.strictEqual(env.OTEL_EXPORTER_JAEGER_AGENT_PORT, 1234);
assert.strictEqual(
env.ECS_CONTAINER_METADATA_URI_V4,
'https://ecs.uri/v4'
Expand Down
1 change: 1 addition & 0 deletions packages/opentelemetry-exporter-jaeger/src/jaeger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export class JaegerExporter implements SpanExporter {
localConfig.password =
localConfig.password || env.OTEL_EXPORTER_JAEGER_PASSWORD;
localConfig.host = localConfig.host || env.OTEL_EXPORTER_JAEGER_AGENT_HOST;
localConfig.port = localConfig.port || env.OTEL_EXPORTER_JAEGER_AGENT_PORT;

this._localConfig = localConfig;

Expand Down
9 changes: 7 additions & 2 deletions packages/opentelemetry-exporter-jaeger/test/jaeger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ describe('JaegerExporter', () => {
assert.strictEqual(sender._host, 'localhost');
});

it('should respect jaeger host env variable', () => {
it('should respect jaeger host and port env variable', () => {
process.env.OTEL_EXPORTER_JAEGER_AGENT_HOST = 'env-set-host';
process.env.OTEL_EXPORTER_JAEGER_AGENT_PORT = '1234';
const exporter = new JaegerExporter();
const sender = exporter['_getSender']({
tags: [{
Expand All @@ -126,12 +127,15 @@ describe('JaegerExporter', () => {
}]
} as any);
assert.strictEqual(sender._host, 'env-set-host');
assert.strictEqual(sender._port, 1234);
});

it('should prioritize host option over env variable', () => {
it('should prioritize host and port option over env variable', () => {
process.env.OTEL_EXPORTER_JAEGER_AGENT_HOST = 'env-set-host';
process.env.OTEL_EXPORTER_JAEGER_AGENT_PORT = '1234';
const exporter = new JaegerExporter({
host: 'option-set-host',
port: 5678
});
const sender = exporter['_getSender']({
tags: [{
Expand All @@ -140,6 +144,7 @@ describe('JaegerExporter', () => {
}]
} as any);
assert.strictEqual(sender._host, 'option-set-host');
assert.strictEqual(sender._port, 5678);
});

it('should construct an exporter with flushTimeout', () => {
Expand Down

0 comments on commit 6f223f5

Please sign in to comment.