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

[SCHEMATIC-212] Prevent traces from being combined #1552

Merged
merged 3 commits into from
Nov 25, 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
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ jobs:
LOGGING_EXPORT_FORMAT: ${{ vars.LOGGING_EXPORT_FORMAT }}
TRACING_SERVICE_NAME: ${{ vars.TRACING_SERVICE_NAME }}
LOGGING_SERVICE_NAME: ${{ vars.LOGGING_SERVICE_NAME }}
SERVICE_INSTANCE_ID: ${{ github.head_ref || github.ref_name }}
run: >
poetry run pytest --durations=0 --cov-append --cov-report=term --cov-report=html:htmlcov --cov-report=xml:coverage.xml --cov=schematic/
-m "not (rule_benchmark or single_process_execution)" --reruns 4 -n 8 --ignore=tests/unit
Expand Down
2 changes: 2 additions & 0 deletions env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ SERVICE_ACCOUNT_CREDS='Provide service account creds'
# LOGGING_EXPORT_FORMAT=otlp
# TRACING_SERVICE_NAME=schematic-api
# LOGGING_SERVICE_NAME=schematic-api
## Instance ID is used during integration tests export to identify the git branch
# SERVICE_INSTANCE_ID=schematic-1234
## Other examples: dev, staging, prod
# DEPLOYMENT_ENVIRONMENT=local
# OTEL_EXPORTER_OTLP_ENDPOINT=https://..../telemetry
Expand Down
5 changes: 5 additions & 0 deletions schematic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from opentelemetry.sdk._logs.export import BatchLogRecordProcessor
from opentelemetry.sdk.resources import (
DEPLOYMENT_ENVIRONMENT,
SERVICE_INSTANCE_ID,
SERVICE_NAME,
SERVICE_VERSION,
Resource,
Expand Down Expand Up @@ -97,10 +98,12 @@ def set_up_tracing(session: requests.Session) -> None:
Synapse.enable_open_telemetry(True)
tracing_service_name = os.environ.get("TRACING_SERVICE_NAME", "schematic-api")
deployment_environment = os.environ.get("DEPLOYMENT_ENVIRONMENT", "")
service_instance_id = os.environ.get("SERVICE_INSTANCE_ID", "")
trace.set_tracer_provider(
TracerProvider(
resource=Resource(
attributes={
SERVICE_INSTANCE_ID: service_instance_id,
SERVICE_NAME: tracing_service_name,
SERVICE_VERSION: __version__,
DEPLOYMENT_ENVIRONMENT: deployment_environment,
Expand All @@ -124,9 +127,11 @@ def set_up_logging(session: requests.Session) -> None:
logging_export = os.environ.get("LOGGING_EXPORT_FORMAT", None)
logging_service_name = os.environ.get("LOGGING_SERVICE_NAME", "schematic-api")
deployment_environment = os.environ.get("DEPLOYMENT_ENVIRONMENT", "")
service_instance_id = os.environ.get("SERVICE_INSTANCE_ID", "")
if logging_export == "otlp":
resource = Resource.create(
{
SERVICE_INSTANCE_ID: service_instance_id,
SERVICE_NAME: logging_service_name,
DEPLOYMENT_ENVIRONMENT: deployment_environment,
SERVICE_VERSION: __version__,
Expand Down
3 changes: 3 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from dotenv import load_dotenv
from flask.testing import FlaskClient
from opentelemetry import trace
from opentelemetry.instrumentation.flask import FlaskInstrumentor
from synapseclient.client import Synapse

from schematic.configuration.configuration import CONFIG, Configuration
Expand Down Expand Up @@ -42,6 +43,8 @@
TESTS_DIR = os.path.dirname(os.path.abspath(__file__))
DATA_DIR = os.path.join(TESTS_DIR, "data")

FlaskInstrumentor().uninstrument()

Comment on lines +46 to +47
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't make us lose much. Mostly just the hooks for tracking what arguments were sent into the flask server, but isn't that important since we can just look at the integration test.


@pytest.fixture(scope="session")
def dataset_id():
Expand Down