Skip to content

Commit

Permalink
Merge branch 'main' into build-erlang-elixir-api-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan Sloughter authored Feb 10, 2022
2 parents 218cfdd + 600257a commit 0f1c08c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 10 deletions.
26 changes: 17 additions & 9 deletions apps/opentelemetry_exporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ Currently only supports the Tracer protocol using either GRPC or Protobuffers ov

## Configuration

### Options to Batch Processor
### Options to span processor

Exporter configuration can be done as arguments to the batch processor in
the OpenTelemetry application environment.
Exporter configuration can be done as arguments to the span processor (simple or batch) in the OpenTelemetry application environment.

For an Erlang release in `sys.config`:

``` erlang
{opentelemetry,
[{processors,
[{processors,
[{otel_batch_processor,
#{exporter => {opentelemetry_exporter, #{endpoints =>
["http://localhost:9090"],
Expand All @@ -31,14 +30,14 @@ The default protocol is `http_protobuf`, to override this and use grpc add

``` erlang
{opentelemetry,
[{processors,
[{otel_batch_processor,
[{processors,
[{otel_simple_processor,
#{exporter => {opentelemetry_exporter, #{protocol => grpc,
endpoints => ["http://localhost:9090"],
headers => [{"x-honeycomb-dataset", "experiments"}]}}}}]}]}
```

An Elixir release uses `releases.exs`:
In Elixir, you can use `config.exs` or `runtime.exs`:

``` elixir
config :opentelemetry, :processors,
Expand All @@ -48,6 +47,16 @@ config :opentelemetry, :processors,
}
```

### The configuration map

The second element of the configuration tuple is a configuration map. It can contain the following keys:

- `protocol` - one of: `http_protobuf`, `grpc` or `http_json`. Defaults to `http_protobuf`. `http_json` is not implemented yet.
- `endpoints` - A list of endpoints to send traces to. Can take one of the forms described below. By default, exporter sends data to `http://localhost:4318`.
- `headers` - a list of headers to send to the collector (i.e `[{<<"x-access-key">> <<"secret">>}]`). Defaults to an empty list.
- `compression` - an atom. Setting it to `gzip` enables gzip compression.
- `ssl_options` - a list of SSL options. See Erlang's [SSL docs](https://www.erlang.org/doc/man/ssl.html#TLS/DTLS%20OPTION%20DESCRIPTIONS%20-%20CLIENT) for what options are available.

### Application Environment

Alternatively the `opentelemetry_exporter` Application can be configured itself.
Expand All @@ -62,7 +71,7 @@ Available configuration keys:
- `otlp_traces_protocol`: The transport protocol to use for exporting traces, supported values: `grpc` and `http_protobuf`. Defaults to `http_protobuf`.
- `otlp_compression`: Compression type to use, supported values: `gzip`. Defaults to no compression.
- `otlp_traces_compression`: Compression type to use for exporting traces, supported values: `gzip`. Defaults to no compression.

``` erlang
{opentelemetry_exporter,
[{otlp_protocol, grpc},
Expand Down Expand Up @@ -136,4 +145,3 @@ $ mv src/opentelemetry_proto_collector_trace_v_1_trace_service_client.erl src/op
```

Then open `src/opentelemetry_trace_service.erl` and fix the module name.

31 changes: 30 additions & 1 deletion apps/opentelemetry_exporter/src/opentelemetry_exporter.erl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
%% environment, the OS environment or directly through a map of options
%% passed when setting up the exporter in the batch processor.
%%
%% `opentelemetry_exporter' application enevironment options are:
%% `opentelemetry_exporter' application environment options are:
%%
%% <ul>
%% <li>
Expand Down Expand Up @@ -63,6 +63,35 @@
%% <li>`OTEL_EXPORTER_OTLP_TRACES_COMPRESSION': Compression to use when exporting traces, supported value: gzip. Defaults to no compression.</li>
%% </ul>
%%
%% You can also set these configuration values in the map passed to the
%% opentelemetry processor configuration.
%% <ul>
%% <li>`endpoints': A list of endpoints to send traces to. Can take one of the forms described below. By default, exporter sends data to `http://localhost:4318'.</li>
%% <li>`headers': List of additional headers to add to export requests.</li>
%% <li>`protocol': The transport protocol to use, supported values: `grpc' and `http_protobuf'. Defaults to `http_protobuf'.</li>
%% <li>`compression': Compression to use, supported value: `gzip'. Defaults to no compression.</li>
%% <li>`ssl_options': a list of SSL options. See Erlang's <a href='https://www.erlang.org/doc/man/ssl.html#TLS/DTLS%20OPTION%20DESCRIPTIONS%20-%20CLIENT'>SSL docs</a> for what options are available.</li>
%% </ul>
%%
%% Endpoints configuration
%%
%% You can pass your collector endpoints in three forms:
%%
%% <ul>
%% <li> As a string, i.e `"https://localhost:4000"'.</li>
%% <li> As a map, with the following keys:
%% <ul>
%% <li>`host => unicode:chardata()'</li>
%% <li>`path => unicode:chardata()'</li>
%% <li>`port => integer() >= 0 | undefined'</li>
%% <li>`scheme => unicode:chardata()'</li>
%% </ul>
%% </li>
%% <li> As a 4 element tuple in format `{Scheme, Host, Port, SSLOptions}'.</li>
%% </ul>
%%
%% While using `http_protobuf' protocol, currently only the first endpoint in that list is used to export traces, the rest is effectively ignored. `grpc' supports multiple endpoints.
%%
%% @end
%%%-------------------------------------------------------------------------
-module(opentelemetry_exporter).
Expand Down

0 comments on commit 0f1c08c

Please sign in to comment.