#2969·datasette

OpenTelemetry: datasette.client 请求开始一个新的追踪,而不是嵌套在调用者的 Span 中

作者: asg017创建于 2026年9月28日更新于 2026年9月28日

datasette/telemetry.py:252, in TelemetryMiddleware.__call__:

python
context = extract(headers, getter=_HEADERS_GETTER)
with tracer.start_as_current_span(method, context=context, kind=SpanKind.SERVER):
  • When extract() gets no context=, it starts from an empty Context(). With no traceparent header, which is always the case for datasette.client calls, it returns that empty context.
  • Passing that context explicitly to start_as_current_span makes the span a new root.
  • The caller's span is still current in contextvars at this point. The _in_datasette_client flag read a

内容来源: simonw/datasette