Skip to content

Commit 7e1f247

Browse files
authored
Update gettracer (#1854)
1 parent f816287 commit 7e1f247

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased](https://github.com/open-telemetry/opentelemetry-python/compare/v1.2.0-0.21b0...HEAD)
88

9+
### Changed
10+
- Updated get_tracer to return an empty string when passed an invalid name
11+
([#1854](https://github.com/open-telemetry/opentelemetry-python/pull/1854))
12+
913
## [1.2.0, 0.21b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.2.0-0.21b0) - 2021-05-11
1014

1115
### Added

opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ def get_tracer(
997997
instrumenting_library_version: str = "",
998998
) -> "trace_api.Tracer":
999999
if not instrumenting_module_name: # Reject empty strings too.
1000-
instrumenting_module_name = "ERROR:MISSING MODULE NAME"
1000+
instrumenting_module_name = ""
10011001
logger.error("get_tracer called with missing module name.")
10021002
return Tracer(
10031003
self.sampler,

opentelemetry-sdk/tests/trace/test_trace.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -257,17 +257,25 @@ def test_invalid_instrumentation_info(self):
257257
tracer1 = tracer_provider.get_tracer("")
258258
with self.assertLogs(level=ERROR):
259259
tracer2 = tracer_provider.get_tracer(None)
260-
self.assertEqual(
261-
tracer1.instrumentation_info, tracer2.instrumentation_info
262-
)
260+
263261
self.assertIsInstance(
264262
tracer1.instrumentation_info, InstrumentationInfo
265263
)
266264
span1 = tracer1.start_span("foo")
267265
self.assertTrue(span1.is_recording())
268266
self.assertEqual(tracer1.instrumentation_info.version, "")
267+
self.assertEqual(tracer1.instrumentation_info.name, "")
268+
269+
self.assertIsInstance(
270+
tracer2.instrumentation_info, InstrumentationInfo
271+
)
272+
span2 = tracer2.start_span("bar")
273+
self.assertTrue(span2.is_recording())
274+
self.assertEqual(tracer2.instrumentation_info.version, "")
275+
self.assertEqual(tracer2.instrumentation_info.name, "")
276+
269277
self.assertEqual(
270-
tracer1.instrumentation_info.name, "ERROR:MISSING MODULE NAME"
278+
tracer1.instrumentation_info, tracer2.instrumentation_info
271279
)
272280

273281
def test_span_processor_for_source(self):

0 commit comments

Comments
 (0)