Skip to content

Commit 6acf7fd

Browse files
authored
Merge pull request #821 from msutkowski/ms/add-spec-links
chore: add relevant links to spec in doc blocks
2 parents d586b0f + e8c3458 commit 6acf7fd

File tree

3 files changed

+76
-17
lines changed

3 files changed

+76
-17
lines changed

README.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ default implementation of the API that must be optional.
8686

8787
When instrumenting a project, your application should only depend on the
8888
[OpenTelemetry API](https://hex.pm/packages/opentelemetry_api) application,
89-
found in directory `apps/opentelemetry_api` of this repo. The API is published as
89+
found in directory `apps/opentelemetry_api` of this repo. The API is published as
9090
the Hex package [opentelemetry_api](https://hex.pm/packages/opentelemetry_api).
9191

9292
The SDK implementation, found under `apps/opentelemetry` and Hex package
@@ -95,7 +95,7 @@ OTP Release along with an exporter.
9595

9696
Example of Release configuration in `rebar.config`:
9797

98-
``` erlang
98+
```erlang
9999
{relx, [{release, {my_instrumented_release, "0.1.0"},
100100
[opentelemetry_exporter,
101101
{opentelemetry, temporary},
@@ -107,7 +107,7 @@ Example of Release configuration in `rebar.config`:
107107
Example configuration for [mix's Release
108108
task](https://hexdocs.pm/mix/Mix.Tasks.Release.html):
109109

110-
``` elixir
110+
```elixir
111111
def project do
112112
[
113113
releases: [
@@ -121,14 +121,14 @@ def project do
121121
end
122122
```
123123

124-
Note that you also need to add `opentelemetry_exporter` before your other `opentelemetry` dependencies in `mix.exs`,
124+
Note that you also need to add `opentelemetry_exporter` before your other `opentelemetry` dependencies in `mix.exs`,
125125
so that it starts before `opentelemetry` does.
126126

127127
In the above example `opentelemetry_exporter` is listed first, ensuring that all of its
128128
dependencies are booted before `opentelemetry` attempts to start the
129129
exporter. `opentelemetry` is set to `temporary` so that if the `opentelemetry`
130130
application crashes, or is shutdown, it does not terminate the other
131-
applications in the project -- `opentelemetry_exporter` does not not need to be
131+
applications in the project -- `opentelemetry_exporter` does not need to be
132132
`temporary` because it does not have a startup and supervision tree. This is
133133
optional; the `opentelemetry` application purposely sticks to `permanent` for
134134
the processes started by the root supervisor to leave it up to the end user
@@ -149,14 +149,13 @@ Applications are kept in a single repository, under the directory `apps`, either
149149
blocks below show how the git repo for the API and/or SDK
150150
Applications can be used in rebar3 and mix.
151151

152-
``` erlang
152+
```erlang
153153
{opentelemetry_api, {git_subdir, "http://github.com/open-telemetry/opentelemetry-erlang", {branch, "main"}, "apps/opentelemetry_api"}},
154-
{opentelemetry, {git_subdir, "http://github.com/open-telemetry/opentelemetry-erlang", {branch, "main"},
155-
"apps/opentelemetry"}},
154+
{opentelemetry, {git_subdir, "http://github.com/open-telemetry/opentelemetry-erlang", {branch, "main"}, "apps/opentelemetry"}},
156155
{opentelemetry_exporter, {git_subdir, "http://github.com/open-telemetry/opentelemetry-erlang", {branch, "main"}, "apps/opentelemetry_exporter"}}
157156
```
158157

159-
``` elixir
158+
```elixir
160159
{:opentelemetry_api, github: "open-telemetry/opentelemetry-erlang", sparse:
161160
"apps/opentelemetry_api", override: true},
162161
{:opentelemetry, github: "open-telemetry/opentelemetry-erlang", sparse:
@@ -175,7 +174,7 @@ it is included the override is necessary.
175174

176175
Running benchmarks is done with [benchee](https://github.com/bencheeorg/benchee). Benchmark functions are stored in modules, under `samples/`. To run them, open a rebar3 shell in the `bench` profile:
177176

178-
``` shell
177+
```shell
179178
$ rebar3 as bench shell
180179

181180
> otel_benchmarks:run().
@@ -184,23 +183,23 @@ $ rebar3 as bench shell
184183
If an Elixir script is wanted for the benchmarks they could be run (after
185184
running `rebar3 as bench compile`) as follows:
186185

187-
``` shell
186+
```shell
188187
$ ERL_AFLAGS="-pa ./_build/bench/extras/samples/" ERL_LIBS=_build/bench/lib/ mix run --no-mix-exs samples/run.exs
189188
```
190189

191190
## W3C Trace Context Interop Tests
192191

193192
Start the interop web server in a shell:
194193

195-
``` shell
194+
```shell
196195
$ rebar3 as interop shell
197196

198197
> w3c_trace_context_interop:start().
199198
```
200199

201200
Then, clone the [W3C Trace Context repo](https://github.com/w3c/trace-context) and run the tests:
202201

203-
``` shell
202+
```shell
204203
$ cd test
205204
$ python3 test.py http://127.0.0.1:5000/test
206205
```
@@ -216,7 +215,7 @@ Approvers ([@open-telemetry/erlang-approvers](https://github.com/orgs/open-telem
216215
- [Łukasz Jan Niemier](https://github.com/hauleth)
217216
- [Iliia Khaprov](https://github.com/deadtrickster), [VMWare](https://www.vmware.com/)
218217

219-
*Find more about the approver role in [community repository](https://github.com/open-telemetry/community/blob/master/community-membership.md#approver).*
218+
_Find more about the approver role in [community repository](https://github.com/open-telemetry/community/blob/master/community-membership.md#approver)._
220219

221220
Maintainers ([@open-telemetry/erlang-maintainers](https://github.com/orgs/open-telemetry/teams/erlang-maintainers)):
222221

@@ -225,7 +224,7 @@ Maintainers ([@open-telemetry/erlang-maintainers](https://github.com/orgs/open-t
225224
- [Łukasz Jan Niemier](https://github.com/hauleth)
226225
- [Iliia Khaprov](https://github.com/deadtrickster), [VMWare](https://www.vmware.com/)
227226

228-
*Find more about the maintainer role in [community repository](https://github.com/open-telemetry/community/blob/master/community-membership.md#maintainer).*
227+
_Find more about the maintainer role in [community repository](https://github.com/open-telemetry/community/blob/master/community-membership.md#maintainer)._
229228

230229
### Thanks to all the people who have contributed
231230

apps/opentelemetry_api/lib/open_telemetry/span.ex

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ defmodule OpenTelemetry.Span do
2727
- A list of Links to other Spans (`t:OpenTelemetry.link/0`)
2828
- A list of timestamped Events (`t:OpenTelemetry.event/0`)
2929
- A Status (`t:OpenTelemetry.status/0`)
30+
31+
See [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/trace/api.md#span)
3032
"""
3133

3234
@type start_opts() :: :otel_span.start_opts()
@@ -67,6 +69,8 @@ defmodule OpenTelemetry.Span do
6769
child Spans that may exist of this Span.
6870
6971
The Span Context is returned with `is_recording` set to `false`.
72+
73+
See [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/trace/api.md#end)
7074
"""
7175
defdelegate end_span(span_ctx), to: :otel_span
7276

@@ -75,21 +79,29 @@ defmodule OpenTelemetry.Span do
7579
child Spans that may exist of this Span.
7680
7781
The Span Context is returned with `is_recording` set to `false`.
82+
83+
See [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/trace/api.md#end)
7884
"""
7985
defdelegate end_span(span_ctx, timestamp), to: :otel_span
8086

8187
@doc """
88+
Returns whether this Span is recording information like events, attributes, status, etc.
8289
90+
See [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/trace/api.md#isrecording)
8391
"""
8492
defdelegate is_recording(span_ctx), to: :otel_span
8593

8694
@doc """
95+
Returns true if the SpanContext has a non-zero TraceId and SpanId.
8796
97+
See [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/trace/api.md#isvalid)
8898
"""
8999
defdelegate is_valid(span_ctx), to: :otel_span
90100

91101
@doc """
92102
Set an attribute with key and value on the currently active Span.
103+
104+
See [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/trace/api.md#set-attributes)
93105
"""
94106
@spec set_attribute(
95107
OpenTelemetry.span_ctx(),
@@ -100,12 +112,16 @@ defmodule OpenTelemetry.Span do
100112

101113
@doc """
102114
Add a list of attributes to the currently active Span.
115+
116+
See [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/trace/api.md#set-attributes)
103117
"""
104118
@spec set_attributes(OpenTelemetry.span_ctx(), OpenTelemetry.attributes_map()) :: boolean()
105119
defdelegate set_attributes(span_ctx, attributes), to: :otel_span
106120

107121
@doc """
108122
Add an event to the currently active Span.
123+
124+
See [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/trace/api.md#add-events)
109125
"""
110126
@spec add_event(
111127
OpenTelemetry.span_ctx(),
@@ -116,6 +132,8 @@ defmodule OpenTelemetry.Span do
116132

117133
@doc """
118134
Add a list of events to the currently active Span.
135+
136+
See [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/trace/api.md#add-events)
119137
"""
120138
@spec add_events(OpenTelemetry.span_ctx(), [OpenTelemetry.event()]) :: boolean()
121139
defdelegate add_events(span_ctx, events), to: :otel_span
@@ -130,6 +148,8 @@ defmodule OpenTelemetry.Span do
130148
Record an exception as an event, following the semantics convetions for exceptions.
131149
132150
If trace is not provided, the stacktrace is retrieved from `Process.info/2`
151+
152+
See [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/trace/api.md#record-exception)
133153
"""
134154
@spec record_exception(OpenTelemetry.span_ctx(), Exception.t()) :: boolean()
135155
def record_exception(span_ctx, exception, trace \\ nil, attributes \\ [])
@@ -154,6 +174,8 @@ defmodule OpenTelemetry.Span do
154174
If used, this will override the default Span Status, which is `:unset`.
155175
Valid statuses are `:ok`, or `:error`. Calling this will also set the
156176
`status_code` attribute to `1`(`:ok`), or `2`(`:error`).
177+
178+
See [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/trace/api.md#set-status)
157179
"""
158180
@spec set_status(OpenTelemetry.span_ctx(), OpenTelemetry.status()) :: boolean()
159181
defdelegate set_status(span_ctx, status), to: :otel_span
@@ -166,10 +188,12 @@ defmodule OpenTelemetry.Span do
166188
logic will be implemented before the Span creation for performance reasons. Thus the name
167189
update may interfere with this logic.
168190
169-
The function name is called UpdateName to differentiate this function from the regular
191+
The function name is called update_name to differentiate this function from the regular
170192
property setter. It emphasizes that this operation signifies a major change for a Span
171193
and may lead to re-calculation of sampling or filtering decisions made previously
172194
depending on the implementation.
195+
196+
See [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/trace/api.md#updatename)
173197
"""
174198
@spec update_name(OpenTelemetry.span_ctx(), OpenTelemetry.span_name()) :: boolean()
175199
defdelegate update_name(span_ctx, name), to: :otel_span

apps/opentelemetry_api/lib/open_telemetry/tracer.ex

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@ defmodule OpenTelemetry.Tracer do
1414
Tracer.with_span "span-1" do
1515
... do something ...
1616
end
17+
18+
See [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/trace/api.md#tracer)
1719
"""
1820

1921
@doc """
2022
Starts a new span and does not make it the current active span of the current process.
2123
2224
The current active Span is used as the parent of the created Span.
25+
26+
See [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/trace/api.md#span-creation)
2327
"""
2428
defmacro start_span(name, opts \\ quote(do: %{})) do
2529
quote bind_quoted: [name: name, start_opts: opts] do
@@ -35,6 +39,8 @@ defmodule OpenTelemetry.Tracer do
3539
Starts a new span and does not make it the current active span of the current process.
3640
3741
The current active Span is used as the parent of the created Span.
42+
43+
See [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/trace/api.md#span-creation)
3844
"""
3945
defmacro start_span(ctx, name, opts) do
4046
quote bind_quoted: [ctx: ctx, name: name, start_opts: opts] do
@@ -49,6 +55,8 @@ defmodule OpenTelemetry.Tracer do
4955

5056
@doc """
5157
Takes a `t:OpenTelemetry.span_ctx/0` and the Tracer sets it to the currently active Span.
58+
59+
See [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/trace/api.md#get-context)
5260
"""
5361
def set_current_span(span_ctx) do
5462
:otel_tracer.set_current_span(span_ctx)
@@ -57,6 +65,8 @@ defmodule OpenTelemetry.Tracer do
5765
@doc """
5866
Takes a `t:OpenTelemetry.Ctx.t/0` and the `t:OpenTelemetry.span_ctx/0` and the Tracer sets
5967
it to the current span in the pass Context.
68+
69+
See [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/trace/api.md#get-context)
6070
"""
6171
def set_current_span(ctx, span_ctx) do
6272
:otel_tracer.set_current_span(ctx, span_ctx)
@@ -68,6 +78,8 @@ defmodule OpenTelemetry.Tracer do
6878
before the block.
6979
7080
See `start_span/2` and `end_span/0`.
81+
82+
See [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/trace/api.md#span-creation)
7183
"""
7284
defmacro with_span(name, start_opts \\ quote(do: %{}), do: block) do
7385
quote do
@@ -86,6 +98,8 @@ defmodule OpenTelemetry.Tracer do
8698
before the block.
8799
88100
See `start_span/2` and `end_span/0`.
101+
102+
See [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/trace/api.md#span-creation)
89103
"""
90104
defmacro with_span(ctx, name, start_opts, do: block) do
91105
quote do
@@ -101,13 +115,17 @@ defmodule OpenTelemetry.Tracer do
101115

102116
@doc """
103117
Returns the currently active `t:OpenTelemetry.span_ctx/0`.
118+
119+
See [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/trace/api.md#get-context)
104120
"""
105121
def current_span_ctx() do
106122
:otel_tracer.current_span_ctx()
107123
end
108124

109125
@doc """
110126
Returns the `t:OpenTelemetry.span_ctx/0` active in Context `ctx`.
127+
128+
See [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/trace/api.md#get-context)
111129
"""
112130
def current_span_ctx(ctx) do
113131
:otel_tracer.current_span_ctx(ctx)
@@ -120,6 +138,8 @@ defmodule OpenTelemetry.Tracer do
120138
To end a specific span, see `OpenTelemetry.Span.end_span/1`.
121139
122140
The Span in the current Context has its `is_recording` set to `false`.
141+
142+
See [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/trace/api.md#end)
123143
"""
124144
@spec end_span(:opentelemetry.timestamp() | :undefined) ::
125145
:opentelemetry.span_ctx() | :undefined
@@ -131,6 +151,8 @@ defmodule OpenTelemetry.Tracer do
131151

132152
@doc """
133153
Set an attribute with key and value on the currently active Span.
154+
155+
See [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/trace/api.md#set-attributes)
134156
"""
135157
@spec set_attribute(OpenTelemetry.attribute_key(), OpenTelemetry.attribute_value()) :: boolean()
136158
def set_attribute(key, value) do
@@ -143,6 +165,8 @@ defmodule OpenTelemetry.Tracer do
143165

144166
@doc """
145167
Add a list of attributes to the currently active Span.
168+
169+
See [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/trace/api.md#set-attributes)
146170
"""
147171
@spec set_attributes(OpenTelemetry.attributes_map()) :: boolean()
148172
def set_attributes(attributes) do
@@ -151,6 +175,8 @@ defmodule OpenTelemetry.Tracer do
151175

152176
@doc """
153177
Add an event to the currently active Span.
178+
179+
See [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/trace/api.md#add-events)
154180
"""
155181
@spec add_event(OpenTelemetry.event_name(), OpenTelemetry.attributes_map()) :: boolean()
156182
def add_event(event, attributes) do
@@ -163,6 +189,8 @@ defmodule OpenTelemetry.Tracer do
163189

164190
@doc """
165191
Add a list of events to the currently active Span.
192+
193+
See [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/trace/api.md#add-events)
166194
"""
167195
@spec add_events([OpenTelemetry.event()]) :: boolean()
168196
def add_events(events) do
@@ -173,6 +201,8 @@ defmodule OpenTelemetry.Tracer do
173201
Record an exception as an event, following the semantics convetions for exceptions.
174202
175203
If trace is not provided, the stacktrace is retrieved from `Process.info/2`
204+
205+
See [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/trace/api.md#record-exception)
176206
"""
177207
@spec record_exception(Exception.t()) :: boolean()
178208
def record_exception(exception, trace \\ nil, attributes \\ []) do
@@ -188,6 +218,8 @@ defmodule OpenTelemetry.Tracer do
188218
Creates and sets the Status of the currently active Span.
189219
190220
If used, this will override the default Span Status, which is `:unset`.
221+
222+
See [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/trace/api.md#set-status)
191223
"""
192224
@spec set_status(OpenTelemetry.status_code(), String.t()) :: boolean()
193225
def set_status(code, message) do
@@ -198,6 +230,8 @@ defmodule OpenTelemetry.Tracer do
198230
Sets the Status of the currently active Span.
199231
200232
If used, this will override the default Span Status, which is `:unset`.
233+
234+
See [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/trace/api.md#set-status)
201235
"""
202236
@spec set_status(OpenTelemetry.status()) :: boolean()
203237
def set_status(status) do
@@ -212,10 +246,12 @@ defmodule OpenTelemetry.Tracer do
212246
logic will be implemented before the Span creation for performance reasons. Thus the name
213247
update may interfere with this logic.
214248
215-
The function name is called UpdateName to differentiate this function from the regular
249+
The function name is called update_name to differentiate this function from the regular
216250
property setter. It emphasizes that this operation signifies a major change for a Span
217251
and may lead to re-calculation of sampling or filtering decisions made previously
218252
depending on the implementation.
253+
254+
See [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/trace/api.md#updatename)
219255
"""
220256
@spec update_name(String.t()) :: boolean()
221257
def update_name(name) do

0 commit comments

Comments
 (0)