Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Commit 188b204

Browse files
authored
Clean up (#654)
Updated doc to use noxfile.py. Used logging.warning instead of warn.
1 parent e0603e0 commit 188b204

File tree

7 files changed

+21
-20
lines changed

7 files changed

+21
-20
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ Open a pull request against the main opencensus-python repo.
5757
If you want to contribute new [extensions](README.rst#extensions), you need some extra steps:
5858

5959
* Prepare the extension code, put it under the [contrib](./contrib/) folder.
60-
* Update [nox.py](./nox.py) to include your new extension for testing purpose.
60+
* Update [noxfile.py](./noxfile.py) to include your new extension for testing purpose.
6161
* Update [README](./README.rst#extensions) to include your extension.

contrib/opencensus-ext-jaeger/opencensus/ext/jaeger/trace_exporter/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,7 @@ def _convert_attribute_to_tag(key, attr):
314314
key=key,
315315
vDouble=attr,
316316
vType=jaeger.TagType.DOUBLE)
317-
logging.warn('Could not serialize attribute \
318-
{}:{} to tag'.format(key, attr))
317+
logging.warning('Could not serialize attribute %s:%r to tag', key, attr)
319318
return None
320319

321320

@@ -450,8 +449,10 @@ def emit(self, batch):
450449
self.client.emitBatch(batch)
451450
buff = self.buffer.getvalue()
452451
if len(buff) > self.max_packet_size:
453-
logging.warn('Data exceeds the max UDP packet size; size {},\
454-
max {}'.format(len(buff), self.max_packet_size))
452+
logging.warning(
453+
'Data exceeds the max UDP packet size; size %r, max %r',
454+
len(buff),
455+
self.max_packet_size)
455456
else:
456457
udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
457458
udp_socket.sendto(buff, self.address)

contrib/opencensus-ext-jaeger/tests/test_jaeger_exporter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ def test_agent_emit_succeeded(self, mock_logging):
104104

105105
agent_client.emit({})
106106
self.assertTrue(agent_client.client.emit_called)
107-
self.assertFalse(mock_logging.warn.called)
107+
self.assertFalse(mock_logging.warning.called)
108108

109109
@mock.patch('opencensus.ext.jaeger.trace_exporter.logging')
110110
def test_packet_capacity_exceeded(self, mock_logging):
111111
agent_client = trace_exporter.AgentClientUDP(
112112
client=MockClient, max_packet_size=-1)
113113
agent_client.emit({})
114-
self.assertTrue(mock_logging.warn.called)
114+
self.assertTrue(mock_logging.warning.called)
115115

116116
@mock.patch('opencensus.ext.jaeger.trace_exporter.logging')
117117
def test_collector_emit_failed(self, mock_logging):

contrib/opencensus-ext-zipkin/opencensus/ext/zipkin/trace_exporter/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def _extract_tags_from_span(attr):
193193
res, _ = check_str_length(str_to_check=attribute_value)
194194
value = res
195195
else:
196-
logging.warn('Could not serialize tag {}'.format(attribute_key))
196+
logging.warning('Could not serialize tag %s', attribute_key)
197197
continue
198198
tags[attribute_key] = value
199199
return tags

opencensus/trace/propagation/google_cloud_format.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ def from_header(self, header):
5050
match = re.search(_TRACE_CONTEXT_HEADER_RE, header)
5151
except TypeError:
5252
logging.warning(
53-
'Header should be str, got {}. Cannot parse the header.'
54-
.format(header.__class__.__name__))
53+
'Header should be str, got %s. Cannot parse the header.',
54+
header.__class__.__name__)
5555
raise
5656

5757
if match:
@@ -70,8 +70,8 @@ def from_header(self, header):
7070
return span_context
7171
else:
7272
logging.warning(
73-
'Cannot parse the header {}, generate a new context instead.'
74-
.format(header))
73+
'Cannot parse the header %s, generate a new context instead.',
74+
header)
7575
return SpanContext()
7676

7777
def from_headers(self, headers):

opencensus/trace/span_context.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def _check_span_id(self, span_id):
102102

103103
if span_id is INVALID_SPAN_ID:
104104
logging.warning(
105-
'Span_id {} is invalid (cannot be all zero)'.format(span_id))
105+
'Span_id %s is invalid (cannot be all zero)', span_id)
106106
self.from_header = False
107107
return None
108108

@@ -112,8 +112,8 @@ def _check_span_id(self, span_id):
112112
return span_id
113113
else:
114114
logging.warning(
115-
'Span_id {} does not the match the '
116-
'required format'.format(span_id))
115+
'Span_id %s does not the match the '
116+
'required format', span_id)
117117
self.from_header = False
118118
return None
119119

@@ -132,8 +132,8 @@ def _check_trace_id(self, trace_id):
132132

133133
if trace_id is _INVALID_TRACE_ID:
134134
logging.warning(
135-
'Trace_id {} is invalid (cannot be all zero), '
136-
'generating a new one.'.format(trace_id))
135+
'Trace_id %s is invalid (cannot be all zero), '
136+
'generating a new one.', trace_id)
137137
self.from_header = False
138138
return generate_trace_id()
139139

@@ -143,8 +143,8 @@ def _check_trace_id(self, trace_id):
143143
return trace_id
144144
else:
145145
logging.warning(
146-
'Trace_id {} does not the match the required format,'
147-
'generating a new one instead.'.format(trace_id))
146+
'Trace_id %s does not the match the required format,'
147+
'generating a new one instead.', trace_id)
148148
self.from_header = False
149149
return generate_trace_id()
150150

opencensus/trace/trace_options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def check_trace_options(self, trace_options_byte):
3939
trace_options_int = int(trace_options_byte)
4040

4141
if trace_options_int < 0 or trace_options_int > 255:
42-
logging.warn("Trace options invalid, should be 1 byte.")
42+
logging.warning("Trace options invalid, should be 1 byte.")
4343
trace_options_byte = DEFAULT
4444

4545
return trace_options_byte

0 commit comments

Comments
 (0)