Skip to content

Commit

Permalink
debug curl
Browse files Browse the repository at this point in the history
Signed-off-by: sallyom <[email protected]>
  • Loading branch information
sallyom committed Jun 20, 2024
1 parent 3af8da0 commit dc012ed
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 31 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/chatbot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ jobs:
protocols:
grpc:
endpoint: "0.0.0.0:4317"
http:
endpoint: "0.0.0.0:4318"
exporters:
otlphttp:
endpoint: https://apps.platform-sts.pcbk.p1.openshiftapps.com
Expand All @@ -65,7 +67,7 @@ jobs:
key_pem: ${{ secrets.CLIENT_KEY_ROSA_OTEL }}
ca_pem: ${{ secrets.SERVER_CERT_ROSA_OTEL }}
logging:
loglevel: debug
verbosity: detailed
service:
pipelines:
traces:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/test-trace-steps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ jobs:
protocols:
grpc:
endpoint: "0.0.0.0:4317"
http:
endpoint: "0.0.0.0:4318"
exporters:
otlphttp:
endpoint: https://apps.platform-sts.pcbk.p1.openshiftapps.com
Expand All @@ -45,7 +47,7 @@ jobs:
key_pem: ${{ secrets.CLIENT_KEY_ROSA_OTEL }}
ca_pem: ${{ secrets.SERVER_CERT_ROSA_OTEL }}
logging:
loglevel: debug
verbosity: detailed
service:
pipelines:
traces:
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/testing_framework.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
schedule: # schedule the job to run once a day
- cron: '0 0 * * *'

workflow_dispatch:
#workflow_dispatch:

# pull_request: ## temporary for debugging development purposes
# branches:
Expand Down Expand Up @@ -65,6 +65,8 @@ jobs:
protocols:
grpc:
endpoint: "0.0.0.0:4317"
http:
endpoint: "0.0.0.0:4318"
exporters:
otlphttp:
endpoint: https://apps.platform-sts.pcbk.p1.openshiftapps.com
Expand All @@ -74,7 +76,7 @@ jobs:
key_pem: ${{ secrets.CLIENT_KEY_ROSA_OTEL }}
ca_pem: ${{ secrets.SERVER_CERT_ROSA_OTEL }}
logging:
loglevel: debug
verbosity: detailed
service:
pipelines:
traces:
Expand Down
33 changes: 6 additions & 27 deletions ci/trace-steps.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import os
import time
import logging
from opentelemetry import trace
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor, ConsoleSpanExporter
from opentelemetry.trace import SpanContext, TraceFlags, TraceState, NonRecordingSpan

# Set up logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

# Set up OpenTelemetry tracing
trace.set_tracer_provider(
TracerProvider(
Expand All @@ -21,30 +15,15 @@
tracer = trace.get_tracer(__name__)

# Set up OTLP exporter to send to OpenTelemetry Collector
otlp_exporter = OTLPSpanExporter(endpoint="http://localhost:4317", insecure=True)

# Set up span processor
span_processor = BatchSpanProcessor(otlp_exporter)
trace.get_tracer_provider().add_span_processor(span_processor)
otlp_exporter = OTLPSpanExporter(endpoint="0.0.0.0:4317", insecure=True)
trace.get_tracer_provider().add_span_processor(BatchSpanProcessor(otlp_exporter))

# Export to console for debugging
console_exporter = ConsoleSpanExporter()
trace.get_tracer_provider().add_span_processor(BatchSpanProcessor(console_exporter))

def retry_operation(operation, retries=3, delay=5):
for attempt in range(retries):
try:
return operation()
except Exception as e:
logger.error(f"Attempt {attempt + 1} failed with error: {e}")
if attempt < retries - 1:
time.sleep(delay)
else:
raise

def start_trace(step_name):
span = tracer.start_span(name=step_name)
return span
return tracer.start_span(name=step_name)

def end_trace(span):
span.end()
Expand All @@ -54,7 +33,7 @@ def end_trace(span):
action = os.getenv("TRACE_ACTION", "start")

if action == "start":
span = retry_operation(lambda: start_trace(step_name))
span = start_trace(step_name)
with open(f"/tmp/trace_{step_name}.txt", "w") as f:
f.write(str(span.get_span_context().trace_id))
elif action == "end":
Expand All @@ -71,6 +50,6 @@ def end_trace(span):
is_remote=True
)
with tracer.start_as_current_span(name=step_name, context=trace.set_span_in_context(NonRecordingSpan(span_context))):
span = retry_operation(lambda: tracer.start_span(name=step_name))
retry_operation(lambda: end_trace(span))
span = start_trace(step_name)
end_trace(span)

0 comments on commit dc012ed

Please sign in to comment.