Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.

Commit 010817f

Browse files
Merge pull request #1821 from splunk/mbechtold-6110-erlang-rust-partition
[6110] Separate the Rust and Erlang instrumentation docs
2 parents 58babd3 + 76782f9 commit 010817f

File tree

9 files changed

+343
-219
lines changed

9 files changed

+343
-219
lines changed

apm/set-up-apm/apm-gdi.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,16 @@ In the following table, follow the instrumentation steps for the language that e
121121
* - PHP
122122
- OpenTelemetry instrumentation for PHP
123123
- :ref:`get-started-php`
124+
125+
* - Rust
126+
- OpenTelemetry instrumentation for Rust
127+
- :ref:`get-started-rust`
124128

125-
After you instrument your applications, you're ready to verify that your data is coming in.
129+
* - Erlang
130+
- OpenTelemetry instrumentation for Erlang
131+
- :ref:`get-started-erlang`
126132

127-
.. note:: To instrument applications or services written in languages other than the ones listed here, see :ref:`apm-instrumentation-other-langs`.
133+
After you instrument your applications, you're ready to verify that your data is coming in.
128134

129135
.. _verify-apm-data:
130136

gdi/get-data-in/application/application.rst

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ Instrument back-end applications to send spans to Splunk APM
1717
Instrument a Python application TOGGLE <python/get-started>
1818
Instrument a Ruby application TOGGLE <ruby/get-started>
1919
Instrument a PHP application TOGGLE <php/get-started>
20-
Instrument applications written in other programming languages <other-languages>
20+
Instrument a Rust application TOGGLE <rust/get-started>
21+
Instrument an Erlang application TOGGLE <erlang/get-started>
2122
Send spans from the Istio service mesh <istio/istio>
2223

2324
You can instrument your back-end services and applications to send metrics and traces to Splunk Observability Cloud.
@@ -89,14 +90,11 @@ You can instrument applications in each of these languages using official Splunk
8990
- :ref:`Python <get-started-python>`
9091
- :ref:`Ruby <get-started-ruby>`
9192
- :ref:`PHP <get-started-php>`
93+
- :ref:`Rust <get-started-rust>`
94+
- :ref:`Erlang <get-started-erlang>`
9295

9396
To send spans from the Istio service mesh, see :ref:`get-started-istio`.
9497

95-
You can also send traces from applications written in languages for which Splunk instrumentation isn't available:
96-
97-
- :ref:`Erlang <apm-instrumentation-other-langs>`
98-
- :ref:`Rust <apm-instrumentation-other-langs>`
99-
10098
To learn more about the data collected by Splunk Observability Cloud, see:
10199

