From 534cd42aab11bfa3581b68ca4c9ed7ed325bcbef Mon Sep 17 00:00:00 2001 From: Matheus Nogueira Date: Wed, 20 Dec 2023 17:36:57 -0300 Subject: [PATCH] migration: migrate agent and no-tracing to otlp tracing backend (#3469) * migration: migrate agent and no-tracing to otlp tracing backend * use "tracing backend" instead of "datastore" --- .../36_migrate_users_to_opentelemetry.sql | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 server/migrations/36_migrate_users_to_opentelemetry.sql diff --git a/server/migrations/36_migrate_users_to_opentelemetry.sql b/server/migrations/36_migrate_users_to_opentelemetry.sql new file mode 100644 index 0000000000..4fbe1b9045 --- /dev/null +++ b/server/migrations/36_migrate_users_to_opentelemetry.sql @@ -0,0 +1,22 @@ +-- We are going to deprecate "no tracing mode" and "agent" tracing backends +-- So we need to migrate all users to a valid trace backend. +-- +-- This means that all users using "no tracing mode" and "agent" tracing backends will become +-- "otlp" tracing backends + +-- If there's an "agent" tracing backend, replace it with an "otlp" tracing backend instead +UPDATE data_stores + SET "name" = 'otlp', "type" = 'otlp', "values" = '{}'::jsonb +from ( + SELECT id, "type" FROM data_stores WHERE "type" = 'agent' +) migration_target +WHERE data_stores.id = migration_target.id; + +-- If there's no "current" tracing backend, add one for otlp. This ensures that if user is on +-- "No tracing mode", it will be migrated to "OpenTelemetry". +INSERT INTO + data_stores (id, "name", "type", is_default, "values", created_at, tenant_id) +VALUES ('current', 'otlp', 'otlp', true, '{}'::jsonb, now(), '') +ON CONFLICT DO NOTHING; + +