Skip to content

Conversation

@abhilash-sivan
Copy link
Contributor

@abhilash-sivan abhilash-sivan commented Nov 25, 2025

EPIC link: https://jsw.ibm.com/browse/INSTA-57356

This will be the final PR to main for the stack trace filtering feature!

This PR proposes a refactor of the current instrumentation error/stack logic and introduces a new configuration option (INSTANA_STACK_TRACE) to control stack trace collection behaviour across all instrumentations based on the EPIC design.


Goals / Design

  • Unify and simplify error/stack handling across all instrumentations. -refactor
  • Add configurable stack trace modes (none, error, all) - implementation

in-code/env:
INSTANA_STACK_TRACE_LENGTH (was already supported by Node.js tracer) - this is global. We don't have any community design for global/local envs yet.
INSTANA_STACK_TRACE (this is new) - this is also global. We don't have any community design for global/local envs yet.
tracing.stackTraceLength (was already supported by Node.js tracer) -> this is also global. We accept tracing.global.stackTraceLength as an input param and we print a deprecation warning for tracing.stackTraceLength. Later on as soon as we have full local filtering support, we can continue with the migration.
tracing.stackTrace (this is new) - this is also global for now. Same here, we start with the migration (tracing.global.stackTrace) and finish it up as soon as we have to (because there is no local filtering support yet)

agent:
tracing.global.stackTraceLength (this is new)
tracing.global.stackTrace (this is new)
-> no local support yet (this needs to go into the post task for stack trace filtering)

1. Refactor & Unify Instrumentation Logic

1.1 Introduce a Common Error / Stack Handling Helper

Unify setError logic

Create a shared helper used by all instrumentations for attaching error details and stack traces.

Ensure getErrorDetails always returns a string

Guarantees consistent type in span.data.<tech>.error.

Implement V8 string → stack trace conversion

Handle cases where the stack arrives as a plain string.
Add a test validating correct conversion behaviour.

Add dedicated tests

At least one test to ensure conversion logic is correct.


1.2 Update All Instrumentations to Use Shared Logic

All categories will be updated to call the new unified helper:

  • DB instrumentations
  • Messaging instrumentations
  • Protocol / HTTP instrumentations

This ensures:

  • Consistent error assignment
  • Consistent stack generation / overwrite rules
  • Reduced code duplication

1.3 Add Category-Level Tests

Tests to validate:

  • Every category behaves consistently under errors
  • Stack traces are attached or removed correctly
  • Error fields are stringified

2. Add Configurable Stack Trace Mode

Introduce a configuration setting:

INSTANA_STACK_TRACE = none | error | all
configuration via agent and custom file

2.1 Implement Stack Trace Mode Behaviour


2.2 Add or Update Tests

Add full coverage for the three modes:

  • none → stack always removed
  • error → stack present only on error
  • all → stack always present (and overwritten on error)

Task List Summary

Refactoring Tasks


Stack Trace Configuration Tasks


Optional

  • We should not generate stacks at all if span is filtered out

After Implementation

  • Update public documentation to reflect the new configuration and unified behaviour.

points to note:

  1. Stack trace length:

    max length: 500
    by default: 10


Other issues to resolve after this PR/in between directly to main

@abhilash-sivan abhilash-sivan changed the title refactor: updated span.data.x.error assignment (#2178) feat: implemented span stack trace configuration Nov 25, 2025
@abhilash-sivan abhilash-sivan force-pushed the feat-stack-trace branch 2 times, most recently from 920e277 to d8122b3 Compare December 9, 2025 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants