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

Add OpenTelemetry tracing #96

Merged
merged 18 commits into from
May 2, 2024
Prev Previous commit
Next Next commit
Code review updates
andmat900 committed May 2, 2024
commit e53b9847764024c77eaa6b6d8780b5acff41f2da
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ gunicorn~=19.9
jsontas~=1.3
packageurl-python~=0.11
etcd3gw~=2.3
etos_lib==4.1.1
etos_lib==4.2.0
opentelemetry-api~=1.21
opentelemetry-exporter-otlp~=1.21
opentelemetry-sdk~=1.21
8 changes: 4 additions & 4 deletions src/log_area_provider/utilities/external_provider.py
Original file line number Diff line number Diff line change
@@ -122,11 +122,11 @@ def checkin(self, log_area: LogArea) -> None:
host = self.ruleset.get("stop", {}).get("host")
headers = {"X-ETOS-ID": self.identifier}
TraceContextTextMapPropagator().inject(headers)
otel_span = opentelemetry.trace.get_current_span()
otel_span.set_attribute(SpanAttributes.URL_FULL, host)
otel_span.set_attribute("http.request.body", json.dumps(log_areas))
span = opentelemetry.trace.get_current_span()
span.set_attribute(SpanAttributes.URL_FULL, host)
span.set_attribute("http.request.body", json.dumps(log_areas))
for header, value in headers.items():
otel_span.set_attribute(f"http.request.headers.{header.lower()}", value)
span.set_attribute(f"http.request.headers.{header.lower()}", value)
timeout = time.time() + end
first_iteration = True
while time.time() < timeout: