tailg8nj commented on code in PR #63839:
URL: https://github.com/apache/airflow/pull/63839#discussion_r3544019341
##########
airflow-core/src/airflow/models/taskinstance.py:
##########
@@ -486,6 +492,17 @@ def uuid7() -> UUID:
return uuid6.uuid7()
+def _make_task_carrier(dag_run_context_carrier):
+ parent_context = (
+ TraceContextTextMapPropagator().extract(dag_run_context_carrier) if
dag_run_context_carrier else None
+ )
+ span = tracer.start_span("notused", context=parent_context) #
intentionally never closed
Review Comment:
Could we get an explanation on the PR as well?
I am trying to bring my own OpenTelemetry
[Distro](https://opentelemetry.io/docs/languages/python/distro/) and
Configurator to the party here, and I realized this
OverrideableRandomIdGenerator is a key piece of the propagation strategy.
Without it, I was getting phantom spans that never made it to the collector
(the span in this line) because the `override_ids` function wasn't having any
effect with the default ID generator my Distro pre-configures.
We should allow folks to use their own OpenTelemetry configuration, distro,
and [auto-instrumentation](https://opentelemetry.io/docs/zero-code/python/) if
possible. Further, this seems like an antipattern. Why are we only creating the
DAG span at the very end? If we created that at the start, wouldn't we be able
to use that as the context_carrier and not have to override IDs?
My current `airflow_local_settings.py` works now with the following:
```python
from opentelemetry.instrumentation import auto_instrumentation
auto_instrumentation.initialize()
from opentelemetry.trace import get_tracer_provider
from airflow._shared.observability.traces import
OverrideableRandomIdGenerator
get_tracer_provider().id_generator = OverrideableRandomIdGenerator()
```
Further, this ID Generator class is in a module marked private. Could it be
exposed using a Python Entry Point so that others could enforce it via ENV VAR
such that I wouldn't have to reference it directly?
* [Upstream ID Generator
Creation](https://github.com/open-telemetry/opentelemetry-python/blob/634cec5f2a2fecb40cb9d8216888c7b8865b845a/opentelemetry-sdk/src/opentelemetry/sdk/_configuration/__init__.py#L627)
* [Upstream ID Generator Environment
Variable](https://github.com/open-telemetry/opentelemetry-python/blob/634cec5f2a2fecb40cb9d8216888c7b8865b845a/opentelemetry-api/src/opentelemetry/environment_variables/__init__.py#L49)
* [Upstream ID Generator Entry
Point](https://github.com/open-telemetry/opentelemetry-python/blob/634cec5f2a2fecb40cb9d8216888c7b8865b845a/opentelemetry-sdk/pyproject.toml#L43-L44)
* [Lack of Entry Point in
Airflow](https://github.com/apache/airflow/blob/a050861fc59193347a60d6ab306a5e0a03c719a7/shared/observability/pyproject.toml)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]