Skip to content

Commit

Permalink
Merge branch 'main' into metrics-ff/instrument
Browse files Browse the repository at this point in the history
  • Loading branch information
dyladan authored Feb 9, 2022
2 parents 1d44c60 + 4fa3270 commit 72d45c5
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 19 deletions.
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ npm run clean

These commands can also be run for specific packages instead of the whole project, which can speed up compilations while developing.

**NOTE**: To run commands in specific packages (compile, lint, etc), please ensure you are using at least `7.x`
version of `npm`.

```sh
# Build a single module and all of its dependencies
cd packages/opentelemetry-module-name
Expand Down
12 changes: 6 additions & 6 deletions packages/exporter-trace-otlp-grpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const { BasicTracerProvider, SimpleSpanProcessor } = require('@opentelemetry/sdk
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-grpc');

const collectorOptions = {
// url is optional and can be omitted - default is grpc://localhost:4317
url: 'grpc://<collector-hostname>:<port>',
// url is optional and can be omitted - default is localhost:4317
url: '<collector-hostname>:<port>',
};

const provider = new BasicTracerProvider();
Expand All @@ -50,8 +50,8 @@ const { BasicTracerProvider, SimpleSpanProcessor } = require('@opentelemetry/sdk
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-grpc');

const collectorOptions = {
// url is optional and can be omitted - default is grpc://localhost:4317
url: 'grpc://<collector-hostname>:<port>',
// url is optional and can be omitted - default is localhost:4317
url: '<collector-hostname>:<port>',
credentials: grpc.credentials.createSsl(),
};

Expand Down Expand Up @@ -90,8 +90,8 @@ const metadata = new grpc.Metadata();
metadata.set('k', 'v');

const collectorOptions = {
// url is optional and can be omitted - default is grpc://localhost:4317
url: 'grpc://<collector-hostname>:<port>',
// url is optional and can be omitted - default is localhost:4317
url: '<collector-hostname>:<port>',
metadata, // // an optional grpc.Metadata object to be sent with each request
};

Expand Down
17 changes: 11 additions & 6 deletions packages/opentelemetry-core/src/baggage/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,17 @@ export function serializeKeyPairs(keyPairs: string[]): string {
}

export function getKeyPairs(baggage: Baggage): string[] {
return baggage
.getAllEntries()
.map(
([key, value]) =>
`${encodeURIComponent(key)}=${encodeURIComponent(value.value)}`
);
return baggage.getAllEntries().map(([key, value]) => {
let entry = `${encodeURIComponent(key)}=${encodeURIComponent(value.value)}`;

// include opaque metadata if provided
// NOTE: we intentionally don't URI-encode the metadata - that responsibility falls on the metadata implementation
if (value.metadata !== undefined) {
entry += BAGGAGE_PROPERTIES_SEPARATOR + value.metadata.toString();
}

return entry;
});
}

export function parsePairKeyValue(entry: string): ParsedBaggageKeyValue | undefined {
Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
defaultTextMapGetter,
defaultTextMapSetter,
propagation,
baggageEntryMetadataFromString
} from '@opentelemetry/api';
import { ROOT_CONTEXT } from '@opentelemetry/api';
import * as assert from 'assert';
Expand All @@ -39,8 +40,9 @@ describe('W3CBaggagePropagator', () => {
it('should set baggage header', () => {
const baggage = propagation.createBaggage({
key1: { value: 'd4cda95b652f4a1592b449d5929fda1b' },
key3: { value: 'c88815a7-0fa9-4d95-a1f1-cdccce3c5c2a' },
'with/slash': { value: 'with spaces' },
key3: { value: 'c88815a7-0fa9-4d95-a1f1-cdccce3c5c2a' },
key4: { value: 'foo', metadata: baggageEntryMetadataFromString('key4prop1=value1;key4prop2=value2;key4prop3WithNoValue') }
});

httpBaggagePropagator.inject(
Expand All @@ -50,7 +52,7 @@ describe('W3CBaggagePropagator', () => {
);
assert.deepStrictEqual(
carrier[BAGGAGE_HEADER],
'key1=d4cda95b652f4a1592b449d5929fda1b,key3=c88815a7-0fa9-4d95-a1f1-cdccce3c5c2a,with%2Fslash=with%20spaces'
'key1=d4cda95b652f4a1592b449d5929fda1b,with%2Fslash=with%20spaces,key3=c88815a7-0fa9-4d95-a1f1-cdccce3c5c2a,key4=foo;key4prop1=value1;key4prop2=value2;key4prop3WithNoValue'
);
});

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
2 changes: 1 addition & 1 deletion packages/template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@
"karma-mocha": "2.0.1",
"karma-spec-reporter": "0.0.32",
"karma-webpack": "4.0.2",
"webpack": "4.44.2"
"webpack": "4.46.0"
}
}
4 changes: 2 additions & 2 deletions selenium-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
"geckodriver": "2.0.4",
"nightwatch": "1.7.12",
"selenium-server": "3.141.59",
"terser-webpack-plugin": "5.2.5",
"webpack": "5.64.1",
"terser-webpack-plugin": "4.2.3",
"webpack": "4.46.0",
"webpack-cli": "4.9.1",
"webpack-dev-server": "4.5.0",
"webpack-merge": "5.8.0"
Expand Down

0 comments on commit 72d45c5

Please sign in to comment.