Skip to main content

Configure Trace Ingestion

Tracetest Agent runs alongside your apps, in the same environment/network, to do two things:

  1. Run tests against your apps.
  2. Ingest traces from your apps.

This page explains (2), how to ingest traces into Tracetest Agent to enable trace-based testing.

Enable Trace Ingestion with an OTLP Endpoint​

Create a file called trace-ingestion.yaml. And, run it with the CLI.

trace-ingestion.yaml
type: DataStore
spec:
name: Opentelemetry Collector pipeline
type: otlp
default: true
Terminal
tracetest apply datastore -f ./trace-ingestion.yaml

Or, use the Web UI. Go to Settings > Trace Ingestion. Toggle "Enable Trace Ingestion" to on and select OpenTelemetry.

trace ingestion 1trace ingestion 2

Configure Trace Exporters to Send Traces to Tracetest Agent​

Once configured, Tracetest Agent exposes OTLP ports 4317 (gRPC) and 4318 (HTTP) for trace ingestion. Configure your trace exporters to send traces to the Tracetest Agent OTLP endpoint.

With the Tracetest Agent running locally, the trace ingestion OTLP endpoints will be:

  • gRPC: http://localhost:4317
  • HTTP: http://localhost:4318/v1/traces

OpenTelemetry auto-instrumentation allows you to send basic data quickly using the OpenTelemetry industry standard, before adding custom context.

  1. Install Dependencies
Terminal
npm install --save @opentelemetry/auto-instrumentations-node
  1. Initilize Tracing

Create an initialization file called tracing.js. Import it as the first step in your application lifecycle or include it with the -r / --require Node.js CLI option.

tracing.js
const opentelemetry = require('@opentelemetry/sdk-node');
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-http');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');

const sdk = new opentelemetry.NodeSDK({
// environment vars are loaded in the start step
traceExporter: new OTLPTraceExporter(),
instrumentations: [
getNodeAutoInstrumentations({
// we recommend disabling fs autoinstrumentation since it can be noisy and expensive during startup
'@opentelemetry/instrumentation-fs': {
enabled: false,
},
}),
],
});

sdk.start();
  1. Configure and Run

Configure OpenTelemetry to send traces to Tracetest using environment variables. Run the Node.js app by preloading the OpenTelemetry initialization file with -r.

Terminal
export OTEL_SERVICE_NAME=my-service-name
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
export OTEL_EXPORTER_OTLP_ENDPOINT="http://<tracetest-agent>:4318"
# export OTEL_EXPORTER_OTLP_HEADERS="x-tracetest-token=<token>"

node -r ./tracing.js app.js
Need more detailed guidance?