Migrate from Elastic APM to TraceKit
Replace your Elastic APM Server and Elasticsearch cluster with TraceKit's managed tracing. No cluster sizing, no index management, no shard tuning -- just traces.
Migration Steps
Replace Elastic APM Agent with TraceKit SDK
Remove the Elastic APM language agent and install the TraceKit SDK. Elastic APM agents auto-instrument frameworks; TraceKit SDKs provide similar auto-instrumentation hooks.
| Category | Before | After (TraceKit) | Notes |
|---|---|---|---|
| Package | go.elastic.co/apm (Go agent) | github.com/tracekit/go-sdk | Go agent replacement |
| Package | elastic-apm-node (npm) | @tracekit/node-apm (npm) | Node.js agent replacement |
| Package | elastic-apm (pip) | tracekit-apm (pip) | Python agent replacement |
Map APM Server Configuration
Replace Elastic APM Server connection settings with TraceKit endpoint configuration. The APM Server URL and secret token map to TraceKit's endpoint and API key.
| Category | Before | After (TraceKit) | Notes |
|---|---|---|---|
| Connection | ELASTIC_APM_SERVER_URL (http://apm-server:8200) | TRACEKIT_ENDPOINT | Managed endpoint replaces self-hosted APM Server |
| Authentication | ELASTIC_APM_SECRET_TOKEN | TRACEKIT_API_KEY | API key for authentication |
| Authentication | ELASTIC_APM_API_KEY | TRACEKIT_API_KEY | Alternative auth method also maps to API key |
| Service Identity | ELASTIC_APM_SERVICE_NAME | TRACEKIT_SERVICE_NAME | Service name for trace grouping |
| Service Identity | ELASTIC_APM_ENVIRONMENT | TRACEKIT_ENVIRONMENT | Environment tagging (production, staging) |
Migrate Custom Instrumentation
Replace Elastic APM's transaction and span API with TraceKit equivalents. Elastic APM distinguishes between transactions (entry points) and spans (operations within a transaction); TraceKit uses spans throughout with parent-child linking.
| Category | Before | After (TraceKit) | Notes |
|---|---|---|---|
| Initialization | elasticapm.DefaultTracer (Go) | tracekit.Init(apiKey) | SDK initialization |
| Transactions | apm.StartTransaction(name, type) | tracekit.StartSpan(ctx, name) | Transactions become root spans |
| Spans | tx.StartSpan(name, spanType, parent) | tracekit.StartSpan(ctx, name) | Context carries parent reference |
| Labels | tx.Context.SetLabel(key, value) | span.SetAttribute(key, value) | Labels become span attributes |
| Errors | apm.CaptureError(err) | span.RecordError(err) | Errors attached to current span |
Update Sampling and Filter Configuration
Map Elastic APM's sampling and filtering settings to TraceKit. Elastic APM uses transaction sample rate and central configuration; TraceKit uses SDK-level configuration.
| Category | Before | After (TraceKit) | Notes |
|---|---|---|---|
| Sampling | ELASTIC_APM_TRANSACTION_SAMPLE_RATE (0-1.0) | TRACEKIT_SAMPLE_RATE (0.0-1.0) | Same range, direct mapping |
| Filtering | ELASTIC_APM_TRANSACTION_IGNORE_URLS | tracekit.WithIgnoreEndpoints(patterns) | SDK init option for URL filtering |
| Stack Traces | ELASTIC_APM_STACK_TRACE_LIMIT | tracekit.WithStackTraceDepth(n) | Control stack trace capture depth |
Verify Traces and Decommission APM Server
Confirm traces appear in TraceKit, then decommission the Elastic APM Server and (if used solely for APM) the associated Elasticsearch indices. Kibana APM views are replaced by TraceKit's built-in dashboard.
| Category | Before | After (TraceKit) | Notes |
|---|---|---|---|
| Verification | Kibana > APM > Services | TraceKit Dashboard > Services | Verify service list and health |
| Verification | Kibana > APM > Traces | TraceKit Dashboard > Traces | Verify trace waterfall and span detail |
| Decommission | APM Server process (port 8200) | (not needed) | Remove APM Server from infrastructure |
Code Examples
import (
"go.elastic.co/apm"
)
func main() {
// Configure via ELASTIC_APM_* environment variables
tracer := apm.DefaultTracer
tx := tracer.StartTransaction("process-order", "request")
defer tx.End()
span, _ := apm.StartSpan(tx.TraceContext(), "fetch-inventory")
span.Context.SetLabel("order.id", "12345")
// ... business logic
span.End()
}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()
_, child := tracekit.StartSpan(ctx, "fetch-inventory")
child.SetAttribute("order.id", "12345")
// ... business logic
child.End()
}const apm = require('elastic-apm-node').start({
serviceName: 'order-service',
serverUrl: 'http://apm-server:8200',
secretToken: 'your-secret-token',
environment: 'production',
});
const trans = apm.startTransaction('process-order', 'request');
const span = trans.startSpan('fetch-inventory');
span.setLabel('order.id', '12345');
// ... business logic
span.end();
trans.end();const tracekit = require('@tracekit/node-apm');
tracekit.init({
apiKey: 'tk_your_api_key',
service: 'order-service',
environment: 'production',
});
const span = tracekit.startSpan('process-order');
const child = tracekit.startSpan('fetch-inventory', { parent: span });
child.setAttribute('order.id', '12345');
// ... business logic
child.end();
span.end();import elasticapm
client = elasticapm.Client(
service_name='order-service',
server_url='http://apm-server:8200',
secret_token='your-secret-token',
environment='production',
)
client.begin_transaction('request')
with elasticapm.capture_span('fetch-inventory'):
elasticapm.label(order_id='12345')
# ... business logic
client.end_transaction('process-order', 'success')import tracekit
tracekit.init(
api_key='tk_your_api_key',
service='order-service',
environment='production',
)
with tracekit.start_span('process-order') as span:
with tracekit.start_span('fetch-inventory') as child:
child.set_attribute('order.id', '12345')
# ... business logic