xBis7 opened a new pull request, #56150:
URL: https://github.com/apache/airflow/pull/56150

   <!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at
   
      http://www.apache.org/licenses/LICENSE-2.0
   
    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
    -->
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of an existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   ## OTel environment variables
   
   The OpenTelemetry SDK for metrics and traces, can be configured with two ways
   1. Adding the values directly in the code via method parameters
   2. Using the standard OTel environment variables
   
   There are multiple OTel env variables which can be automatically picked up 
by the SDK if exported. 
   
   
https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/
   
   https://opentelemetry.io/docs/languages/sdk-configuration/general/
   
   https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/
   
   Currently, there is no need to support all of them. 
   
   Airflow is providing the code configuration based on
   * Values that have been added to custom Airflow config properties
   * Hard-coded values
   
   ## How it works
   
   On the OTel side, the environment variables are only checked if there is no 
code configuration. If a value is provided in the code, then that will take 
priority and the environment will be ignored.
   
   Airflow has its own version of the OTel configs. It reads the Airflow-OTel 
properties and based on the values, it uses code to configure the OTel SDK.
   
   If we were to export the regular environment variables and then just call 
the SDK methods without any parameters, the env values would be automatically 
used.
   
   The OTel priorities are
   1. Code configuration
   2. OTel checks env vars
   
   The current Airflow priorities are
   1. Airflow-OTel configs
   2. Code configuration
   3. OTel checks the env vars
   
   For Airflow, there is always code configuration and therefore as mentioned 
above the OTel env vars are ignored.
   
   ## Changes
   
   This patch removes all OTel related configs from the Airflow configuration 
except the flags that enable OTel metrics and traces.
   
   The values that we would get from the Airflow config, are now accessed 
through the following OTel environment variables.
   
   ```
   - Common
   OTEL_EXPORTER_OTLP_PROTOCOL
   OTEL_EXPORTER_OTLP_ENDPOINT
   OTEL_SERVICE_NAME
   OTEL_RESOURCE_ATTRIBUTES
   OTEL_EXPORTER_OTLP_HEADERS
   
   - Traces specific
   OTEL_TRACES_EXPORTER
   OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
   
   - Metrics specific
   OTEL_METRICS_EXPORTER
   OTEL_EXPORTER_OTLP_METRICS_ENDPOINT
   OTEL_METRIC_EXPORT_INTERVAL
   ```
   
   For info regarding the values of each property, check the updated docs.
   
   * `OTEL_TRACES_EXPORTER` replaces `otel_debugging_on` if the value is 
`console`
   * ```
       OTEL_EXPORTER_OTLP_ENDPOINT (common)
       OTEL_EXPORTER_OTLP_TRACES_ENDPOINT (traces)
       OTEL_EXPORTER_OTLP_METRICS_ENDPOINT (metrics)
       ```
       replaces
       ```
       otel_host
       otel_port
       otel_ssl_active
       ```
   
   * `OTEL_METRIC_EXPORT_INTERVAL` replaces `otel_interval_milliseconds`
   
   ## Why
   
   When you have a cluster where multiple applications are running and all of 
them are using OTel, then it’s common to configure the regular OTel environment 
variables and export them. That way, you won’t have to configure each project 
separately to work with your shared otel-collector service.
   
   
   
   
   <!-- Please keep an empty line above the dashes. -->
   ---
   **^ Add meaningful description above**
   Read the **[Pull Request 
Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)**
 for more information.
   In case of fundamental code changes, an Airflow Improvement Proposal 
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals))
 is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party 
License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in a 
newsfragment file, named `{pr_number}.significant.rst` or 
`{issue_number}.significant.rst`, in 
[airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
   


-- 
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]

Reply via email to