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

ref(functions): Clean up Kafka message #394

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Changelog

## Unreleased

**Features**:

- Add support for speedscope rendering of Android reactnative profiles ([#386](https://github.com/getsentry/vroom/pull/386))
Expand All @@ -18,7 +20,7 @@
- Bump trufflesecurity/trufflehog from 3.63.8 to 3.63.9 ([#389](https://github.com/getsentry/vroom/pull/389))
- Bump trufflesecurity/trufflehog from 3.63.9 to 3.63.10 ([#391](https://github.com/getsentry/vroom/pull/391))
- Bump trufflesecurity/trufflehog from 3.63.10 to 3.63.11 ([#393](https://github.com/getsentry/vroom/pull/393))

- ref(functions): Clean up Kafka message ([#394](https://github.com/getsentry/vroom/pull/394))

## 23.12.0

Expand Down
62 changes: 20 additions & 42 deletions cmd/vroom/kafka.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package main

import (
"strconv"

"github.com/getsentry/vroom/internal/nodetree"
"github.com/getsentry/vroom/internal/platform"
"github.com/getsentry/vroom/internal/profile"
Expand All @@ -11,22 +9,16 @@ import (
type (
// FunctionsKafkaMessage is representing the struct we send to Kafka to insert functions in ClickHouse.
FunctionsKafkaMessage struct {
Functions []nodetree.CallTreeFunction `json:"functions"`
Environment string `json:"environment,omitempty"`
ID string `json:"profile_id"`
Platform platform.Platform `json:"platform"`
ProjectID uint64 `json:"project_id"`
Received int64 `json:"received"`
Release string `json:"release,omitempty"`
Dist string `json:"dist,omitempty"`
RetentionDays int `json:"retention_days"`
Timestamp int64 `json:"timestamp"`
TransactionName string `json:"transaction_name"`
TransactionOp string `json:"transaction_op"`
TransactionStatus string `json:"transaction_status"`
HTTPMethod string `json:"http_method,omitempty"`
BrowserName string `json:"browser_name,omitempty"`
DeviceClass uint64 `json:"device_class,omitempty"`
Environment string `json:"environment,omitempty"`
Functions []nodetree.CallTreeFunction `json:"functions"`
ID string `json:"profile_id"`
Platform platform.Platform `json:"platform"`
ProjectID uint64 `json:"project_id"`
Received int64 `json:"received"`
Release string `json:"release,omitempty"`
RetentionDays int `json:"retention_days"`
Timestamp int64 `json:"timestamp"`
TransactionName string `json:"transaction_name"`
}

// ProfileKafkaMessage is representing the struct we send to Kafka to insert a profile in ClickHouse.
Expand Down Expand Up @@ -57,31 +49,17 @@ type (
)

func buildFunctionsKafkaMessage(p profile.Profile, functions []nodetree.CallTreeFunction) FunctionsKafkaMessage {
tm := p.TransactionMetadata()
tt := p.TransactionTags()

deviceClass, err := strconv.ParseUint(tt["device.class"], 10, 8)
if err != nil {
deviceClass = 0
}

return FunctionsKafkaMessage{
Functions: functions,
Environment: p.Environment(),
ID: p.ID(),
Platform: p.Platform(),
ProjectID: p.ProjectID(),
Received: p.Received().Unix(),
Release: p.Release(),
Dist: tm.Dist,
RetentionDays: p.RetentionDays(),
Timestamp: p.Timestamp().Unix(),
TransactionName: p.Transaction().Name,
TransactionOp: tm.TransactionOp,
TransactionStatus: tm.TransactionStatus,
HTTPMethod: tm.HTTPMethod,
BrowserName: tt["browser.name"],
DeviceClass: deviceClass,
Environment: p.Environment(),
Functions: functions,
ID: p.ID(),
Platform: p.Platform(),
ProjectID: p.ProjectID(),
Received: p.Received().Unix(),
Release: p.Release(),
RetentionDays: p.RetentionDays(),
Timestamp: p.Timestamp().Unix(),
TransactionName: p.Transaction().Name,
}
}

Expand Down
Loading