Tracing setup and SDKs

Automatic Railpack instrumentation and lightweight 2–3 line OpenTelemetry SDK hooks across Go, Node.js, Next.js 15+, Python, Java, and .NET.

Formatio collects distributed traces and crash-safe error groups over standard OpenTelemetry HTTP/protobuf (OTLP) with zero collector sidecars. For supported Railpack builds, instrumentation injects automatically during image build; for Dockerfiles, Nixpacks, Next.js 15+, Fastify, or local runs, each thin Formatio SDK (github.com/Overal-X/otel) configures standard OTLP in 2–3 lines without vendor lock-in.

Support matrix by language and builder

Language Railpack build Dockerfile, Nixpacks, or custom setup
Go Automatic compile-time instrumentation Go SDK (formatio.Init / Handler / Transport)
Node.js (18.19+) Automatic @formatio/otel-node preload Preload @formatio/otel-node/register or init() + Fastify hook
Next.js (15+) Add 1-line instrumentation.ts for Server Components/Actions @formatio/otel-next in instrumentation.ts + external config
Python (3.10+) Automatic formatio-otel startup preload formatio-otel + formatio_otel.init() before app init
Java Automatic OpenTelemetry Java agent (v2.32.0) + crash extension Add agent JARs and JAVA_TOOL_OPTIONS
C# and .NET (8+) Automatic OpenTelemetry .NET auto-instrumentation OpenTelemetry.AutoInstrumentation NuGet + instrument.sh

[!NOTE] The Node.js and Python SDKs publish directly as release archives on github.com/Overal-X/otel/releases rather than public registries, keeping package imports identical to standard OpenTelemetry packages so migrating later preserves every span and error group.

Automatic Railpack instrumentation

When Tracing is enabled (the default for new apps), Railpack builds inject instrumentation into /opt/formatio without mutating your repository:

  • Go: Compiled in via OpenTelemetry Go compile-time instrumentation, tracing HTTP handlers, outgoing HTTP, database/sql, gRPC, and Redis while recording handler panics.
  • Node.js (18.19+): Preloads @formatio/otel-node into application Node processes (skipping package managers and Bun).
  • Python (3.10+): Starts formatio-otel via PYTHONPATH ahead of your entrypoint while respecting versions declared by your app.
  • Java: Attaches the OpenTelemetry Java agent with Formatio's startup/uncaught-exception extension via JAVA_TOOL_OPTIONS.
  • .NET (8+): Attaches OpenTelemetry .NET auto-instrumentation via DOTNET_STARTUP_HOOKS with an unhandled-exception plugin.

Reading build output and fallbacks

  • formatio: tracing compiled in or formatio: tracing added with <package> confirms active instrumentation.
  • building without tracing instrumentation: <reason> skips injection gracefully and never fails a build (for instance if you supply custom GOFLAGS or override BASH_ENV).
  • Build overhead is roughly 1–2 minutes cold compile time for Go, and 15–30 MB of image layer weight (about 80 MB for Node.js) for preloaded runtimes.

Environment configuration and guarantees

On Formatio, the runtime injects OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_PROTOCOL, OTEL_EXPORTER_OTLP_HEADERS, OTEL_SERVICE_NAME, and OTEL_RESOURCE_ATTRIBUTES automatically. Outside Formatio (such as local development), export the public endpoint and token from Settings › Tracing:

export OTEL_EXPORTER_OTLP_ENDPOINT='https://your-formatio-host/otlp'
export OTEL_EXPORTER_OTLP_HEADERS='authorization=Bearer REPLACE_INGESTION_TOKEN'
  • Fail-open startup: Missing tokens log a single warning and run the app untraced without crashing startup.
  • Crash-safe 2-second flush: Uncaught exceptions outside requests emit a span named uncaught exception and flush up to 2 seconds over OTLP before process exit.
  • Exception recording: Captures request exceptions, 5xx responses without exceptions, and explicitly captured handled exceptions while ignoring expected 4xx client errors.

Per-language setup reference

Tabs

Node.js

A Railpack build preloads @formatio/otel-node automatically. Install the package explicitly to instrument Dockerfile / Nixpacks builds, register Fastify, or capture handled errors:

