Skip to main content

traceAI-sagemaker

OpenTelemetry instrumentation for Amazon SageMaker real-time endpoints called through boto3's sagemaker-runtime client.

Install

pip install traceAI-sagemaker

Use

import boto3
from fi_instrumentation import register
from traceai_sagemaker import SageMakerInstrumentor

trace_provider = register(project_name="my-project")
SageMakerInstrumentor().instrument(tracer_provider=trace_provider)

# Create the client after instrumenting.
runtime = boto3.client("sagemaker-runtime", region_name="us-east-1")
response = runtime.invoke_endpoint(
    EndpointName="my-llm-endpoint",
    ContentType="application/json",
    Body='{"inputs": "What is the capital of France?", "parameters": {"max_new_tokens": 32}}',
)
print(response["Body"].read())

With fi-instrumentation-otel auto-instrumentation (fi-instrument, or FI_INSTRUMENTATIONS), the sagemaker integration is enabled whenever boto3 is installed and this package is present.

What is traced

Call Span Notes
invoke_endpoint sagemaker.invoke_endpoint Request and response bodies, token usage.
invoke_endpoint_async sagemaker.invoke_endpoint_async Request span only: the payload is in S3 and there is no output.
invoke_endpoint_with_response_stream sagemaker.invoke_endpoint_with_response_stream Ends when the stream is exhausted, fails or is closed.

Each span has kind LLM, gen_ai.provider.name = aws.sagemaker, and gen_ai.request.model set to the endpoint name. aws.sagemaker.inference_component and aws.sagemaker.target_variant are set when passed. A ClientError (or any other exception) is re-raised unchanged and recorded as ERROR with error.type; the exception message is never exported.

Content capture

  • Bodies are captured as content only when their ContentType says JSON (application/json, application/jsonlines, *+json) or text (text/*). Any other type, including a missing ContentType, is noted as [binary content: <type>, <n> bytes] and the bytes are never recorded. Binary and file-like bodies are not read for tracing.
  • The hide/capture settings of TraceConfig apply (hide_inputs, hide_outputs, and the text, message, image and invocation-parameter variants).
  • Token usage and output text are read best-effort from common JSON shapes: Hugging Face TGI (generated_text, details.generated_tokens, details.prefill), OpenAI-compatible (choices, usage), Anthropic-style (content, usage) and Bedrock-style (generation, prompt_token_count, generation_token_count). An unrecognised shape records the raw decoded body and no counts; it never fails the call.
  • Streaming responses are reassembled from PayloadPart chunks, including JSON lines split across chunks and data: server-sent events.

Running with Bedrock

traceAI-bedrock and traceAI-sagemaker both hook boto3 client creation. Each only wraps its own services (bedrock-* and sagemaker-runtime), so install and instrument both freely.

Only the Python SDK clients created after instrument() are traced.

Metadata

Release files for traceAI-sagemaker 0.1.0

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

Source distribution (sdist)

Source distribution for traceAI-sagemaker 0.1.0
File Size Uploaded Provenance Actions
traceai_sagemaker-0.1.0.tar.gz 11.2 kB Without provenance Details for traceai_sagemaker-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for traceAI-sagemaker 0.1.0
File Interpreter ABI Platform Actions
traceai_sagemaker-0.1.0-py3-none-any.whl Python 3 none any Details for traceai_sagemaker-0.1.0-py3-none-any.whl

Total release size: 23.2 kB

Release files / traceai_sagemaker-0.1.0.tar.gz

Download URL traceai_sagemaker-0.1.0.tar.gz
Size 11.2 kB
Tags Source
SHA-256 checksum
How to use checksums
127760f87f1c307071bb63141b534f367045e83b85cecf473d6789abbea670ec
BLAKE2b-256 checksum
How to use checksums
f0a605a518d5dbc52fca84cf814a06378aa858339d40d80ab776422d3cb18fee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / traceai_sagemaker-0.1.0-py3-none-any.whl

Download URL traceai_sagemaker-0.1.0-py3-none-any.whl
Size 12.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
acbcefe6bb56b2c4ed704e140fe9e05c7368aab345c17c0f1e0b98e9ebd32f50
BLAKE2b-256 checksum
How to use checksums
73ac71b92960117638dadb9d2e55c9c4e2fa3b4844a1a84eae851b7a18f12cf1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for traceAI-sagemaker 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.1.0 This release

2 release files No 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