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 [] routes exempted from request-context capture (none by default — health checks are captured)

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.2.0.tar.gz (17.9 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.2.0-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: foam_otel_core-0.2.0.tar.gz
  • Upload date:
  • Size: 17.9 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.2.0.tar.gz
Algorithm Hash digest
SHA256 f6d5cab426475495ce02642eb88a239996e113c540bfb666bdb10f9c7a3af377
MD5 90eb5c0dc3e5f04661c30da970539f6c
BLAKE2b-256 21e3dd6f8f309356c52d01ca6d718310537c55a4398c638475b031e291db54ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for foam_otel_core-0.2.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.2.0-py3-none-any.whl.

File metadata

  • Download URL: foam_otel_core-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 15.0 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a9aac1c0c55887969bcb7d37f6d8a3552a7b8b149924451890bfdf188642bb9e
MD5 a378bb5110adcec9c04a1829baefb8e0
BLAKE2b-256 8bb8c40c939222cd8b22d471b24fd143c5b4149a7a0e448bdd46f319c234b1b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for foam_otel_core-0.2.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