npm i https://github.com/overal-x/otel/releases/download/node/v0.1.0/formatio-otel-node-0.1.0.tgz
  • ESM preload: Run node --import @formatio/otel-node/register server.js or set NODE_OPTIONS="--import @formatio/otel-node/register".
  • CommonJS: Pass --require @formatio/otel-node/register or call require('@formatio/otel-node').init() on line 1.
  • Fastify error hook: Fastify catches thrown errors silently unless registered:
import { setupFastifyErrorHandler } from '@formatio/otel-node'
setupFastifyErrorHandler(fastify)
  • Handled errors: Call captureException(err, { 'job.name': 'nightly-sync' }). Express captures thrown errors automatically (app.use(expressErrorHandler()) is optional).

Next.js

Railpack preloads Node tracing for requests, while Next.js handles errors inside Server Components, Route Handlers, and Server Actions internally. Add @formatio/otel-next across all build types to report rendering and action failures:

npm i https://github.com/overal-x/otel/releases/download/node/v0.1.0/formatio-otel-next-0.1.0.tgz

Create instrumentation.ts at the repo root (or src/):

export { register, onRequestError } from '@formatio/otel-next'

Keep @formatio/otel-node external so Next.js does not bundle over runtime patches in next.config.js:

module.exports = { serverExternalPackages: ['@formatio/otel-node'] }

(Note: Node.js runtime is traced; Edge runtime spans are not captured.)

Python

Railpack builds preload formatio-otel automatically. Install explicitly for Dockerfiles, local runs, or capture_exception:

formatio-otel @ https://github.com/overal-x/otel/releases/download/python/v0.1.0/formatio_otel-0.1.0-py3-none-any.whl

Call formatio_otel.init() before instantiating FastAPI, Starlette, Django, or Flask (requests, httpx, urllib, psycopg, psycopg2, SQLAlchemy, redis, and Celery instrument automatically):

import formatio_otel
formatio_otel.init()

from fastapi import FastAPI
app = FastAPI()
  • Django: Initialize inside wsgi.py/asgi.py before get_wsgi_application(), and in manage.py.
  • uWSGI: Add lazy-apps = true and enable-threads = true so workers initialize post-fork.
  • Handled errors: Call formatio_otel.capture_exception(attributes={"order.id": order.id}).

Go

Railpack builds compile in OpenTelemetry automatically unless custom GOFLAGS is set. For Dockerfiles or explicit error capture/panic recovery:

go get github.com/overal-x/otel/go
import formatio "github.com/overal-x/otel/go"

func main() {
	ctx := context.Background()
	shutdown, err := formatio.Init(ctx)
	if err != nil {
		log.Fatal(err)
	}
	defer shutdown(ctx)
	defer formatio.Recover(ctx)

	mux := http.NewServeMux()
	mux.HandleFunc("GET /users/{id}", showUser)
	log.Print(http.ListenAndServe(":8080", formatio.Handler(mux)))
}
  • Wrap outbound HTTP clients with formatio.Transport(nil) for distributed trace context propagation.
  • Defer formatio.Recover(ctx) in main (after shutdown) and in spawned goroutines, and use formatio.CaptureError(ctx, err, attribute.String("order.id", id)) for handled failures.

Java

Railpack injects the OpenTelemetry Java agent (v2.32.0) and Formatio crash extension automatically. For Dockerfile builds, bundle both artifacts and configure JAVA_TOOL_OPTIONS:

ADD https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v2.32.0/opentelemetry-javaagent.jar /otel/opentelemetry-javaagent.jar
ADD https://github.com/overal-x/otel/releases/download/java/v0.1.0/formatio-otel-javaagent-extension.jar /otel/formatio-otel-javaagent-extension.jar
ENV JAVA_TOOL_OPTIONS="-javaagent:/otel/opentelemetry-javaagent.jar -Dotel.javaagent.extensions=/otel/formatio-otel-javaagent-extension.jar"

(If overriding JAVA_TOOL_OPTIONS in Environment, preserve the -javaagent flags.) Record handled exceptions via OpenTelemetry API Span.current().recordException(e).

C# and .NET

Railpack injects .NET auto-instrumentation automatically. For Dockerfiles, add the NuGet package and wrap startup with instrument.sh:

dotnet add package OpenTelemetry.AutoInstrumentation
ENTRYPOINT ["./instrument.sh", "dotnet", "MyApp.dll"]

Record handled errors via Activity.Current?.AddException(ex) and Activity.Current?.SetStatus(ActivityStatusCode.Error).


Further reading