Skip to content

Commit ab363df

Browse files
authored
refactor namespace package - cleanup opencensus.common namespace (census-instrumentation#529)
* cleanup opencensus.common namespace * address review comments * minor fix * manually merge changes * fix merge conflict * keep copyright year untouched
1 parent 5dac1d9 commit ab363df

File tree

15 files changed

+22
-34
lines changed

15 files changed

+22
-34
lines changed

opencensus/common/__init__.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1 @@
1-
# Copyright 2018, OpenCensus Authors
2-
#
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
6-
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
1+
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
File renamed without changes.
File renamed without changes.
File renamed without changes.

opencensus/common/utils.py renamed to opencensus/common/utils/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
ISO_DATETIME_REGEX = '%Y-%m-%dT%H:%M:%S.%fZ'
3030

3131

32-
def _get_truncatable_str(str_to_convert):
32+
def get_truncatable_str(str_to_convert):
3333
"""Truncate a string if exceed limit and record the truncated bytes
3434
count.
3535
"""
File renamed without changes.

opencensus/trace/attributes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def _format_attribute_value(value):
2323
value_type = 'int_value'
2424
elif isinstance(value, six.string_types):
2525
value_type = 'string_value'
26-
value = utils._get_truncatable_str(value)
26+
value = utils.get_truncatable_str(value)
2727
elif isinstance(value, float):
2828
value_type = 'double_value'
2929
else:

opencensus/trace/span.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from datetime import datetime
1616
from itertools import chain
1717

18-
from opencensus.common.utils import _get_truncatable_str
18+
from opencensus.common.utils import get_truncatable_str
1919
from opencensus.trace import attributes
2020
from opencensus.trace import base_span
2121
from opencensus.trace import link as link_module
@@ -265,7 +265,7 @@ def format_span_json(span):
265265
:returns: Formatted Span.
266266
"""
267267
span_json = {
268-
'displayName': _get_truncatable_str(span.name),
268+
'displayName': get_truncatable_str(span.name),
269269
'spanId': span.span_id,
270270
'startTime': span.start_time,
271271
'endTime': span.end_time,

opencensus/trace/span_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def _format_legacy_span_json(span_data):
106106
:return: Dictionary representing the Span
107107
"""
108108
span_json = {
109-
'displayName': utils._get_truncatable_str(span_data.name),
109+
'displayName': utils.get_truncatable_str(span_data.name),
110110
'spanId': span_data.span_id,
111111
'startTime': span_data.start_time,
112112
'endTime': span_data.end_time,

opencensus/trace/stack_trace.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import random
1818
import traceback
1919

20-
from opencensus.common.utils import _get_truncatable_str
20+
from opencensus.common.utils import get_truncatable_str
2121

2222
MAX_FRAMES = 128
2323

@@ -86,18 +86,18 @@ def __init__(self,
8686
def format_stack_frame_json(self):
8787
"""Convert StackFrame object to json format."""
8888
stack_frame_json = {}
89-
stack_frame_json['function_name'] = _get_truncatable_str(
89+
stack_frame_json['function_name'] = get_truncatable_str(
9090
self.func_name)
91-
stack_frame_json['original_function_name'] = _get_truncatable_str(
91+
stack_frame_json['original_function_name'] = get_truncatable_str(
9292
self.original_func_name)
93-
stack_frame_json['file_name'] = _get_truncatable_str(self.file_name)
93+
stack_frame_json['file_name'] = get_truncatable_str(self.file_name)
9494
stack_frame_json['line_number'] = self.line_num
9595
stack_frame_json['column_number'] = self.col_num
9696
stack_frame_json['load_module'] = {
97-
'module': _get_truncatable_str(self.load_module),
98-
'build_id': _get_truncatable_str(self.build_id),
97+
'module': get_truncatable_str(self.load_module),
98+
'build_id': get_truncatable_str(self.build_id),
9999
}
100-
stack_frame_json['source_version'] = _get_truncatable_str(
100+
stack_frame_json['source_version'] = get_truncatable_str(
101101
self.source_version)
102102

103103
return stack_frame_json

0 commit comments

Comments
 (0)