obelisk.asynchronous.producer.Producer

class obelisk.asynchronous.producer.Producer(client: str, secret: str, retry_strategy: ~obelisk.strategies.retry.RetryStrategy = <obelisk.strategies.retry.NoRetryStrategy object>, kind: ~obelisk.types.ObeliskKind = ObeliskKind.CLASSIC)[source]

Bases: Client

Allows publishing of data to Obelisk.

Attributes:
token
token_expires

Methods

http_post(url[, data, params])

Send an HTTP POST request to Obelisk, with proper auth.

send(dataset, data[, precision, mode])

Publishes data to Obelisk

__init__(client: str, secret: str, retry_strategy: ~obelisk.strategies.retry.RetryStrategy = <obelisk.strategies.retry.NoRetryStrategy object>, kind: ~obelisk.types.ObeliskKind = ObeliskKind.CLASSIC) None

Methods

__init__(client, secret[, retry_strategy, kind])

http_post(url[, data, params])

Send an HTTP POST request to Obelisk, with proper auth.

send(dataset, data[, precision, mode])

Publishes data to Obelisk

Attributes

grace_period

Controls how much before the expiration deadline a token will be refreshed.

token

Current authentication token

token_expires

Deadline after which token is no longer useable

retry_strategy

kind

log

grace_period: timedelta = datetime.timedelta(seconds=10)

Controls how much before the expiration deadline a token will be refreshed.

async http_post(url: str, data: Any = None, params: dict | None = None) Response

Send an HTTP POST request to Obelisk, with proper auth.

Possibly refreshes the authentication token and performs backoff as per retry_strategy. This method is not of stable latency because of these properties.

No validation is performed on the input data, callers are responsible for formatting it in a method Obelisk understands.

async send(dataset: str, data: List[dict], precision: TimestampPrecision = TimestampPrecision.MILLISECONDS, mode: IngestMode = IngestMode.DEFAULT) Response[source]

Publishes data to Obelisk

Parameters:
datasetstr

ID for the dataset to publish to

dataList[dict]

List of Obelisk-acceptable datapoints. Exact format varies between Classic or HFS, caller is responsible for formatting.

precisionTimestampPrecision = TimestampPrecision.MILLISECONDS

Precision used in the numeric timestamps contained in data. Ensure it matches to avoid weird errors.

modeIngestMode = IngestMode.DEFAULT

See docs for IngestMode.

Raises:
ObeliskError

When the resulting status code is not 204, an empty ObeliskError is raised.

token: str | None = None

Current authentication token

token_expires: datetime | None = None

Deadline after which token is no longer useable