Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit c77a9c7

Browse files
committed
fix path to sytest script
1 parent 0443a05 commit c77a9c7

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ jobs:
234234
working-directory: /src
235235
- name: Summarise results.tap
236236
if: ${{ always() }}
237-
run: /scripts/tap_to_gha.pl /logs/results.tap
237+
run: /sytest/scripts/tap_to_gha.pl /logs/results.tap
238238
- name: Upload SyTest logs
239239
uses: actions/upload-artifact@v2
240240
if: ${{ always() }}

synapse/logging/opentracing.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,12 @@ class _DummyTagNames:
220220
import opentracing
221221

222222
tags = opentracing.tags
223+
Span = opentracing.Span
223224
except ImportError:
224225
opentracing = None
225226
tags = _DummyTagNames
227+
Span = None
228+
226229
try:
227230
from jaeger_client import Config as JaegerConfig
228231

@@ -272,6 +275,12 @@ class SynapseTags:
272275
REQUEST_TAG = "request_tag"
273276

274277

278+
class SynapseBaggage:
279+
"""labels for synapse's baggage items"""
280+
281+
DEBUG_TRACING = "s"
282+
283+
275284
# Block everything by default
276285
# A regex which matches the server_names to expose traces for.
277286
# None means 'block everything'.
@@ -404,6 +413,13 @@ def whitelisted_homeserver(destination):
404413

405414
# Start spans and scopes
406415

416+
417+
@only_if_tracing
418+
def active_span():
419+
"""Returns the active span, if any"""
420+
return opentracing.tracer.active_span
421+
422+
407423
# Could use kwargs but I want these to be explicit
408424
def start_active_span(
409425
operation_name,
@@ -561,6 +577,22 @@ def set_operation_name(operation_name):
561577
opentracing.tracer.active_span.set_operation_name(operation_name)
562578

563579

580+
@ensure_active_span("set baggage on the trace")
581+
def set_baggage_item(key, value):
582+
"""Stores a Baggage item on the active span as a key/value pair.
583+
584+
Baggage is arbitrary data which is attached to a span, and inherited by
585+
children of that span, including spans on remote servers.
586+
"""
587+
return opentracing.tracer.active_span.set_baggage_item(key, value)
588+
589+
590+
@ensure_active_span("get baggage on the trace")
591+
def get_baggage_item(key):
592+
"""Get a Baggage item from the active span."""
593+
return opentracing.tracer.active_span.set_baggage_item(key)
594+
595+
564596
# Injection and extraction
565597

566598

synapse/storage/database.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
from synapse.api.errors import StoreError
4242
from synapse.config.database import DatabaseConnectionConfig
43+
from synapse.logging import opentracing
4344
from synapse.logging.context import (
4445
LoggingContext,
4546
current_context,
@@ -707,6 +708,10 @@ async def runWithConnection(
707708

708709
start_time = monotonic_time()
709710

711+
# if we have an active opentracing span, and that span has been prioritised,
712+
# start a new span for the query.
713+
opentracing.trace()
714+
710715
def inner_func(conn, *args, **kwargs):
711716
# We shouldn't be in a transaction. If we are then something
712717
# somewhere hasn't committed after doing work. (This is likely only

0 commit comments

Comments
 (0)