It seems that using the Sentry SDK for PHP causes spans to be ignored.
time=2026-06-13T13:40:25.527+10:00 level=WARN msg="sentry: failed to store structured transaction" err="insert sentry_transactions: constraint failed: UNIQUE constraint failed: sentry_transactions.event_id (2067)"
This seems to be because the envelope doesn't contain an event_id.
Host: 10.0.10.161:8000
User-Agent: sentry.php/4.27.0
Accept: */*
Accept-Encoding: deflate, gzip, br, zstd
Proxy-Connection: Keep-Alive
Content-Type: application/x-sentry-envelope
X-Sentry-Auth: Sentry sentry_version=7, sentry_client=sentry.php/4.27.0, sentry_key=sentry
Content-Encoding: gzip
Content-Length: 19977
{"sent_at":"2026-06-13T03:44:42Z","dsn":"http:\/\/sentry@10.0.10.161:8000\/1","sdk":{"name":"sentry.php","version":"4.27.0","packages":[{"name":"composer:sentry\/sentry","version":"4.27.0"}]},"trace":{"trace_id":"922d838166144bef80687ee18a0ca47a","sample_rate":"1","transaction":"\/dashboard\/test","public_key":"sentry","environment":"dev","sampled":"true","sample_rand":"0.972972"}}
{"type":"log","item_count":5,"content_type":"application\/vnd.sentry.items.log+json"}
{"items":[{"timestamp":1781322282.616196,"trace_id":"922d838166144bef80687ee18a0ca47a","level":"info","body":"SELECT `b`.* FROM `auth_assignment` `a`, `auth_item` `b` WHERE (`a`.`item_name`=`b`.`name`) AND (`a`.`user_id`='3') AND (`b`.`type`=1)","attributes":{"sentry.release":{"type":"string","value":"null"},"sentry.environment":{"type":"string","value":"dev"},"server.address":{"type":"string","value":"d78b669f473f"},"sentry.trace.parent_span_id":{"type":"string","value":"acef3420355343a1"},"sentry.sdk.name":{"type":"string","value":"sentry.php"},"sentry.sdk.version":{"type":"string","value":"4.27.0"},"user.id":{"type":"integer","value":3},"user.email":{"type":"string","value":"my@email.com"},"category":{"type":"string","value":"yii\\db\\Command::query"}}},{"timestamp":1781322282.616749,"trace_id":"922d838166144bef80687ee18a0ca47a","level":"info","body":"SELECT `b`.* FROM `auth_assignment` `a`, `auth_item` `b` WHERE (`a`.`item_name`=`b`.`name`) AND (`a`.`user_id`='3') AND (`b`.`type`=2)","attributes":{"sentry.release":{"type":"string","value":"null"},"sentry.environment":{"type":"string","value":"dev"},"server.address":{"type":"string","value":"d78b669f473f"},"sentry.trace.parent_span_id":{"type":"string","value":"acef3420355343a1"},"sentry.sdk.name":{"type":"string","value":"sentry.php"},"sentry.sdk.version":{"type":"string","value":"4.27.0"},"user.id":{"type":"integer","value":3},"user.email":{"type":"string","value":"my@email.com"},"category":{"type":"string","value":"yii\\db\\Command::query"}}},
... etc ...
My Sentry configuration is as such:
\Sentry\init([
'dsn' => $this->backendDSN,
'logger' => YII_DEBUG ? new \Sentry\Logger\DebugFileLogger(filePath: Yii::getAlias('@app/_tmp/sentry.log')) : null,
'environment' => $this->environment,
'traces_sampler' => fn($ctx) => $this->tracesSampler($ctx),
'profiles_sample_rate' => $this->profileSampleRate,
'enable_logs' => true,
'before_send_log' => fn($log) => $this->beforeSendLog($log),
'before_send' => fn($evt) => $this->beforeSendEvent($evt),
'http_proxy' => 'http://10.0.10.161:9090'
]);
With a lot of shenanigans with Transactions for Yii2 (we have each DB and Action automatically create new spans in the transaction).
It seems that using the Sentry SDK for PHP causes spans to be ignored.
time=2026-06-13T13:40:25.527+10:00 level=WARN msg="sentry: failed to store structured transaction" err="insert sentry_transactions: constraint failed: UNIQUE constraint failed: sentry_transactions.event_id (2067)"This seems to be because the envelope doesn't contain an event_id.
My Sentry configuration is as such:
With a lot of shenanigans with Transactions for Yii2 (we have each DB and Action automatically create new spans in the transaction).