Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python-web-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ai3
tools
python-web-common
Commits
84be9fd3
Commit
84be9fd3
authored
2 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
Include float container info in trace, if present
parent
5c616d9c
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#53329
passed
2 years ago
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ai_web_common/flask_ai/tracing.py
+18
-3
18 additions, 3 deletions
ai_web_common/flask_ai/tracing.py
with
18 additions
and
3 deletions
ai_web_common/flask_ai/tracing.py
+
18
−
3
View file @
84be9fd3
...
@@ -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
=
R
esource
(
attributes
=
{
default_r
esource
_
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
'
])
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment