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

Handle long tracing names #1038

Merged
merged 2 commits into from
Dec 17, 2018
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
10 changes: 10 additions & 0 deletions ambassador/ambassador/ir/ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,16 @@ def __init__(self, aconf: Config, tls_secret_resolver=None, file_checker=None) -
self.logger.info("%s => %s" % (name, mangled_name))
self.clusters[name]['name'] = mangled_name

# After we have the cluster names fixed up, go finalize filters.
if self.tracing:
self.tracing.finalize()

if self.ratelimit:
self.ratelimit.finalize()

for filter in self.filters:
filter.finalize()

# XXX Brutal hackery here! Probably this is a clue that Config and IR and such should have
# a common container that can hold errors.
def post_error(self, rc: Union[str, RichStatus], resource: Optional[IRResource]=None):
Expand Down
3 changes: 3 additions & 0 deletions ambassador/ambassador/ir/irfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ def __init__(self, ir: 'IR', aconf: Config,

def config_dict(self) -> Optional[dict]:
return self.config

def finalize(self) -> None:
pass
6 changes: 4 additions & 2 deletions ambassador/ambassador/ir/irtracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ def add_mappings(self, ir: 'IR', aconf: Config):
cluster.referenced_by(self)
self.cluster = cluster

self.driver_config['collector_cluster'] = cluster.name

# if not ir.add_to_primary_listener(tracing=True):
# raise Exception("Failed to update primary listener with tracing config")

def finalize(self):
self.ir.logger.info("tracing cluster name: %s" % self.cluster.name)
self.driver_config['collector_cluster'] = self.cluster.name
2 changes: 1 addition & 1 deletion ambassador/tests/013-tracing/config/tracing-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: ambassador/v0
kind: TracingService
name: tracing
service: "example-tracing:5000"
service: "example-tracing-with-a-really-really-long-name-omfg-baby-baby:5000"
tag_headers:
- ":authority"
- ":path"
Expand Down
15 changes: 6 additions & 9 deletions ambassador/tests/013-tracing/gold.intermediate.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@
"_referenced_by": [
"tracing-service.yaml.1"
],
"_service": "example-tracing:5000",
"_service": "example-tracing-with-a-really-really-long-name-omfg-baby-baby:5000",
"_source": "tracing-service.yaml.1",
"lb_type": "round_robin",
"name": "cluster_tracing_example_tracing_5000",
"name": "cluster_tracing_example_tracing_with_a_r-0",
"type": "strict_dns",
"urls": [
"tcp://example-tracing:5000"
]
"tcp://example-tracing-with-a-really-really-long-name-omfg-baby-baby:5000" ]
},
{
"_referenced_by": [
Expand Down Expand Up @@ -173,10 +172,9 @@
"tracing": [
{
"_source": "tracing-service.yaml.1",
"cluster_name": "cluster_tracing_example_tracing_5000",
"cluster_name": "cluster_tracing_example_tracing_with_a_r-0",
"config": {
"collector_cluster": "cluster_tracing_example_tracing_5000"
},
"collector_cluster": "cluster_tracing_example_tracing_with_a_r-0" },
"driver": "zipkin",
"tag_headers": [
":authority",
Expand Down Expand Up @@ -232,7 +230,6 @@
"kind": "TracingService",
"name": "tracing",
"version": "ambassador/v0",
"yaml": "apiVersion: ambassador/v0\ndriver: zipkin\nkind: TracingService\nname: tracing\nservice: example-tracing:5000\ntag_headers:\n- :authority\n- :path\n"
}
"yaml": "apiVersion: ambassador/v0\ndriver: zipkin\nkind: TracingService\nname: tracing\nservice: example-tracing-with-a-really-really-long-name-omfg-baby-baby:5000\ntag_headers:\n- :authority\n- :path\n" }
}
}
7 changes: 3 additions & 4 deletions ambassador/tests/013-tracing/gold.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@

]},
{
"name": "cluster_tracing_example_tracing_5000",
"name": "cluster_tracing_example_tracing_with_a_r-0",
"connect_timeout_ms": 3000,
"type": "strict_dns",
"lb_type": "round_robin",
"hosts": [
{
"url": "tcp://example-tracing:5000"
"url": "tcp://example-tracing-with-a-really-really-long-name-omfg-baby-baby:5000"
}

]}
Expand All @@ -146,8 +146,7 @@
"driver": {
"type": "zipkin",
"config": {
"collector_cluster": "cluster_tracing_example_tracing_5000"
}
"collector_cluster": "cluster_tracing_example_tracing_with_a_r-0" }
}
}
}
Expand Down