Repository: getsentry/sentry-python

Issue:
Empty DSN crashes Otel integration
### How do you use Sentry?

Sentry Saas (sentry.io)

### Version

1.12.0

### Steps to Reproduce

Do not give a DSN when initializing the SDK with the Otel integration. 

You will get this:

```
recommendation-service   | 2023-01-18 10:24:50,723 ERROR [grpc._server] [_server.py:454] [trace_id=0 span_id=0 resource.service.name=recommendationservice] - Exce
ption calling application: Unsupported scheme ''
recommendation-service   | Traceback (most recent call last):
recommendation-service   |   File "/usr/local/lib/python3.10/site-packages/grpc/_server.py", line 444, in _call_behavior
recommendation-service   |     response_or_iterator = behavior(argument, context)
recommendation-service   |   File "/usr/local/lib/python3.10/site-packages/opentelemetry/instrumentation/grpc/_server.py", line 282, in telemetry_interceptor
recommendation-service   |     with self._start_span(
recommendation-service   |   File "/usr/local/lib/python3.10/contextlib.py", line 135, in __enter__
recommendation-service   |     return next(self.gen)
recommendation-service   |   File "/usr/local/lib/python3.10/site-packages/opentelemetry/sdk/trace/__init__.py", line 1017, in start_as_current_span
recommendation-service   |     span = self.start_span(
recommendation-service   |   File "/usr/local/lib/python3.10/site-packages/opentelemetry/sdk/trace/__init__.py", line 1107, in start_span
recommendation-service   |     span.start(start_time=start_time, parent_context=context)
recommendation-service   |   File "/usr/local/lib/python3.10/site-packages/opentelemetry/sdk/trace/__init__.py", line 870, in start
recommendation-service   |     self._span_processor.on_start(self, parent_context=parent_context)
recommendation-service   |   File "/usr/local/lib/python3.10/site-packages/opentelemetry/sdk/trace/__init__.py", line 162, in on_start
recommendation-service   |     sp.on_start(span, parent_context=parent_context)
recommendation-service   |   File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/opentelemetry/span_processor.py", line 107, in on_start
recommendation-service   |     if self._is_sentry_span(hub, otel_span):
recommendation-service   |   File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/opentelemetry/span_processor.py", line 177, in _is_sentry_span
recommendation-service   |     dsn_url = hub.client and Dsn(hub.client.dsn or "").netloc
recommendation-service   |   File "/usr/local/lib/python3.10/site-packages/sentry_sdk/utils.py", line 200, in __init__
recommendation-service   |     raise BadDsn("Unsupported scheme %r" % parts.scheme)
recommendation-service   | sentry_sdk.utils.BadDsn: Unsupported scheme ''
```

### Expected Result

The Sentry SDK should just give a Warning and then do nothing and NOT crash everything.

### Actual Result

Crash


Discussion:

Resolving patch:
diff --git a/sentry_sdk/integrations/opentelemetry/span_processor.py b/sentry_sdk/integrations/opentelemetry/span_processor.py
--- a/sentry_sdk/integrations/opentelemetry/span_processor.py
+++ b/sentry_sdk/integrations/opentelemetry/span_processor.py
@@ -98,6 +98,14 @@ def on_start(self, otel_span, parent_context=None):
         if not hub:
             return
 
+        if not hub.client or (hub.client and not hub.client.dsn):
+            return
+
+        try:
+            _ = Dsn(hub.client.dsn or "")
+        except Exception:
+            return
+
         if hub.client and hub.client.options["instrumenter"] != INSTRUMENTER.OTEL:
             return
 


Test patch: