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

Commit

Permalink
fix path to sytest script
Browse files Browse the repository at this point in the history
  • Loading branch information
richvdh committed May 28, 2021
1 parent 0443a05 commit c77a9c7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ jobs:
working-directory: /src
- name: Summarise results.tap
if: ${{ always() }}
run: /scripts/tap_to_gha.pl /logs/results.tap
run: /sytest/scripts/tap_to_gha.pl /logs/results.tap
- name: Upload SyTest logs
uses: actions/upload-artifact@v2
if: ${{ always() }}
Expand Down
32 changes: 32 additions & 0 deletions synapse/logging/opentracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,12 @@ class _DummyTagNames:
import opentracing

tags = opentracing.tags
Span = opentracing.Span
except ImportError:
opentracing = None
tags = _DummyTagNames
Span = None

try:
from jaeger_client import Config as JaegerConfig

Expand Down Expand Up @@ -272,6 +275,12 @@ class SynapseTags:
REQUEST_TAG = "request_tag"


class SynapseBaggage:
"""labels for synapse's baggage items"""

DEBUG_TRACING = "s"


# Block everything by default
# A regex which matches the server_names to expose traces for.
# None means 'block everything'.
Expand Down Expand Up @@ -404,6 +413,13 @@ def whitelisted_homeserver(destination):

# Start spans and scopes


@only_if_tracing
def active_span():
"""Returns the active span, if any"""
return opentracing.tracer.active_span


# Could use kwargs but I want these to be explicit
def start_active_span(
operation_name,
Expand Down Expand Up @@ -561,6 +577,22 @@ def set_operation_name(operation_name):
opentracing.tracer.active_span.set_operation_name(operation_name)


@ensure_active_span("set baggage on the trace")
def set_baggage_item(key, value):
"""Stores a Baggage item on the active span as a key/value pair.
Baggage is arbitrary data which is attached to a span, and inherited by
children of that span, including spans on remote servers.
"""
return opentracing.tracer.active_span.set_baggage_item(key, value)


@ensure_active_span("get baggage on the trace")
def get_baggage_item(key):
"""Get a Baggage item from the active span."""
return opentracing.tracer.active_span.set_baggage_item(key)


# Injection and extraction


Expand Down
5 changes: 5 additions & 0 deletions synapse/storage/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

from synapse.api.errors import StoreError
from synapse.config.database import DatabaseConnectionConfig
from synapse.logging import opentracing
from synapse.logging.context import (
LoggingContext,
current_context,
Expand Down Expand Up @@ -707,6 +708,10 @@ async def runWithConnection(

start_time = monotonic_time()

# if we have an active opentracing span, and that span has been prioritised,
# start a new span for the query.
opentracing.trace()

def inner_func(conn, *args, **kwargs):
# We shouldn't be in a transaction. If we are then something
# somewhere hasn't committed after doing work. (This is likely only
Expand Down

0 comments on commit c77a9c7

Please sign in to comment.