aws / aws/aws-xray-sdk-python

Issue with passing trace_entity when using ThreadPoolExecutor in lambda

Abierto
#342 4 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Python
Estrellas
338
Forks
147
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

I followed the instructions in the readme for passing the trace entity in a ThreadPoolExecutor but this does not appear to work properly in a lambda. The first time a thread does some work the trace_entity does not stick and the subsegment gets put under the root node not the one it should be assiciated with. The next time a thread picks up a job everything seems to operate fine.

I dug into the code a bit and it seems like there is a custome context class for lambdas but it does not override `set_trace_entity` to work properly with the other changes in the class. To workaround the issue I have found calling `get_trace_entity` before setting sets the internal state up properly.

example workaround from readme
```
def load_url(url, trace_entity):
xray_recorder.get_trace_entity() # Workaround to setup internal state
xray_recorder.set_trace_entity(trace_entity)

resp = requests.get(url)

xray_recorder.clear_trace_entities()
return resp
```

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza con el ejemplo de ThreadPoolExecutor del README e inspecciona la clase de contexto personalizada utilizada para las lambdas, especialmente cómo se inicializan y establecen las entidades de traza. Reproduce el primer trabajo gestionado por un hilo y verifica que su subsegmento se adjunta a la entidad de traza proporcionada sin necesidad de una llamada previa a get_trace_entity.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
aws, python
Área
observability-sre
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.