102100
- :ref:`data-model`
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.. _get-started-erlang:
2+
3+
*****************************************************************
4+
Instrument Erlang applications for Splunk Observability Cloud
5+
*****************************************************************
6+
7+
.. meta::
8+
:description: Get started with instrumenting your Erlang applications for Splunk Observability Cloud.
9+
10+
.. toctree::
11+
:hidden:
12+
13+
Requirements <requirements>
14+
Instrument your Erlang application <instrument-erlang>
15+
16+
You can send application traces and metrics from your Erlang applications to Splunk Observability Cloud using the OpenTelemetry instrumentation for Erlang.
17+
18+
To instrument your Erlang applications, follow these steps:
19+
20+
#. Make sure you've met the prerequisites. See :ref:`requirements-erlang`
21+
#. Instrument your application. See :ref:`instrument-erlang`
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
.. _instrument-erlang:
2+
3+
*************************************************************************
4+
Instrument your Erlang application for Splunk Observability Cloud
5+
*************************************************************************
6+
7+
.. meta::
8+
:description: Learn how to instrument your Erlang application using the OpenTelemetry instrumentation for Erlang and send your application traces to Splunk Observability Cloud.
9+
10+
You can send traces from your Erlang applications using the OpenTelemetry instrumentation for Erlang. To get started, follow these instructions.
11+
12+
.. _erlang-add-dependencies:
13+
14+
1. Add the required dependencies or packages
15+
==================================================
16+
17+
To instrument your application for Splunk Observability Cloud, you need to generate traces and spans that follow the OpenTelemetry format and semantic conventions. Add the required OpenTelemetry dependencies to your project, including gRPC communication libraries for communicating with the Splunk OpenTelemetry Collector.
18+
19+
Add the OpenTelemetry packages to the list of dependencies in your rebar.config file:
20+
21+
.. code-block:: Erlang
22+
23+
%% rebar.config file
24+
25+
{deps, [opentelemetry_api
26+
opentelemetry,
27+
opentelemetry_exporter]}.
28+
29+
You also must add them to the ``Applications`` section, together with gRPC libraries:
30+
31+
.. code-block:: erlang
32+
33+
%% app.src file
34+
35+
{applications,
36+
[kernel,
37+
stdlib,
38+
opentelemetry_api,
39+
opentelemetry,
40+
opentelemetry_exporter
41+
]},
42+
43+
.. _erlang-init-tracer:
44+
45+
2. Initialize the OpenTelemetry tracer
46+
=================================================
47+
48+
In your application code, initialize the OpenTelemetry library and tracer like in the following example:
49+
50+
.. code-block:: erlang
51+
52+
-module(otel_getting_started).
53+
54+
-export([hello/0]).
55+
56+
-include_lib("opentelemetry_api/include/otel_tracer.hrl").
57+
58+
Erlang automatically initializes the tracer.
59+
60+
.. _erlang-generate-spans:
61+
62+
3. Generate spans for your application
63+
==================================================
64+
65+
In your Erlang application code, create spans for the operations you want to track.
66+
67+
The following example shows how to create spans that have attributes or tags:
68+
69+
.. code-block:: erlang
70+
71+
hello() ->
72+
%% start an active span and run a local function
73+
?with_span(<<"operation">>, #{}, fun nice_operation/1).
74+
75+
nice_operation(_SpanCtx) ->
76+
?add_event(<<"Nice operation!">>, [{<<"bogons">>, 100}]),
77+
?set_attributes([{another_key, <<"yes">>}]),
78+
79+
%% start an active span and run an anonymous function
80+
?with_span(<<"Sub operation...">>, #{},
81+
fun(_ChildSpanCtx) ->
82+
?set_attributes([{lemons_key, <<"five">>}]),
83+
?add_event(<<"Sub span event!">>, [])
84+
end).
85+
86+
.. _export-directly-to-olly-cloud-erlang:
87+
88+
Send data directly to Splunk Observability Cloud
89+
==================================================
90+
91+
By default, all telemetry goes to the local instance of the Splunk Distribution of OpenTelemetry Collector.
92+
93+
If you need to send data directly to Splunk Observability Cloud, set the following environment variables. When instrumenting Rust applications or services you might need to read the values of the environment variables first.
94+
95+
.. code-block:: shell
96+
97+
OTEL_EXPORTER_OTLP_PROTOCOL=grpc
98+
OTEL_EXPORTER_OTLP_TRACES_HEADERS=x-sf-token=<access_token>
99+
OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.<realm>.signalfx.com
100+
101+
To obtain an access token, see :ref:`admin-api-access-tokens`.
102+
103+
To find your Splunk realm, see :ref:`Note about realms <about-realms>`.
104+
105+
.. note:: For more information on the ingest API endpoints, see :new-page:`Send APM traces <https://dev.splunk.com/observability/docs/apm/send_traces/>`.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.. _requirements-erlang:
2+
3+
**************************************************************
4+
Erlang instrumentation compatibility and requirements
5+
**************************************************************
6+
7+
.. meta::
8+
:description: Make sure you've met these requirements before instrumenting an Erlang application.
9+
10+
The OpenTelemetry instrumentation for Erlang requires the following components:
11+
12+
* Erlang
13+
* Elixir
14+
* PostgreSQL or the database of your choice
15+
* Phoenix. See :new-page:`https://hexdocs.pm/phoenix/installation.html`
16+
17+
Additionally, you need to install the Splunk Distribution of OpenTelemetry Collector. The following distributions are available:
18+
19+
* :ref:`Linux <collector-linux-intro>`
20+
* :ref:`Kubernetes <collector-kubernetes-intro>`
21+
* :ref:`Windows <collector-windows-intro>`
22+
23+
After installing the Collector, make sure that you have an instance of the Collector running in your environment.
24+

0 commit comments

Comments
 (0)