Skip to content

Commit

Permalink
Changed get_tracer of invalid values to return empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyleelin committed May 13, 2021
1 parent 42213c4 commit b01c83e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ def get_tracer(
instrumenting_library_version: str = "",
) -> "trace_api.Tracer":
if not instrumenting_module_name: # Reject empty strings too.
instrumenting_module_name = "ERROR:MISSING MODULE NAME"
instrumenting_module_name = ""
logger.error("get_tracer called with missing module name.")
return Tracer(
self.sampler,
Expand Down
11 changes: 9 additions & 2 deletions opentelemetry-sdk/tests/trace/test_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,22 @@ def test_invalid_instrumentation_info(self):
self.assertEqual(
tracer1.instrumentation_info, tracer2.instrumentation_info
)

self.assertIsInstance(
tracer1.instrumentation_info, InstrumentationInfo
)
span1 = tracer1.start_span("foo")
self.assertTrue(span1.is_recording())
self.assertEqual(tracer1.instrumentation_info.version, "")
self.assertEqual(
tracer1.instrumentation_info.name, "ERROR:MISSING MODULE NAME"
self.assertEqual(tracer1.instrumentation_info.name, "")

self.assertIsInstance(
tracer2.instrumentation_info, InstrumentationInfo
)
span2 = tracer2.start_span("bar")
self.assertTrue(span2.is_recording())
self.assertEqual(tracer2.instrumentation_info.version, "")
self.assertEqual(tracer2.instrumentation_info.name, "")

def test_span_processor_for_source(self):
tracer_provider = trace.TracerProvider()
Expand Down

0 comments on commit b01c83e

Please sign in to comment.