MCPcopy Create free account
hub / github.com/DataDog/datadog-agent / encodeData

Method encodeData

pkg/network/encoding/http2.go:59–99  ·  view source on GitHub ↗
(connectionData *USMConnectionData[http.Key, *http.RequestStats], w io.Writer)

Source from the content-addressed store, hash-verified

57}
58
59func (e *http2Encoder) encodeData(connectionData *USMConnectionData[http.Key, *http.RequestStats], w io.Writer) (uint64, map[string]struct{}) {
60 var staticTags uint64
61 dynamicTags := make(map[string]struct{})
62 e.http2AggregationsBuilder.Reset(w)
63
64 for _, kvPair := range connectionData.Data {
65 e.http2AggregationsBuilder.AddEndpointAggregations(func(http2StatsBuilder *model.HTTPStatsBuilder) {
66 key := kvPair.Key
67 stats := kvPair.Value
68
69 http2StatsBuilder.SetPath(key.Path.Content.Get())
70 http2StatsBuilder.SetFullPath(key.Path.FullPath)
71 http2StatsBuilder.SetMethod(uint64(model.HTTPMethod(key.Method)))
72
73 for code, stats := range stats.Data {
74 http2StatsBuilder.AddStatsByStatusCode(func(w *model.HTTPStats_StatsByStatusCodeEntryBuilder) {
75 w.SetKey(int32(code))
76 w.SetValue(func(w *model.HTTPStats_DataBuilder) {
77 w.SetCount(uint32(stats.Count))
78 if latencies := stats.Latencies; latencies != nil {
79
80 blob, _ := proto.Marshal(latencies.ToProto())
81 w.SetLatencies(func(b *bytes.Buffer) {
82 b.Write(blob)
83 })
84 } else {
85 w.SetFirstLatencySample(stats.FirstLatencySample)
86 }
87 })
88 })
89
90 staticTags |= stats.StaticTags
91 for _, dynamicTag := range stats.DynamicTags {
92 dynamicTags[dynamicTag] = struct{}{}
93 }
94 }
95 })
96 }
97
98 return staticTags, dynamicTags
99}
100
101func (e *http2Encoder) Close() {
102 if e == nil {

Callers 1

Calls 6

makeFunction · 0.85
ResetMethod · 0.65
GetMethod · 0.65
MarshalMethod · 0.65
WriteMethod · 0.65
ToProtoMethod · 0.45

Tested by

no test coverage detected