Skip to content

Commit

Permalink
WIP add function file
Browse files Browse the repository at this point in the history
  • Loading branch information
ocelotl committed Nov 7, 2023
1 parent 2f302f1 commit a9b325e
Show file tree
Hide file tree
Showing 4 changed files with 384 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
)
from ipdb import set_trace

set_trace


class Configurator:

Expand Down Expand Up @@ -105,33 +107,34 @@ def create_tracer_provider_processors_batch(dictionary):
def traverse_configuration(schema_dictionary, configuration_dictionary):

def traverse(
schema_dictionary, configuration_dictionary, mapping_path
schema_dictionary,
configuration_dictionary,
mapping_path,
mapping_paths
):

mapping_path_joined = "/".join(mapping_path)

if "trace_id_ratio_based" in mapping_path_joined:
set_trace

print(mapping_path_joined)
# print(mapping_path)
mapping_paths.append(mapping_path_joined)

if "properties" in schema_dictionary.keys():
if mapping_path:
if mapping_path and not mapping_path[-1].endswith("properties"):
mapping_path[-1] = f"{mapping_path[-1]}/properties"
else:
mapping_path.append("properties")
schema_dictionary = schema_dictionary["properties"]

elif "items" in schema_dictionary.keys():
if mapping_path and not mapping_path[-1].endswith("items"):
mapping_path[-1] = f"{mapping_path[-1]}/items"
else:
mapping_path.append("items")
schema_dictionary = schema_dictionary["items"]
if "properties" in schema_dictionary.keys():
mapping_path[-1] = f"{mapping_path[-1]}/properties"
if not mapping_path[-1].endswith("properties"):
mapping_path[-1] = f"{mapping_path[-1]}/properties"
schema_dictionary = schema_dictionary["properties"]

if mapping_path and "logger_provider/properties" == mapping_path[-1]:
set_trace

for configuration_dictionary_key, configuration_dictionary_value in (
configuration_dictionary.items()
):
Expand All @@ -141,11 +144,12 @@ def traverse(
schema_dictionary_key = configuration_dictionary_key
mapping_path.append(schema_dictionary_key)
else:
set_trace()
1 / 0
traverse(
schema_dictionary[schema_dictionary_key],
configuration_dictionary_value,
mapping_path
mapping_path,
mapping_paths
)
mapping_path.pop()

Expand All @@ -154,20 +158,21 @@ def traverse(
schema_dictionary_key = configuration_dictionary_key
mapping_path.append(schema_dictionary_key)
else:
set_trace()
1 / 0
for element in configuration_dictionary_value:
if isinstance(element, dict):
traverse(
schema_dictionary[schema_dictionary_key],
element,
mapping_path
mapping_path,
mapping_paths
)
# FIXME adding this apparently causes an issue and
# fixes another one. Look at mapping_path.
mapping_path.pop()
mapping_path.pop()

mapping_path = []
mapping_paths = []

traverse(schema_dictionary, configuration_dictionary, mapping_path)
traverse(schema_dictionary, configuration_dictionary, [], mapping_paths)

set_trace()
return mapping_paths
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright The 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.

from json import dumps
from jsonref import loads
from ipdb import set_trace

set_trace, dumps


def resolve_schema(json_file_path) -> dict:

root_path = json_file_path.absolute()

with open(json_file_path, "r") as json_file:
dictionary = loads(json_file.read(), base_uri=root_path.as_uri())

return dictionary
Loading

0 comments on commit a9b325e

Please sign in to comment.