Overview
Runtime Context is a lightweight ODC External Logic library that lets any app discover which stage it is running on — and whether it is Production — at runtime, with zero configuration.
No per-stage settings. No app config files. Call an action and get the answer.
The Problem It Solves
ODC has no built-in, runtime-readable way to know the current stage. The typical workaround is a per-stage app setting that must be manually configured on every stage. This works but adds operational overhead and is easy to misconfigure.
Runtime Context reads the stage tier directly from the platform-injected execution environment, so it works on every stage with no setup required from the deploying team.
Requirements
Unknown
IsProductionStage()
ExplainClassification
Read This First
IsProductionStage() is directional. It returns False both when the stage is confirmed non-production and when the stage could not be determined at all.
If IsProductionStage() Then
If Not IsProductionStage() Then
The unsafe pattern routes real production traffic into test behavior on any stage where the platform signal is missing. When the distinction matters, read GetCurrentStage() and branch on IsClassified, which is True only when the stage was positively identified.
GetCurrentStage()
Features
Actions
All actions take no input parameters. They can be called directly in any server-side logic flow.
GetCurrentStage
Returns the full classification and context of the stage the app is running on.
Output: Stage (StageDetails) — classification, production flag, IsClassified flag, identifier, URL, subdomain, and infrastructure realm.
Stage
StageDetails
IsProductionStage
Quick boolean check. Use this to guard logic that should only run on Production. See Read This First above before using it.
Output: IsProduction (Boolean) — True only when the app is positively identified as running on a Production stage.
IsProduction
Returns the raw platform signals and the rule that produced the classification. Reach for this first when stage detection returns something unexpected — it tells you whether the signal was absent, or present but carrying a realm token this version does not recognize.
Output: Diagnostics (StageDiagnostics) — raw signals, extracted realm, recognized flag, reason, resolved host, and the realms this version knows.
Diagnostics
StageDiagnostics
GetTraceContext
Returns the underlying AWS trace and log context, for correlating ODC logs with infrastructure traces in Datadog, New Relic or the AWS console. The trace identifier changes on every invocation, so read it at the moment you log rather than caching it.
Output: Trace (TraceContext) — X-Ray trace identifier, CloudWatch log group, and log stream.
Trace
TraceContext
GetRuntimeLifecycle
Returns facts about the lifetime of the runtime process serving this library, for reasoning about warm reuse of the underlying serverless worker. This describes the External Logic runtime, which is a separate serverless function from your app — it is not your app's cold start.
Output: Lifecycle (RuntimeLifecycle) — process uptime and whether this is the first call within the process.
Lifecycle
RuntimeLifecycle
GetStageId
Returns the unique identifier of the current stage.
Output: StageId (Text) — unique identifier (GUID) of the current stage.
StageId
GetRuntimeUrl
Returns the URL the current stage is served from.
Output: RuntimeUrl (Text) — URL the current stage is served from.
RuntimeUrl
GetRuntimeDetails
Returns technical details about the server runtime that executes the external logic.
Output: Runtime (RuntimeDetails) — .NET version, OS, CPU count, cloud region, and serverless function name and memory.
Runtime
RuntimeDetails
Classification Values
StageDetails.Classification is one of Production, NonProduction, Development or Unknown.
StageDetails.Classification
Production
NonProduction
Development
Unknown means the stage was not identified — either the signal was absent, or it carried a realm token this version does not recognize, so a future ODC tier is never reported as a stage the library claims to understand. Read IsClassified rather than inferring anything from Unknown: it is False in exactly those cases.
Notes and Best Practices
RuntimeDetails.MachineName
169
LambdaFunctionName
AwsRegion