ctx Class
The ctx class passes execution context metadata, telemetry interfaces, secrets, and metrics instruments to your function handler.
The ctx object is passed as an argument to both the event initializer function (init(ctx)) and the event handler function (handler()).
It provides access to the following capabilities:
Embedded OpenTelemetry tracer and span creation helpers.
Embedded OpenTelemetry logger.
Embedded OpenTelemetry
meterand custom metrics methods (counter,histogram,updowncounter,gauge).Access to pipeline and function secrets mounted at runtime.
Access to the pipeline triggers map and conditional trigger routing metadata.
Access to custom attributes, initialized during
init().
Property / Method | Type / Return Type | Description |
|---|---|---|
| logging.Logger | The function logger instance with OpenTelemetry logging integration. |
| opentelemetry.trace.Tracer | The OpenTelemetry tracer used to generate trace spans. |
| Optional[opentelemetry.metrics.Meter] | The OpenTelemetry meter instance used to generate custom metrics. |
| dict | Access to Kubernetes secrets mounted to the function runtime. Returns an empty dictionary if secrets are not mounted. |
| str | The deployed service name of the function. |
| dict | The pipeline triggers map structure containing function trigger linkages and conditional trigger labels. |
| dict | Getter method returning the pipeline triggers map dictionary. |
| Optional[Counter] | Creates or retrieves a monotonic counter metric instrument. |
| Optional[Histogram] | Creates or retrieves a histogram metric instrument with optional custom bucket boundaries. |
| Optional[UpDownCounter] | Creates or retrieves a metric instrument for values that can increase or decrease (e.g., queue size). |
| Optional[ObservableGauge] | Creates or retrieves an observable gauge metric instrument measured via a callback function. |
| ContextManager[Span] | Starts a new OpenTelemetry span set as the active span in the current context. |
| ContextManager[Span] | Starts a new OpenTelemetry span explicitly attached to the specified |
Tracer and Spans
The embedded tracer is a standard OpenTelemetry tracer. You can use ctx.tracer or the helper methods ctx.start_as_current_span() and ctx.start_as_current_event_span() to generate telemetry spans visualizable in DataEngine.
Logger
The embedded logger (ctx.logger) is an OpenTelemetry-integrated Python logger. Use standard severity levels (info, warning, error, etc.) to produce trace-correlated execution logs.
Note
By default, the runtime also captures
stdout(such asprint()statements) and logs from standard Python loggers, automatically transmitting them via OpenTelemetry to VAST DataEngine.
Access to Custom Attributes
You can use the ctx object to create custom attributes. Custom attributes must be initialized by the init() function and then they can be accessed in the event handler path.
For example:
def init(ctx):
# One-time initialization
ctx.logger.info("Initialized...")
# Initialize custom attributes on the context object
ctx.myvalue = "some_value"
ctx.counter = 1
def handler(ctx, event):
# Event processing path
ctx.logger.info(f"Handler processing event: {event}")
# Access and update custom attributes set during init
ctx.counter += 1
return f"myvalue={ctx.myvalue}, counter={ctx.counter}"Custom Metrics
Functions can register and emit custom OpenTelemetry metrics using helper methods on the ctx object:
counter: Track cumulative counts (e.g., total items processed).histogram: Measure value distributions (e.g., request latency in milliseconds). Custom bucket boundaries can be provided using theboundariesargument.updowncounter: Track fluctuating quantities (e.g., active concurrent tasks).gauge: Observe instantaneous values measured via an asynchronous callback function (e.g., memory utilization).
Access to Secrets
Secrets mounted to your pipeline or function deployment are accessible via the ctx.secrets dictionary. If no secrets directory is mounted, ctx.secrets returns an empty dictionary.
Pipeline Triggers Map
The ctx.pipeline_triggers_map property provides access to the pipeline configuration map, detailing downstream function trigger relationships and conditional trigger labels.
VastEvent Class
Base class for all event types. It provides access to CloudEvent attributes, OpenTelemetry trace context, conditional trigger labeling, and type-casting methods (as_element_event(), as_schedule_event(), as_function_event(), as_manual_event()).
Base class for all event types. Returns the following properties:
Property | Type | Description |
|---|---|---|
| str | The version of the CloudEvents specification which the event uses. This is hardcoded as 1.0. |
| str | A unique identifier for the event. |
| str | The timestamp of the event. |
| str | The name of the source trigger for the event. |
| str | The identifier of the source trigger of the event. |
| str | The event broker that handled the event. |
| str | The topic that handled the event. |
| str | Returns one of the following event types:
|
| str | For element type events, returns one of the following:
For schedule type events, returns For |
| dict | A dictionary of custom CloudEvent extension attributes attached to the event. |
| str | The topic partition that handled the event. Maps to the raw CloudEvent JSON attribute |
| Optional[int] | The trace ID extracted from the |
| int | Returns the integer trace ID for the event, using inherited headers or generating one from the event ID and pipeline revision ID. |
| str | Returns the 32-character hexadecimal string representation of the trace ID. |
| None | Sets a dictionary of key-value conditional trigger labels on the event context. |
| ContextManager[Span] | Starts an OpenTelemetry span attached to the event's trace context. |
ElementTriggerVastEvent Class
Represents element type events. This type of event is produced by an element type trigger that watches for the creation or removal of an element (S3 object) or tag (s3 object tag) in a source view (bucket).
Includes all VastEvent properties plus:
Property | Type | Description |
|---|---|---|
| str | The object key of the object that was involved in the event. Depending on the subtype, the object may have been uploaded to the bucket, deleted from the bucket, a tag added to the object, or a tag removed from the object. |
| str | The bucket where the event was produced. |
| str | The path to the element that involved in the event, formed as |
FunctionVastEvent Class
Represents function type events. This type of event is sent by a function to another function if the first function triggers the second function in a deployed pipeline.
Includes all VastEvent properties plus:
Property | Type | Description |
|---|---|---|
| str | The name/identifier of the function that triggered this event. |
Note
For
FunctionVastEvent,subtypeis not available and returnsNone. Accessingtriggerortrigger_idwill log a warning directing you to usefunction_triggerinstead.
ScheduleVastEvent Class
Represents schedule type events. This type of event is produced by a schedule type trigger that produces events on a configured schedule.
Includes all VastEvent properties plus:
Property | Type | Description |
|---|---|---|
| str | The schedule of the trigger that produced the event, in cron schedule format. |
| str | The time at which the schedule fired the trigger to produce the event, as a timestamp in the format: |
ManualVastEvent Class
Represents manual type events triggered directly by a user.
This class inherits all base properties and methods from VastEvent without adding additional specialized properties. It provides the as_manual_event() casting method.
VastEventList Class
A wrapper class around a list of VastEvent objects designed for batch event processing.
Method | Return Type | Description |
|---|---|---|
| None | Sets conditional trigger labels for all events contained within the batch. |