Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support of host.name in OTEL metrics and usage of OTEL_RESOURCE_ATTRI… #42604

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions airflow/metrics/otel_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from opentelemetry.metrics import Observation
from opentelemetry.sdk.metrics import MeterProvider
from opentelemetry.sdk.metrics._internal.export import ConsoleMetricExporter, PeriodicExportingMetricReader
from opentelemetry.sdk.resources import SERVICE_NAME, Resource
from opentelemetry.sdk.resources import HOST_NAME, SERVICE_NAME, Resource

from airflow.configuration import conf
from airflow.metrics.protocols import Timer
Expand All @@ -39,6 +39,7 @@
get_validator,
stat_name_otel_handler,
)
from airflow.utils.net import get_hostname

if TYPE_CHECKING:
from opentelemetry.metrics import Instrument
Expand Down Expand Up @@ -398,7 +399,7 @@ def get_otel_logger(cls) -> SafeOtelLogger:
debug = conf.getboolean("metrics", "otel_debugging_on")
service_name = conf.get("metrics", "otel_service")

resource = Resource(attributes={SERVICE_NAME: service_name})
resource = Resource.create(attributes={HOST_NAME: get_hostname(), SERVICE_NAME: service_name})

protocol = "https" if ssl_active else "http"
endpoint = f"{protocol}://{host}:{port}/v1/metrics"
Expand Down