Skip to content

Commit

Permalink
[DPE-4614] Add support for tracing through tempo-k8s (#149)
Browse files Browse the repository at this point in the history
## Issue
We would like to be able to instrument our charm and generate traces to
discover inefficiencies in charm code execution. The observability team
has developed a charm for
[tempo](https://github.com/canonical/tempo-k8s-operator) that we would
like to integrate with.

## Solution
Integrate with the tempo charm

## Considerations
1. We are not supporting sending traces to tempo-k8s using HTTPS are
there are still some rough edges to be rounded with this integration
2. We need to use the `edge` version of cos-lite until they release to
stable as it contains some critical fixes


![image](https://github.com/canonical/mysql-router-operator/assets/99665202/f4bd2bce-0b7f-4e1c-9794-129ba5f84cb4)
  • Loading branch information
shayancanonical authored Jun 13, 2024
1 parent 5f353e8 commit 7c24a35
Show file tree
Hide file tree
Showing 11 changed files with 1,860 additions and 151 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ jobs:
bases-index: 0
- series: jammy
bases-index: 1
juju-snap-channel: ["2.9/stable", "3.1/stable"]
juju-snap-channel: ["2.9/stable", "3.4/stable"]
include:
- juju-snap-channel: "3.1/stable"
agent-version: "3.1.6"
libjuju-version: "3.2.2"
- juju-snap-channel: "3.4/stable"
agent-version: "3.4.3"
libjuju-version: "3.4.0.0"
- juju-snap-channel: "2.9/stable"
agent-version: "2.9.45"
libjuju-version: "2.9.44.1"
Expand Down
14 changes: 9 additions & 5 deletions lib/charms/data_platform_libs/v0/data_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def _on_topic_requested(self, event: TopicRequestedEvent):

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version
LIBPATCH = 35
LIBPATCH = 37

PYDEPS = ["ops>=2.0.0"]

Expand Down Expand Up @@ -642,22 +642,26 @@ def _move_to_new_label_if_needed(self):
return

# Create a new secret with the new label
old_meta = self._secret_meta
content = self._secret_meta.get_content()
self._secret_uri = None

# I wish we could just check if we are the owners of the secret...
try:
self._secret_meta = self.add_secret(content, label=self.label)
except ModelError as err:
if "this unit is not the leader" not in str(err):
raise
old_meta.remove_all_revisions()
self.current_label = None

def set_content(self, content: Dict[str, str]) -> None:
"""Setting cached secret content."""
if not self.meta:
return

# DPE-4182: do not create new revision if the content stay the same
if content == self.get_content():
return

if content:
self._move_to_new_label_if_needed()
self.meta.set_content(content)
Expand Down Expand Up @@ -1586,7 +1590,7 @@ def _register_secret_to_relation(
"""
label = self._generate_secret_label(relation_name, relation_id, group)

# Fetchin the Secret's meta information ensuring that it's locally getting registered with
# Fetching the Secret's meta information ensuring that it's locally getting registered with
CachedSecret(self._model, self.component, label, secret_id).meta

def _register_secrets_to_relation(self, relation: Relation, params_name_list: List[str]):
Expand Down Expand Up @@ -2309,7 +2313,7 @@ def _secrets(self) -> dict:
return self._cached_secrets

def _get_secret(self, group) -> Optional[Dict[str, str]]:
"""Retrieveing secrets."""
"""Retrieving secrets."""
if not self.app:
return
if not self._secrets.get(group):
Expand Down
14 changes: 10 additions & 4 deletions lib/charms/operator_libs_linux/v2/snap.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version
LIBPATCH = 5
LIBPATCH = 7


# Regex to locate 7-bit C1 ANSI sequences
Expand Down Expand Up @@ -319,7 +319,10 @@ def get(self, key: Optional[str], *, typed: bool = False) -> Any:
Default is to return a string.
"""
if typed:
config = json.loads(self._snap("get", ["-d", key]))
args = ["-d"]
if key:
args.append(key)
config = json.loads(self._snap("get", args))
if key:
return config.get(key)
return config
Expand Down Expand Up @@ -584,13 +587,16 @@ def ensure(
"Installing snap %s, revision %s, tracking %s", self._name, revision, channel
)
self._install(channel, cohort, revision)
else:
logger.info("The snap installation completed successfully")
elif revision is None or revision != self._revision:
# The snap is installed, but we are changing it (e.g., switching channels).
logger.info(
"Refreshing snap %s, revision %s, tracking %s", self._name, revision, channel
)
self._refresh(channel=channel, cohort=cohort, revision=revision, devmode=devmode)
logger.info("The snap installation completed successfully")
logger.info("The snap refresh completed successfully")
else:
logger.info("Refresh of snap %s was unnecessary", self._name)

self._update_snap_apps()
self._state = state
Expand Down
Loading

0 comments on commit 7c24a35

Please sign in to comment.