Migrate from Sentry to TraceKit
Sentry started as error tracking and added performance monitoring later. TraceKit is traces-first with error recording built in -- get both in a single SDK without the bolt-on feel.
Migration Steps
Replace Sentry SDK with TraceKit SDK
Remove the Sentry SDK package and install TraceKit. Sentry uses a DSN (Data Source Name) for authentication; TraceKit uses an API key.
| Category | Before | After (TraceKit) | Notes |
|---|---|---|---|
| Package | @sentry/node (npm) | @tracekit/node-apm (npm) | Node.js SDK replacement |
| Package | sentry-sdk (pip) | tracekit-apm (pip) | Python SDK replacement |
| Package | sentry/sentry-go | github.com/tracekit/go-sdk | Go SDK replacement |
Map Sentry DSN and Init Options
Replace Sentry's DSN-based initialization with TraceKit's API key initialization. Sentry's tracesSampleRate becomes TraceKit's sample rate.
| Category | Before | After (TraceKit) | Notes |
|---|---|---|---|
| Authentication | SENTRY_DSN (https://key@org.ingest.sentry.io/id) | TRACEKIT_API_KEY | API key replaces DSN URL |
| Sampling | tracesSampleRate (0.0-1.0) | TRACEKIT_SAMPLE_RATE (0.0-1.0) | Same numeric range, direct mapping |
| Environment | environment option in Sentry.init() | TRACEKIT_ENVIRONMENT | Environment tagging |
| Release | release option in Sentry.init() | TRACEKIT_VERSION | Release/version tracking |
Migrate Error Tracking Calls
Replace Sentry's captureException and captureMessage with TraceKit's span-level error recording. In Sentry, errors are top-level events; in TraceKit, errors are attached to the span where they occurred for better trace correlation.
| Category | Before | After (TraceKit) | Notes |
|---|---|---|---|
| Error Capture | Sentry.captureException(error) | span.RecordError(err) | Errors attached to active span for trace correlation |
| Error Capture | Sentry.captureMessage(msg) | span.AddEvent(msg) | Messages become span events |
| Breadcrumbs | Sentry.addBreadcrumb({message, category}) | span.AddEvent(message, {category: cat}) | Breadcrumbs map to span events with attributes |
| Context | Sentry.setTag(key, value) | span.SetAttribute(key, value) | Tags become span attributes |
Replace Performance Monitoring Transactions
Sentry's performance monitoring uses transactions and spans. TraceKit uses spans throughout -- a root span is equivalent to a Sentry transaction.
| Category | Before | After (TraceKit) | Notes |
|---|---|---|---|
| Transactions | Sentry.startTransaction({name, op}) | tracekit.StartSpan(ctx, name) | Transactions become root spans |
| Child Spans | transaction.startChild({op, description}) | tracekit.StartSpan(ctx, name) | Context propagation links parent-child automatically |
| Finish | transaction.finish() | span.End() | Same concept, different method name |
Verify Error and Trace Capture
Trigger a test error and some API requests, then verify both error recording and trace capture in the TraceKit dashboard. TraceKit shows errors inline within the trace waterfall.
| Category | Before | After (TraceKit) | Notes |
|---|---|---|---|
| Verification | Sentry > Issues | TraceKit Dashboard > Traces (filter by error) | Errors appear as span events in traces |
| Verification | Sentry > Performance > Transactions | TraceKit Dashboard > Traces | Transactions map to trace roots |
| Verification | Sentry > Performance > Web Vitals | TraceKit Frontend Dashboard | Web vitals via browser SDK |
Code Examples
import "github.com/getsentry/sentry-go"
func main() {
sentry.Init(sentry.ClientOptions{
Dsn: "https://key@org.ingest.sentry.io/123",
TracesSampleRate: 1.0,
Environment: "production",
})
defer sentry.Flush(2 * time.Second)
span := sentry.StartSpan(context.Background(), "process.order")
defer span.Finish()
sentry.CaptureException(fmt.Errorf("out of stock"))
}import "github.com/tracekit/go-sdk/tracekit"
func main() {
tracekit.Init("tk_your_api_key",
tracekit.WithService("order-service"),
tracekit.WithEnvironment("production"),
)
defer tracekit.Shutdown(context.Background())
ctx, span := tracekit.StartSpan(context.Background(), "process.order")
defer span.End()
span.RecordError(fmt.Errorf("out of stock"))
}const Sentry = require('@sentry/node');
Sentry.init({
dsn: 'https://key@org.ingest.sentry.io/123',
tracesSampleRate: 1.0,
environment: 'production',
});
const transaction = Sentry.startTransaction({
name: 'process-order',
op: 'http.server',
});
try {
// ... business logic
} catch (err) {
Sentry.captureException(err);
} finally {
transaction.finish();
}const tracekit = require('@tracekit/node-apm');
tracekit.init({
apiKey: 'tk_your_api_key',
service: 'order-service',
environment: 'production',
});
const span = tracekit.startSpan('process-order');
try {
// ... business logic
} catch (err) {
span.recordError(err);
} finally {
span.end();
}import sentry_sdk
sentry_sdk.init(
dsn="https://key@org.ingest.sentry.io/123",
traces_sample_rate=1.0,
environment="production",
)
with sentry_sdk.start_transaction(name="process-order", op="task"):
try:
# ... business logic
pass
except Exception as e:
sentry_sdk.capture_exception(e)import tracekit
tracekit.init(
api_key='tk_your_api_key',
service='order-service',
environment='production',
)
with tracekit.start_span('process-order') as span:
try:
# ... business logic
pass
except Exception as e:
span.record_error(e)