-
Notifications
You must be signed in to change notification settings - Fork 687
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add propagation_modes for the Lightstep Tracer
The Lightstep tracer supports multiple propagation modes. See https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/trace/v3/lightstep.proto#enum-config-trace-v3-lightstepconfig-propagationmode With this PR it is now possible to set a list of propagation modes in the config field of the TracingService. Signed-off-by: Paul Salaberria <[email protected]>
- Loading branch information
1 parent
a9b94f4
commit 66c957e
Showing
9 changed files
with
238 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
from typing import Optional, TYPE_CHECKING | ||
|
||
import logging | ||
import pytest | ||
|
||
from tests.selfsigned import TLSCerts | ||
from tests.utils import assert_valid_envoy_config, module_and_mapping_manifests | ||
|
||
logging.basicConfig( | ||
level=logging.INFO, | ||
format="%(asctime)s test %(levelname)s: %(message)s", | ||
datefmt='%Y-%m-%d %H:%M:%S' | ||
) | ||
|
||
logger = logging.getLogger("ambassador") | ||
|
||
from ambassador import Config, IR | ||
from ambassador.envoy import EnvoyConfig | ||
from ambassador.fetch import ResourceFetcher | ||
from ambassador.utils import SecretHandler, SecretInfo | ||
|
||
if TYPE_CHECKING: | ||
from ambassador.ir.irresource import IRResource # pragma: no cover | ||
|
||
class MockSecretHandler(SecretHandler): | ||
def load_secret(self, resource: 'IRResource', secret_name: str, namespace: str) -> Optional[SecretInfo]: | ||
return SecretInfo('fallback-self-signed-cert', 'ambassador', "mocked-fallback-secret", | ||
TLSCerts["acook"].pubcert, TLSCerts["acook"].privkey, decode_b64=False) | ||
|
||
|
||
def lightstep_tracing_service_manifest(): | ||
return """ | ||
--- | ||
apiVersion: getambassador.io/v3alpha1 | ||
kind: TracingService | ||
metadata: | ||
name: tracing | ||
namespace: ambassador | ||
spec: | ||
service: lightstep:80 | ||
driver: lightstep | ||
config: | ||
access_token_file: /lightstep-credentials/access-token | ||
propagation_modes: ["ENVOY", "TRACE_CONTEXT"] | ||
""" | ||
|
||
@pytest.mark.compilertest | ||
def test_tracing_config_v3(): | ||
aconf = Config() | ||
|
||
yaml = module_and_mapping_manifests(None, []) + "\n" + lightstep_tracing_service_manifest() | ||
fetcher = ResourceFetcher(logger, aconf) | ||
fetcher.parse_yaml(yaml, k8s=True) | ||
|
||
aconf.load_all(fetcher.sorted()) | ||
|
||
secret_handler = MockSecretHandler(logger, "mockery", "/tmp/ambassador/snapshots", "v1") | ||
ir = IR(aconf, file_checker=lambda path: True, secret_handler=secret_handler) | ||
|
||
assert ir | ||
|
||
econf = EnvoyConfig.generate(ir, "V3") | ||
|
||
bootstrap_config, ads_config, _ = econf.split_config() | ||
assert "tracing" in bootstrap_config | ||
assert bootstrap_config["tracing"] == { | ||
"http": { | ||
"name": "envoy.lightstep", | ||
"typed_config": { | ||
"@type": "type.googleapis.com/envoy.config.trace.v3.LightstepConfig", | ||
"access_token_file": "/lightstep-credentials/access-token", | ||
"collector_cluster": "cluster_tracing_lightstep_80_ambassador", | ||
"propagation_modes": ["ENVOY", "TRACE_CONTEXT"] | ||
} | ||
} | ||
} | ||
|
||
ads_config.pop('@type', None) | ||
assert_valid_envoy_config(ads_config) | ||
assert_valid_envoy_config(bootstrap_config) | ||
|
||
|
||
@pytest.mark.compilertest | ||
def test_tracing_config_v2(): | ||
aconf = Config() | ||
|
||
yaml = module_and_mapping_manifests(None, []) + "\n" + lightstep_tracing_service_manifest() | ||
fetcher = ResourceFetcher(logger, aconf) | ||
fetcher.parse_yaml(yaml, k8s=True) | ||
|
||
aconf.load_all(fetcher.sorted()) | ||
|
||
secret_handler = MockSecretHandler(logger, "mockery", "/tmp/ambassador/snapshots", "v1") | ||
ir = IR(aconf, file_checker=lambda path: True, secret_handler=secret_handler) | ||
|
||
assert ir | ||
|
||
econf = EnvoyConfig.generate(ir, "V2") | ||
|
||
bootstrap_config, ads_config, _ = econf.split_config() | ||
assert "tracing" in bootstrap_config | ||
assert bootstrap_config["tracing"] == { | ||
"http": { | ||
"name": "envoy.lightstep", | ||
"typed_config": { | ||
"@type": "type.googleapis.com/envoy.config.trace.v2.LightstepConfig", | ||
"access_token_file": "/lightstep-credentials/access-token", | ||
"collector_cluster": "cluster_tracing_lightstep_80_ambassador", | ||
"propagation_modes": ["ENVOY", "TRACE_CONTEXT"] | ||
} | ||
} | ||
} | ||
|
||
ads_config.pop('@type', None) | ||
assert_valid_envoy_config(ads_config, v2=True) | ||
assert_valid_envoy_config(bootstrap_config, v2=True) | ||
|