Skip to main content

spanlint

ci PyPI

Checks whether GenAI telemetry actually matches the OpenTelemetry GenAI semantic conventions.

Most AI frameworks now emit OpenTelemetry spans for model calls, and the GenAI semantic conventions say what those spans are supposed to contain. The two do not always agree. Attributes get left out. Old names stick around long after the spec renames them. Token metrics turn up without the right unit. Required events are missing entirely.

You normally find this out from a dashboard, when a panel is empty and nobody can say which layer dropped the attribute.

spanlint reads the telemetry a framework really emits and reports where it diverges from the spec.

Not Weaver, not the conformance suite

Weaver works on the convention registries: the YAML that defines what an attribute is, code generation from it, and, with weaver registry live-check, validation of sample telemetry against them. The OpenTelemetry project runs that live-check over scenario programs for several dozen GenAI library and instrumentation pairs in semantic-conventions-conformance and publishes the results. If you maintain an instrumentation, that is where its conformance is tracked.

spanlint is for the other side. You have an application, it exports telemetry, and you want to know in CI whether what it exports still matches the conventions. It reads OTLP JSON files or captures spans in a pytest fixture, needs no mock server and no scenario, and tells you which spans came from which framework. It also carries a few checks the suite does not have today, span kind among them, and fixtures from runtimes the suite does not run (.NET, Node). The first comparison across nine frameworks is in docs/conformance/2026-11.md.

Install

pip install spanlint

Usage

Point spanlint check at an OTLP JSON export of your telemetry:

$ spanlint check trace.json
no findings

Divergences from the GenAI conventions show up as one line each, with the target span, the message, and the rule name:

$ spanlint check broken.json
chat: gen_ai.request.model must be a string [gen_ai.request.model.type]
1 finding

The exit code is nonzero whenever there are findings, so this fits a CI step. Pass --format json for a machine-readable report:

$ spanlint check trace.json --format json
{
  "findings": []
}

