This repository has been archived by the owner on Oct 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make max annotations and events per span configurable (#85)
* Implement changes to make max annotations and events per span configurable * Go fmt the files modified
- Loading branch information
Showing
6 changed files
with
110 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package ocagent | ||
|
||
const ( | ||
maxAnnotationEventsPerSpan = 32 | ||
maxMessageEventsPerSpan = 128 | ||
) | ||
|
||
type SpanConfig struct { | ||
AnnotationEventsPerSpan int | ||
MessageEventsPerSpan int | ||
} | ||
|
||
func (spanConfig SpanConfig) GetAnnotationEventsPerSpan() int { | ||
if spanConfig.AnnotationEventsPerSpan <= 0 { | ||
return maxAnnotationEventsPerSpan | ||
} | ||
return spanConfig.AnnotationEventsPerSpan | ||
} | ||
|
||
func (spanConfig SpanConfig) GetMessageEventsPerSpan() int { | ||
if spanConfig.MessageEventsPerSpan <= 0 { | ||
return maxMessageEventsPerSpan | ||
} | ||
return spanConfig.MessageEventsPerSpan | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package ocagent | ||
|
||
import "testing" | ||
|
||
func TestSpanConfig_GetAnnotationEventsPerSpan(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
inputSpanConfig SpanConfig | ||
expectedMaxAnnotations int | ||
}{ | ||
{ | ||
name: "WhenConfigNotProvided", | ||
inputSpanConfig: SpanConfig{}, | ||
expectedMaxAnnotations: 32, | ||
}, | ||
{ | ||
name: "WhenConfigProvided", | ||
inputSpanConfig: SpanConfig{AnnotationEventsPerSpan: 256}, | ||
expectedMaxAnnotations: 256, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
got := test.inputSpanConfig.GetAnnotationEventsPerSpan() | ||
if got != test.expectedMaxAnnotations { | ||
t.Errorf("Got = %d; want %d", got, test.expectedMaxAnnotations) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestSpanConfig_GetMessageEventsPerSpan(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
inputSpanConfig SpanConfig | ||
expectedMaxMessageEvents int | ||
}{ | ||
{ | ||
name: "WhenConfigNotProvided", | ||
inputSpanConfig: SpanConfig{}, | ||
expectedMaxMessageEvents: 128, | ||
}, | ||
{ | ||
name: "WhenConfigProvided", | ||
inputSpanConfig: SpanConfig{MessageEventsPerSpan: 256}, | ||
expectedMaxMessageEvents: 256, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
got := test.inputSpanConfig.GetMessageEventsPerSpan() | ||
if got != test.expectedMaxMessageEvents { | ||
t.Errorf("Got = %d; want %d", got, test.expectedMaxMessageEvents) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters