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 oteltest to test http export #568

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/splunk_otel/distro.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
SPLUNK_PROFILER_ENABLED,
SPLUNK_PROFILER_LOGS_ENDPOINT,
SPLUNK_TRACE_RESPONSE_HEADER_ENABLED,
X_SF_TOKEN,
Env,
)
from splunk_otel.propagator import ServerTimingResponsePropagator
Expand All @@ -42,6 +41,7 @@
Set your service name using the OTEL_SERVICE_NAME environment variable.
e.g. `OTEL_SERVICE_NAME="<YOUR_SERVICE_NAME_HERE>"`"""
_DEFAULT_SERVICE_NAME = "unnamed-python-service"
_X_SF_TOKEN = "x-sf-token" # noqa S105

_pylogger = logging.getLogger(__name__)

Expand Down Expand Up @@ -87,7 +87,7 @@ def set_resource_attributes(self):
def configure_headers(self):
tok = self.env.getval(SPLUNK_ACCESS_TOKEN).strip()
if tok:
self.env.list_append(OTEL_EXPORTER_OTLP_HEADERS, f"{X_SF_TOKEN}={tok}")
self.env.list_append(OTEL_EXPORTER_OTLP_HEADERS, f"{_X_SF_TOKEN}={tok}")

def set_server_timing_propagator(self):
if self.env.is_true(SPLUNK_TRACE_RESPONSE_HEADER_ENABLED, "true"):
Expand Down
2 changes: 0 additions & 2 deletions src/splunk_otel/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
SPLUNK_PROFILER_CALL_STACK_INTERVAL = "SPLUNK_PROFILER_CALL_STACK_INTERVAL"
SPLUNK_PROFILER_LOGS_ENDPOINT = "SPLUNK_PROFILER_LOGS_ENDPOINT"

X_SF_TOKEN = "x-sf-token" # noqa S105

_pylogger = logging.getLogger(__name__)


Expand Down
30 changes: 30 additions & 0 deletions tests/ott_http.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from ott_lib import project_path, trace_loop

if __name__ == "__main__":
trace_loop(1)


class HttpProtocolOtelTest:
def requirements(self):
return (project_path(),)

def environment_variables(self):
return {
"OTEL_SERVICE_NAME": "my-otel-test",
"OTEL_EXPORTER_OTLP_PROTOCOL": "http/protobuf",
"OTEL_PYTHON_DISABLED_INSTRUMENTATIONS": "system_metrics",
}

def wrapper_command(self):
return "opentelemetry-instrument"

def on_start(self):
return None

def on_stop(self, telemetry, stdout: str, stderr: str, returncode: int) -> None:
from oteltest.telemetry import count_spans

assert count_spans(telemetry)

def is_http(self):
return True
Loading