-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from ferd/fix-otel-usage-and-others
Rework tracing, bump deps, turn disk cache on
- Loading branch information
Showing
8 changed files
with
235 additions
and
252 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
-module(revault_otel). | ||
-export([start_active_span/1, start_active_span/2, | ||
end_active_span/0, | ||
extract_propagation_data/0, apply_propagation_data/1]). | ||
|
||
-include_lib("opentelemetry_api/include/otel_tracer.hrl"). | ||
|
||
-define(KEY, {self(), ?MODULE}). | ||
|
||
start_active_span(Name) -> | ||
start_active_span(Name, #{}). | ||
|
||
start_active_span(Name, StartOpts) -> | ||
SpanCtx = otel_tracer:start_span(?current_tracer, Name, StartOpts), | ||
Ctx = otel_tracer:set_current_span(otel_ctx:get_current(), SpanCtx), | ||
Token = otel_ctx:attach(Ctx), | ||
Stack = case erlang:get(?KEY) of | ||
undefined -> []; | ||
Val -> Val | ||
end, | ||
erlang:put(?KEY, [{SpanCtx, Token}|Stack]), | ||
ok. | ||
|
||
end_active_span() -> | ||
case erlang:get(?KEY) of | ||
undefined -> | ||
ok; | ||
[] -> | ||
ok; | ||
[{SpanCtx, Token} | Stack] -> | ||
_ = otel_tracer:set_current_span(otel_ctx:get_current(), | ||
otel_span:end_span(SpanCtx, undefined)), | ||
otel_ctx:detach(Token), | ||
erlang:put(?KEY, Stack), | ||
ok | ||
end. | ||
|
||
extract_propagation_data() -> | ||
otel_propagator_text_map:inject([]). | ||
|
||
apply_propagation_data(Data) when is_list(Data) -> | ||
otel_propagator_text_map:extract(Data). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-define(start_active_span(Name), | ||
revault_otel:start_active_span(Name)). | ||
|
||
-define(start_active_span(Name, StartOpts), | ||
revault_otel:start_active_span(Name, StartOpts)). | ||
|
||
-define(end_active_span(), | ||
revault_otel:end_active_span()). | ||
|
||
-define(extract_propagation_data(), | ||
revault_otel:extract_propagation_data()). | ||
|
||
-define(apply_propagation_data(Data), | ||
revault_otel:apply_propagation_data(Data)). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
[ | ||
{revault, [ | ||
{s3_tmpdir, ".tmp"}, | ||
%% Turn this on at your own risk, some updates | ||
%% may be missed since this cache uses a mix of modification | ||
%% times and file sizes to avoid re-hashing files. | ||
{disk_hash_cache, false} | ||
{disk_hash_cache, true} | ||
]}, | ||
{maestro, []}, | ||
{opentelemetry, | ||
[{span_processor, batch}, | ||
{text_map_propagators, [trace_context, baggage]}, | ||
{traces_exporter, otlp}]} | ||
]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
[ | ||
{revault, [ | ||
{s3_tmpdir, ".tmp"}, | ||
%% keep the cache off for most testing purposes | ||
%% since it has an effect on invalidation efforts | ||
%% and specific tests are geared to see it is | ||
%% equivalent (when properly invalidated) to working | ||
%% without it. | ||
{disk_hash_cache, false} | ||
]}, | ||
{maestro, []}, | ||
{opentelemetry, | ||
[{span_processor, batch}, | ||
{text_map_propagators, [trace_context, baggage]}, | ||
{traces_exporter, {otel_exporter_stdout, []}}]} | ||
]. |
Oops, something went wrong.