aws / aws/aws-xray-sdk-java

Default streaming strategy for Lambda should export segments immediately upon ending

Aperta
#327 1 commento 1 reazione 0 assegnatari Vedi su GitHub
Lingua principale
Java
Stelle
100
Fork
100
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

## Description

In the X-Ray Java SDK, the default streaming strategy is to wait until there are 100 segments to send (export to the X-Ray Daemon for publishing) and then sending them all at once:

https://github.com/aws/aws-xray-sdk-java/blob/a2bc1ad7b8481d0f5090e460dcbdaaa7f77e5aa1/aws-xray-recorder-sdk-core/src/main/java/com/amazonaws/xray/strategy/DefaultStreamingStrategy.java#L25-L27

This means that the streaming strategy for Lambda, which follows the recorder's streaming strategy, also batches segments:

https://github.com/aws/aws-xray-sdk-java/blob/a2bc1ad7b8481d0f5090e460dcbdaaa7f77e5aa1/aws-xray-recorder-sdk-core/src/main/java/com/amazonaws/xray/contexts/LambdaSegmentContext.java#L126-L128

This is a problem when instrumented Lambdas **timeout** and segments that have ended and are ready to be published aren't because they were waiting (for example) the 99th span to finish when the application timed out.

Users can already set the streaming strategy as so:

```java
AWSXRay.getGlobalRecorder().setStreamingStrategy(new DefaultStreamingStrategy(0));
```

But this should be the default behavior for Lambda. We do this in other SDKs:
* [X-Ray Python SDK Default Streaming Strategy Default of 0](https://github.com/aws/aws-xray-sdk-python/blob/f5f9c470b189bb34f31a1d0a28f497741132b7d2/aws_xray_sdk/core/recorder.py#L55-L61)
* [X-Ray JS SDK Default Streaming Strategy Default of 0](https://github.com/aws/aws-xray-sdk-node/blob/a9d0cf9cbd0328e40f30554f61b4bd5fac08bafc/packages/core/lib/env/aws_lambda.js#L25-L26)

We do _not_ do it in the following languages even though we should:
* [X-Ray Go Lambda Context](https://github.com/aws/aws-xray-sdk-go/blob/c4ccab1d3ca59f5ce66f3dab6522dc1fc4a490c7/xray/lambda.go)
* [X-Ray .NET Lambda Context](https://github.com/aws/aws-xray-sdk-dotnet/blob/d2b64125ecdd734af220795d5b102bd96b037981/sdk/src/Core/Internal/Context/LambdaContextContainer.netstandard.cs)
* [X-Ray Ruby Lambda Context](https://github.com/aws/aws-xray-sdk-ruby/blob/5d482e76d86b7610d5fe8e404c44cd0bce9e9547/lib/aws-xray-sdk/lambda/lambda_context.rb)

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia da aws-xray-recorder-sdk-core/src/main/java/com/amazonaws/xray/strategy/DefaultStreamingStrategy.java e LambdaSegmentContext.java, in particolare dalle righe referenziate relative alla strategia di streaming. Traccia il modo in cui Lambda ottiene la strategia del recorder e confronta la configurazione esistente con una soglia pari a zero; il lavoro è completato quando Lambda esporta immediatamente per impostazione predefinita i segmenti terminati e il comportamento è coperto da test appropriati.

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

Valutazione

Stack tecnologico
java
Ambito
observability-sre
Tipo di issue
Funzionalità
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.