-
Notifications
You must be signed in to change notification settings - Fork 441
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
end to end support for integration, product, client configuration cha…
…nge payloads Signed-off-by: Eliott Bouhana <[email protected]>
- Loading branch information
1 parent
1ee7e85
commit 54a315e
Showing
6 changed files
with
246 additions
and
60 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2025 Datadog, Inc. | ||
|
||
package newtelemetry | ||
|
||
import ( | ||
"sync" | ||
|
||
"gopkg.in/DataDog/dd-trace-go.v1/internal/newtelemetry/internal/transport" | ||
"gopkg.in/DataDog/dd-trace-go.v1/internal/newtelemetry/types" | ||
) | ||
|
||
type configuration struct { | ||
mu sync.Mutex | ||
config map[string]transport.ConfKeyValue | ||
seqID uint64 | ||
} | ||
|
||
func (c *configuration) Add(key string, value any, origin types.Origin) { | ||
c.mu.Lock() | ||
defer c.mu.Unlock() | ||
|
||
if c.config == nil { | ||
c.config = make(map[string]transport.ConfKeyValue) | ||
} | ||
|
||
c.config[key] = transport.ConfKeyValue{ | ||
Name: key, | ||
Value: value, | ||
Origin: origin, | ||
} | ||
} | ||
|
||
func (c *configuration) Payload() transport.Payload { | ||
c.mu.Lock() | ||
defer c.mu.Unlock() | ||
if len(c.config) == 0 { | ||
return nil | ||
} | ||
|
||
configs := make([]transport.ConfKeyValue, len(c.config)) | ||
idx := 0 | ||
for _, conf := range c.config { | ||
conf.SeqID = c.seqID | ||
configs[idx] = conf | ||
idx++ | ||
c.seqID++ | ||
} | ||
c.config = nil | ||
return transport.AppClientConfigurationChange{ | ||
Configuration: configs, | ||
} | ||
} |
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,44 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2025 Datadog, Inc. | ||
|
||
package newtelemetry | ||
|
||
import ( | ||
"sync" | ||
|
||
"gopkg.in/DataDog/dd-trace-go.v1/internal/newtelemetry/internal/transport" | ||
) | ||
|
||
type integrations struct { | ||
mu sync.Mutex | ||
integrations []Integration | ||
} | ||
|
||
func (i *integrations) Add(integration Integration) { | ||
i.mu.Lock() | ||
defer i.mu.Unlock() | ||
i.integrations = append(i.integrations, integration) | ||
} | ||
|
||
func (i *integrations) Payload() transport.Payload { | ||
i.mu.Lock() | ||
defer i.mu.Unlock() | ||
if len(i.integrations) == 0 { | ||
return nil | ||
} | ||
|
||
integrations := make([]transport.Integration, len(i.integrations)) | ||
for idx, integration := range i.integrations { | ||
integrations[idx] = transport.Integration{ | ||
Name: integration.Name, | ||
Version: integration.Version, | ||
Enabled: true, | ||
Error: integration.Error, | ||
} | ||
} | ||
return transport.AppIntegrationChange{ | ||
Integrations: integrations, | ||
} | ||
} |
Oops, something went wrong.