Skip to main content

Foam's shared server-side OpenTelemetry package for Python. One core, adapters as optional extras, per-customer behavior via configuration.

Project description

foam-otel-core (Python)

Foam's shared server-side OpenTelemetry package for Python — the Python counterpart of @foam-ai/otel-core. One core, adapters as optional extras, per-customer behavior via configuration.

Quick start

pip install foam-otel-core[fastapi]
from foam_otel import init
from foam_otel.fastapi import FoamMiddleware

init(service_name="my-service")  # token from FOAM_OTEL_TOKEN env
app.add_middleware(FoamMiddleware)

init() only exports in production (ENVIRONMENT/ENV/PYTHON_ENV/ NODE_ENV set to production) or with force_export=True. It registers global OTel providers, so afterwards the standard OTel API exports to foam:

from opentelemetry import trace, metrics
from foam_otel import get_tracer, get_meter, get_logger

with get_tracer("app").start_as_current_span("work") as span:
    span.record_exception(err)          # exceptions
get_meter("app").create_counter("jobs").add(1)
get_meter("app").create_histogram("latency_ms").record(12.5)
get_meter("app").create_up_down_counter("active").add(-1)
get_logger("app").emit(...)             # log records

Configuration

Option Default Notes
token FOAM_OTEL_TOKEN env required to export
endpoint OTEL_EXPORTER_OTLP_ENDPOINT env, then https://otel.api.foam.ai
force_export False export outside production
redact_contact_info False adds email/phone/telefono/celular to redaction
redact_keys [] extra keys to redact
health_routes [] extra routes skipped for request-context capture

Batch cadence honors OTEL_BSP_SCHEDULE_DELAY, OTEL_BLRP_SCHEDULE_DELAY, and OTEL_METRIC_EXPORT_INTERVAL (read natively by the SDK).

The wire contract (stamps, foam.rid baggage, redaction defaults, anti-fabrication) is specified in contract/SPEC.md and enforced by test-apps/python-fastapi.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

foam_otel_core-0.1.0.tar.gz (17.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

foam_otel_core-0.1.0-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file foam_otel_core-0.1.0.tar.gz.

File metadata

  • Download URL: foam_otel_core-0.1.0.tar.gz
  • Upload date:
  • Size: 17.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for foam_otel_core-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a3fc465d021d021b5712e22d7ce66cbc007df9098c7fb2631c3c563a2c9bfc30
MD5 22a26b7a83b05bec623ce61df8b0f934
BLAKE2b-256 e88036cf7b1af126186d33326fa7eba843523afbc92fcd514b176c518df44990

See more details on using hashes here.

Provenance

The following attestation bundles were made for foam_otel_core-0.1.0.tar.gz:

Publisher: release.yml on foam-ai/packages

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file foam_otel_core-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: foam_otel_core-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for foam_otel_core-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8acb4a66d0711320817335c12a2c78e59e86d72f5490f947d9b314d67e860700
MD5 2d2fca22c834f2498b4b2bfce914a1ef
BLAKE2b-256 beb02c49e4ec4e7dd40c71a4054b03d5d6647a57a172e162ba4c696b3e623d96

See more details on using hashes here.

Provenance

The following attestation bundles were made for foam_otel_core-0.1.0-py3-none-any.whl:

Publisher: release.yml on foam-ai/packages

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page