-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for splunk access token env var
- Loading branch information
Showing
5 changed files
with
66 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import time | ||
from pathlib import Path | ||
|
||
from opentelemetry import trace | ||
|
||
|
||
def project_path(): | ||
return str(Path(__file__).parent.parent) | ||
|
||
|
||
def trace_loop(loops): | ||
tracer = trace.get_tracer("my-tracer") | ||
for _ in range(loops): | ||
with tracer.start_as_current_span("my-span"): | ||
time.sleep(0.5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from oteltest import Telemetry | ||
from ott_lib import project_path, trace_loop | ||
|
||
if __name__ == "__main__": | ||
trace_loop(12) | ||
|
||
|
||
class AccessTokenOtelTest: | ||
def requirements(self): | ||
return project_path(), "oteltest" | ||
|
||
def environment_variables(self): | ||
return { | ||
"OTEL_SERVICE_NAME": "my-svc", | ||
"SPLUNK_ACCESS_TOKEN": "s3cr3t", | ||
} | ||
|
||
def wrapper_command(self): | ||
return "opentelemetry-instrument" | ||
|
||
def on_start(self): | ||
return None | ||
|
||
def on_stop(self, telemetry: Telemetry, stdout: str, stderr: str, returncode: int) -> None: # noqa: ARG002 | ||
for request in telemetry.get_trace_requests(): | ||
assert request.headers.get("x-sf-token") == "s3cr3t" | ||
|
||
def is_http(self): | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters