Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### SDK

#### Added

- Support `OTEL_EXPERIMENTAL_CONFIG_FILE` environment variable to specify a json
file assumed to already be validated against the Otel file configuration
jsonschema.
- Support the new file configuration schema as Erlang application environment
configuration in addition to as json.

#### Changes

- *Deprecated*: Resource attribute configuration: No longer use maps to
structure resource attribute keys with dots. Meaning use a key of
`service.name` instead of `#{service => #{name => ...}}` to represent
`service.name` attribute in the resource.
- Options passed to the start of a tracer server and span processor have changed
to correspond to the file configuration schema.

## Experimental API 0.5.2 - 2024-11-22

### Added
Expand Down
36 changes: 31 additions & 5 deletions apps/opentelemetry/src/opentelemetry_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,18 @@
-include_lib("opentelemetry_api/include/opentelemetry.hrl").

start(_StartType, _StartArgs) ->
Config = otel_configuration:merge_with_os(
application:get_all_env(opentelemetry)),
Env = application:get_all_env(opentelemetry),
Config = case os:getenv("OTEL_EXPERIMENTAL_CONFIG_FILE") of
false ->
case proplists:get_value(config_file, Env) of
undefined ->
otel_configuration:merge_with_os(Env);
File ->
otel_configuration:merge_with_env(otel_file_configuration:parse_file(File), Env)
end;
File ->
otel_configuration:merge_with_env(otel_file_configuration:parse_file(File), Env)
end,

%% set the global propagators for HTTP based on the application env
%% these get set even if the SDK is disabled
Expand All @@ -34,7 +44,7 @@ start(_StartType, _StartArgs) ->
SupResult = opentelemetry_sup:start_link(Config),

case Config of
#{sdk_disabled := true} ->
#{disabled := true} ->
%% skip the rest if the SDK is disabled
SupResult;
_ ->
Expand All @@ -57,8 +67,14 @@ stop(_State) ->

%% internal functions

setup_text_map_propagators(#{text_map_propagators := List}) ->
CompositePropagator = otel_propagator_text_map_composite:create(List),
setup_text_map_propagators(Config) ->
Propagator = maps:get(propagator, Config, #{}),
PropagatorList = maps:get(composite_list, Propagator, []),
Propagators = maps:get(composite, Propagator, []),

Combined = append_if_not_found(otel_configuration:transform(propagators, PropagatorList), Propagators),

CompositePropagator = otel_propagator_text_map_composite:create(Combined),
opentelemetry:set_text_map_propagator(CompositePropagator).

create_loaded_application_tracers(#{create_application_tracers := true}) ->
Expand All @@ -68,3 +84,13 @@ create_loaded_application_tracers(#{create_application_tracers := true}) ->
ok;
create_loaded_application_tracers(_) ->
ok.

append_if_not_found([], Existing) ->
Existing;
append_if_not_found([C | Rest], Existing) ->
case lists:member(C, Existing) of
true ->
append_if_not_found(Rest, Existing);
false ->
append_if_not_found(Rest, Existing ++ [C])
end.
Comment on lines +88 to +96
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we don't expect dupes in C, then this can be Existing ++ (C -- Existing) and preserve ordering.

2 changes: 1 addition & 1 deletion apps/opentelemetry/src/opentelemetry_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
start_link(Opts) ->
supervisor:start_link({local, ?SERVER}, ?MODULE, [Opts]).

init([#{sdk_disabled := true}]) ->
init([#{disabled := true}]) ->
{ok, {#{}, []}};
init([Opts]) ->
SupFlags = #{strategy => one_for_one,
Expand Down
4 changes: 2 additions & 2 deletions apps/opentelemetry/src/otel_batch_processor.erl
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ init([Args=#{reg_name := RegName}]) ->
process_flag(trap_exit, true),

SizeLimit = maps:get(max_queue_size, Args, ?DEFAULT_MAX_QUEUE_SIZE),
ExportingTimeout = maps:get(exporting_timeout_ms, Args, ?DEFAULT_EXPORTER_TIMEOUT_MS),
ScheduledDelay = maps:get(scheduled_delay_ms, Args, ?DEFAULT_SCHEDULED_DELAY_MS),
ExportingTimeout = maps:get(export_timeout, Args, ?DEFAULT_EXPORTER_TIMEOUT_MS),
ScheduledDelay = maps:get(schedule_delay, Args, ?DEFAULT_SCHEDULED_DELAY_MS),
CheckTableSize = maps:get(check_table_size_ms, Args, ?DEFAULT_CHECK_TABLE_SIZE_MS),

%% TODO: this should be passed in from the tracer server
Expand Down
Loading