diff --git a/lib/charms/loki_k8s/v1/loki_push_api.py b/lib/charms/loki_k8s/v1/loki_push_api.py index 1aa092e..4b3bcfe 100644 --- a/lib/charms/loki_k8s/v1/loki_push_api.py +++ b/lib/charms/loki_k8s/v1/loki_push_api.py @@ -519,7 +519,7 @@ def _alert_rules_error(self, event): # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 9 +LIBPATCH = 10 PYDEPS = ["cosl"] @@ -535,17 +535,20 @@ def _alert_rules_error(self, event): # update all sha256 sums in PROMTAIL_BINARIES. To support a new architecture # you only need to add a new key value pair for the architecture in PROMTAIL_BINARIES. PROMTAIL_VERSION = "v2.9.7" +PROMTAIL_ARM_BINARY = { + "filename": "promtail-static-arm64", + "zipsha": "c083fdb45e5c794103f974eeb426489b4142438d9e10d0ae272b2aff886e249b", + "binsha": "4cd055c477a301c0bdfdbcea514e6e93f6df5d57425ce10ffc77f3e16fec1ddf", +} + PROMTAIL_BINARIES = { "amd64": { "filename": "promtail-static-amd64", "zipsha": "6873cbdabf23062aeefed6de5f00ff382710332af3ab90a48c253ea17e08f465", "binsha": "28da9b99f81296fe297831f3bc9d92aea43b4a92826b8ff04ba433b8cb92fb50", }, - "arm64": { - "filename": "promtail-static-arm64", - "zipsha": "c083fdb45e5c794103f974eeb426489b4142438d9e10d0ae272b2aff886e249b", - "binsha": "4cd055c477a301c0bdfdbcea514e6e93f6df5d57425ce10ffc77f3e16fec1ddf", - }, + "arm64": PROMTAIL_ARM_BINARY, + "aarch64": PROMTAIL_ARM_BINARY, } # Paths in `charm` container diff --git a/lib/charms/prometheus_k8s/v0/prometheus_scrape.py b/lib/charms/prometheus_k8s/v0/prometheus_scrape.py index be96768..e3d35c6 100644 --- a/lib/charms/prometheus_k8s/v0/prometheus_scrape.py +++ b/lib/charms/prometheus_k8s/v0/prometheus_scrape.py @@ -178,7 +178,7 @@ def __init__(self, *args): - `scrape_timeout` - `proxy_url` - `relabel_configs` -- `metrics_relabel_configs` +- `metric_relabel_configs` - `sample_limit` - `label_limit` - `label_name_length_limit` @@ -362,7 +362,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 = 46 +LIBPATCH = 47 PYDEPS = ["cosl"] @@ -377,7 +377,7 @@ def _on_scrape_targets_changed(self, event): "scrape_timeout", "proxy_url", "relabel_configs", - "metrics_relabel_configs", + "metric_relabel_configs", "sample_limit", "label_limit", "label_name_length_limit", diff --git a/lib/charms/tempo_k8s/v1/charm_tracing.py b/lib/charms/tempo_k8s/v1/charm_tracing.py index 39ebcd4..7c11885 100644 --- a/lib/charms/tempo_k8s/v1/charm_tracing.py +++ b/lib/charms/tempo_k8s/v1/charm_tracing.py @@ -126,14 +126,15 @@ def my_tracing_endpoint(self) -> Optional[str]: from opentelemetry.sdk.resources import Resource from opentelemetry.sdk.trace import Span, TracerProvider from opentelemetry.sdk.trace.export import BatchSpanProcessor -from opentelemetry.trace import INVALID_SPAN, Tracer -from opentelemetry.trace import get_current_span as otlp_get_current_span from opentelemetry.trace import ( + INVALID_SPAN, + Tracer, get_tracer, get_tracer_provider, set_span_in_context, set_tracer_provider, ) +from opentelemetry.trace import get_current_span as otlp_get_current_span from ops.charm import CharmBase from ops.framework import Framework @@ -146,7 +147,7 @@ def my_tracing_endpoint(self) -> Optional[str]: # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 5 +LIBPATCH = 6 PYDEPS = ["opentelemetry-exporter-otlp-proto-http==1.21.0"] diff --git a/lib/charms/tempo_k8s/v2/tracing.py b/lib/charms/tempo_k8s/v2/tracing.py index 3cf54b1..9e5defc 100644 --- a/lib/charms/tempo_k8s/v2/tracing.py +++ b/lib/charms/tempo_k8s/v2/tracing.py @@ -12,7 +12,7 @@ object from this charm library. For the simplest use cases, using the `TracingEndpointRequirer` object only requires instantiating it, typically in the constructor of your charm. The `TracingEndpointRequirer` constructor requires the name of the relation over which a tracing endpoint - is exposed by the Tempo charm, and a list of protocols it intends to send traces with. + is exposed by the Tempo charm, and a list of protocols it intends to send traces with. This relation must use the `tracing` interface. The `TracingEndpointRequirer` object may be instantiated as follows @@ -21,7 +21,7 @@ def __init__(self, *args): super().__init__(*args) # ... - self.tracing = TracingEndpointRequirer(self, + self.tracing = TracingEndpointRequirer(self, protocols=['otlp_grpc', 'otlp_http', 'jaeger_http_thrift'] ) # ... @@ -29,20 +29,20 @@ def __init__(self, *args): Note that the first argument (`self`) to `TracingEndpointRequirer` is always a reference to the parent charm. -Alternatively to providing the list of requested protocols at init time, the charm can do it at -any point in time by calling the -`TracingEndpointRequirer.request_protocols(*protocol:str, relation:Optional[Relation])` method. +Alternatively to providing the list of requested protocols at init time, the charm can do it at +any point in time by calling the +`TracingEndpointRequirer.request_protocols(*protocol:str, relation:Optional[Relation])` method. Using this method also allows you to use per-relation protocols. -Units of provider charms obtain the tempo endpoint to which they will push their traces by calling +Units of provider charms obtain the tempo endpoint to which they will push their traces by calling `TracingEndpointRequirer.get_endpoint(protocol: str)`, where `protocol` is, for example: - `otlp_grpc` - `otlp_http` - `zipkin` - `tempo` -If the `protocol` is not in the list of protocols that the charm requested at endpoint set-up time, -the library will raise an error. +If the `protocol` is not in the list of protocols that the charm requested at endpoint set-up time, +the library will raise an error. ## Requirer Library Usage @@ -104,7 +104,7 @@ def __init__(self, *args): # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 3 +LIBPATCH = 5 PYDEPS = ["pydantic"] @@ -308,6 +308,9 @@ class TracingProviderAppData(DatabagModel): # noqa: D101 external_url: Optional[str] = None """Server url. If an ingress is present, it will be the ingress address.""" + internal_scheme: Optional[str] = None + """Scheme for internal communication. If it is present, it will be protocol accepted by the provider.""" + class TracingRequirerAppData(DatabagModel): # noqa: D101 """Application databag model for the tracing requirer.""" @@ -495,6 +498,7 @@ def __init__( host: str, external_url: Optional[str] = None, relation_name: str = DEFAULT_RELATION_NAME, + internal_scheme: Optional[Literal["http", "https"]] = "http", ): """Initialize. @@ -505,6 +509,7 @@ def __init__( if an ingress is present. relation_name: an optional string name of the relation between `charm` and the Tempo charmed service. The default is "tracing". + internal_scheme: scheme to use with internal urls. Raises: RelationNotFoundError: If there is no relation in the charm's metadata.yaml @@ -525,6 +530,7 @@ def __init__( self._host = host self._external_url = external_url self._relation_name = relation_name + self._internal_scheme = internal_scheme self.framework.observe( self._charm.on[relation_name].relation_joined, self._on_relation_event ) @@ -590,10 +596,11 @@ def publish_receivers(self, receivers: Sequence[RawReceiver]): try: TracingProviderAppData( host=self._host, - external_url=self._external_url, + external_url=self._external_url or None, receivers=[ Receiver(port=port, protocol=protocol) for protocol, port in receivers ], + internal_scheme=self._internal_scheme, ).dump(relation.data[self._charm.app]) except ModelError as e: @@ -822,11 +829,10 @@ def _get_endpoint( receiver = receivers[0] # if there's an external_url argument (v2.5+), use that. Otherwise, we use the tempo local fqdn if app_data.external_url: - url = app_data.external_url + url = f"{app_data.external_url}:{receiver.port}" else: - # FIXME: if we don't get an external url but only a - # hostname, we don't know what scheme we need to be using. ASSUME HTTP - url = f"http://{app_data.host}:{receiver.port}" + # if we didn't receive a scheme (old provider), we assume HTTP is used + url = f"{app_data.internal_scheme or 'http'}://{app_data.host}:{receiver.port}" if receiver.protocol.endswith("grpc"): # TCP protocols don't want an http/https scheme prefix