Skip to content
Snippets Groups Projects
Commit 84be9fd3 authored by ale's avatar ale
Browse files

Include float container info in trace, if present

parent 5c616d9c
Branches
No related tags found
No related merge requests found
Pipeline #53329 passed
...@@ -6,7 +6,8 @@ from opentelemetry import trace ...@@ -6,7 +6,8 @@ from opentelemetry import trace
from opentelemetry.exporter.zipkin.json import ZipkinExporter from opentelemetry.exporter.zipkin.json import ZipkinExporter
from opentelemetry.sdk.trace import TracerProvider from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.sdk.resources import SERVICE_NAME, HOST_NAME, Resource from opentelemetry.sdk.resources import Resource, \
SERVICE_NAME, HOST_NAME, CONTAINER_NAME, CONTAINER_IMAGE_NAME, CONTAINER_IMAGE_TAG
tracing_config_file = os.getenv('TRACING_CONFIG', '/etc/tracing/client.conf') tracing_config_file = os.getenv('TRACING_CONFIG', '/etc/tracing/client.conf')
...@@ -21,10 +22,24 @@ def setup_tracing(service_name): ...@@ -21,10 +22,24 @@ def setup_tracing(service_name):
if 'report_url' not in config: if 'report_url' not in config:
return False return False
resource = Resource(attributes={ default_resource_attributes = {
SERVICE_NAME: service_name, SERVICE_NAME: service_name,
HOST_NAME: socket.gethostname(), HOST_NAME: socket.gethostname(),
}) }
if os.getenv('FLOAT_SERVICE'):
default_resource_attributes['float.service'] = os.getenv('FLOAT_SERVICE')
if os.getenv('FLOAT_INSTANCE_NAME'):
default_resource_attributes['float.instance'] = os.getenv('FLOAT_INSTANCE_NAME')
if os.getenv('FLOAT_CONTAINER_NAME'):
default_resource_attributes[CONTAINER_NAME] = os.getenv('FLOAT_CONTAINER_NAME')
if os.getenv('FLOAT_CONTAINER_IMAGE'):
image_name, tag = os.getenv('FLOAT_CONTAINER_IMAGE'), 'latest'
if ':' in image_name:
image_name, tag = image_name.split(':', 1)
default_resource_attributes[CONTAINER_IMAGE_NAME] = image_name
default_resource_attributes[CONTAINER_IMAGE_TAG] = tag
resource = Resource(attributes=default_resource_attributes)
zipkin_exporter = ZipkinExporter(endpoint=config['report_url']) zipkin_exporter = ZipkinExporter(endpoint=config['report_url'])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment