Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(otlp-exporter): add timeout env var #2738

Merged
merged 82 commits into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
4e81f83
feat(otlp-exporter): add timeout env var
svetlanabrennan Jan 24, 2022
11ea770
feat(otlp-exporter): add timeout env var test
svetlanabrennan Jan 25, 2022
a9a526f
Merge branch 'main' into add-exporter-timeout
svetlanabrennan Jan 26, 2022
4f659fb
Merge branch 'main' into add-exporter-timeout
svetlanabrennan Jan 26, 2022
2bc61e4
feat(otlp-exporter): add trace_timeout env var
svetlanabrennan Jan 26, 2022
48a25d7
Merge branch 'add-exporter-timeout' of github.com:svetlanabrennan/ope…
svetlanabrennan Jan 26, 2022
da3211f
feat(otlp-exporter): add how timeout is selected
svetlanabrennan Jan 26, 2022
0c1011d
feat(otlp-exporter): add negative value check to env vars
svetlanabrennan Jan 27, 2022
ed4079f
feat(otlp-exporter): add negative value check to env vars
svetlanabrennan Jan 27, 2022
fc486a1
feat(otlp-exporter): add timeout config information to readme
svetlanabrennan Jan 28, 2022
7292244
feat(otlp-exporter): add const var for default timeout value
svetlanabrennan Jan 28, 2022
ca98326
Merge branch 'main' into add-exporter-timeout
svetlanabrennan Jan 31, 2022
5e7d2f5
Merge branch 'main' into add-exporter-timeout
svetlanabrennan Jan 31, 2022
e8dc21b
feat(otlp-exporter): refactor code based on feedback
svetlanabrennan Feb 1, 2022
6c3a42d
Merge branch 'add-exporter-timeout' of github.com:svetlanabrennan/ope…
svetlanabrennan Feb 1, 2022
111cb83
feat(otlp-exporter): move configuring timeout to utils and tests
svetlanabrennan Feb 3, 2022
bbb75cb
feat(otlp-exporter): add timeout to http and xhr request
svetlanabrennan Feb 8, 2022
8866035
Merge branch 'main' into add-exporter-timeout
svetlanabrennan Feb 8, 2022
b8543c0
Fix typo in environment.ts
svetlanabrennan Feb 8, 2022
3873a85
feat(otlp-exporter): update timeout to general timers
svetlanabrennan Feb 14, 2022
1fe1847
feat(otlp-exporter): update node http timeout tests
svetlanabrennan Feb 15, 2022
a207d50
Merge branch 'main' into add-exporter-timeout
svetlanabrennan Feb 15, 2022
991beeb
feat(otlp-exporter): fix dependency version for http exporter
svetlanabrennan Feb 15, 2022
4e5af76
feat(otlp-exporter): add grpc deadline test
svetlanabrennan Feb 15, 2022
b27ca5f
feat(otlp-exporter): fix typos
svetlanabrennan Feb 15, 2022
a428d9d
Merge branch 'main' into add-exporter-timeout
svetlanabrennan Feb 17, 2022
21f596e
feat(otlp-exporter): add browser timeout test
svetlanabrennan Feb 18, 2022
3043e10
Merge branch 'main' into add-exporter-timeout
svetlanabrennan Feb 18, 2022
d66cb4a
feat(otlp-exporter): fix lint errors
svetlanabrennan Feb 18, 2022
fd4406b
Merge branch 'add-exporter-timeout' of github.com:svetlanabrennan/ope…
svetlanabrennan Feb 18, 2022
d42991e
Merge branch 'main' into add-exporter-timeout
svetlanabrennan Feb 23, 2022
c7fe6cc
Merge branch 'main' into add-exporter-timeout
Flarna Feb 24, 2022
10880be
feat(otlp-exporter): fix tests after main merge
svetlanabrennan Feb 25, 2022
3e8360d
feat(otlp-exporter): fix one test and lint on readme
svetlanabrennan Feb 26, 2022
481795d
feat(otlp-exporter): fix tests that call export method
svetlanabrennan Mar 1, 2022
e8db3dc
Merge branch 'main' into add-exporter-timeout
svetlanabrennan Mar 1, 2022
4f9a556
Merge branch 'main' into add-exporter-timeout
svetlanabrennan Mar 2, 2022
d9a665f
feat(otlp-exporter): update various items based on feedback
svetlanabrennan Mar 2, 2022
4222cc6
feat(otlp-exporter): add additional tests
svetlanabrennan Mar 2, 2022
0d9de49
feat(otlp-exporter): add two more tests
svetlanabrennan Mar 2, 2022
80c1b0a
Merge branch 'main' into add-exporter-timeout
svetlanabrennan Mar 10, 2022
eff3298
feat(otlp-exporter): add 1 more test
svetlanabrennan Mar 11, 2022
84aa2ec
Merge branch 'add-exporter-timeout' of github.com:svetlanabrennan/ope…
svetlanabrennan Mar 11, 2022
70ca58d
Merge branch 'main' into add-exporter-timeout
svetlanabrennan Mar 15, 2022
b00c3e6
Merge branch 'main' into add-exporter-timeout
svetlanabrennan Mar 16, 2022
83092e6
Merge branch 'main' into add-exporter-timeout
svetlanabrennan Mar 17, 2022
44eeb56
feat(otlp-exporter): add logic around request aborted after response …
svetlanabrennan Mar 24, 2022
cfeb182
feat(otlp-exporter): update grpc deadline calculation
svetlanabrennan Mar 24, 2022
8b6a005
feat(otlp-exporter): add real http request test to proto exporter
svetlanabrennan Mar 24, 2022
d955eac
Merge branch 'main' into add-exporter-timeout
svetlanabrennan Mar 24, 2022
5547628
feat(otlp-exporter): fix timeout test
svetlanabrennan Mar 24, 2022
bc6bb16
feat(otlp-exporter): fix grpc readme
svetlanabrennan Mar 24, 2022
f5309fd
Merge branch 'main' into add-exporter-timeout
svetlanabrennan Mar 28, 2022
8c0eda7
Update packages/exporter-trace-otlp-http/src/platform/node/util.ts
svetlanabrennan Mar 28, 2022
5f24eb9
Merge branch 'add-exporter-timeout' of github.com:svetlanabrennan/ope…
svetlanabrennan Mar 28, 2022
7f103cb
feat(otlp-exporter): remove comment from sendWithHttp
svetlanabrennan Mar 31, 2022
1a3b0bf
Merge branch 'main' into add-exporter-timeout
rauno56 Apr 13, 2022
a9f6a9a
Merge branch 'main' into add-exporter-timeout
svetlanabrennan Apr 19, 2022
f0055a0
feat(otlp-exporter): fix metric tests and add changelong
svetlanabrennan Apr 19, 2022
c79c521
feat(otlp-exporter): fix lint
svetlanabrennan Apr 19, 2022
d887480
Merge branch 'main' into add-exporter-timeout
svetlanabrennan Apr 20, 2022
d18c587
feat(otlp-exporter): fix metric tests
svetlanabrennan Apr 20, 2022
d1ccc95
Merge branch 'add-exporter-timeout' of github.com:svetlanabrennan/ope…
svetlanabrennan Apr 20, 2022
b97a418
feat(otlp-exporter): fix proto tests
svetlanabrennan Apr 20, 2022
0b8f7da
feat(otlp-exporter): fix lint
svetlanabrennan Apr 20, 2022
f053d09
feat(otlp-exporter): Merge branch 'main' into add-exporter-timeout
svetlanabrennan Apr 21, 2022
78d4e93
feat(otlp-exporter): fix tests after main merge
svetlanabrennan Apr 22, 2022
f32b965
Merge branch 'main' into add-exporter-timeout
svetlanabrennan Apr 25, 2022
0b4c617
Merge branch 'main' into add-exporter-timeout
Flarna Apr 26, 2022
e81f9dd
feat(otlp-exporter): fix lint
svetlanabrennan Apr 26, 2022
ae49cd3
Merge branch 'main' into add-exporter-timeout
svetlanabrennan Apr 27, 2022
828993e
Merge branch 'main' into add-exporter-timeout
vmarchaud Apr 30, 2022
dc647fd
Merge branch 'main' into add-exporter-timeout
svetlanabrennan May 5, 2022
fbaa457
feat(otlp-exporter): fix accidentally removed code after main merge
svetlanabrennan May 5, 2022
14ba7d3
feat(otlp-exporter): replace nextTick with queueMicroTask for browser…
svetlanabrennan May 9, 2022
1ebc461
feat(otlp-exporter): add more details to changelog item
svetlanabrennan May 9, 2022
27b2b86
Merge branch 'main' into add-exporter-timeout
svetlanabrennan May 9, 2022
b186cbf
Merge branch 'main' into add-exporter-timeout
svetlanabrennan May 10, 2022
511999a
feat(otlp-exporter): fix server timing issue in real http request tes…
svetlanabrennan May 10, 2022
b553759
feat(otlp-exporter): fix real http request tests
svetlanabrennan May 10, 2022
5da6ce2
feat(otlp-exporter): add comment to two ways of destroying request
svetlanabrennan May 11, 2022
6ee89b0
Merge branch 'main' into add-exporter-timeout
dyladan May 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion packages/exporter-trace-otlp-http/src/OTLPExporterBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { SpanAttributes, diag } from '@opentelemetry/api';
import { ExportResult, ExportResultCode, BindOnceFuture } from '@opentelemetry/core';
import { ExportResult, ExportResultCode, BindOnceFuture, getEnv } from '@opentelemetry/core';
import {
OTLPExporterError,
OTLPExporterConfigBase,
Expand All @@ -36,6 +36,7 @@ export abstract class OTLPExporterBase<
protected _concurrencyLimit: number;
protected _sendingPromises: Promise<unknown>[] = [];
protected _shutdownOnce: BindOnceFuture<void>;
private readonly _timeoutMillis: number;

/**
* @param config
Expand All @@ -56,6 +57,8 @@ export abstract class OTLPExporterBase<
? config.concurrencyLimit
: Infinity;

this._timeoutMillis = this._configureTimeout(config.timeoutMillis);

// platform dependent
this.onInit(config);
}
Expand Down Expand Up @@ -93,6 +96,11 @@ export abstract class OTLPExporterBase<

private _export(items: ExportItem[]): Promise<unknown> {
return new Promise<void>((resolve, reject) => {
setTimeout(() => {
svetlanabrennan marked this conversation as resolved.
Show resolved Hide resolved
// don't wait anymore for export
reject(new Error('Timeout'));
vmarchaud marked this conversation as resolved.
Show resolved Hide resolved
}, this._timeoutMillis);

try {
diag.debug('items to be sent', items);
this.send(items, resolve, reject);
Expand All @@ -102,6 +110,26 @@ export abstract class OTLPExporterBase<
});
}

private _configureTimeout(timeoutMillis: number | undefined): number {
svetlanabrennan marked this conversation as resolved.
Show resolved Hide resolved
let defaultTimeout = getEnv().OTEL_EXPORTER_OTLP_TRACES_TIMEOUT;

if ( defaultTimeout === null) {
svetlanabrennan marked this conversation as resolved.
Show resolved Hide resolved
defaultTimeout = getEnv().OTEL_EXPORTER_OTLP_TIMEOUT;
}

return typeof timeoutMillis === 'number'
? timeoutMillis < 0
? this._invalidTimeout(timeoutMillis, defaultTimeout)
: timeoutMillis
: defaultTimeout;
}

private _invalidTimeout(timeout: number, defaultTimeout: number): number {
svetlanabrennan marked this conversation as resolved.
Show resolved Hide resolved
diag.warn('Timeout must be non-negative', timeout);
svetlanabrennan marked this conversation as resolved.
Show resolved Hide resolved

return defaultTimeout;
}

/**
* Shutdown the exporter.
*/
Expand Down
3 changes: 3 additions & 0 deletions packages/exporter-trace-otlp-http/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,9 @@ export interface OTLPExporterConfigBase {
attributes?: SpanAttributes;
url?: string;
concurrencyLimit?: number;
/** Maximum time the OTLP exporter will wait for each batch export.
* The default value is 10000ms. */
timeoutMillis?: number;
}

/**
Expand Down
4 changes: 4 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,8 @@ const ENVIRONMENT_NUMBERS_KEYS = [
'OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT',
'OTEL_SPAN_EVENT_COUNT_LIMIT',
'OTEL_SPAN_LINK_COUNT_LIMIT',
'OTEL_EXPORTER_OTLP_TIMEOUT',
'OTEL_EXPORTER_OTLP_TRACES_TIMEOUT'
] as const;

type ENVIRONMENT_NUMBERS = {
Expand Down Expand Up @@ -118,6 +120,8 @@ export const DEFAULT_ENVIRONMENT: Required<ENVIRONMENT> = {
OTEL_EXPORTER_OTLP_HEADERS: '',
OTEL_EXPORTER_OTLP_TRACES_HEADERS: '',
OTEL_EXPORTER_OTLP_METRICS_HEADERS: '',
OTEL_EXPORTER_OTLP_TIMEOUT: 10000,
OTEL_EXPORTER_OTLP_TRACES_TIMEOUT: 10000,
OTEL_EXPORTER_ZIPKIN_ENDPOINT: 'http://localhost:9411/api/v2/spans',
OTEL_LOG_LEVEL: DiagLogLevel.INFO,
OTEL_NO_PATCH_MODULES: [],
Expand Down
4 changes: 4 additions & 0 deletions packages/opentelemetry-core/test/utils/environment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ describe('environment', () => {
OTEL_SPAN_LINK_COUNT_LIMIT: 30,
OTEL_TRACES_SAMPLER: 'always_on',
OTEL_TRACES_SAMPLER_ARG: '0.5',
OTEL_EXPORTER_OTLP_TIMEOUT: 10000,
OTEL_EXPORTER_OTLP_TRACES_TIMEOUT: 10000,
svetlanabrennan marked this conversation as resolved.
Show resolved Hide resolved
});
const env = getEnv();
assert.deepStrictEqual(env.OTEL_NO_PATCH_MODULES, ['a', 'b', 'c']);
Expand Down Expand Up @@ -126,6 +128,8 @@ describe('environment', () => {
assert.strictEqual(env.OTEL_BSP_SCHEDULE_DELAY, 50);
assert.strictEqual(env.OTEL_TRACES_SAMPLER, 'always_on');
assert.strictEqual(env.OTEL_TRACES_SAMPLER_ARG, '0.5');
assert.strictEqual(env.OTEL_EXPORTER_OTLP_TIMEOUT, 10000);
assert.strictEqual(env.OTEL_EXPORTER_OTLP_TRACES_TIMEOUT, 10000);
});

it('should parse OTEL_LOG_LEVEL despite casing', () => {
Expand Down