-
Couldn't load subscription status.
- Fork 321
chore: split json otel collector to enable both during dev #1247
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -94,13 +94,22 @@ type CollectorConfig = { | |
| password: string; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd suggest adding another custom config YAML file to the JSON collector. In the original collector, we can add a separate config to fork the telemetry. This way, we don't need to modify the OpAMP controller. |
||
| ttl: string; | ||
| timeout: string; | ||
| logs_table_name: string; | ||
| traces_table_name: string; | ||
| retry_on_failure: { | ||
| enabled: boolean; | ||
| initial_interval: string; | ||
| max_interval: string; | ||
| max_elapsed_time: string; | ||
| }; | ||
| }; | ||
| 'otlphttp/internal'?: { | ||
| endpoint: string; | ||
| headers: { | ||
| authorization: string; | ||
| compression: string; | ||
| }; | ||
| }; | ||
| }; | ||
| service: { | ||
| extensions: string[]; | ||
|
|
@@ -124,6 +133,38 @@ export const buildOtelCollectorConfig = (teams: ITeam[]): CollectorConfig => { | |
| } | ||
| } | ||
|
|
||
| let clickhouseExporterTables = { | ||
| logs_table_name: 'otel_logs', | ||
| traces_table_name: 'otel_traces', | ||
| }; | ||
| let otlpForward: string[] | undefined; | ||
| let otlpExporter: { | ||
| 'otlphttp/internal': NonNullable< | ||
| CollectorConfig['exporters'] | ||
| >['otlphttp/internal']; | ||
| } = { | ||
| 'otlphttp/internal': undefined, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't the type definition on line 142 remove |
||
| }; | ||
| if (config.IS_DEV) { | ||
| if (config.IS_JSON_OPAMP) { | ||
| clickhouseExporterTables = { | ||
| logs_table_name: 'otel_logs_json', | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should also create the json source in dev by default in |
||
| traces_table_name: 'otel_traces_json', | ||
| }; | ||
| } else { | ||
| otlpForward = ['otlphttp/internal']; | ||
| otlpExporter = { | ||
| 'otlphttp/internal': { | ||
| endpoint: 'http://host.docker.internal:14318', | ||
| headers: { | ||
| authorization: apiKeys.length > 0 ? apiKeys[0] : '', | ||
| compression: 'gzip', | ||
| }, | ||
| }, | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| const collectorAuthenticationEnforced = | ||
| teams[0]?.collectorAuthenticationEnforced; | ||
|
|
||
|
|
@@ -217,15 +258,17 @@ export const buildOtelCollectorConfig = (teams: ITeam[]): CollectorConfig => { | |
| max_interval: '30s', | ||
| max_elapsed_time: '300s', | ||
| }, | ||
| ...clickhouseExporterTables, | ||
| }, | ||
| ...(otlpExporter ? otlpExporter : {}), | ||
| }, | ||
| service: { | ||
| extensions: [], | ||
| pipelines: { | ||
| traces: { | ||
| receivers: ['nop'], | ||
| processors: ['memory_limiter', 'batch'], | ||
| exporters: ['clickhouse'], | ||
| exporters: ['clickhouse', ...(otlpForward ? otlpForward : [])], | ||
| }, | ||
| metrics: { | ||
| // TODO: prometheus needs to be authenticated | ||
|
|
@@ -236,7 +279,7 @@ export const buildOtelCollectorConfig = (teams: ITeam[]): CollectorConfig => { | |
| 'logs/in': { | ||
| // TODO: fluentforward needs to be authenticated | ||
| receivers: ['fluentforward'], | ||
| exporters: ['routing/logs'], | ||
| exporters: ['routing/logs', ...(otlpForward ? otlpForward : [])], | ||
| }, | ||
| 'logs/out-default': { | ||
| receivers: ['routing/logs'], | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,28 +45,33 @@ export default class Server { | |
| } | ||
|
|
||
| async start() { | ||
| this.appServer = this.createAppServer(); | ||
| this.appServer.keepAliveTimeout = 61000; // Ensure all inactive connections are terminated by the ALB, by setting this a few seconds higher than the ALB idle timeout | ||
| this.appServer.headersTimeout = 62000; // Ensure the headersTimeout is set higher than the keepAliveTimeout due to this nodejs regression bug: https://github.com/nodejs/node/issues/27363 | ||
| const runningServers: http.Server[] = []; | ||
| if (!(config.IS_DEV && !config.IS_OPAMP_ONLY)) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we simplify this conditional to |
||
| this.appServer = this.createAppServer(); | ||
| this.appServer.keepAliveTimeout = 61000; // Ensure all inactive connections are terminated by the ALB, by setting this a few seconds higher than the ALB idle timeout | ||
| this.appServer.headersTimeout = 62000; // Ensure the headersTimeout is set higher than the keepAliveTimeout due to this nodejs regression bug: https://github.com/nodejs/node/issues/27363 | ||
|
|
||
| this.appServer.listen(config.PORT, () => { | ||
| logger.info( | ||
| `API Server listening on port ${config.PORT}, NODE_ENV=${process.env.NODE_ENV}`, | ||
| ); | ||
| }); | ||
| runningServers.push(this.appServer); | ||
| } | ||
|
|
||
| this.opampServer = this.createOpampServer(); | ||
| this.opampServer.keepAliveTimeout = 61000; | ||
| this.opampServer.headersTimeout = 62000; | ||
|
|
||
| this.appServer.listen(config.PORT, () => { | ||
| logger.info( | ||
| `API Server listening on port ${config.PORT}, NODE_ENV=${process.env.NODE_ENV}`, | ||
| ); | ||
| }); | ||
|
|
||
| this.opampServer.listen(config.OPAMP_PORT, () => { | ||
| logger.info( | ||
| `OpAMP Server listening on port ${config.OPAMP_PORT}, NODE_ENV=${process.env.NODE_ENV}`, | ||
| ); | ||
| }); | ||
| runningServers.push(this.opampServer); | ||
|
|
||
| if (this.shouldHandleGracefulShutdown) { | ||
| [this.appServer, this.opampServer].forEach(server => { | ||
| runningServers.forEach(server => { | ||
| gracefulShutdown(server, { | ||
| signals: 'SIGINT SIGTERM', | ||
| timeout: 10000, // 10 secs | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove the commented line