Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ Environment Variable | Description | Default
| `SW_AWS_LAMBDA_CHAIN` | Pass trace ID to AWS Lambda function in its parameters (to allow linking). Only use if both caller and callee will be instrumented. | `false` |
| `SW_AWS_SQS_CHECK_BODY` | Incoming SQS messages check inside the body for trace ID in order to allow linking outgoing SNS messages to incoming SQS. | `false` |
| `SW_AGENT_MAX_BUFFER_SIZE` | The maximum buffer size before sending the segment data to backend | `'1000'` |
| `SW_AGENT_TRACE_TIMEOUT` | The timeout for trace requests to backend services | `'10000'` |


Note that the various ignore options like `SW_IGNORE_SUFFIX`, `SW_TRACE_IGNORE_PATH` and `SW_HTTP_IGNORE_METHOD` as well as endpoints which are not recorded due to exceeding `SW_AGENT_MAX_BUFFER_SIZE` all propagate their ignored status downstream to any other endpoints they may call. If that endpoint is running the Node Skywalking agent then regardless of its ignore settings it will not be recorded since its upstream parent was not recorded. This allows the elimination of entire trees of endpoints you are not interested in as well as eliminating partial traces if a span in the chain is ignored but calls out to other endpoints which are recorded as children of ROOT instead of the actual parent.

Expand Down
16 changes: 10 additions & 6 deletions src/agent/protocol/grpc/clients/TraceReportClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,17 @@ export default class TraceReportClient implements Client {
return;
}

const stream = this.reporterClient.collect(AuthInterceptor(), (error, _) => {
if (error) {
logger.error('Failed to report trace data', error);
}
const stream = this.reporterClient.collect(
AuthInterceptor(),
{ deadline: Date.now() + config.traceTimeout },
(error, _) => {
if (error) {
logger.error('Failed to report trace data', error);
}

if (callback) callback();
});
if (callback) callback();
},
);

try {
for (const segment of this.buffer) {
Expand Down
4 changes: 4 additions & 0 deletions src/config/AgentConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export type AgentConfig = {
reDisablePlugins?: RegExp;
reIgnoreOperation?: RegExp;
reHttpIgnoreMethod?: RegExp;
traceTimeout?: number;
};

export function finalizeConfig(config: AgentConfig): void {
Expand Down Expand Up @@ -136,6 +137,9 @@ const _config = {
reDisablePlugins: RegExp(''), // temporary placeholder so Typescript doesn't throw a fit
reIgnoreOperation: RegExp(''),
reHttpIgnoreMethod: RegExp(''),
traceTimeout: Number.isSafeInteger(process.env.SW_AGENT_TRACE_TIMEOUT)
? Number.parseInt(process.env.SW_AGENT_TRACE_TIMEOUT as string, 10)
: 10 * 1000,
};

export default _config;
Expand Down