Security Observability With OpenTelemetry in 15 Minutes
A step-by-step guide to instrumenting your app with OpenTelemetry and sending traces to SecureNow for real-time threat detection, AI analysis and alerts.

Security Observability With OpenTelemetry in 15 Minutes
Most developers treat observability and security as separate concerns. You instrument your app with traces and metrics for performance monitoring, and you bolt on a WAF or SAST tool for security. The result is two disconnected systems that each tell half the story — your observability stack knows how your app behaves but ignores threat signals, and your security tools watch the perimeter but are blind to internal application behavior.
Security observability eliminates this gap. By feeding your existing OpenTelemetry traces into a platform built for security analysis, every HTTP request, database query, and outbound call becomes a data point for threat detection. You don't need a separate agent, a new SDK, or a dedicated security pipeline. You just point your traces at SecureNow and start seeing what your application is actually doing — from a security perspective.
This guide walks you through the entire setup in under 15 minutes: registering your application, instrumenting a Node.js/Express app with OpenTelemetry, verifying trace flow, and running your first security analysis.
Prerequisites
Before you start, make sure you have:
- A running Node.js application (this guide uses Express, but the concepts apply to any framework)
- Node.js 20 or newer
- A SecureNow account (the 14-day free trial works for this tutorial)
- Basic familiarity with npm and environment variables
If you're running Python, Java, Go, or another language, the SecureNow side is identical — only the OpenTelemetry SDK installation differs. The OpenTelemetry documentation covers every supported language.
On Node.js, the shorter path is the SDK:
npm install securenow,npx securenow login, thennode -r securenow/register app.js. It sends the same traces plus logs and redacted request bodies, and adds the firewall, rate limits and session revocation. This guide uses plain OpenTelemetry, which is also how apps in other languages connect.
Step 1: Get Your App Key and Runtime API Key
An exporter needs two values from SecureNow: the app key (a UUID that names your application) and a runtime API key (snk_live_...) that authenticates what you send. The CLI creates both:
npx securenow login # browser flow: pick or create the app
npx securenow credentials runtime --env production --stdout # prints the runtime credentials as JSON
In the JSON, app.key is the app key and apiKey is the runtime API key. The runtime API key is a secret: keep it out of the repository.
The application starts in an unprotected state. SecureNow checks whether it has received traces in the last 15 minutes to determine protection status. Once traces start flowing, the status flips to protected — a green indicator that confirms your instrumentation is working.
Step 2: Install OpenTelemetry Dependencies
OpenTelemetry's Node.js SDK uses a modular architecture. You need the core SDK, the auto-instrumentation package, and the OTLP HTTP exporter:
npm install @opentelemetry/sdk-node \
@opentelemetry/auto-instrumentations-node \
@opentelemetry/exporter-trace-otlp-http
The auto-instrumentations-node package is the heavy lifter here. It automatically instruments Express, HTTP, pg, mysql2, redis, ioredis, mongodb, grpc, and dozens of other libraries — no manual span creation required. The full list of supported instrumentations is extensive.
Step 3: Create the Instrumentation File
OpenTelemetry instrumentation must initialize before your application code loads. Create a tracing.js file in your project root:
const { NodeSDK } = require('@opentelemetry/sdk-node');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-http');
// The service name, endpoint and headers come from the OTEL_* variables in Step 4.
const sdk = new NodeSDK({
traceExporter: new OTLPTraceExporter(),
instrumentations: [
getNodeAutoInstrumentations({
'@opentelemetry/instrumentation-http': {
// Incoming requests only: record the address the connection came from.
startIncomingSpanHook: (request) => ({
'http.client_ip': request.socket?.remoteAddress || '',
}),
},
}),
],
});
sdk.start();
process.on('SIGTERM', () => {
sdk.shutdown().finally(() => process.exit(0));
});
A few things worth noting in this configuration:
- Service name must be your app key (Step 4). SecureNow files every trace under the app whose key matches
service.name, so any other name leaves the dashboard empty. - Client IP comes from the connection's remote address. Behind a load balancer or reverse proxy that address is the proxy's: read the client from the forwarding header your proxy sets, and only when the request came from that proxy, because a client can send any
X-Forwarded-Forit likes. Client IPs drive SecureNow's IP investigation and threat detection. - Authentication is two headers:
authorization: Bearer <runtime API key>andx-securenow-app-key: <app key>. Without the runtime API key the gateway rejects the data. - Graceful shutdown ensures spans are flushed before the process exits.
Step 4: Configure Environment Variables
These are the standard OpenTelemetry variables, which the SDK and the exporter read themselves:
OTEL_SERVICE_NAME=a1b2c3d4-e5f6-4890-abcd-ef1234567890
OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.securenow.ai
OTEL_EXPORTER_OTLP_HEADERS=authorization=Bearer%20snk_live_xxxxxxxx,x-securenow-app-key=a1b2c3d4-e5f6-4890-abcd-ef1234567890
OTEL_SERVICE_NAMEandx-securenow-app-keyare both the app key;snk_live_xxxxxxxxstands for your runtime API key.%20is the space afterBearer: header values in this variable are URL-encoded.- The exporter appends
/v1/tracesto the endpoint. - The same three variables configure the OpenTelemetry SDKs for Python, Java, Go and .NET. Use an HTTP exporter (
http/protobuforhttp/json): the gateway does not accept gRPC.
For production, store them with your platform's secrets management — Kubernetes secrets, AWS Parameter Store, or whatever your deployment pipeline supports. Never commit the runtime API key to version control.
Step 5: Start Your Application with Instrumentation
The key step: load the tracing file before your application code using Node's --require flag:
node --require ./tracing.js app.js
Or add it to your package.json scripts:
{
"scripts": {
"start": "node --require ./tracing.js app.js",
"dev": "nodemon --require ./tracing.js app.js"
}
}
That's it for the application side. Every HTTP request your Express app handles now generates a trace with spans for the HTTP layer, route handlers, middleware, database calls, and any outbound HTTP requests.
Step 6: Verify Traces in SecureNow
Generate some traffic against your application — hit a few endpoints, trigger a login flow, make some API calls. Then open SecureNow and check two things:
Protection Status
Navigate to your application in the Applications list. Within 15 minutes of your first trace arriving, the protection status indicator turns green. This confirms that:
- Your OpenTelemetry exporter is correctly configured
- Traces are reaching the ingestion endpoint
- Data is being stored in ClickHouse
- SecureNow is actively monitoring your application
If the status remains red after 15 minutes, check the common issues: a service name that is not the app key, a wrong or revoked runtime API key, a wrong exporter URL, network connectivity between your app and the ingestion endpoint, or a firewall blocking outbound HTTPS.
Trace Explorer
Open the Trace Explorer from the sidebar and select your application. You should see traces populating in near-real-time. Each trace shows:
- Timestamp — when the request was received
- Duration — total request processing time
- HTTP method and URL — the endpoint that was hit
- Status code — the HTTP response code
- Client IP — the source IP (recorded by the
startIncomingSpanHookin Step 3) - Span count — how many operations the request triggered
Use the filters to narrow by time range, status code, IP address, or URL pattern. The Trace Explorer is your primary interface for understanding what's happening in your application right now.
Click any trace to see its full span tree — every operation your application performed to handle that request, displayed in tree, Gantt, or timeline view. Database queries, cache lookups, outbound API calls — it's all there.
Step 7: Run Your First AI Trace Analysis
This is where security observability gets interesting. Select a trace that looks non-trivial — one with multiple spans, especially if it includes database queries or outbound HTTP calls.
Click the AI Analysis button on the trace detail page. SecureNow sends the complete span tree to its AI security engine, which evaluates:
- Whether database spans contain dynamic SQL that could indicate injection vulnerabilities
- Whether outbound HTTP spans connect to suspicious or unexpected destinations
- Whether authentication and authorization flows follow secure patterns
- Whether error spans leak sensitive information
- Whether timing patterns suggest brute-force or enumeration attempts
The analysis returns a structured security report with findings categorized by severity, specific span references, and remediation guidance. Even on a healthy trace, the AI often identifies hardening opportunities — parameterized query suggestions, missing rate limiting, or overly permissive CORS configurations.
For a deeper dive into what the AI analyzes and how it detects specific attack patterns, see AI-Powered Trace Analysis: Detecting Security Issues Hidden in Application Spans.
Step 8: Set Up Your First Alert Rule
Now that traces are flowing, set up a basic alert rule to detect suspicious activity automatically. A good starter rule monitors for IPs generating high rates of client errors — a common indicator of scanning, brute-force, or fuzzing activity.
Navigate to Alert Rules and click Create Rule. Configure it with the following SQL:
SELECT
attribute_string_peer_ip AS ip,
count(*) AS total_requests,
countIf(response_status_code >= 400 AND response_status_code < 500) AS error_count,
round(error_count / total_requests * 100, 2) AS error_rate
FROM signoz_traces.distributed_signoz_index_v2
WHERE timestamp >= now() - INTERVAL 15 MINUTE
AND serviceName IN (__USER_APP_KEYS__)
GROUP BY ip
HAVING error_count > 50 AND error_rate > 60
ORDER BY error_count DESC
This query identifies IPs with more than 50 client errors and an error rate above 60% in the last 15 minutes. The __USER_APP_KEYS__ placeholder automatically scopes the query to your registered applications.
Set the schedule to run every 15 minutes, configure a 15-minute throttle to prevent duplicate notifications, and add your preferred notification channel — Email, Slack, or in-app.
For more alert rule patterns and advanced configuration, check out From Traces to Security Alerts: A Developer's Guide to Threat Detection.
Adding Custom Span Attributes for Richer Security Data
The auto-instrumentation captures a solid baseline, but you can enrich your traces with security-relevant attributes using manual spans. Here are a few high-value additions:
const { trace } = require('@opentelemetry/api');
function authenticateUser(req, res) {
const span = trace.getActiveSpan();
span.setAttribute('auth.method', 'jwt');
span.setAttribute('auth.user_id', req.user?.id || 'anonymous');
span.setAttribute('auth.role', req.user?.role || 'none');
if (req.headers['x-forwarded-for']) {
span.setAttribute('http.client_ip', req.headers['x-forwarded-for'].split(',')[0].trim());
}
// Your authentication logic here
}
Adding auth.method, auth.user_id, and auth.role as span attributes lets SecureNow's AI analysis detect privilege escalation patterns and authorization bypass attempts. Client IP attribution enables IP investigation and geographic analysis.
What You Can Do Next
With traces flowing into SecureNow, you now have access to the full platform:
- Trace Explorer — search and filter traces by IP, time range, status code, URL pattern, and more. Export results to CSV for offline analysis.
- AI Trace Analysis — trigger security analysis on any trace to detect injection, SSRF, path traversal, and other attack patterns hidden in spans.
- Forensics — ask natural language questions about your trace data ("Show me all 5xx errors from Chinese IPs in the last 24 hours") and get instant results. Save queries to your library for reuse.
- Alert Rules — build SQL-based detection rules for automated threat monitoring. Start with the basics and add more specific rules as you understand your traffic patterns.
- API Map — discover all endpoints your application exposes, including shadow APIs and undocumented routes, through AI-enhanced analysis of your trace data.
- IP Investigation — investigate suspicious IPs with AI-powered verdicts, risk scores, and SecureNow AI IPDB integration.
For a complete walkthrough of the security monitoring workflow, see Application Security Monitoring Workflow.
Troubleshooting Common Issues
Traces not appearing in SecureNow:
OTEL_SERVICE_NAMEmust be the app key, exactly- A 401 from the gateway means the runtime API key is missing, wrong or revoked: check the
authorization=Bearer%20snk_live_...entry inOTEL_EXPORTER_OTLP_HEADERS - Verify
OTEL_EXPORTER_OTLP_ENDPOINTishttps://ingest.securenow.ai(no/v1/traces: the exporter adds it) - Check that your application can reach the ingestion endpoint (test with
curl) - Look for OpenTelemetry SDK error messages in your application logs (
OTEL_LOG_LEVEL=debugshows them)
Missing or wrong client IPs:
- Ensure the
startIncomingSpanHookis configured as shown in Step 3 - Behind a load balancer or reverse proxy, every request shows the proxy's address: read the client from the header that proxy sets, and only trust it when the request came from the proxy
- Check your proxy configuration — some reverse proxies strip client IP headers
High span volume:
- Use sampling strategies to reduce volume while maintaining security visibility
ParentBasedSamplerwith aTraceIdRatioBasedroot sampler is a good starting point- Avoid sampling below 10% in security-sensitive applications — low sample rates create detection blind spots
Protection status stays red:
- The 15-minute window must contain at least one trace
- Verify your service name is the app key
- Check ClickHouse instance connectivity if using a dedicated instance
From Monitoring to Security Posture
What you've built in 15 minutes is more than application monitoring — it's a security observability pipeline. Every request your application handles generates structured data that SecureNow continuously analyzes for threats. You didn't need to install a WAF, configure a SIEM, or hire a SOC team. You took the OpenTelemetry traces your app was already capable of generating and gave them a security purpose.
The natural next step is building detection rules tailored to your application's threat model. Start with the basic error-rate alert from Step 8, then add rules for specific attack patterns as you learn what your traffic looks like. The developer's guide to threat detection covers the essential alert rules every application should have.
Security observability is not a replacement for secure coding practices, dependency management, or infrastructure hardening. It's the layer that tells you when those defenses fail — and gives you the trace data to understand exactly how.
Frequently Asked Questions
Do I need to modify my application code?
Minimal changes are required. OpenTelemetry provides auto-instrumentation for most frameworks (Express, Next.js, Django, Spring Boot, etc.) that captures traces without manual span creation.
What languages does SecureNow support?
Traces and logs: any application that exports OpenTelemetry over HTTP — Node.js, Python, Java, Go, .NET, Ruby, PHP and more. Blocking (the firewall, rate limits, challenges, session revocation) and redacted request bodies come from the Node.js SDK, the securenow npm package.
How quickly will I see security data after setup?
Once traces are flowing, SecureNow shows protection status within 15 minutes. You can immediately search traces, run forensic queries, and set up alert rules.
Does OpenTelemetry instrumentation affect application performance?
OpenTelemetry is designed for production use with minimal overhead. Sampling strategies let you balance observability coverage with performance requirements.
Frequently Asked Questions
Do I need to modify my application code?
Minimal changes are required. OpenTelemetry provides auto-instrumentation for most frameworks (Express, Next.js, Django, Spring Boot, etc.) that captures traces without manual span creation.
What languages does SecureNow support?
Traces and logs: any application that exports OpenTelemetry over HTTP — Node.js, Python, Java, Go, .NET, Ruby, PHP and more. Blocking (the firewall, rate limits, challenges, session revocation) and redacted request bodies come from the Node.js SDK, the securenow npm package.
How quickly will I see security data after setup?
Once traces are flowing, SecureNow shows protection status within 15 minutes. You can immediately search traces, run forensic queries, and set up alert rules.
Does OpenTelemetry instrumentation affect application performance?
OpenTelemetry is designed for production use with minimal overhead. Sampling strategies let you balance observability coverage with performance requirements.
Recommended reading
Block one IP, a CIDR range, or a single route and method in a Node.js app within seconds, with no code change: setup, scoping, CLI, MCP, verification and undo.
Oct 27Built your app with a coding agent? 11 warning signs it needs a security audit, each checkable in five minutes, and how to run the full audit yourself.
Oct 26Part 1 of the AI security audit series: set up an AI coding agent to audit your app locally, connect SecureNow, and run your first threat-model pass.
Jul 24