{"id":17951836,"url":"https://github.com/francoposa/echo-server-rust-logging-metrics-tracing","last_synced_at":"2025-03-25T00:31:36.159Z","repository":{"id":46872667,"uuid":"515666135","full_name":"francoposa/echo-server-rust-logging-metrics-tracing","owner":"francoposa","description":"Echo Server Demonstrating a Fully Instrumented Rust Backend Application","archived":false,"fork":false,"pushed_at":"2024-12-01T18:48:02.000Z","size":78,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-19T05:33:38.860Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/francoposa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-19T16:42:06.000Z","updated_at":"2025-02-09T05:19:12.000Z","dependencies_parsed_at":"2024-06-16T00:31:01.874Z","dependency_job_id":"5b4ffcdc-00f3-435e-bbd9-8eaaae0f0fef","html_url":"https://github.com/francoposa/echo-server-rust-logging-metrics-tracing","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francoposa%2Fecho-server-rust-logging-metrics-tracing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francoposa%2Fecho-server-rust-logging-metrics-tracing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francoposa%2Fecho-server-rust-logging-metrics-tracing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francoposa%2Fecho-server-rust-logging-metrics-tracing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/francoposa","download_url":"https://codeload.github.com/francoposa/echo-server-rust-logging-metrics-tracing/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245377920,"owners_count":20605374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-29T09:51:24.068Z","updated_at":"2025-03-25T00:31:36.137Z","avatar_url":"https://github.com/francoposa.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# echo-server-rust-logging-tracing-metrics\n\n## Configuration\n\n### Server Configuration\n\n* `SERVER_ADDR` - server bind address in `host:port` format; defaults to `0.0.0.0:8080`.\n* `BASE_URL_PATH` - URL path prefix to be applied to all public API endpoints; defaults to `/api/v0`\n\n### OTEL Instrumentation Official Configuration\n\nOpenTelemetry library configuration is done with the standardized environment variables listed here\n[here](https://opentelemetry.io/docs/concepts/sdk-configuration/) and\n[here] (https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/).\n\nOf particular interest are:\n\n* `OTEL_EXPORTER_OTLP_ENDPOINT` - this server currently only exports via gRPC.\n  The RPC exporter endpoint defaults to `http://localhost:4317`.\n  Endpoints can also be configured separately for metrics and (logs + traces) via\n  `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT` and `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT`.\n* `OTEL_METRIC_EXPORT_INTERVAL` - this defaults to 60000 (60 seconds), but I set it to 10000 or 15000 (10 or 15\n  seconds).\n  I primarily export metrics to Mimir/Prometheus/Grafana where I want to evaluate or graph the metrics rate on\n  one-minute intervals.\n  The rule of thumb for Prometheus-compatible tooling seems to be an\n  [evaluation range \u003e= 4x the scrape interval](https://www.robustperception.io/what-range-should-i-use-with-rate/).\n\n### Additional Configuration\n\nI have also added the options to enable or disable stdout and OTLP exporting for each of logs, metrics, and traces.\n\n* `STD_STREAM_LOGS_EXPORTER_ENABLED`: default `false`\n* `STD_STREAM_METRICS_EXPORTER_ENABLED`: default `false`\n* `STD_STREAM_TRACES_EXPORTER_ENABLED`: default `false`\n* `OTEL_COLLECTOR_LOGS_EXPORTER_ENABLED`: default `true`\n* `OTEL_COLLECTOR_TRACES_EXPORTER_ENABLED`: default `true`\n* `OTEL_COLLECTOR_METRICS_EXPORTER_ENABLED`: default `true`\n\nEnvironment variable names and defaults subject to change.\n\nThe stdout exporter prints the telemetry signals to the console\nin the same human-readable format as the OTEL Collector's debug exporter\nIt is intended only for debugging and development purposes only.\n\n## Usage\n\n### Docker Compose\n\n#### Echo Server\n\nIn the `development` directory, bring up the echo server with:\n\n```shell\ndocker-compose up -d echo-server  # add the --build option to include any local changes\n```\n\nThe Docker Compose configuration binds the container port to the host network's port 8080.\nHit either the vanilla echo endpoint at `localhost:8080` or the json echo endpoint at `localhost:8080/json`:\n\n```shell\ncurl -i -X GET localhost:8080/api/v0/echo -d 'hello world'\n\ncurl -i -X GET --header \"content-type: application/json\" localhost:8080/api/v0/echo/json -d '{\"hello\": \"world\"}'\n```\n\n#### Telemetry Collectors\n\nOnly use one of the two collectors for the telemetry data, either the OTEL Collector or Grafana Agent:\n\n```shell\ndocker-compose up -d otel-collector\n# or\ndocker-compose up -d grafana-agent\n```\n\nFor now, the pre-set-up configuration options are more limited for the Grafana Agent.\n\n#### Ingesting And Visualizing Metrics:\n\nThe Docker Compose setup uses Grafana's Mimir metrics database in monolithic mode to ingest metrics,\nand Grafana (the visualization application itself) to query and graph the data.\n\nQuerying may also be done via HTTP calls to Mimir's Prometheus query endpoints.\n\n```shell\ndocker compose up -d mimir grafana\n```\n\nAccess the Grafana UI at `localhost:3000/explore` and view the metrics with a PromQL query:\n\n```PromQL\nrate(http_server_request_duration_count[1m])\n```\n\n#### Ingesting and Visualizing Traces\n\nThe easiest way to view traces is with the Jaeger all-in-one docker image.\nJaeger added support for OpenTelemetry-formatted traces in v1.35\n\n```shell\ndocker run -d --name jaeger \\\n  -e COLLECTOR_OTLP_ENABLED=true \\\n  -p 16686:16686 \\\n  -p 4317:4317 \\\n  -p 4318:4318 \\\n  jaegertracing/all-in-one:1.35\n```\n\nThen access the Jaeger UI at http://localhost:16686.\nThe echo server service will appear once traces have been produced.\nMake individual requests to the server or use the load gen scripts and container to create activity on the server.\n\nTrace spans do not link together much at this point - I believe this is due to the lack of tracing support thus far in\nHyper.\n\n## Development\n\nCompiling outside of Docker requires protobuf compiler packages to be installed on the operating system.\nThe packages are generally called `protobuf`, `protobuf-devel`, or similar in Linux repos\n\n---\n\nCreated by Franco Posa (franco @ [francoposa.io](https://francoposa.io))\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrancoposa%2Fecho-server-rust-logging-metrics-tracing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrancoposa%2Fecho-server-rust-logging-metrics-tracing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrancoposa%2Fecho-server-rust-logging-metrics-tracing/lists"}