Skip to content

Commit

Permalink
Disallow configurable data streams for RUM
Browse files Browse the repository at this point in the history
  • Loading branch information
carsonip committed Jan 24, 2024
1 parent 3473528 commit 9c48095
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions model/modelprocessor/datastream.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ func (s *SetDataStream) ProcessBatch(ctx context.Context, b *modelpb.Batch) erro
if (*b)[i].DataStream == nil {
(*b)[i].DataStream = modelpb.DataStreamFromVTPool()
}
if (*b)[i].DataStream.Namespace == "" {
// Only set namespace if it is not already set in the input event
if (*b)[i].DataStream.Namespace == "" || isRUMAgentName((*b)[i].GetAgent().GetName()) {
// Only set namespace if
// 1. it is not already set in the input event; OR
// 2. it is from RUM agents, so that they cannot create arbitrarily many data streams
(*b)[i].DataStream.Namespace = s.Namespace
}
if (*b)[i].DataStream.Type == "" || (*b)[i].DataStream.Dataset == "" {
Expand All @@ -70,11 +72,12 @@ func (s *SetDataStream) setDataStream(event *modelpb.APMEvent) {
if event.DataStream.Dataset == "" {
// Only set dataset if it is not already set in the input event
event.DataStream.Dataset = tracesDataset
// In order to maintain different ILM policies, RUM traces are sent to
// a different datastream.
if isRUMAgentName(event.GetAgent().GetName()) {
event.DataStream.Dataset = rumTracesDataset
}
}
// In order to maintain different ILM policies, RUM traces are sent to
// a different datastream.
// RUM agents should not be able to configure dataset.
if isRUMAgentName(event.GetAgent().GetName()) {
event.DataStream.Dataset = rumTracesDataset
}
case modelpb.ErrorEventType:
event.DataStream.Type = logsType
Expand Down
2 changes: 1 addition & 1 deletion model/modelprocessor/datastream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func TestSetDataStream(t *testing.T) {
Agent: &modelpb.Agent{Name: "iOS/swift"},
DataStream: &modelpb.DataStream{Dataset: "dataset", Namespace: "namespace"},
},
output: &modelpb.DataStream{Type: "traces", Dataset: "dataset", Namespace: "namespace"},
output: &modelpb.DataStream{Type: "traces", Dataset: "apm.rum", Namespace: "custom"},
}, {
input: &modelpb.APMEvent{Transaction: &modelpb.Transaction{Type: "type"}, Agent: &modelpb.Agent{Name: "go"}},
output: &modelpb.DataStream{Type: "traces", Dataset: "apm", Namespace: "custom"},
Expand Down

0 comments on commit 9c48095

Please sign in to comment.