Instrument Your Code
3 minute read
Overview
Instrumentation adds telemetry collection to your application so it emits structured logs, metrics, and traces. OpenTelemetry provides the SDKs and agents to do this in a vendor-neutral way. Once instrumented, your application sends OTLP data to an Edge Delta pipeline for processing and routing.
Code-based vs zero-code
Code-based solutions involve directly utilizing the OpenTelemetry API within your application to produce custom telemetry data. This method is well-suited for gaining detailed insights directly from inside the application. By facilitating precise tracking, these solutions enable monitoring of custom application events and performance metrics. However, they require modifications to the application’s source code, which might not always be feasible or desirable. Additionally, this approach involves a more complex setup and maintenance compared to zero-code solutions, potentially increasing the development time and effort.
On the other hand, zero-code solutions collect telemetry without requiring any changes to the application code. They leverage functionality built into existing libraries or extract information from the broader application environment. This approach is ideal for rapid implementation and situations where altering application code is not an option. Zero-code solutions provide valuable insights regarding application-level interactions, assisting in understanding external dependencies and behaviors. Nevertheless, they may not offer as deep insights as code-based solutions because they lack access to the internal logic and state of the application. They are typically limited to observations of libraries and the application environment, possibly missing some application-specific telemetry.
Language guides
Edge Delta provides instrumentation guides for five languages. Each guide covers both code-based and zero-code approaches.
| Language | Code-based | Zero-code |
|---|---|---|
| Java | Instrument Java | Zero-code Java |
| Python | Instrument Python | Zero-code Python |
| Node.js | Instrument Node.js | Zero-code Node.js |
| Go | Instrument Go | Zero-code Go |
| .NET | Instrument .NET | Zero-code .NET |
Where to send instrumented data
After instrumenting your application, configure the OTLP exporter to send data to Edge Delta. You have three options:
Edge pipeline (Kubernetes): If you run an Edge Delta agent in the same cluster, point the exporter to the agent’s OTLP source node port. This keeps data within the cluster and uses the agent for local processing. See OTel Collector Setup for endpoint details.
Edge pipeline (non-Kubernetes): Point the exporter to the agent’s host and OTLP port directly. See Ingest Data from OTLP Sources for configuration details.
Cloud pipeline (direct): Send OTLP data directly to an Edge Delta Cloud Pipeline without a local agent. This suits mobile applications, serverless functions, or environments where deploying an agent is impractical.
Applications instrumented with OpenTelemetry SDKs can send telemetry directly to an Edge Delta Cloud Pipeline without an intermediate collector. This approach reduces infrastructure complexity for mobile applications, serverless functions, or environments where deploying a collector is impractical.
Authentication:
Cloud Pipelines require API key authentication. Include the API key in the OTLP exporter headers:
// .NET example
options.Headers = "x-ed-api-key=YOUR_API_KEY";
// Node.js example
headers: {
'x-ed-api-key': process.env.ED_API_KEY
}
# Python example
headers = (("x-ed-api-key", os.environ.get("ED_API_KEY")),)
// Go example
otlptracegrpc.WithHeaders(map[string]string{
"x-ed-api-key": os.Getenv("ED_API_KEY"),
})
Endpoint configuration:
Configure the SDK exporter to use your Cloud Pipeline endpoint. The endpoint URL is available in your Cloud Pipeline settings:
| Protocol | Endpoint format | Port |
|---|---|---|
| gRPC | your-pipeline-id-grpc-region.aws.edgedelta.com | 443 |
| HTTP | https://your-pipeline-id-http-region.aws.edgedelta.com | 443 |
Tip: Use gRPC for lower overhead and better performance. Use HTTP when gRPC is blocked by firewalls or proxies.
Verifying data flow:
After configuring the SDK exporter, verify that telemetry arrives in Edge Delta:
- Open your Cloud Pipeline in the Edge Delta UI.
- Click Multi Processor to access the pipeline node.
- Use Live Capture to view incoming OTLP data in real time.
For language-specific SDK configuration, see Instrument Code using OpenTelemetry.
See also
- Instrument Code using OpenTelemetry for the full instrumentation reference
- OTLP Source Node for configuring the receiving end
- OTel Collector Setup for using a collector between your application and Edge Delta