This repository has been archived by the owner on Oct 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8d4ef06
commit 0acc707
Showing
7 changed files
with
298 additions
and
8 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
%%%------------------------------------------------------------------------ | ||
%% Copyright 2019, OpenTelemetry Authors | ||
%% Licensed under the Apache License, Version 2.0 (the "License"); | ||
%% you may not use this file except in compliance with the License. | ||
%% You may obtain a copy of the License at | ||
%% | ||
%% http://www.apache.org/licenses/LICENSE-2.0 | ||
%% | ||
%% Unless required by applicable law or agreed to in writing, software | ||
%% distributed under the License is distributed on an "AS IS" BASIS, | ||
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
%% See the License for the specific language governing permissions and | ||
%% limitations under the License. | ||
%% | ||
%% @doc | ||
%% @end | ||
%%%------------------------------------------------------------------------- | ||
-module(ot_baggage). | ||
|
||
-export([ctx_key/0, | ||
set/2, | ||
get/1, | ||
remove/1, | ||
clear/0, | ||
get_http_extractor/0, | ||
get_http_injector/0]). | ||
|
||
-type key() :: string(). | ||
-type value() :: string(). | ||
|
||
-export_type([key/0, | ||
value/0]). | ||
|
||
-define(BAGGAGE_KEY, '$__ot_baggage_ctx_key'). | ||
|
||
ctx_key() -> | ||
?BAGGAGE_KEY. | ||
|
||
-spec set(key(), value()) -> ok. | ||
set(Key, Value) -> | ||
ot_ctx:set_value(?BAGGAGE_KEY, Key, Value). | ||
|
||
-spec get(key()) -> value(). | ||
get(Key)-> | ||
ot_ctx:get_value(?BAGGAGE_KEY, Key). | ||
|
||
-spec remove(key()) -> ok. | ||
remove(Key) -> | ||
ot_ctx:remove(?BAGGAGE_KEY, Key). | ||
|
||
-spec clear() -> ok. | ||
clear() -> | ||
ot_ctx:clear(?BAGGAGE_KEY). | ||
|
||
-spec get_http_extractor() -> ot_propagation:extractor(). | ||
get_http_extractor() -> | ||
ok. | ||
|
||
-spec get_http_injector() -> ot_propagation:injector(). | ||
get_http_injector() -> | ||
ok. |
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,47 @@ | ||
%%%------------------------------------------------------------------------ | ||
%% Copyright 2019, OpenTelemetry Authors | ||
%% Licensed under the Apache License, Version 2.0 (the "License"); | ||
%% you may not use this file except in compliance with the License. | ||
%% You may obtain a copy of the License at | ||
%% | ||
%% http://www.apache.org/licenses/LICENSE-2.0 | ||
%% | ||
%% Unless required by applicable law or agreed to in writing, software | ||
%% distributed under the License is distributed on an "AS IS" BASIS, | ||
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
%% See the License for the specific language governing permissions and | ||
%% limitations under the License. | ||
%% | ||
%% @doc | ||
%% @end | ||
%%%------------------------------------------------------------------------- | ||
-module(ot_correlations). | ||
|
||
-export([ctx_key/0, | ||
set/3, | ||
get_http_extractor/0, | ||
get_http_injector/0]). | ||
|
||
-type key() :: string(). | ||
-type value() :: string(). | ||
-type hop_limit() :: no_propagation | unlimited_propagation. | ||
|
||
-export_type([key/0, | ||
value/0]). | ||
|
||
-define(CORRELATIONS_KEY, '$__ot_correlations_ctx_key'). | ||
|
||
ctx_key() -> | ||
?CORRELATIONS_KEY. | ||
|
||
-spec set(key(), value(), hop_limit()) -> ok. | ||
set(Key, Value, HopLimit) -> | ||
ot_ctx:set_value(?CORRELATIONS_KEY, Key, {Value, HopLimit}). | ||
|
||
-spec get_http_extractor() -> ot_propagation:extractor(). | ||
get_http_extractor() -> | ||
ok. | ||
|
||
-spec get_http_injector() -> ot_propagation:injector(). | ||
get_http_injector() -> | ||
ok. |
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,89 @@ | ||
%%%------------------------------------------------------------------------ | ||
%% Copyright 2019, OpenTelemetry Authors | ||
%% Licensed under the Apache License, Version 2.0 (the "License"); | ||
%% you may not use this file except in compliance with the License. | ||
%% You may obtain a copy of the License at | ||
%% | ||
%% http://www.apache.org/licenses/LICENSE-2.0 | ||
%% | ||
%% Unless required by applicable law or agreed to in writing, software | ||
%% distributed under the License is distributed on an "AS IS" BASIS, | ||
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
%% See the License for the specific language governing permissions and | ||
%% limitations under the License. | ||
%% | ||
%% @doc | ||
%% @end | ||
%%%------------------------------------------------------------------------- | ||
-module(ot_ctx). | ||
|
||
-export([set_value/3, | ||
get_value/2, | ||
remove/2, | ||
clear/1, | ||
set_current/2, | ||
get_current/1]). | ||
|
||
-type ctx() :: map(). | ||
-type namespace() :: term(). | ||
-type key() :: string(). | ||
-type value() :: string(). | ||
|
||
-callback set_value(namespace(), key(), value()) -> ok. | ||
-callback get_value(namespace(), key()) -> value(). | ||
-callback remove(namespace(), key()) -> ok. | ||
-callback clear(namespace()) -> ok. | ||
-callback set_current(namespace(), ctx()) -> ok. | ||
-callback get_current(namespace()) -> ctx(). | ||
|
||
-export_type([ctx/0, | ||
key/0, | ||
value/0]). | ||
|
||
-spec set_value(namespace(), key(), value()) -> ok. | ||
set_value(Namespace, Key, Value) -> | ||
set_value(opentelemetry:get_context_manager(), Namespace, Key, Value). | ||
|
||
-spec set_value(module(), namespace(), key(), value()) -> ok. | ||
set_value(CtxModule, Namespace, Key, Value) -> | ||
CtxModule:set_value(Namespace, Key, Value). | ||
|
||
-spec get_value(namespace(), key()) -> value(). | ||
get_value(Namespace, Key) -> | ||
get_value(opentelemetry:get_context_manager(), Namespace, Key). | ||
|
||
-spec get_value(module(), namespace(), key()) -> value(). | ||
get_value(Module, Namespace, Key) -> | ||
Module:get_value(Namespace, Key). | ||
|
||
-spec remove(namespace(), key()) -> ok. | ||
remove(Namespace, Key) -> | ||
remove(opentelemetry:get_context_manager(), Namespace, Key). | ||
|
||
-spec remove(module(), namespace(), key()) -> ok. | ||
remove(CtxModule, Namespace, Key) -> | ||
CtxModule:remove(Namespace, Key). | ||
|
||
-spec clear(namespace()) -> ok. | ||
clear(Namespace) -> | ||
clear(opentelemetry:get_context_manager(), Namespace). | ||
|
||
-spec clear(module(), namespace()) -> ok. | ||
clear(CtxModule, Namespace) -> | ||
CtxModule:clear(Namespace). | ||
|
||
-spec set_current(namespace(), ctx()) -> ok. | ||
set_current(Namespace, Ctx) -> | ||
set_current(opentelemetry:get_context_manager(), Namespace, Ctx). | ||
|
||
-spec set_current(module(), namespace(), ctx()) -> ok. | ||
set_current(CtxModule, Namespace, Ctx) -> | ||
CtxModule:set_current(Namespace, Ctx). | ||
|
||
-spec get_current(namespace()) -> ctx(). | ||
get_current(Namespace) -> | ||
get_current(opentelemetry:get_context_manager(), Namespace). | ||
|
||
-spec get_current(module(), namespace()) -> ctx(). | ||
get_current(CtxModule, Namespace) -> | ||
CtxModule:get_current(Namespace). |
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,51 @@ | ||
%%%------------------------------------------------------------------------ | ||
%% Copyright 2019, OpenTelemetry Authors | ||
%% Licensed under the Apache License, Version 2.0 (the "License"); | ||
%% you may not use this file except in compliance with the License. | ||
%% You may obtain a copy of the License at | ||
%% | ||
%% http://www.apache.org/licenses/LICENSE-2.0 | ||
%% | ||
%% Unless required by applicable law or agreed to in writing, software | ||
%% distributed under the License is distributed on an "AS IS" BASIS, | ||
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
%% See the License for the specific language governing permissions and | ||
%% limitations under the License. | ||
%% | ||
%% @doc | ||
%% @end | ||
%%%------------------------------------------------------------------------- | ||
-module(ot_ctx_noop). | ||
|
||
-behaviour(ot_ctx). | ||
|
||
-export([set_value/3, | ||
get_value/2, | ||
remove/2, | ||
clear/1, | ||
set_current/2, | ||
get_current/1]). | ||
|
||
-spec set_value(ot_ctx:namespace(), ot_ctx:key(), ot_ctx:value()) -> ok. | ||
set_value(_Namespace, _Key, _Value) -> | ||
ok. | ||
|
||
-spec get_value(ot_ctx:namespace(), ot_ctx:key()) -> ot_ctx:value(). | ||
get_value(_Namespace, _Key) -> | ||
undefined. | ||
|
||
-spec remove(ot_ctx:namespace(), ot_ctx:key()) -> ok. | ||
remove(_Namespace, _Key) -> | ||
ok. | ||
|
||
-spec clear(ot_ctx:namespace()) -> ok. | ||
clear(_Namespace) -> | ||
ok. | ||
|
||
-spec set_current(ot_ctx:namespace(), ot_ctx:ctx()) -> ok. | ||
set_current(_Namespace, _Ctx) -> | ||
ok. | ||
|
||
-spec get_current(ot_ctx:namespace()) -> ot_ctx:ctx(). | ||
get_current(_Namespace) -> | ||
#{}. |
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,37 @@ | ||
%%%------------------------------------------------------------------------ | ||
%% Copyright 2019, OpenTelemetry Authors | ||
%% Licensed under the Apache License, Version 2.0 (the "License"); | ||
%% you may not use this file except in compliance with the License. | ||
%% You may obtain a copy of the License at | ||
%% | ||
%% http://www.apache.org/licenses/LICENSE-2.0 | ||
%% | ||
%% Unless required by applicable law or agreed to in writing, software | ||
%% distributed under the License is distributed on an "AS IS" BASIS, | ||
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
%% See the License for the specific language governing permissions and | ||
%% limitations under the License. | ||
%% | ||
%% @doc | ||
%% @end | ||
%%%------------------------------------------------------------------------- | ||
-module(ot_propagation). | ||
|
||
-export([]). | ||
|
||
-type extractor() :: fun(). | ||
-type injector() :: fun(). | ||
-type http_headers() :: [{string(), string()}]. | ||
|
||
-callback http_inject(ot_ctx:ctx()) -> http_headers(). | ||
-callback http_extract(ot_ctx:ctx(), http_headers()) -> ot_ctx:ctx(). | ||
|
||
-callback set_http_injector(injector()) -> ok. | ||
-callback get_http_injector() -> injector(). | ||
|
||
-callback set_http_extractor(extractor()) -> ok. | ||
-callback get_http_extractor() -> extractor(). | ||
|
||
-export_type([extractor/0, | ||
injector/0, | ||
http_headers/0]). |
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