Skip to content
This repository has been archived by the owner on Feb 11, 2024. It is now read-only.

Commit

Permalink
fix: add debug traces (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavier Basty authored Mar 31, 2023
1 parent a28a479 commit 42e9439
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/handlers/save_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use {
error,
handlers::Response,
increment_counter,
log::prelude::*,
relay::signature::RequireValidSignature,
state::{AppState, CachedRegistration},
store::{registrations::Registration, StoreError},
Expand All @@ -28,6 +29,8 @@ pub async fn handler(
StateExtractor(state): StateExtractor<Arc<AppState>>,
RequireValidSignature(Json(payload)): RequireValidSignature<Json<HistoryPayload>>,
) -> error::Result<Response> {
debug!("Received `save_message` query: {:?}", payload);

increment_counter!(state.metrics, received_items);

let registration = if let Some(registration) = state
Expand All @@ -39,9 +42,11 @@ pub async fn handler(
tags: r.tags,
relay_url: r.relay_url,
}) {
debug!("loaded registration from cache");
increment_counter!(state.metrics, cached_registrations);
registration
} else {
debug!("loading registration from database");
let registration = match state
.registration_store
.get_registration(payload.client_id.as_ref())
Expand All @@ -67,6 +72,7 @@ pub async fn handler(
let tags = registration.tags;
for tag in &tags {
if match_tag(payload.tag, tag) {
debug!("tag matching, storing message");
state
.messages_store
.upsert_message(
Expand All @@ -78,6 +84,8 @@ pub async fn handler(
)
.await?;

debug!("message stored, sending ack");

increment_counter!(state.metrics, stored_items);

return Ok(Response::default());
Expand Down
5 changes: 4 additions & 1 deletion terraform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,8 @@

## Outputs

No outputs.
| Name | Description |
|------|-------------|
| <a name="output_fqdn"></a> [fqdn](#output\_fqdn) | The FQDN of the deployed instance |
| <a name="output_version"></a> [version](#output\_version) | The version of the deployed instance |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
3 changes: 2 additions & 1 deletion terraform/ecs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ Create an ECS cluster and hook it up to a load-balancer.
| <a name="input_id_length_limit"></a> [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).<br>Set to `0` for unlimited length.<br>Set to `null` for keep the existing setting, which defaults to `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
| <a name="input_image"></a> [image](#input\_image) | The name of the ECR image to use for the container. | `string` | n/a | yes |
| <a name="input_label_key_case"></a> [label\_key\_case](#input\_label\_key\_case) | Controls the letter case of the `tags` keys (label names) for tags generated by this module.<br>Does not affect keys of tags passed in via the `tags` input.<br>Possible values: `lower`, `title`, `upper`.<br>Default value: `title`. | `string` | `null` | no |
| <a name="input_label_order"></a> [label\_order](#input\_label\_order) | The order in which the labels (ID elements) appear in the `id`.<br>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br>You can omit any of the 5 labels, but at least one must be present. | `list(string)` | `null` | no |
| <a name="input_label_order"></a> [label\_order](#input\_label\_order) | The order in which the labels (ID elements) appear in the `id`.<br>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br>You can omit any of the 5 labels, but at least one must be present. | `list(string)` | <pre>[<br> "namespace",<br> "stage",<br> "name",<br> "attributes"<br>]</pre> | no |
| <a name="input_label_value_case"></a> [label\_value\_case](#input\_label\_value\_case) | Controls the letter case of ID elements (labels) as included in `id`,<br>set as tag values, and output by this module individually.<br>Does not affect values of tags passed in via the `tags` input.<br>Possible values: `lower`, `title`, `upper` and `none` (no transformation).<br>Set this to `title` and set `delimiter` to `""` to yield Pascal Case IDs.<br>Default value: `lower`. | `string` | `null` | no |
| <a name="input_log_level"></a> [log\_level](#input\_log\_level) | The log level to use for the application. | `string` | `"INFO"` | no |
| <a name="input_log_region"></a> [log\_region](#input\_log\_region) | The region to send Cloudwatch logs to. | `string` | n/a | yes |
| <a name="input_memory"></a> [memory](#input\_memory) | The amount of memory (in MiB) to reserve for the container. | `number` | n/a | yes |
| <a name="input_name"></a> [name](#input\_name) | ID element. Usually the component name.<br>This is the only ID element not also included as a `tag`.<br>The "name" tag is set to the full `id` string. There is no tag with the value of the `name` input. | `string` | `null` | no |
Expand Down
2 changes: 1 addition & 1 deletion terraform/ecs/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ resource "aws_ecs_task_definition" "app_task_definition" {
environment = [
{ name = "PORT", value = "8080" },
{ name = "PUBLIC_URL", value = "http://localhost:8080" }, // TODO: Change this to the actual public URL
{ name = "LOG_LEVEL", value = "INFO" },
{ name = "LOG_LEVEL", value = var.log_level },
{ name = "MONGO_ADDRESS", value = var.docdb-connection_url },
{ name = "CORS_ALLOWED_ORIGINS", value = "*" },
{ name = "TELEMETRY_PROMETHEUS_PORT", value = "8081" }
Expand Down
6 changes: 6 additions & 0 deletions terraform/ecs/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ variable "log_region" {
type = string
}

variable "log_level" {
description = "The log level to use for the application."
type = string
default = "INFO"
}

variable "image" {
description = "The name of the ECR image to use for the container."
type = string
Expand Down
2 changes: 2 additions & 0 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ module "ecs" {
allowed_app_ingress_cidr_blocks = module.vpc.vpc_cidr_block
allowed_lb_ingress_cidr_blocks = module.vpc.vpc_cidr_block
docdb-connection_url = module.history_docdb.connection_url

log_level = "DEBUG"
}

################################################################################
Expand Down

0 comments on commit 42e9439

Please sign in to comment.