jeffrey-traces-http-client
/jeffrey-traces-http-client
Instrumentuje wychodzące wywołania HTTP zdarzeniami JFR Jeffrey: ClientHttpRequestInterceptor emituje HttpClientExchangeEvent jako liść pod obsługiwanym żądaniem, widoczny w panelu HTTP Client i w śladach.
- Autor
- petrbouda ↗
- Repozytorium
- jeffrey ↗
- Licencja
- Apache-2.0
- Ostatnia zmiana repozytorium
- 27.10.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 1
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 27.10.2026, bez odwołań do wycofanych modeli i API.
Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.
Co robi i kiedy
Instrumentuje wychodzące wywołania HTTP zdarzeniami JFR Jeffrey: ClientHttpRequestInterceptor emituje HttpClientExchangeEvent jako liść pod obsługiwanym żądaniem, widoczny w panelu HTTP Client i w śladach.
Oryginalny opis (EN)
Instrument outbound HTTP calls with Jeffrey JFR events — a ClientHttpRequestInterceptor (RestTemplate, or any HTTP client with an interception point) emitting HttpClientExchangeEvent as a leaf span nested under the request being served. Use when the application calls other services over HTTP and those calls should appear in Jeffrey's HTTP Client dashboard and Traces. Requires the jeffrey-traces-core skill for the data model, emit rules, recording setup, and verification; inbound requests are covered by jeffrey-traces-spring-rest-server.
Jak działa
- 1. The shipped interceptor (Spring)
- 2. Writing it yourself: RestTemplate interceptor
- 3. Registration
- 4. Async clients (WebClient, async HttpClient)
- 5. Client-side pitfalls
Podgląd SKILL.md
---
name: jeffrey-traces-http-client
description: Instrument outbound HTTP calls with Jeffrey JFR events — a ClientHttpRequestInterceptor (RestTemplate, or any HTTP client with an interception point) emitting HttpClientExchangeEvent as a leaf span nested under the request being served. Use when the application calls other services over HTTP and those calls should appear in Jeffrey's HTTP Client dashboard and Traces. Requires the jeffrey-traces-core skill for the data model, emit rules, recording setup, and verification; inbound requests are covered by jeffrey-traces-spring-rest-server.
---
# Jeffrey Traces — Outbound HTTP Client Instrumentation
Read **`jeffrey-traces-core`** first — it defines the data model, the emit
rules, the dependency, recording configuration, and verification. This skill
applies those rules to outbound HTTP calls. Inbound request handling is the
companion skill **`jeffrey-traces-spring-rest-server`**.
The client exchange is a **leaf span**: the downstream work happens in another
process this recording cannot see, so the event is committed with
`commitSpan()` — nesting it under the span in progress (usually the server
exchange of the request being served) — never with `Tracer.inSpanOf`.
Rules recap (from the core skill) that this code embodies:
- Leaf events commit with `commitSpan()`; a bare `commit()` silently drops
the call from every trace. `TracedEvents.emit` below commits that way for
you.
- `uri` must be low-cardinality: the URI template you expanded, or host + path
with variable segments collapsed — never a URL containing an entity id.
- `statusCode` drives span status automatically: `describeSpan()` marks
`>= 400` as `ERROR` — never set `name`/`status` yourself. A transport
failure that produced no status code is recorded with `event.failed(e)`,
which the derived verdict never paints over.
---
## 1. The shipped interceptor (Spring)
`jeffrey-tracing-spring` ships this interceptor, so on Spring you do not write it. Adding
`jeffrey-tracing-spring-boot-starter` (or `@Import(JeffreyTracingConfiguration.class)` on plain
Spring) gives you a `JfrClientHttpRequestInterceptor` bean; attach it where you build the client:
```java
RestTemplate restTemplate = new RestTemplate();
restTemplate.getInterceptors().add(interceptor); // the bean from the configuration
```
It is only a bean, not attached automatically: Spring Boot 4 removed `RestTemplateCustomizer`, and
applications build clients in too many ways for a starter to guess. By default it records host and
path with the query string dropped — that is where ids and tokens live — and you can pass a
`Function<URI, String>` to collapse variable path segments into a template instead.
The rest of this section shows what that interceptor does, for a client with no Spring involved.
## 2. Writing it yourself: RestTemplate interceptor
For `RestTemplate` (a `ClientHttpRequestInterceptor`); the same shape applies
to any HTTP client with an interception point:
```java
public class JeffreyJfrRestTemplateInterceptor implements ClientHttpRequestInterceptor {
@Override
public ClientHttpResponse intercept(
HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
// TracedEvents.emit is the whole leaf lifecycle: guard, begin, end on
// success, failed(e) on the exception path (a transport failure that
// never produced a status code shows red), commitSpan() stamping the
// event under the span in progress — usually the server exchange of
// the request being served. The IOException propagates through typed.
HttpClientExchangeEvent event = new HttpClientExchangeEvent();
return TracedEvents.emit(event,
() -> execution.execute(request, body),
(e, response) -> {
e.method = request.getMethod().name();
// Low-cardinality: host + path with variable segments
// collapsed, ideally the URI template you expanded. Never a
// URL containing an entity id — one distinct name per
// endpoint, not per call.
e.uri = request.getURI().getHost() + normalizePath(request.getURI().getPath());
e.remoteHost = request.getURI().getHost();
e.remotePort = request.getURI().getPort();
e.requestLength = body.length;
// response is null when the call threw before answering.
e.statusCode = response != null ? response.getStatusCode().value() : 0;
});
}
}
```
Where `TracedEvents` does not fit, write the expanded shape from the core
skill's §4 rule 3 instead (guard, `begin()`, `end()` on success, `commitSpan()`
in the `finally`).
## 3. Registration
```java
restTemplate.getInterceptors().add(new JeffreyJfrRestTemplateInterceptor());
```
Or, in Spring Boot, via a `RestTemplateCustomizer`/`RestTemplateBuilder` bean
so every built `RestTemplate` carries it:
```java
@Bean
public RestTemplateCustomizer jeffreyJfrRestTemplateCustomizer() {
return restTemplate ->
restTemplate.getInterceptors().add(new JeffreyJfrRestTemplateInterceptor());
}
```
## 4. Async clients (WebClient, async HttpClient)
A blocking interceptor shape does not fit a client whose response arrives via
callbacks on threads you don't control. Use the callback pattern from the core
skill instead: `Tracer.openSpanOf(event)` when the call starts (on
the thread whose span it belongs to), `Tracer.reenter(ctx, ...)` around each
callback, and `event.commitSpan()` at completion. `openSpanOf` stamps the ids
eagerly, so a completion running after the enclosing binding is gone still
carries the right identity.
## 5. Client-side pitfalls
| Symptom | Cause | Fix |
|---|---|---|
| Calls in the HTTP Client dashboard but not in Traces | committed with `commit()` | `TracedEvents.emit`, or `commitSpan()` in the `finally` |
| Client calls are roots of their own one-span traces | call ran outside a bound span (no server filter, `@Async`, scheduled job) | register the root-span filter (`jeffrey-traces-spring-rest-server`); wrap background work with `Tracer.fork`/`continueIn` |
| One "endpoint" per entity id | raw expanded URL recorded as `uri` | record the template / normalized path |
| Connection failures look green | exception path missing `failed(e)` | `TracedEvents.emit` records it; by hand, catch the transport exception, call `event.failed(e)`, rethrow |
| Async call measured as ~0 ms | event ended when the request was *sent*, not when the response arrived | complete the event from the response callback (deferred-commit pattern, §3) |
Wersje
W bazie nie ma innych skilli o nazwie jeffrey-traces-http-client.
Migawka bazy z 13.11.2026 · wersja paczki 63aa16660056 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100advise-jfr
Zamienia profil Jeffrey w konkretne zmiany kodu: mapuje najgorętsze ramki CPU, zegara, alokacji i blokowania, najwolniejsze ślady oraz pracę bazy i HTTP na źródła, proponuje minimalne poprawki i weryfikuje je testami i ponownym profilowaniem. - 90help
Wyjaśnia, co Jeffrey Microscope może zbadać w zapisie JFR i zrzucie sterty oraz które umiejętności obsłużą każdy obszar. - 100spring-testing-http-client
Testuje kod wywołujący zewnętrzne API w Spring Boot: RestClient, klienty HTTP, MockRestServiceServer i błędy odpowiedzi. - 100http-client-config
Prawdopodobnie wspiera konfigurację klienta HTTP w integracjach API. - 100laravel-rest-api
Podaje reguły REST API i krawędzi HTTP w Laravel: autoryzacja przed domeną, walidacja i DTO w Form Requests, scoped route model binding, Resources JSON, cienkie kontrolery, mapowanie wyjątków domenowych i wywołania wychodzące. - 87snowbank-betterhttp
Pomaga w wykonywaniu wywołań HTTP przez BetterHttpClient w aplikacjach ASP.NET Core i .NET z generic host.