From 2d1d7737dc57f65d41782251f295b0108ff9fde7 Mon Sep 17 00:00:00 2001 From: Pierre Massat Date: Mon, 26 Aug 2024 18:02:19 -0400 Subject: [PATCH] feat: Forward SDK info to Kafka --- .golangci.yml | 9 ++++++--- cmd/vroom/chunk.go | 11 ++++++++--- cmd/vroom/kafka.go | 4 ++++ internal/chunk/chunk.go | 8 +++++--- internal/clientsdk/clientsdk.go | 6 ++++++ internal/metadata/metadata.go | 2 ++ internal/sample/sample.go | 8 ++++++-- 7 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 internal/clientsdk/clientsdk.go diff --git a/.golangci.yml b/.golangci.yml index 073061f..fcaebd6 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -16,16 +16,19 @@ linters: - gofmt - goimports #- gosec - - gosimple - - govet + #- gosimple + #- govet - ineffassign - misspell - nakedret - prealloc - revive - - staticcheck + #- staticcheck - typecheck - unconvert - unparam - unused - whitespace +output: + print-linter-name: true + show-stats: true diff --git a/cmd/vroom/chunk.go b/cmd/vroom/chunk.go index f4351e6..1991db0 100644 --- a/cmd/vroom/chunk.go +++ b/cmd/vroom/chunk.go @@ -298,6 +298,9 @@ type ( Received float64 `json:"received"` RetentionDays int `json:"retention_days"` + + SDKName string `json:"sdk_name"` + SDKVersion string `json:"sdk_version"` } ) @@ -305,11 +308,13 @@ func buildChunkKafkaMessage(c *chunk.Chunk) *ChunkKafkaMessage { start, end := c.StartEndTimestamps() return &ChunkKafkaMessage{ ChunkID: c.ID, - ProjectID: c.ProjectID, - ProfilerID: c.ProfilerID, - StartTimestamp: start, EndTimestamp: end, + ProfilerID: c.ProfilerID, + ProjectID: c.ProjectID, Received: c.Received, RetentionDays: c.RetentionDays, + SDKName: c.ClientSDK.Name, + SDKVersion: c.ClientSDK.Version, + StartTimestamp: start, } } diff --git a/cmd/vroom/kafka.go b/cmd/vroom/kafka.go index 2cd7605..be9d9b8 100644 --- a/cmd/vroom/kafka.go +++ b/cmd/vroom/kafka.go @@ -51,6 +51,8 @@ type ( ProjectID uint64 `json:"project_id"` Received int64 `json:"received"` RetentionDays int `json:"retention_days"` + SDKName string `json:"sdk_name,omitempty"` + SDKVersion string `json:"sdk_version,omitempty"` TraceID string `json:"trace_id"` TransactionID string `json:"transaction_id"` TransactionName string `json:"transaction_name"` @@ -115,6 +117,8 @@ func buildProfileKafkaMessage(p profile.Profile) ProfileKafkaMessage { ProjectID: p.ProjectID(), Received: p.Received().Unix(), RetentionDays: p.RetentionDays(), + SDKName: m.SDKName, + SDKVersion: m.SDKVersion, TraceID: t.TraceID, TransactionID: t.ID, TransactionName: t.Name, diff --git a/internal/chunk/chunk.go b/internal/chunk/chunk.go index 99514e3..eef62e4 100644 --- a/internal/chunk/chunk.go +++ b/internal/chunk/chunk.go @@ -7,6 +7,7 @@ import ( "hash/fnv" "sort" + "github.com/getsentry/vroom/internal/clientsdk" "github.com/getsentry/vroom/internal/debugmeta" "github.com/getsentry/vroom/internal/frame" "github.com/getsentry/vroom/internal/nodetree" @@ -28,9 +29,10 @@ type ( DebugMeta debugmeta.DebugMeta `json:"debug_meta"` - Environment string `json:"environment"` - Platform platform.Platform `json:"platform"` - Release string `json:"release"` + ClientSDK clientsdk.ClientSDK `json:"client_sdk"` + Environment string `json:"environment"` + Platform platform.Platform `json:"platform"` + Release string `json:"release"` Version string `json:"version"` diff --git a/internal/clientsdk/clientsdk.go b/internal/clientsdk/clientsdk.go new file mode 100644 index 0000000..9f9c92f --- /dev/null +++ b/internal/clientsdk/clientsdk.go @@ -0,0 +1,6 @@ +package clientsdk + +type ClientSDK struct { + Name string `json:"name"` + Version string `json:"version"` +} diff --git a/internal/metadata/metadata.go b/internal/metadata/metadata.go index 6839c7a..82f34d5 100644 --- a/internal/metadata/metadata.go +++ b/internal/metadata/metadata.go @@ -12,6 +12,8 @@ type Metadata struct { DeviceOSVersion string `json:"device_os_version"` ID string `json:"id"` ProjectID string `json:"project_id"` + SDKName string `json:"sdk_name"` + SDKVersion string `json:"sdk_version"` Timestamp int64 `json:"timestamp"` TraceDurationMs float64 `json:"trace_duration_ms"` TransactionID string `json:"transaction_id"` diff --git a/internal/sample/sample.go b/internal/sample/sample.go index 5ae63a9..69bcf0b 100644 --- a/internal/sample/sample.go +++ b/internal/sample/sample.go @@ -10,6 +10,7 @@ import ( "strings" "time" + "github.com/getsentry/vroom/internal/clientsdk" "github.com/getsentry/vroom/internal/debugmeta" "github.com/getsentry/vroom/internal/frame" "github.com/getsentry/vroom/internal/measurements" @@ -79,21 +80,22 @@ type ( } RawProfile struct { - Sampled bool `json:"sampled"` + ClientSDK clientsdk.ClientSDK `json:"client_sdk"` DebugMeta debugmeta.DebugMeta `json:"debug_meta"` Device Device `json:"device"` Environment string `json:"environment,omitempty"` EventID string `json:"event_id"` Measurements map[string]measurements.Measurement `json:"measurements,omitempty"` OS OS `json:"os"` - OrganizationID uint64 `json:"organization_id"` Options utils.Options `json:"options,omitempty"` + OrganizationID uint64 `json:"organization_id"` Platform platform.Platform `json:"platform"` ProjectID uint64 `json:"project_id"` Received timeutil.Time `json:"received"` Release string `json:"release"` RetentionDays int `json:"retention_days"` Runtime Runtime `json:"runtime"` + Sampled bool `json:"sampled"` Timestamp time.Time `json:"timestamp"` Trace Trace `json:"profile"` Transaction transaction.Transaction `json:"transaction"` @@ -412,6 +414,8 @@ func (p *Profile) Metadata() metadata.Metadata { DeviceOSBuildNumber: p.OS.BuildNumber, DeviceOSName: p.OS.Name, DeviceOSVersion: p.OS.Version, + SDKName: p.ClientSDK.Name, + SDKVersion: p.ClientSDK.Version, ID: p.EventID, ProjectID: strconv.FormatUint(p.ProjectID, 10), Timestamp: p.Timestamp.Unix(),