File tree 1 file changed +19
-0
lines changed
exporter/sematextexporter
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -209,6 +209,23 @@ type tag struct {
209
209
210
210
// optimizeTags sorts tags by key and removes tags with empty keys or values
211
211
func (b * sematextHTTPWriterBatch ) optimizeTags (m map [string ]string ) []tag {
212
+ // Ensure token and os.host tags are always present
213
+ m ["token" ] = b .token
214
+ m ["os.host" ] = b .hostname
215
+
216
+ // Limit to 18 other tags, excluding token and os.host
217
+ if len (m ) > 20 {
218
+ count := 0
219
+ for k := range m {
220
+ if k != "token" && k != "os.host" {
221
+ count ++
222
+ if count > 18 {
223
+ delete (m , k )
224
+ }
225
+ }
226
+ }
227
+ }
228
+
212
229
tags := make ([]tag , 0 , len (m ))
213
230
for k , v := range m {
214
231
switch {
@@ -220,9 +237,11 @@ func (b *sematextHTTPWriterBatch) optimizeTags(m map[string]string) []tag {
220
237
tags = append (tags , tag {k , v })
221
238
}
222
239
}
240
+
223
241
sort .Slice (tags , func (i , j int ) bool {
224
242
return tags [i ].k < tags [j ].k
225
243
})
244
+
226
245
return tags
227
246
}
228
247
You can’t perform that action at this time.
0 commit comments