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

Add profiles' self-scraping support #392

Merged
merged 12 commits into from
Jan 31, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ provides:
self-profiling-endpoint:
interface: parca_scrape
description: |
The profiling endpoint at which profiles for this parca instance are served.
Endpoint to allow this parca instance profiles to be scraped by a remote parca instance.
parca-store-endpoint:
interface: parca_store
description: |
Expand Down
301 changes: 0 additions & 301 deletions lib/charms/observability_libs/v0/juju_topology.py

This file was deleted.

21 changes: 19 additions & 2 deletions lib/charms/parca_k8s/v0/parca_scrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,11 @@ def _on_scrape_targets_changed(self, event):
import json
import logging
import socket
from cosl import JujuTopology
from typing import List, Optional, Union
from ops.model import Relation

import ops
from charms.observability_libs.v0.juju_topology import JujuTopology

# The unique Charmhub library identifier, never change it
LIBID = "dbc3d2e89cb24917b99c40e14354dd25"
michaeldmitry marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -184,7 +185,7 @@ def _on_scrape_targets_changed(self, event):

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


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -811,6 +812,22 @@ def _is_valid_unit_address(self, address: str) -> bool:
except ValueError:
return False

@property
def _relations(self) -> List[Relation]:
"""The relations currently active on this endpoint."""
return self._charm.model.relations[self._relation_name]

def is_ready(self, relation: Optional[Relation] = None) -> bool:
"""Check if the relation(s) on this endpoint are ready."""
relations = [relation] if relation else self._relations

if not relations:
logger.debug(f"no relation on {self._relation_name!r}.")
return False

# TODO: once we have a pydantic model, we can also check for the integrity of the databags.
return all((relation.app and relation.data) for relation in relations)

@property
def _scrape_jobs(self) -> list:
"""Fetch list of scrape jobs.
Expand Down
Loading
Loading