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

feat: dedicated logger service #1225

Merged
merged 40 commits into from Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
d8945d8
feat: merge logger service from feat/shuttle-runtime-scaling (#1139)
oddgrd Aug 18, 2023
4c83051
deployer: update logs APIs to fetch the logs from shuttle-logger (#1…
iulianbarbu Aug 21, 2023
f04245f
logger: store span names (#1166)
iulianbarbu Aug 22, 2023
2314c12
Merge remote-tracking branch 'upstream/main' into feat/shuttle-logger…
jonaro00 Aug 23, 2023
149e9b0
logger: adjust logger to receive logs blobs (#1172)
iulianbarbu Aug 24, 2023
bb62a4f
Merge remote-tracking branch 'upstream/feat/shuttle-logger-service' i…
jonaro00 Aug 25, 2023
4541ef6
feat(deployer): send runtime logs to the logger service (#1173)
orhun Aug 28, 2023
5fda73c
refactor: remove tracing from runtime (#1185)
chesedo Aug 29, 2023
8bd9ff2
refactor: remove println from logger (#1186)
chesedo Aug 29, 2023
0f269d6
feat(runtime): write next runtime logs to stdout (#1187)
orhun Aug 29, 2023
786c2dd
refactor(runtime): replace trace with println (#1190)
orhun Aug 30, 2023
64520fb
feat: logs batching (#1188)
chesedo Aug 30, 2023
ffd1b13
Create the local setup for replacing shuttle-logger sqlite with postg…
iulianbarbu Sep 1, 2023
bd5c9ff
chore(gateway): stop setting `RUST_LOG` in deployers (#1197)
orhun Sep 6, 2023
7ab8d11
feat(deployer): StateChangeLayer, DeploymentLogLayer, new log item st…
jonaro00 Sep 6, 2023
d661143
bug: service name being unknown (#1202)
chesedo Sep 6, 2023
3d2feca
feat(runtime): set up a tracing-subscriber as a default feature (#1203)
orhun Sep 7, 2023
86767f8
test(deployer): fixed deployer tests and removed unnecessary runtime …
iulianbarbu Sep 7, 2023
b158bca
chore(services): disable default features for shuttle-runtime (#1205)
orhun Sep 7, 2023
9f391ee
refactor(proto): fix the use of deprecated chrono datetime (#1207)
orhun Sep 7, 2023
a7d0ee0
refactor(runtime,codegen): avoid double timestamps problem (#1210)
iulianbarbu Sep 8, 2023
e8e0f12
feat(codegen): restore default log level, improve error messages (#1211)
jonaro00 Sep 8, 2023
4b4b7b3
Merge remote-tracking branch 'upstream/main' into feat/shuttle-logger…
jonaro00 Sep 8, 2023
8c8e338
fix(logger): resolve CI failures caused by recent changes (#1212)
iulianbarbu Sep 8, 2023
b8bedf7
fix: span names, log levels and messages (#1213)
jonaro00 Sep 11, 2023
1d13115
feat: match local logs with deployer logs (#1216)
chesedo Sep 11, 2023
9249beb
fix(otel): restore honeycomb and dd exporters (#1218)
oddgrd Sep 11, 2023
ef47eae
feat(shuttle-next): enable tracing by default (#1219)
iulianbarbu Sep 11, 2023
d94a7ee
refactor: switch to LOGGER_POSTGRES_URI (#1220)
chesedo Sep 11, 2023
91e9239
refactor: improve stream logs (#1221)
chesedo Sep 11, 2023
c2a4892
refactor: add index to deployment id (#1224)
chesedo Sep 12, 2023
2c5a0bb
batch in 1 sec intervals (#1222)
jonaro00 Sep 12, 2023
395624b
fix: logger branch cleanups (#1226)
oddgrd Sep 12, 2023
4fb7629
ci: logger postgres uri (#1228)
oddgrd Sep 12, 2023
30c0bde
fix: truncate log item strings (#1227)
jonaro00 Sep 12, 2023
da71952
feat(common): change request_span to info (#1230)
oddgrd Sep 13, 2023
57f5b15
feat(logger): refactor to loop, add traces (#1232)
oddgrd Sep 13, 2023
c2c4ca0
feat(logger): logger broadcast channel queue size traces (#1235)
oddgrd Sep 14, 2023
7703d85
ci: uncomment build & deploy branch filters (#1238)
oddgrd Sep 14, 2023
2421117
Merge branch 'main' into feat/shuttle-logger-service
oddgrd Sep 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions .circleci/config.yml
Expand Up @@ -383,6 +383,9 @@ jobs:
deploys-api-key:
description: "Shuttle api key used by the gateway to authorise starting idle deployments"
type: env_var_name
logger-postgres-uri:
description: "URI used to connect to the logger RDS postgres database."
type: string
production:
description: "Push and deploy to production"
type: boolean
Expand Down Expand Up @@ -411,6 +414,7 @@ jobs:
DD_API_KEY=$DD_API_KEY \
HONEYCOMB_API_KEY=${<< parameters.honeycomb-api-key >>} \
DEPLOYS_API_KEY=${<< parameters.deploys-api-key >>} \
LOGGER_POSTGRES_URI=${<< parameters.logger-postgres-uri >>} \
make deploy
- when:
condition: << parameters.production >>
Expand Down Expand Up @@ -709,6 +713,7 @@ workflows:
# need to spawn docker containers, therefore in a machine
- cargo-shuttle
- shuttle-provisioner
- shuttle-logger
- e2e-test:
requires:
- test-standalone
Expand Down Expand Up @@ -739,6 +744,7 @@ workflows:
mongodb-password: DEV_MONGO_INITDB_ROOT_PASSWORD
honeycomb-api-key: DEV_HONEYCOMB_API_KEY
deploys-api-key: DEV_DEPLOYS_API_KEY
logger-postgres-uri: DEV_LOGGER_POSTGRES_URI
requires:
- build-and-push-unstable
release:
Expand Down Expand Up @@ -818,6 +824,7 @@ workflows:
mongodb-password: PROD_MONGO_INITDB_ROOT_PASSWORD
honeycomb-api-key: PROD_HONEYCOMB_API_KEY
deploys-api-key: PROD_DEPLOYS_API_KEY
logger-postgres-uri: PROD_LOGGER_POSTGRES_URI
ssh-fingerprint: 6a:c5:33:fe:5b:c9:06:df:99:64:ca:17:0d:32:18:2e
ssh-config-script: production-ssh-config.sh
ssh-host: shuttle.prod.internal
Expand Down
36 changes: 34 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Cargo.toml
Expand Up @@ -9,6 +9,7 @@ members = [
"common-tests",
"deployer",
"gateway",
"logger",
"proto",
"provisioner",
"resource-recorder",
Expand Down Expand Up @@ -46,6 +47,7 @@ bytes = "1.3.0"
cap-std = "1.0.2"
cargo_metadata = "0.15.3"
chrono = { version = "0.4.23", default-features = false }
colored = "2.0.0"
clap = { version = "4.2.7", features = ["derive"] }
crossbeam-channel = "0.5.7"
crossterm = "0.26.0"
Expand All @@ -64,6 +66,8 @@ jsonwebtoken = { version = "8.2.0" }
once_cell = "1.16.0"
opentelemetry = { version = "0.19.0", features = ["rt-tokio"] }
opentelemetry-http = "0.8.0"
opentelemetry-otlp = "0.12.0"
opentelemetry-proto = "0.2.0"
pin-project = "1.0.12"
pipe = "0.4.0"
portpicker = "0.1.1"
Expand All @@ -83,6 +87,7 @@ tempfile = "3.4.0"
thiserror = "1.0.37"
tar = "0.4.38"
tokio = { version = "1.22.0" }
tokio-stream = "0.1.11"
toml = "0.5.9"
toml_edit = "0.16.0"
tonic = "0.8.3"
Expand All @@ -93,7 +98,6 @@ tracing = { version = "0.1.37", default-features = false }
tracing-opentelemetry = "0.19.0"
tracing-subscriber = { version = "0.3.16", default-features = false, features = [
"registry",
"std",
] }
ttl_cache = "0.5.1"
utoipa = { version = "3.2.1", features = [ "uuid", "chrono" ] }
Expand Down
6 changes: 5 additions & 1 deletion Containerfile
Expand Up @@ -45,8 +45,9 @@ RUN cargo build \
$(if [ "$CARGO_PROFILE" = "release" ]; then echo --release; fi) \
--bin shuttle-auth \
--bin shuttle-deployer \
--bin shuttle-provisioner \
--bin shuttle-gateway \
--bin shuttle-logger \
--bin shuttle-provisioner \
--bin shuttle-resource-recorder \
--bin shuttle-next -F next

Expand Down Expand Up @@ -92,6 +93,9 @@ FROM shuttle-gateway AS shuttle-gateway-dev
# For testing certificates locally
COPY --from=planner /build/*.pem /usr/src/shuttle/

FROM shuttle-crate-base AS shuttle-logger
FROM shuttle-logger AS shuttle-logger-dev

FROM shuttle-crate-base AS shuttle-provisioner
ARG CARGO_PROFILE
COPY --from=builder /build/target/${CARGO_PROFILE}/shuttle-provisioner /usr/local/bin/service
Expand Down
4 changes: 2 additions & 2 deletions DEVELOPING.md
Expand Up @@ -228,7 +228,7 @@ USE_PANAMAX=disable make images
make docker-compose.rendered.yml

# then run
docker compose -f docker-compose.rendered.yml up provisioner resource-recorder
docker compose -f docker-compose.rendered.yml up provisioner resource-recorder logger otel-collector
```

This starts the provisioner and the auth service, while preventing `gateway` from starting up.
Expand All @@ -237,7 +237,7 @@ Make sure an admin user is inserted into auth and that the key is used by cargo-
We're now ready to start a local run of the deployer:

```bash
cargo run -p shuttle-deployer -- --provisioner-address http://localhost:3000 --auth-uri http://localhost:8008 --resource-recorder http://localhost:8007 --proxy-fqdn local.rs --admin-secret dh9z58jttoes3qvt --local --project-id "01H7WHDK23XYGSESCBG6XWJ1V0" --project <name>
OTLP_ADDRESS=http://127.0.0.1:4317 cargo run -p shuttle-deployer -- --provisioner-address http://localhost:3000 --auth-uri http://localhost:8008 --resource-recorder http://localhost:8007 --logger-uri http://localhost:8080 --proxy-fqdn local.rs --admin-secret dh9z58jttoes3qvt --local --project-id "01H7WHDK23XYGSESCBG6XWJ1V0" --project <name>
```

The `<name>` needs to match the name of the project that will be deployed to this deployer.
Expand Down
44 changes: 38 additions & 6 deletions Makefile
Expand Up @@ -22,8 +22,10 @@ BUILDX_FLAGS=$(BUILDX_OP) $(PLATFORM_FLAGS) $(CACHE_FLAGS)
RUSTUP_TOOLCHAIN=1.72.0

TAG?=$(shell git describe --tags --abbrev=0)
BACKEND_TAG?=$(TAG)
AUTH_TAG?=$(TAG)
DEPLOYER_TAG?=$(TAG)
GATEWAY_TAG?=$(TAG)
LOGGER_TAG?=$(TAG)
PROVISIONER_TAG?=$(TAG)
RESOURCE_RECORDER_TAG?=$(TAG)

Expand Down Expand Up @@ -68,6 +70,11 @@ CARGO_PROFILE?=debug
RUST_LOG?=shuttle=debug,info
DEV_SUFFIX=-dev
DEPLOYS_API_KEY?=gateway4deployes

# this should use the same version as our prod RDS database
LOGGER_POSTGRES_TAG?=15
LOGGER_POSTGRES_PASSWORD?=postgres
LOGGER_POSTGRES_URI?=postgres://postgres:${LOGGER_POSTGRES_PASSWORD}@logger-postgres:5432/postgres
endif

ifeq ($(CI),true)
Expand Down Expand Up @@ -98,11 +105,16 @@ endif

DOCKER_COMPOSE_ENV=\
STACK=$(STACK)\
BACKEND_TAG=$(BACKEND_TAG)\
AUTH_TAG=$(AUTH_TAG)\
DEPLOYER_TAG=$(DEPLOYER_TAG)\
GATEWAY_TAG=$(GATEWAY_TAG)\
LOGGER_TAG=$(LOGGER_TAG)\
PROVISIONER_TAG=$(PROVISIONER_TAG)\
RESOURCE_RECORDER_TAG=$(RESOURCE_RECORDER_TAG)\
POSTGRES_TAG=${POSTGRES_TAG}\
LOGGER_POSTGRES_TAG=${LOGGER_POSTGRES_TAG}\
LOGGER_POSTGRES_PASSWORD=${LOGGER_POSTGRES_PASSWORD}\
LOGGER_POSTGRES_URI=${LOGGER_POSTGRES_URI}\
PANAMAX_TAG=${PANAMAX_TAG}\
OTEL_TAG=${OTEL_TAG}\
APPS_FQDN=$(APPS_FQDN)\
Expand All @@ -118,15 +130,31 @@ DOCKER_COMPOSE_ENV=\
COMPOSE_PROFILES=$(COMPOSE_PROFILES)\
DOCKER_SOCK=$(DOCKER_SOCK)

.PHONY: images clean src up down deploy shuttle-% shuttle-images postgres docker-compose.rendered.yml test bump-% deploy-examples publish publish-% --validate-version
.PHONY: clean images the-shuttle-images shuttle-% postgres panamax otel deploy test docker-compose.rendered.yml up down

clean:
rm .shuttle-*
rm docker-compose.rendered.yml

images: shuttle-images postgres panamax otel
images: the-shuttle-images postgres panamax otel

shuttle-images: shuttle-auth shuttle-deployer shuttle-gateway shuttle-provisioner shuttle-resource-recorder
the-shuttle-images: shuttle-auth shuttle-deployer shuttle-gateway shuttle-logger shuttle-provisioner shuttle-resource-recorder

shuttle-%:
$(DOCKER_BUILD) \
--target $(@)$(DEV_SUFFIX) \
--build-arg folder=$(*) \
--build-arg crate=$(@) \
--build-arg prepare_args=$(PREPARE_ARGS) \
--build-arg PROD=$(PROD) \
--build-arg RUSTUP_TOOLCHAIN=$(RUSTUP_TOOLCHAIN) \
--build-arg CARGO_PROFILE=$(CARGO_PROFILE) \
--tag $(CONTAINER_REGISTRY)/$(*):$(COMMIT_SHA) \
--tag $(CONTAINER_REGISTRY)/$(*):$(TAG) \
--tag $(CONTAINER_REGISTRY)/$(*):latest \
$(BUILDX_FLAGS) \
-f Containerfile \
.

postgres:
$(DOCKER_BUILD) \
Expand Down Expand Up @@ -175,7 +203,11 @@ up: $(DOCKER_COMPOSE_FILES)
$(SHUTTLE_DETACH)

down: $(DOCKER_COMPOSE_FILES)
$(DOCKER_COMPOSE_ENV) $(DOCKER_COMPOSE) $(addprefix -f ,$(DOCKER_COMPOSE_FILES)) -p $(STACK) down
$(DOCKER_COMPOSE_ENV) \
$(DOCKER_COMPOSE) \
$(addprefix -f ,$(DOCKER_COMPOSE_FILES)) \
-p $(STACK) \
down

shuttle-%:
$(DOCKER_BUILD) \
Expand Down
4 changes: 2 additions & 2 deletions auth/src/main.rs
@@ -1,7 +1,7 @@
use std::io;

use clap::Parser;
use shuttle_common::backends::tracing::setup_tracing;
use shuttle_common::{backends::tracing::setup_tracing, log::Backend};
use sqlx::migrate::Migrator;
use tracing::{info, trace};

Expand All @@ -15,7 +15,7 @@ async fn main() -> io::Result<()> {

trace!(args = ?args, "parsed args");

setup_tracing(tracing_subscriber::registry(), "auth");
setup_tracing(tracing_subscriber::registry(), Backend::Auth);

let db_path = args.state.join("authentication.sqlite");

Expand Down
2 changes: 1 addition & 1 deletion cargo-shuttle/src/args.rs
Expand Up @@ -350,7 +350,7 @@ pub(crate) fn parse_init_path(path: OsString) -> Result<PathBuf, io::Error> {
)
})?;

parse_path(path.clone()).map_err(|e| io::Error::new(ErrorKind::InvalidInput, e))
parse_path(path).map_err(|e| io::Error::new(ErrorKind::InvalidInput, e))
}

#[cfg(test)]
Expand Down