Line-delimited OTLP exports (.jsonl, one export per line, which is what the OTel Collector's file exporter writes) are read the same way. The parser is picked by the file's extension.

spanlint matrix <dir> runs the bundled framework adapters over a tree of exports laid out as <dir>/<framework>/*.json and prints a markdown table of finding counts per framework and rule. The fixtures in this repository are laid out that way, so spanlint matrix tests/fixtures reproduces the table in docs/conformance/2026-11.md.

Use in CI

In GitHub Actions, spanlint-action installs spanlint and checks a set of OTLP exports, for example the traces your integration tests write through the Collector's file exporter:

- uses: inormis/spanlint-action@v1
  with:
    files: traces/**/*.json

Findings show up as warnings on the files and in the job summary, and the step fails if there are any.

Supported frameworks

Framework detection is what tells spanlint which spans came from where, so per-framework conformance can be reported without mixing everything together.

  • openai-python: spans from the OpenTelemetry contrib instrumentation (opentelemetry-instrumentation-openai-v2, scope opentelemetry.instrumentation.openai_v2) and from Traceloop's OpenAI instrumentation (scope opentelemetry.instrumentation.openai.v1). Identification falls back to gen_ai.system=openai or gen_ai.provider.name=openai when the scope name is not one of the expected values; that is also how the contrib instrumentation's gen_ai_latest_experimental output is recognised, since that path emits from opentelemetry-util-genai's own opentelemetry.util.genai.handler scope.
  • LangChain: spans emitted by Traceloop's opentelemetry-instrumentation-langchain, which is also what the Traceloop SDK installs, and by Arize's openinference-instrumentation-langchain. Identification falls back to gen_ai.provider.name being langchain or langgraph when the scope name is not one of those.
  • LlamaIndex: spans from LlamaIndex's own OpenTelemetry bridge (llama-index-observability-otel), from Traceloop's opentelemetry-instrumentation-llamaindex, and from Arize's openinference-instrumentation-llama-index. Scope name only; none of the three puts a LlamaIndex-specific attribute on every span.
  • LiteLLM: spans from LiteLLM's own OpenTelemetry callback (tracer name litellm), from Traceloop's opentelemetry-instrumentation-litellm, and from Arize's openinference-instrumentation-litellm. Scope name only.
  • Semantic Kernel (Python): spans from Semantic Kernel's own telemetry, which is off until SEMANTICKERNEL_EXPERIMENTAL_GENAI_ENABLE_OTEL_DIAGNOSTICS is set. Every tracer there is named after its module, so any scope starting with semantic_kernel. counts.
  • Microsoft.Extensions.AI (.NET): spans from the library's UseOpenTelemetry chat client, which puts them on the Experimental.Microsoft.Extensions.AI activity source unless the application names its own. Scope name only. The attributes are plain gen_ai.*, so a span from a renamed source goes unrecognised.
  • Vercel AI SDK (Node): spans from @ai-sdk/otel, which is where AI SDK 7 keeps its OpenTelemetry support. Its OpenTelemetry integration puts the invoke_agent, agent_step and chat spans on a tracer named gen_ai; the LegacyOpenTelemetry one puts the older ai.generateText spans on a tracer named ai. Either scope name counts. A legacy span under an application-supplied tracer is still recognised by its ai.operationId attribute; a semconv one carries nothing of the SDK's own, so it is not.
  • Langfuse: spans from the Langfuse Python SDK, which is built on OpenTelemetry and puts everything it emits, the @observe decorator and its OpenAI and LangChain integrations included, on one tracer named langfuse-sdk. Scope name only. The langfuse.* attributes are no help because the SDK also copies propagated ones onto third-party spans.
  • Traceloop SDK: the workflow, task, agent and tool spans that the traceloop-sdk decorators emit under the traceloop.tracer scope. Spans from Traceloop's per-framework instrumentations are claimed by the framework adapters above, not by this one.

More adapters land as work on them starts.

Status

Early, but it runs. You can feed it an OTLP JSON export and get a list of findings back, in text or JSON. The rules follow the GenAI conventions as of November 2026 (the registry is pinned to a semantic-conventions-genai commit, see scripts/refresh_registry.sh): gen_ai.operation.name on every GenAI span and gen_ai.provider.name where the span definitions require it, renamed and removed attribute names, the open operation name enum, span kind per operation, attribute types, the two legacy message/choice events, and the token/duration histograms. It recognises spans from the OpenAI contrib instrumentation, LangChain, LlamaIndex, LiteLLM, Semantic Kernel, Microsoft.Extensions.AI, the Vercel AI SDK, Langfuse and the Traceloop SDK, and spanlint matrix turns a tree of exports into the per-framework table in docs/conformance/. There is also a pytest fixture that grabs whatever spans your test emits so you can lint them in place.

On PyPI as of 0.2.0, and runs in GitHub Actions through spanlint-action. Next up: a second dataset once the conventions move again.

Apache-2.0

Metadata

Release files for spanlint 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spanlint 0.2.1
File Size Uploaded Provenance Actions
spanlint-0.2.1.tar.gz 66.9 kB With provenance Details for spanlint-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for spanlint 0.2.1
File Interpreter ABI Platform Actions
spanlint-0.2.1-py3-none-any.whl Python 3 none any Details for spanlint-0.2.1-py3-none-any.whl

Total release size: 102.2 kB

Release files / spanlint-0.2.1.tar.gz

Download URL spanlint-0.2.1.tar.gz
Size 66.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b0c86dd8d2e1ca11de8df974a0b87f4f35b2e2dcd4e65baaad0c47661562a8ab
BLAKE2b-256 checksum
How to use checksums
9b668c320a6a868c8f992e48e4c9989a53d2eb83d1fa7bfc9751c19edca373a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / spanlint-0.2.1-py3-none-any.whl

Download URL spanlint-0.2.1-py3-none-any.whl
Size 35.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
52aa9a5fcbbdc62af2392710acbeb9cd33b5fd67aa36a40ac138ee5b162098aa
BLAKE2b-256 checksum
How to use checksums
6ee82166b2833aa39bda5d2cf7abdc0de51639073f8b77ed2a48c06145f694f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Security for spanlint 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for spanlint-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page