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

Fix grpc port conflict #8

Merged
merged 5 commits into from
Jul 11, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ build/
.coverage
__pycache__/
*.py[cod]
*.egg-info
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ jsonschema==4.17.0
lightkube==0.11.0
lightkube-models==1.24.1.4
tenacity==8.1.0
ops-scenario==4.0
2 changes: 1 addition & 1 deletion src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
logger = logging.getLogger(__name__)


@trace_charm(tempo_endpoint="_tempo_otlp_grpc_endpoint", service_name="TempoCharm")
@trace_charm(tempo_endpoint="_tempo_otlp_grpc_endpoint")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there anything other than 'charm'? I.e. should it be shortened to just @trace(...)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't see this one until now, but yeah, there's trace_function, trace_type.
Idea is:

@trace_function
def my_custom_fn()...

@trace_type
class MyObj...

@trace_charm(...)
 class MyCharm...
     def foo(self):
          my_custom_fn()  # we'll open a span corresponding with `my_custom_fn` being called
          obj = MyObj()  # each method call on this type will open a span
          obj.bar()

In fact, trace_charm is a specialization of trace_type.
I thought about having a @trace that automagically dispatches to one of the three based on the type (and subclass) of the first argument, but it felt out of scope for now

class TempoCharm(CharmBase):
"""Charmed Operator for Tempo; a distributed tracing backend."""

Expand Down
11 changes: 9 additions & 2 deletions src/tempo.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ class Tempo:
wal_path = "/etc/tempo_wal"
log_path = "/var/log/tempo.log"

def __init__(self, port: int = 3200, local_host: str = "0.0.0.0"):
def __init__(self, port: int = 3200,
grpc_listen_port: int = 9096, local_host: str = "0.0.0.0"):
self.tempo_port = port

# default grpc listen port is 9095, but that conflicts with promtail.
self.grpc_listen_port = grpc_listen_port

# ports source: https://github.com/grafana/tempo/blob/main/example/docker-compose/local/docker-compose.yaml
# todo make configurable?
self.otlp_grpc_port = 4317
Expand Down Expand Up @@ -62,7 +66,10 @@ def get_config(self) -> str:
{
"auth_enabled": False,
"search_enabled": True,
"server": {"http_listen_port": self.tempo_port},
"server": {
"http_listen_port": self.tempo_port,
"grpc_listen_port": self.grpc_listen_port,
},
# this configuration will listen on all ports and protocols that tempo is capable of.
# the receives all come from the OpenTelemetry collector. more configuration information can
# be found there: https://github.com/open-telemetry/opentelemetry-collector/tree/overlord/receiver
Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ deps =
pytest
juju
pytest-operator
tenacity
requests
-r{toxinidir}/requirements.txt
commands =
Expand Down