spring-cloud / spring-cloud/spring-cloud-function

FunctionInvocationWrapper.wrapped flag never resets when a function invocation throws

Aperta Adatta ai principianti
#1,384 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Java
Stelle
1.1k
Fork
641
Merge medio
11h 2m
PR unite (30g)
8

Descrizione

Bug

In SimpleFunctionRegistry.FunctionInvocationWrapper.apply(), the FunctionInvocationWrapper.wrapped flag is set to true before delegating to doApply() (to prevent re-entrant wrapping). It is reset to false afterwards — but not in a finally block:

Object result = this.doApply(input, targetFunction);
targetFunction.wrapped = false; // ← skipped if doApply throws
return result;

When a function invocation throws, wrapped stays true forever. Every subsequent message finds wrapped = true and bypasses the ObservationFunctionAroundWrapper entirely.

This means ObservationFunctionAroundWrapper — and therefore the spring_cloud_function_seconds Micrometer timer — only records the very first message invocation which leads to an error. Every subsequent message bypasses the observation entirely.

Symptom

spring_cloud_function_seconds_count with an error is permanently stuck at 1 regardless of how many more messages result in an error. Confirmed with OTLP cumulative temporality (default), no pod restarts.

Expected behaviour

spring_cloud_function_seconds_count increments on every function invocation which leads to an error.

Actual behaviour

spring_cloud_function_seconds_count is always 1 after the first invocation which led to an error — further invocations are not observed.

Versions

  • spring-cloud-function-context:4.3.0
  • Also confirmed present in main branch (same lines 622–623 in SimpleFunctionRegistry.java)

Suggested fix

Reset this.wrapped = false after the wrapper call returns, e.g. in a finally block:

    this.wrapped = true;
    try {
        result = functionAroundWrapper.apply(input, this);
    }
    finally {
        this.wrapped = false;
    }
}

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia in SimpleFunctionRegistry.java, in SimpleFunctionRegistry.FunctionInvocationWrapper.apply(), soprattutto per il reset che avvolge doApply(). Traccia il percorso dell’errore e l’interazione con ObservationFunctionAroundWrapper. Il lavoro è completato quando le invocazioni fallite ripetute continuano a essere osservate e spring_cloud_function_seconds_count viene incrementato per ogni errore.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
observability
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Tranquilla
Chiarezza
Specificata chiaramente
Idoneità per principianti
76/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.