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

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

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

  • Unify setError across all instrumentations
  • strong test in generic stack_trace for error case
  • Extension of setErrorDetails function: refactor: added error stack replacement logic #2167 (comment)
  • setErrorDetails needs to handle err being a string – e.g., nats, natsStreaming
  • setErrorDetails needs to handle err.details – e.g., grpcJs
  • fix SDK Error capture logic (Different custom key for error)
  • Remove usage of getErrorDetails
  • Implement V8 string → stack trace conversion
  • Add tests for conversion
  • Add category-level tests

Stack Trace Configuration Tasks

  • Add INSTANA_STACK_TRACE config
  • Add tests for all three modes
  • Implement mode logic (none | error | all)

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.

@abhilash-sivan abhilash-sivan changed the title refactor: updated span.data.x.error assignment (#2178) feat: implemented span stack trace configuration Nov 25, 2025
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