Skip to content
Snippets Groups Projects
Commit 9fb1e9ae authored by ale's avatar ale
Browse files

Drop dependency on opencensus-ext-flask

Until https://github.com/census-instrumentation/opencensus-python/issues/1022
is resolved, this is locking us on a Flask 1 dependency, which can
no longer be built successfully (not easily).
parent 45ed09d3
No related branches found
No related tags found
No related merge requests found
...@@ -2,11 +2,6 @@ import json ...@@ -2,11 +2,6 @@ import json
import os import os
from urllib.parse import urlsplit from urllib.parse import urlsplit
from opencensus.trace import config_integration from opencensus.trace import config_integration
from opencensus.ext.zipkin.trace_exporter import ZipkinExporter
from opencensus.ext.flask.flask_middleware import FlaskMiddleware
from opencensus.trace.samplers import AlwaysOnSampler, AlwaysOffSampler, \
ProbabilitySampler
from opencensus.trace.propagation.b3_format import B3FormatPropagator
tracing_config_file = os.getenv('TRACING_CONFIG', '/etc/tracing/client.conf') tracing_config_file = os.getenv('TRACING_CONFIG', '/etc/tracing/client.conf')
...@@ -20,39 +15,6 @@ def setup_tracing(app, service_name): ...@@ -20,39 +15,6 @@ def setup_tracing(app, service_name):
if 'report_url' not in config: if 'report_url' not in config:
return return
# Configure the Zipkin exporter.
report_url = urlsplit(config['report_url'])
report_host, report_port = report_url.netloc.split(':')
trace_exporter = ZipkinExporter(
service_name=service_name,
host_name=report_host,
port=report_port,
endpoint=report_url.path,
protocol=report_url.scheme,
)
# Configure the sampler.
sample_pct = config.get('sample', 'always')
if sample_pct == 'always':
trace_sampler = AlwaysOnSampler()
elif sample_pct == 'never':
trace_sampler = AlwaysOffSampler()
else:
trace_sampler = ProbabilitySampler(float(sample_pct))
# We use the B3 (Zipkin) propagator because it seems to be the
# default in the Go implementation.
propagator = B3FormatPropagator()
# Set up the OpenCensus Flask middleware.
middleware = FlaskMiddleware(
app,
sampler=trace_sampler,
exporter=trace_exporter,
propagator=propagator,
excludelist_paths=['static'],
)
# Patch the 'requests' module so that HTTP clients propagate the # Patch the 'requests' module so that HTTP clients propagate the
# trace ID. Note that this is mostly useless, as the requests # trace ID. Note that this is mostly useless, as the requests
# integration only patches the high-level API (get, post) and does # integration only patches the high-level API (get, post) and does
......
...@@ -16,7 +16,6 @@ setup( ...@@ -16,7 +16,6 @@ setup(
"flask-talisman", "flask-talisman",
"opencensus", "opencensus",
"opencensus-ext-zipkin", "opencensus-ext-zipkin",
"opencensus-ext-flask",
"opencensus-ext-requests", "opencensus-ext-requests",
"sso", "sso",
"urllib3", "urllib3",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment